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


C# Drawing.Pen类代码示例

本文整理汇总了C#中System.Drawing.Pen的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Pen类属于System.Drawing命名空间,在下文中一共展示了Pen类的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: InterestPointDrawer

 public InterestPointDrawer(Bitmap background, SRegion[] regions)
     : base(background, regions)
 {
     Color c = Color.FromArgb(125, Color.Red);
     pen = new Pen(c);
     brush = new SolidBrush(c);
 }
开发者ID:paveltimofeev,项目名称:Skin-analize,代码行数:7,代码来源:InterestPointDrawer.cs

示例3: Constructor_Color_Float

		public void Constructor_Color_Float ()
		{
			using (Pen p = new Pen (Color.Red, 2.5f)) {
				Assert.AreEqual (2.5f, p.Width, "Width");
				Check (p);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:PenTest.cs

示例4: Constructor_Color

		public void Constructor_Color ()
		{
			using (Pen p = new Pen (Color.Red)) {
				Assert.AreEqual (1, p.Width, "Width");
				Check (p);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:PenTest.cs

示例5: DrawRoundRectangle

 public static void DrawRoundRectangle(Graphics g, Pen pen, Rectangle rect, int cornerRadius)
 {
     using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
     {
         g.DrawPath(pen, path);
     }
 }
开发者ID:wawa0210,项目名称:jgq,代码行数:7,代码来源:ValidateCode.aspx.cs

示例6: Draw

 public void Draw(Graphics gr, Pen pen, Brush backgroundBrush, Pen forePen)
 {
     //draw minus
     gr.FillRectangle(backgroundBrush, rectangle);
     gr.DrawRectangle(pen, rectangle);
     gr.DrawLine(forePen, rectangle.Left + 2, rectangle.Top + rectangle.Height / 2, rectangle.Right - 2, rectangle.Top + rectangle.Height / 2);
 }
开发者ID:tsovince,项目名称:V_Library,代码行数:7,代码来源:VisualMarker.cs

示例7: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            int width = this.Width;
            int height = this.Height;
            int banJing = 10;
            int ellipseX = (width - banJing * 4) / 2;
            int ellipseY = (height - banJing * 4) / 2;
            int fontX = (width - banJing * 8) / 2;
            int fontY = height / 2;
            //计算中点:width/2,height/2
            Graphics g = e.Graphics;
            Pen pn = new Pen(Color.Green, 10);
            Rectangle rect = new Rectangle(ellipseX, ellipseY, 10, 10);
            g.DrawEllipse(pn, rect);

            Font fnt = new Font("宋体", 16);
            g.DrawString("你好", fnt, new SolidBrush(Color.Red), fontX, fontY);

            int n = 10;
            double average = 360 / n;
            int size = 100;
            for (int i = 1; i < n + 1; i++)
            {
                int ellipseX1 = ellipseX + (int)(Math.Cos(((average * i * Math.PI) / 180.0)) * size);
                int ellipseY1 = ellipseY + (int)(Math.Sin(((average * i * Math.PI) / 180.0)) * size);
                Pen pn1 = new Pen(Color.Green, 10);
                Rectangle rect1 = new Rectangle(ellipseX1, ellipseY1, 10, 10);
                g.DrawEllipse(pn1, rect1);
                //Console.WriteLine("average=" + average + "   " + "average * i=" + average * i);
                //Console.WriteLine("Math.Cos(average * i):" + Math.Cos(average * i) + "      " + "Math.Sin(average * i):" + Math.Sin(average * i));
            }

            int m = 10;
            average = 360 / m;
            size = 150;
            for (int i = 1; i < n + 1; i++)
            {
                int ellipseX1 = ellipseX + (int)(Math.Cos(((average * i * Math.PI) / 180.0)) * size);
                int ellipseY1 = ellipseY + (int)(Math.Sin(((average * i * Math.PI) / 180.0)) * size);
                Pen pn1 = new Pen(Color.Green, 10);
                Rectangle rect1 = new Rectangle(ellipseX1, ellipseY1, 10, 10);
                g.DrawEllipse(pn1, rect1);
                //Console.WriteLine("average=" + average + "   " + "average * i=" + average * i);
                //Console.WriteLine("Math.Cos(average * i):" + Math.Cos(average * i) + "      " + "Math.Sin(average * i):" + Math.Sin(average * i));
            }

            int p = 10;
            average = 360 / p;
            size = 200;
            for (int i = 1; i < n + 1; i++)
            {
                int ellipseX1 = ellipseX + (int)(Math.Cos(((average * i * Math.PI) / 180.0)) * size);
                int ellipseY1 = ellipseY + (int)(Math.Sin(((average * i * Math.PI) / 180.0)) * size);
                Pen pn1 = new Pen(Color.Green, 10);
                Rectangle rect1 = new Rectangle(ellipseX1, ellipseY1, 10, 10);
                g.DrawEllipse(pn1, rect1);
                //Console.WriteLine("average=" + average + "   " + "average * i=" + average * i);
                //Console.WriteLine("Math.Cos(average * i):" + Math.Cos(average * i) + "      " + "Math.Sin(average * i):" + Math.Sin(average * i));
            }
        }
开发者ID:628Laboratory,项目名称:IPScan,代码行数:60,代码来源:Form1.cs

示例8: RectangleTransparent

        public RectangleTransparent()
        {
            clearPen = new Pen(Color.FromArgb(1, 0, 0, 0));
            borderDotPen = new Pen(Color.Black, 1);
            borderDotPen2 = new Pen(Color.White, 1);
            borderDotPen2.DashPattern = new float[] { 5, 5 };
            penTimer = Stopwatch.StartNew();
            ScreenRectangle = CaptureHelpers.GetScreenBounds();

            surface = new Bitmap(ScreenRectangle.Width, ScreenRectangle.Height);
            gSurface = Graphics.FromImage(surface);
            gSurface.InterpolationMode = InterpolationMode.NearestNeighbor;
            gSurface.SmoothingMode = SmoothingMode.HighSpeed;
            gSurface.CompositingMode = CompositingMode.SourceCopy;
            gSurface.CompositingQuality = CompositingQuality.HighSpeed;
            gSurface.Clear(Color.FromArgb(1, 0, 0, 0));

            StartPosition = FormStartPosition.Manual;
            Bounds = ScreenRectangle;
            Text = "ShareX - " + Resources.RectangleTransparent_RectangleTransparent_Rectangle_capture_transparent;

            Shown += RectangleLight_Shown;
            KeyUp += RectangleLight_KeyUp;
            MouseDown += RectangleLight_MouseDown;
            MouseUp += RectangleLight_MouseUp;

            using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
            {
                Cursor = new Cursor(cursorStream);
            }

            timer = new Timer { Interval = 10 };
            timer.Tick += timer_Tick;
            timer.Start();
        }
开发者ID:KamilKZ,项目名称:ShareX,代码行数:35,代码来源:RectangleTransparent.cs

示例9: GetPen

 public Pen GetPen()
 {
     Random r = new Random();
     Color color = Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255));
     Pen pen = new Pen(color);
     return pen;
 }
开发者ID:isen131,项目名称:Rectangles,代码行数:7,代码来源:Form1.cs

示例10: DrawAppointment

        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
开发者ID:bshultz,项目名称:ctasks,代码行数:60,代码来源:Office11Renderer.cs

示例11: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                GraphicsPath path = new GraphicsPath();

                path.AddLine(20, 20, 170, 20);
                path.AddLine(20, 20, 20, 100);
                // рисуем новую фигуру
                path.StartFigure();
                path.AddLine(240, 140, 240, 50);
                path.AddLine(240, 140, 80, 140);
                path.AddRectangle(new Rectangle(30, 30, 200, 100));
                // локальное преобразование траектории
                //Matrix X = new Matrix();
                //X.RotateAt(45, new PointF(60.0f, 100.0f));
                //path.Transform(X);
                // рисуем  path
                Pen redPen = new Pen(Color.Red, 2);
                g.FillPath(new SolidBrush(Color.Bisque), path);
                g.DrawPath(redPen, path);

            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:25,代码来源:Form1.cs

示例12: DrawPath

 public void DrawPath(Graphics g, Pen p)
 {
     if (m_points != null)
      {
     g.DrawLines(p, m_points);
      }
 }
开发者ID:Aswanthsb,项目名称:aguaviva-libs,代码行数:7,代码来源:Path.cs

示例13: Circle

 public Circle(float x, float y, float r, Color color)
 {
     this.x = x;
     this.y = y;
     this.radius = r;
     this.p = new System.Drawing.Pen(color, 3.5f);
 }
开发者ID:Karljr79,项目名称:Multiple_World_Sim,代码行数:7,代码来源:Circle.cs

示例14: Surface

        public Surface()
        {
            ScreenRectangle = CaptureHelpers.GetScreenBounds();
            ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle);

            InitializeComponent();

            using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
            {
                Cursor = new Cursor(cursorStream);
            }

            DrawableObjects = new List<DrawableObject>();
            Config = new SurfaceOptions();
            timerStart = new Stopwatch();
            timerFPS = new Stopwatch();

            borderPen = new Pen(Color.Black);
            borderDotPen = new Pen(Color.White);
            borderDotPen.DashPattern = new float[] { 5, 5 };
            nodeBackgroundBrush = new SolidBrush(Color.White);
            textFont = new Font("Verdana", 16, FontStyle.Bold);
            infoFont = new Font("Verdana", 9);
            textBackgroundBrush = new SolidBrush(Color.FromArgb(75, Color.Black));
            textBackgroundPenWhite = new Pen(Color.FromArgb(50, Color.White));
            textBackgroundPenBlack = new Pen(Color.FromArgb(150, Color.Black));
            markerPen = new Pen(Color.FromArgb(200, Color.Red)) { DashStyle = DashStyle.Dash };
        }
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:28,代码来源:Surface.cs

