当前位置: 首页>>代码示例>>C#>>正文


C# Pen.Dispose方法代码示例

本文整理汇总了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();
        }
开发者ID:stnk3000,项目名称:sysdrawing-coregraphics,代码行数:34,代码来源:DrawingView.cs

示例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();
        }
开发者ID:cyotek,项目名称:translateclient,代码行数:31,代码来源:Drawing.cs

示例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();
            }
        }
开发者ID:WesleyYep,项目名称:ispyconnect,代码行数:25,代码来源:MediaPanel.cs

示例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();
 }
开发者ID:Diullei,项目名称:Storm,代码行数:28,代码来源:Line.cs

示例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();
                }
            }
        }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:29,代码来源:PainterSolid.cs

示例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();
        }
开发者ID:CoolBatchPopulator,项目名称:CoolBatchPopulator,代码行数:36,代码来源:DrawFile.cs

示例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();
 }
开发者ID:svutborg,项目名称:Programming-II,代码行数:7,代码来源:Rect.cs

示例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();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:27,代码来源:DrawingView.cs

示例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();
        }
开发者ID:glocklueng,项目名称:helocamosun,代码行数:27,代码来源:HelicopterIcon.cs

示例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();
		}
开发者ID:bbriggs,项目名称:wesay,代码行数:26,代码来源:AxisLine.cs

示例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();
		}
开发者ID:Raixur,项目名称:BeGraph,代码行数:34,代码来源:Edge.cs

示例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);

        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:38,代码来源:FontFamilyDropDown.cs

示例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();
 }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:27,代码来源:MeasureBeginExtension.cs

示例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();
        }
开发者ID:wybq68,项目名称:DIH_LUMBARROBAT,代码行数:28,代码来源:SinControl.xaml.cs

示例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();
 }
开发者ID:KristijanLaskovski,项目名称:SpotTheDifference,代码行数:7,代码来源:Line.cs


注:本文中的System.Drawing.Pen.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。