本文整理汇总了C#中System.Drawing.Pen.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.Dispose方法的具体用法?C# Pen.Dispose怎么用?C# Pen.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(System.Drawing.RectangleF dirtyRect)
{
var g = new Graphics();
// NSView does not have a background color so we just use Clear to white here
g.Clear(Color.White);
//RectangleF ClientRectangle = this.Bounds;
RectangleF ClientRectangle = dirtyRect;
// Calculate the location and size of the drawing area
// within which we want to draw the graphics:
Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y,
(int)ClientRectangle.Width, (int)ClientRectangle.Height);
drawingRectangle = new Rectangle(rect.Location, rect.Size);
drawingRectangle.Inflate(-offset, -offset);
//Draw ClientRectangle and drawingRectangle using Pen:
g.DrawRectangle(Pens.Red, rect);
g.DrawRectangle(Pens.Black, drawingRectangle);
// Draw a line from point (3,2) to Point (6, 7)
// using the Pen with a width of 3 pixels:
Pen aPen = new Pen(Color.Green, 3);
g.DrawLine(aPen, Point2D(new PointF(3, 2)),
Point2D(new PointF(6, 7)));
g.PageUnit = GraphicsUnit.Inch;
ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f);
aPen.Width = 1 / g.DpiX;
g.DrawRectangle(aPen, ClientRectangle);
aPen.Dispose();
g.Dispose();
}
示例2: Frame3D
public static void Frame3D(Graphics graphics, Rectangle rc, Color topColor, Color bottomColor, int width)
{
if(graphics == null)
throw new ArgumentNullException("graphics");
Pen pen = new Pen(topColor, 1);
pen.Width = 1;
while(width > 0)
{
width--;
pen.Color = topColor;
Point[] top_pnts =
{
new Point(rc.Left, rc.Bottom),
new Point(rc.Left, rc.Top),
new Point(rc.Right, rc.Top)
};
graphics.DrawLines(pen, top_pnts);
pen.Color = bottomColor;
Point[] bottom_pnts =
{
new Point(rc.Right, rc.Top),
new Point(rc.Right, rc.Bottom),
new Point(rc.Left, rc.Bottom)
};
graphics.DrawLines(pen, bottom_pnts);
rc.Inflate(-1, -1);
}
pen.Dispose();
}
示例3: OnPaint
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
var g = pe.Graphics;
if (Loading)
{
var txt = LocRm.GetString("Loading");
var s = g.MeasureString(txt, MainForm.Drawfont);
g.DrawString(txt, MainForm.Drawfont, MainForm.OverlayBrush, Convert.ToInt32(Width / 2) - s.Width / 2, Convert.ToInt32(Height / 2) - s.Height / 2);
}
if (SelectStart != Point.Empty && SelectEnd != Point.Empty)
{
var b = new SolidBrush(Color.White);
var p = new Pen(b, 1) { DashStyle = DashStyle.Dash };
g.DrawLine(p, SelectStart.X, SelectStart.Y, SelectStart.X, SelectEnd.Y);
g.DrawLine(p, SelectStart.X, SelectEnd.Y, SelectEnd.X, SelectEnd.Y);
g.DrawLine(p, SelectEnd.X, SelectEnd.Y, SelectEnd.X, SelectStart.Y);
g.DrawLine(p, SelectEnd.X, SelectStart.Y, SelectStart.X, SelectStart.Y);
b.Dispose();
p.Dispose();
}
}
示例4: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
Rectangle r = ClientRectangle;
r.Inflate(-2,-2);
Pen p = new Pen(ForeColor, 1);
if ((int)(LinePositions & AnchorStyles.Left) > 0)
{
e.Graphics.DrawLine(p, r.Left-1, r.Top, r.Left-1, r.Bottom-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Left, r.Bottom-1);
}
if ((int)(LinePositions & AnchorStyles.Right) > 0)
{
e.Graphics.DrawLine(p, r.Right, r.Top, r.Right, r.Bottom-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Right+1, r.Top, r.Right+1, r.Bottom-1);
}
if ((int)(LinePositions & AnchorStyles.Top) > 0)
{
e.Graphics.DrawLine(p, r.Left, r.Top-1, r.Right-1, r.Top-1);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Top, r.Right-1, r.Top);
}
if ((int)(LinePositions & AnchorStyles.Bottom) > 0)
{
e.Graphics.DrawLine(p, r.Left, r.Bottom, r.Right-1, r.Bottom);
e.Graphics.DrawLine(Pens.WhiteSmoke, r.Left, r.Bottom+1, r.Right-1, r.Bottom+1);
}
p.Dispose();
}
示例5: Paint
//------ End Constructors -----//
public override void Paint(Graphics g, System.Drawing.Drawing2D.GraphicsPath gp, bool isSelected)
{
if (isSelected)
{
SolidBrush br = new SolidBrush(selectedBack);
Pen pen = new Pen(selectedLine);
g.FillPath(br, gp);
g.DrawPath(pen, gp);
br.Dispose();
pen.Dispose();
}
else //is not selected
{
if (_PaintBack)
{
SolidBrush br = new SolidBrush(_BackColor);
g.FillPath(br,gp);
br.Dispose();
}
if (_PaintLine)
{
Pen pen = new Pen(_LineColor);
g.DrawPath(pen, gp);
pen.Dispose();
}
}
}
示例6: Draw
/// <summary>
/// Draw rectangle
/// </summary>
/// <param name="g"></param>
public override void Draw(Graphics g)
{
Pen pen = new Pen(Color, PenWidth);
Rectangle _rect = new Rectangle();
_rect = DrawRectangle.GetNormalizedRectangle(Rectangle);
int x = _rect.X;
int y = _rect.Y;
int w = _rect.Width;
int h = _rect.Height;
int wArc = (w/6);
int wArc2 = wArc * 2;
int wReta = w - wArc;
// g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);
Point SE = new Point(x, y); //SuperiorEsquerdo
Point SD = new Point(x + wReta, y); //SuperiorDireito
Point IE = new Point(x, y + h); //InferioriEsquerdo
Point ID = new Point(x + wReta, y + h); //InferiorDireito
g.DrawLine(pen, SE, SD);
g.DrawLine(pen, IE, ID);
//g.DrawRectangle(pen, x, y, w, h);
pen.Dispose();
}
示例7: DrawRectangle
public void DrawRectangle(Pen pen, Panel canvas)
{
Graphics g = canvas.CreateGraphics();
g.DrawRectangle(pen, new Rectangle(X, Y, Width, Height));
g.Dispose();
pen.Dispose();
}
示例8: Draw
public override void Draw(CGRect rect)
{
var g = Graphics.FromCurrentContext ();
// NSView does not have a background color so we just use Clear to white here
g.Clear (Color.White);
CGRect ClientRectangle = rect;
var rectangle = new Rectangle ((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height);
drawingRectangle = new Rectangle (rectangle.Location, rectangle.Size);
drawingRectangle.Inflate (-offset, -offset);
//Draw ClientRectangle and drawingRectangle using Pen:
g.DrawRectangle (Pens.Red, rectangle);
g.DrawRectangle (Pens.Black, drawingRectangle);
// Draw a line from point (3,2) to Point (6, 7)
// using the Pen with a width of 3 pixels:
var aPen = new Pen (Color.Green, 3);
g.DrawLine (aPen, Point2D (new CGPoint (3, 2)), Point2D (new CGPoint (6, 7)));
g.PageUnit = GraphicsUnit.Inch;
ClientRectangle = new CGRect(0.5f,0.5f, 1.5f, 1.5f);
aPen.Width = 1 / g.DpiX;
g.DrawRectangle (aPen, (float)ClientRectangle.X, (float)ClientRectangle.Y, (float)ClientRectangle.Width, (float)ClientRectangle.Height);
aPen.Dispose();
g.Dispose();
}
示例9: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics myGraphics = e.Graphics;
Pen myPen = new Pen(Color.Black, 1.0f);
GraphicsPath gp = new GraphicsPath();
Matrix RotationTransform;
float centerX = this.Size.Width / 2f;
float centerY = this.Size.Height / 2f;
gp.AddPolygon(new PointF[] {
new PointF(centerX, centerY - 5),
new PointF(centerX-5, centerY + 5),
new PointF(centerX+5, centerY + 5)
});
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
PointF RotationPoint = new PointF(centerX, centerY); // rotation point
RotationTransform.RotateAt(heading, RotationPoint);
gp.Transform(RotationTransform);
myGraphics.FillPath(myPen.Brush, gp);
myGraphics.DrawPath(myPen, gp);
myPen.Dispose();
gp.Dispose();
}
示例10: Draw
public void Draw(Graphics graphics)
{
graphics.SetClip(parentGraph.ClientRectangle);
Pen axisPen = new Pen(new SolidBrush(parentGraph.YAxisColor), 2F);
axisPen.EndCap = LineCap.ArrowAnchor;
RectangleF graphArea = parentGraph.GraphArea;
graphics.DrawLine(axisPen,
graphArea.Left,
graphArea.Bottom,
graphArea.Left,
graphArea.Top);
axisPen.Color = parentGraph.XAxisColor;
axisPen.EndCap = LineCap.ArrowAnchor;
graphics.DrawLine(axisPen,
graphArea.Left,
graphArea.Bottom,
graphArea.Right,
graphArea.Bottom);
axisPen.Dispose();
}
示例11: Draw
public override void Draw(Graphics gr) {
// Calculation of begin and end points of edge.
double c = Math.Sqrt(Math.Pow(second.Position.X - first.Position.X, 2) + Math.Pow(second.Position.Y - first.Position.Y, 2));
double sin = (second.Position.Y - first.Position.Y) / c;
double cos = (second.Position.X - first.Position.X) / c;
Point firstPoint = new Point(first.Position.X + (int)(cos * Vertex.r), first.Position.Y + (int)(sin * Vertex.r));
Point secondPoint = new Point(second.Position.X - (int)(cos * Vertex.r), second.Position.Y - (int)(sin * Vertex.r));
Pen edgePen = new Pen(Color.DarkBlue, 2);
gr.DrawLine(edgePen, firstPoint, secondPoint);
if (weight != 0) {
string text = weight.ToString();
Font textFont = new Font("Arial", 11);
Brush textBrush = new SolidBrush(Color.Black);
Brush textBackground = new SolidBrush(Color.White);
Point textLocation = new Point((firstPoint.X + secondPoint.X) / 2, (firstPoint.Y + secondPoint.Y) / 2 - 6);
SizeF textSize = new Size();
textSize = gr.MeasureString(text, textFont);
// Рисование линии между вершинам графа
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr.DrawLine(edgePen, firstPoint, secondPoint);
textBackground.Dispose();
textBrush.Dispose();
textFont.Dispose();
}
edgePen.Dispose();
}
示例12: OnDrawItem
/// <summary>
/// Occurs during the drawing of an item
/// </summary>
/// <param name="e"></param>
protected override void OnDrawItem(DrawItemEventArgs e)
{
Rectangle outer = e.Bounds;
outer.Inflate(1, 1);
e.Graphics.FillRectangle(Brushes.White, outer);
Brush fontBrush = Brushes.Black;
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
Rectangle r = e.Bounds;
r.Inflate(-1, -1);
e.Graphics.FillRectangle(Global.HighlightBrush(r, Color.FromArgb(215, 238, 252)), r);
Pen p = new Pen(Color.FromArgb(215, 238, 252));
Global.DrawRoundedRectangle(e.Graphics, p, e.Bounds);
p.Dispose();
}
string name = Items[e.Index].ToString();
FontFamily ff = new FontFamily(name);
Font fnt = new Font("Arial", 10, FontStyle.Regular);
if (ff.IsStyleAvailable(FontStyle.Regular))
{
fnt = new Font(name, 10, FontStyle.Regular);
}
else if (ff.IsStyleAvailable(FontStyle.Italic))
{
fnt = new Font(name, 10, FontStyle.Italic);
}
SizeF box = e.Graphics.MeasureString(name, Font);
e.Graphics.DrawString(name, Font, fontBrush, e.Bounds.X, e.Bounds.Y);
e.Graphics.DrawString("ABC", fnt, fontBrush, e.Bounds.X + box.Width, e.Bounds.Y);
}
示例13: RepertoryImage
public static void RepertoryImage(Graphics drawDestination)
{
StringFormat itemStringFormat = new StringFormat();
RectangleF itemBox = new RectangleF(10, 30, 60, 20);
float[] pattern = {4f,4f};
Pen rPen = new Pen(Color.Black);
rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
rPen.DashPattern = pattern;
itemStringFormat.Alignment = StringAlignment.Center;
itemStringFormat.LineAlignment = StringAlignment.Center;
drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
drawDestination.DrawLine(rPen,10,20,70,20);
drawDestination.DrawLine(rPen,10,60,70,60);
PointF[] capPolygon = new PointF[3];
capPolygon[0] = new PointF(65, 19);
capPolygon[1] = new PointF(69, 11);
capPolygon[2] = new PointF(61, 11);
drawDestination.DrawPolygon(Pens.Black,capPolygon);
capPolygon[0] = new PointF(65, 61);
capPolygon[1] = new PointF(69, 69);
capPolygon[2] = new PointF(61, 69);
drawDestination.DrawPolygon(Pens.Black,capPolygon);
drawDestination.DrawLine(rPen,65,20,65,60);
drawDestination.DrawString("Measure",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
rPen.Dispose();
itemStringFormat.Dispose();
}
示例14: draw
public void draw(int numb)
{
Graphics g = this.picback.CreateGraphics();
g.SmoothingMode = SmoothingMode.AntiAlias;
//g.Clear(this.picback.BackColor);
System.Drawing.Pen pn = new System.Drawing.Pen(System.Drawing.Color.Green, 2);
int maxY = (int)this.picback.Height;//获取窗体的高
int maxX = (int)this.picback.Width - 1;//获取窗体的宽
double f = numb * 2.0 * Math.PI / maxX;
int lmin = 0;
int rmax = maxX; //this.picback.Width;//把具体的宽度分成200等份
int count = rmax - lmin;
PointF[] mypoint = new PointF[count + 1];
int x = 0;
for (int i = lmin; i <= rmax; i++)
{
//0.5为半个波形占容器高度的50%
//根据具体的容器高度设置PointF点的Y坐标,(具体情况而定)
double temp = 0.5 * (maxY - maxY * Math.Sin(f * i));
mypoint[x] = new PointF((float)i, (float)temp);
x++;
}
g.DrawCurve(pn, mypoint);
pn.Dispose();
g.Dispose();
}
示例15: Draw
public void Draw(Graphics g)
{
Pen pen = new Pen(Color.Yellow, Width);
Point p = new Point(X, Y);
g.DrawLine(pen, p, End);
pen.Dispose();
}