示例15: DrawPipeLine

        public void DrawPipeLine(Graphics g,GSOPipeLineStyle3D pipeLineStyle)
        {
            Pen newPen = new Pen(pipeLineStyle.LineColor, 1.0f);

            int nEllipseHeight = (int)(Height * 0.3);
            int nEllipseWidth = nEllipseHeight/2;
            int nStartX = (int)(Width*0.1);

            int nHalfHeight=Height/2;

            int nBodyStartX=nStartX+nEllipseWidth/2;

            Rectangle rcEllipse = new Rectangle(nStartX, nHalfHeight - nEllipseHeight / 2, nEllipseWidth, nEllipseHeight);
            Rectangle rcTailEllipse = new Rectangle(this.Width - nStartX - nEllipseWidth, nHalfHeight - nEllipseHeight / 2, nEllipseWidth, nEllipseHeight);
            Rectangle rcFill = new Rectangle(nBodyStartX, rcEllipse.Top, Width - 2*nBodyStartX+nEllipseWidth/2, nEllipseHeight);

            Color FColor = pipeLineStyle.LineColor;

            Color TColor = Color.FromArgb(255, 255, 255);

            Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.BackwardDiagonal);

            g.FillRectangle(b, rcFill);

            g.DrawEllipse(newPen, rcEllipse);

            g.DrawEllipse(newPen, rcTailEllipse);

            g.DrawLine(newPen, nBodyStartX, rcEllipse.Top, Width - nBodyStartX, rcEllipse.Top);
            g.DrawLine(newPen, nBodyStartX, rcEllipse.Bottom, Width - nBodyStartX, rcEllipse.Bottom);
        }
开发者ID:StarU,项目名称:qkKL6Dgf12,代码行数:31,代码来源:CtrlLineStylePreview.cs


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