本文整理汇总了C#中System.Drawing.SolidBrush.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SolidBrush.Dispose方法的具体用法?C# SolidBrush.Dispose怎么用?C# SolidBrush.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.SolidBrush
的用法示例。
在下文中一共展示了SolidBrush.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Operation
/// <summary>
/// 主要作業方法
/// </summary>
public Image Operation()
{
Graphics g = Graphics.FromImage(image);
_mask_pos_x = (image.Width / 2) + _Xoffset;
SizeF steSize = new SizeF();
for (int i = _FontMaxSize; i >= _FontMinSize; i--)
{
using (Font testFont = new Font(_FontFamily, i, FontStyle.Bold))
{
steSize = g.MeasureString(_text, testFont);
if ((ushort)steSize.Width < (ushort)_Width || i == _FontMinSize)
{
using (SolidBrush semiTransBrush = new SolidBrush(_fontcolor))
{
StringFormat StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Center;
g.DrawString(_text, testFont, semiTransBrush, new PointF(_mask_pos_x, _mask_pos_y), StrFormat);
semiTransBrush.Dispose();
}
testFont.Dispose();
break;
}
}
}
return image;
}
示例2: OnDrawItem
protected override void OnDrawItem(DrawItemEventArgs e)
{
RectangleF tabFill = (RectangleF)GetTabRect(e.Index);
if (e.Index == SelectedIndex)
{
Brush textBrush = new SolidBrush(Color.Black);
Brush fillBrush = new SolidBrush(Color.White);
e.Graphics.FillRectangle(fillBrush, tabFill);
e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 5));
int offset = (e.Bounds.Height - 16) / 2;
e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset);
textBrush.Dispose();
fillBrush.Dispose();
}
else
{
Brush textBrush = new SolidBrush(Color.White);
Brush fillBrush = new SolidBrush(Color.DimGray);
e.Graphics.FillRectangle(fillBrush, tabFill);
fillBrush.Dispose();
e.Graphics.DrawString(TabPages[e.Index].Text, Font, textBrush, new Point(e.Bounds.X + 5, e.Bounds.Y + 3));
int offset = (e.Bounds.Height - 16) / 2;
e.Graphics.DrawImage(Image.FromFile(pathCloseImg), e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y + offset + 2);
textBrush.Dispose();
fillBrush.Dispose();
}
}
示例3: DrawSegmentNumbers
public static Bitmap DrawSegmentNumbers(Bitmap bmp, Narray<Rect> bboxes)
{
int numAreaHeight = 10;
Bitmap newbitmap = new Bitmap(bmp.Width, bmp.Height + numAreaHeight, bmp.PixelFormat);
int height = bmp.Height;
using (Graphics g = Graphics.FromImage(newbitmap))
{
SolidBrush bgrnBrush = new SolidBrush(Color.White);
SolidBrush txtBrush = new SolidBrush(Color.Black);
Pen rectPen = new Pen(Color.DarkGray);
g.FillRectangle(bgrnBrush, new Rectangle(Point.Empty, newbitmap.Size));
g.DrawImage(bmp, Point.Empty);
bgrnBrush.Dispose();
FontFamily fontFam;
try { fontFam = new FontFamily("Tahoma"); }
catch { fontFam = FontFamily.GenericSansSerif; }
Font font = new Font(fontFam, 5f);
for (int i = 1; i < bboxes.Length(); i++)
{
Rect b = bboxes[i];
int bposY = (height - b.y1);
// draw bounding rects
g.DrawRectangle(rectPen, Math.Max(0, b.x0-1), Math.Max(0, bposY-1), b.W, b.H+1);
// draw numbers
g.DrawString(i.ToString(), font, txtBrush, b.x0, height + 1);
}
txtBrush.Dispose();
}
return newbitmap;
}
示例4: OnRenderMenuItemBackground
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{
ToolStripItem tsi = ((e != null) ? e.Item : null);
if((tsi != null) && ((tsi.Owner is ContextMenuStrip) ||
(tsi.OwnerItem != null)) && tsi.Selected && !tsi.Enabled)
{
Rectangle rect = tsi.ContentRectangle;
rect.Offset(0, -1);
rect.Height += 1;
// In image area (228, 228, 228), in text area (230, 230, 230)
Color clrBack = Color.FromArgb(229, 229, 229);
Color clrBorder = Color.FromArgb(229, 229, 229);
SolidBrush br = new SolidBrush(clrBack);
Pen p = new Pen(clrBorder);
Graphics g = e.Graphics;
if(g != null)
{
g.FillRectangle(br, rect);
g.DrawRectangle(p, rect);
}
else { Debug.Assert(false); }
p.Dispose();
br.Dispose();
}
else base.OnRenderMenuItemBackground(e);
}
示例5: CardShopViewForm_Paint
private void CardShopViewForm_Paint(object sender, PaintEventArgs e)
{
Color col = Color.FromArgb(180, Color.Black);
SolidBrush brush = new SolidBrush(col);
e.Graphics.FillRectangle(brush, 0, 0, formWidth, formHeight);
brush.Dispose();
}
示例6: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Color color = Color.FromArgb(0xcc, 0xd9, 0xea);
Color color2 = Color.FromArgb(0xd9, 0xe3, 240);
Color color3 = Color.FromArgb(0xe8, 0xee, 0xf7);
Color color4 = Color.FromArgb(0xed, 0xf2, 0xf9);
Color color5 = Color.FromArgb(240, 0xf4, 250);
Color color6 = Color.FromArgb(0xf1, 0xf5, 0xfb);
Rectangle rect = new Rectangle(0, 0, base.Width, 1);
SolidBrush brush = new SolidBrush(color);
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 1, base.Width, 1);
brush.Color = color2;
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 2, base.Width, 1);
brush.Color = color3;
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 3, base.Width, 1);
brush.Color = color3;
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 4, base.Width, 1);
brush.Color = color4;
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 5, base.Width, 1);
brush.Color = color5;
e.Graphics.FillRectangle(brush, rect);
rect = new Rectangle(0, 6, base.Width, base.Height - 5);
brush.Color = color6;
e.Graphics.FillRectangle(brush, rect);
brush.Dispose();
}
示例7: btStop_Click
private void btStop_Click(object sender, EventArgs e)
{
if (ckTest.Checked == false)
{
timer1.Stop();
myBrush = new SolidBrush(Color.Red);
Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 120, 130));
myBrush.Dispose();
formGraphics.Dispose();
MessageBox.Show("Your result: " + sec.ToString() + " seconds");
resultLight.Add(sec);
sec = 0;
}
if (ckTest.Checked == true)
{
timer1.Stop();
myBrush = new SolidBrush(Color.Red);
Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(myBrush, new Rectangle(0, 0, 120, 130));
myBrush.Dispose();
formGraphics.Dispose();
MessageBox.Show("Your result: " + sec.ToString() + " seconds");
sec = 0;
}
}
示例8: monthCalendar1_DayRender
private void monthCalendar1_DayRender(object sender, Pabo.Calendar.DayRenderEventArgs e)
{
Brush bgBrush = new SolidBrush(Color.White);
Brush dateBrush = new SolidBrush(Color.Black);
Font dateFont = new Font("Microsoft Sans Serif",(float)8.25);
StringFormat dateAlign = new StringFormat();
dateAlign.Alignment = StringAlignment.Far;
dateAlign.LineAlignment = StringAlignment.Near;
Rectangle rect = new Rectangle(0,0,e.Width,e.Height);
// Set OwnerDraw = true to override built in formatting...
e.OwnerDraw = true;
// ...then Draw the appearance of the date
e.Graphics.FillRectangle(bgBrush,rect);
e.Graphics.DrawString(e.Date.Day.ToString(),
dateFont,dateBrush,rect,dateAlign);
// Clean up
bgBrush.Dispose();
dateBrush.Dispose();
dateAlign.Dispose();
dateFont.Dispose();
}
示例9: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
Brush backBrush = new SolidBrush(this.BackColor);
Brush foreBrush = new SolidBrush(this.ForeColor);
// 背景を描画する
e.Graphics.FillRectangle(backBrush, this.ClientRectangle);
// バーの幅を計算する
int chunksWidth = (int)(
(double)this.ClientSize.Width *
(double)(this.Value - this.Minimum) /
(double)(this.Maximum - this.Minimum));
Rectangle chunksRect = new Rectangle(0, 0,
chunksWidth, this.ClientSize.Height);
// バーを描画する
e.Graphics.FillRectangle(foreBrush, chunksRect);
// 残り時間を描画する
var f = new Font("メイリオ", 8);
var NwTime = (Value >= 10000 ? "99.99" : ((double)Value / 100).ToString("#0.00"));
var MxTime = (Maximum >= 10000 ? "99.99" : ((double)Maximum / 100).ToString("#0.00"));
e.Graphics.DrawString(String.Format("{0} / {1}", NwTime, MxTime),
f, Brushes.White, new Point(ClientSize.Width - 80, 4));
backBrush.Dispose();
foreBrush.Dispose();
}
示例10: Subtitle
public Subtitle(string content,
Font font, Color fillColor, Color borderColor, float borderWidth,
long startTime, long endTime)
{
StartTime = startTime;
EndTime = endTime;
IntPtr screenDc = ApiHelper.GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(screenDc);
SizeF gsize = g.MeasureString(content, font);
g.Dispose();
this.Size = Size.Ceiling(new SizeF(gsize.Width + borderWidth, gsize.Height + borderWidth));
hMemDc = ApiHelper.CreateCompatibleDC(screenDc);
hMemBitmap = ApiHelper.CreateCompatibleBitmap(screenDc, Size.Width, Size.Height);
ApiHelper.ReleaseDC(IntPtr.Zero, screenDc);
ApiHelper.SelectObject(hMemDc, hMemBitmap);
g = Graphics.FromHdc(hMemDc);
g.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath path = new GraphicsPath();
path.AddString(content, font.FontFamily, (int)font.Style, font.Size,
new Rectangle(Point.Empty, Size), defaultFormat);
Pen pen = new Pen(borderColor, borderWidth);
pen.LineJoin = LineJoin.Round;
pen.Alignment = PenAlignment.Outset;
g.DrawPath(pen, path);
pen.Dispose();
Brush brush = new SolidBrush(fillColor);
g.FillPath(brush, path);
brush.Dispose();
g.Dispose();
}
示例11: Draw
/// <summary>
/// Renders the grid offset from its origin position by the given indices. If Draw() is called before the Graphics object has been
/// set, a null reference exception will be thrown
/// </summary>
public override void Draw()
{
// Iterate through all cells in grid
for (int column = 0; column < Grid.Size; column++)
{
for (int row = 0; row < Grid.Size; row++)
{
Cell currentCell = Grid[column, row];
int hex = Shader.HexValue(currentCell[GrayScottDiffusionReaction.CHEMICAL_B]);
// Convert colour hex to .NET Color and create brush to draw it with
Color colour = Color.FromArgb(hex);
Brush brush = new SolidBrush(colour);
// Calculate cell position and dimensions
float cellX = column * CellWidth;
float cellY = row * CellHeight;
// Draw cell
Graphics.FillRectangle(brush, cellX, cellY, CellWidth, CellHeight);
// Dispose of brush
brush.Dispose();
}
}
}
示例12: Draw
public override void Draw(Graphics aGfx,int alWorldX,int alWorldY ,eEditMode mMode, bool abSelected)
{
Color Col;
if(mMode == eEditMode.Lights)
{
Col = abSelected?Color.FromArgb(80,255,80):Color.FromArgb(255,0,255);
SolidBrush CenterBrush = new SolidBrush(Col);
aGfx.FillEllipse(CenterBrush,mlX-10-alWorldX,mlY-10-alWorldY,
20,20);
CenterBrush.Dispose();
}
else
{
Col = Color.Gray;
SolidBrush CenterBrush = new SolidBrush(Col);
aGfx.FillEllipse(CenterBrush,mlX-3-alWorldX,mlY-3-alWorldY,
6,6);
CenterBrush.Dispose();
}
Pen OuterPen = new Pen(Col);
aGfx.DrawEllipse(OuterPen,mlX-mfRadius-alWorldX,mlY-mfRadius-alWorldY,
mfRadius*2,mfRadius*2);
OuterPen.Dispose();
}
示例13: DrawPDF417
public void DrawPDF417(ref Graphics g)
{
g.Clear(this.backcolor);
SolidBrush brush = new SolidBrush(this.forecolor);
int x = this.leftmargin;
int y = this.topmargin;
SizeF ef = g.MeasureString(this.bottomcomment, this.txtFont, 0x7fffffff, StringFormat.GenericTypographic);
for (int i = 0; i < this.encodebinarystr.Length; i++)
{
char ch = this.encodebinarystr[i];
switch (ch)
{
case '0':
x += this.modulewidth;
break;
case '1':
g.FillRectangle(brush, x, y, this.modulewidth, this.moduleheight);
x += this.modulewidth;
break;
default:
if (ch == 'Z')
{
y += this.moduleheight;
x = this.leftmargin;
}
break;
}
}
g.DrawString(this.topcomment, this.txtFont, brush, (float) this.topcommentleftmargin, (float) this.topcommenttopmargin);
//g.DrawString(" ", this.txtFont, brush, (float) 0f, (float) (this.symbolheight - ef.Height));
brush.Dispose();
}
示例14: Draw
public void Draw(Graphics g, bool enable)
{
Image back = PicLoader.Read("System", "ItemGrid.JPG");
g.DrawImage(back, x+3, y+3, 32, 32);
back.Dispose();
if (itemPos >= 0)
{
Font font = new Font("Aril", 11*1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
if (enable)
{
g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), x + 3, y + 3, 32, 32);
}
else
{
Rectangle ret = new Rectangle(x + 3, y + 3, 32, 32);
g.DrawImage(HItemBook.GetHItemImage(UserProfile.InfoBag.Items[itemPos].Type), ret, 0, 0, 64, 64, GraphicsUnit.Pixel, HSImageAttributes.ToGray);
}
g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.Black, x + 4, y + 4);
g.DrawString(UserProfile.InfoBag.Items[itemPos].Value.ToString(), font, Brushes.White, x + 3, y + 3);
if (percent>1)
{
Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black));
g.FillRectangle(brush, x, y, 35, 35*percent/100);
brush.Dispose();
}
font.Dispose();
}
}
示例15: _grid_OwnerDrawCell
private void _grid_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
{
if (e.Column.Name == "Progress")
{
// Create a gradient brush
Point pt1, pt2;
pt1 = new Point(e.CellRect.X, e.CellRect.Y);
pt2 = new Point(e.CellRect.Right, e.CellRect.Y);
SolidBrush solidBrush = new SolidBrush(e.Row % 2 == 0 ? _grid.EvenRowStyle.BackColor : _grid.OddRowStyle.BackColor);
LinearGradientBrush linGrBrush = new LinearGradientBrush(pt1, pt2, Color.Cyan, Color.DarkBlue);
RectangleF rt = new RectangleF(e.CellRect.X, e.CellRect.Y, Convert.ToInt32(e.CellRect.Width * .7), e.CellRect.Height);
// Fill solid brackground
e.Graphics.FillRectangle(solidBrush, e.CellRect);
// Fill the cell rectangle with the gradient.
e.Graphics.FillRectangle(linGrBrush, e.Row % 2 == 0 ? rt : e.CellRect);
Brush whiteBR = new SolidBrush(Color.White);
C1DisplayColumn dispCol = this._grid.Splits[0].DisplayColumns[e.Col];
// Center the text horizontally.
StringFormat sfmt = new StringFormat();
sfmt.Alignment = StringAlignment.Far;
// Draw the text.
e.Graphics.DrawString(dispCol.DataColumn.CellText(e.Row), dispCol.Style.Font, whiteBR, rt, sfmt);
whiteBR.Dispose();
// Let the grid know the event was handled.
e.Handled = true;
}
}