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


C# System.Drawing.Drawing2D.GraphicsPath.AddLines方法代码示例

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


在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.AddLines方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawCurves

        /// <summary>
        /// Draw curves on graphics with transform and given pen
        /// </summary>
        static void DrawCurves(
            Graphics graphics,
            List<PointF[]> curves,
            System.Drawing.Drawing2D.Matrix transform,
            Pen pen)
        {
            foreach( PointF[] curve in curves )
              {
            System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath();
            if( curve.Length == 0 )
            {
              break;
            }
            if( curve.Length == 1 )
            {
              gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI );
            }
            else
            {
              gPath.AddLines( curve );
            }
            if( transform != null )
              gPath.Transform( transform );

            graphics.DrawPath( pen, gPath );
              }
        }
开发者ID:Nakyoung,项目名称:FramingXsecAnalyzer,代码行数:30,代码来源:GeoSnoop.cs

示例2: DrawLineString

 /// <summary>
 /// Renders a LineString to the map.
 /// </summary>
 /// <param name="g">Graphics reference</param>
 /// <param name="line">LineString to render</param>
 /// <param name="pen">Pen style used for rendering</param>
 /// <param name="map">Map reference</param>
 public static void DrawLineString(System.Drawing.Graphics g, Geometries.LineString line, System.Drawing.Pen pen, SharpMap.Map map)
 {
     if (line.Vertices.Count > 1)
     {
         System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
         gp.AddLines(line.TransformToImage(map));
         g.DrawPath(pen, gp);
     }
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:16,代码来源:VectorRenderer.cs

示例3: Render

        public void Render(LittleSharpRenderEngine engine, Graphics graphics, ILineString line, ILineStyle style)
        {
            if (line == null || style == null)
                return;

            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            //TODO: Does not seems to add a single long line, but multiple line segments
            gp.AddLines(RenderUtil.CoordToPoint(line.Coordinates));

            if (style.Outlines != null)
                foreach(IOutline linestyle in style.Outlines)
                    RenderUtil.RenderOutline(engine, graphics, gp, linestyle);
        }
开发者ID:mustafayalcin,项目名称:littlesharprenderengine,代码行数:13,代码来源:Line.cs

示例4: DrawBorder

        private void DrawBorder(Graphics graphics)
        {
            var rectangleCloseButton = new Rectangle(Width - titleBarThickness - 1, 0, titleBarThickness, titleBarThickness);
            var rectangleMinimizeButton = new Rectangle(Width - titleBarThickness * 2, 0, titleBarThickness, titleBarThickness);

            var pLeftUp1 = new Point(0, 0);
            var pLeftUp2 = new Point(thickness, thickness);

            var pRightUp1 = new Point(Width, 0);
            var pRightUp2 = new Point(Width - thickness, thickness);

            var pLeftDown1 = new Point(0, Height);
            var pLeftDown2 = new Point(thickness, Height - thickness);

            var pRightDown1 = new Point(Width, Height);
            var pRightDown2 = new Point(Width - thickness, Height - thickness);

            //UP
            var pathUp = new System.Drawing.Drawing2D.GraphicsPath();
            pathUp.AddLines(new[] { pLeftUp1, new Point(0, titleBarThickness), new Point(Width, titleBarThickness), pRightUp1 });

            //Left
            var pathLeft = new System.Drawing.Drawing2D.GraphicsPath();
            pathLeft.AddLines(new[] { pLeftUp1, pLeftUp2, pLeftDown2, pLeftDown1 });

            //Bottom
            var pathBottom = new System.Drawing.Drawing2D.GraphicsPath();
            pathBottom.AddLines(new[] { pLeftDown1, pLeftDown2, pRightDown2, pRightDown1 });

            //Right
            var pathRight = new System.Drawing.Drawing2D.GraphicsPath();
            pathRight.AddLines(new[] { pRightDown1, pRightDown2, pRightUp2, pRightUp1 });

            //External Up
            graphics.SetClip(pathUp);
            graphics.DrawLine(PenBorder, pLeftUp1, pRightUp1);

            //External Left
            graphics.SetClip(pathLeft);
            graphics.DrawLine(PenBorder, pLeftUp1, pLeftDown1);

            //External Bottom
            graphics.SetClip(pathBottom);
            graphics.DrawLine(PenBorder, pLeftDown1, pRightDown1);

            //External Right
            graphics.SetClip(pathRight);
            graphics.DrawLine(PenBorder, pRightUp1, pRightDown1);

            graphics.ResetClip();
        }
开发者ID:henrydm,项目名称:Air-Mouse-Windows,代码行数:51,代码来源:MessageForm.cs

示例5: Draw

 public override void Draw(Graphics g,string str)
 {
     PointF A;
     PointF B;
     System.Drawing.Drawing2D.GraphicsPath graphPath = new System.Drawing.Drawing2D.GraphicsPath();
     switch(str)
     {
         case "XY": A = new PointF(_v1.X+3, g.VisibleClipBounds.Height - _v1.Y); B = new PointF(_v2.X+3, g.VisibleClipBounds.Height - _v2.Y); break;
         case "XZ": A = new PointF(_v1.X + 3, g.VisibleClipBounds.Height - _v1.Z); B = new PointF(_v2.X + 3, g.VisibleClipBounds.Height - _v2.Z); break;
         case "YZ": A = new PointF(_v1.Y + 3, g.VisibleClipBounds.Height - _v1.Z); B = new PointF(_v2.Y + 3, g.VisibleClipBounds.Height - _v2.Z); break;
         default: A = new PointF();  B = new PointF(); break;
     }
     PointF[] arrayOfPoint =
         {
             A,
             B
         };
     graphPath.AddLines(arrayOfPoint);
     g.DrawPath(new Pen(Color.Black),graphPath);
 }
开发者ID:flufferok,项目名称:OOP,代码行数:20,代码来源:Line.cs

示例6: CreateRegion

		/// <summary>
		/// creates the region for the control. The region will have curved edges.
		/// This prevents any drawing outside of the region.
		/// </summary>
		private void CreateRegion(int nContract)
		{
			Point[] points = border_Get(0,0,this.Width,this.Height);
			border_Contract(nContract,ref points);
			System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
			path.AddLines(points);
			this.Region = new Region(path);
		}
开发者ID:unieagle,项目名称:libpalaso,代码行数:12,代码来源:BitmapButton.cs

示例7: drawer

        public static int drawer(OptsType opts, ArgsType args)
        {
            string[] commands = Regex.Split(Console.In.ReadToEnd(), @"\r?\n");

              System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
              List<PointF> pts = new List<PointF>();
              foreach (var line in commands) {
            var items = Regex.Split(line, @"\s+");
            if (items.Length != 2) {
              if (pts.Count > 0) {
            if (pts.Count == 1) {
              gp.AddLine(pts.First(), pts.First());
            }
            else {
              gp.AddLines(pts.ToArray());
            }
            pts.Clear();
              }
              continue;
            }
            float x, y;
            if (float.TryParse(items[0], out x) && float.TryParse(items[1], out y)) {
              pts.Add(new PointF(x, y));
            }
              }

              Color bgcolor = Color.Black;
              if (opts.ContainsKey("bgcolor")) {
            bgcolor = Color.FromName(opts["bgcolor"]);
              }

              Color fgcolor = Color.White;
              if (opts.ContainsKey("fgcolor")) {
            fgcolor = Color.FromName(opts["fgcolor"]);
              }

              float pensize = 1.0f;
              if (opts.ContainsKey("pensize")) {
            float val;
            if (float.TryParse(opts["pensize"], out val)) {
              pensize = val;
            }
              }

              string title = "fwfw drawer";
              if (opts.ContainsKey("title")) {
            title = opts["title"];
              }

              int width = 512;
              if (opts.ContainsKey("width")) {
            int val;
            if (int.TryParse(opts["width"], out val)) {
              width = val;
            }
              }
              int height = 512;
              if (opts.ContainsKey("height")) {
            int val;
            if (int.TryParse(opts["height"], out val)) {
              height = val;
            }
              }

              Form f = new Form();
              f.Text = title;
              f.StartPosition = FormStartPosition.CenterScreen;
              f.Size = new Size(width, height);

              f.Resize += (s, e) => {
            Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height);
            Graphics g = Graphics.FromImage(bitmap);
            g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle);
            g.DrawPath(new Pen(fgcolor, pensize), gp);
            g.Dispose();
            f.BackgroundImage = bitmap;
              };

              f.MouseClick += (s, e) => {
            // var loc = f.PointToClient(e.Location);
            Console.Out.WriteLine("{e.Location.X}\t{e.Location.Y}");
              };

              f.Shown +=  (s, e) => {
            Bitmap bitmap = new Bitmap(f.ClientRectangle.Width, f.ClientRectangle.Height);
            Graphics g = Graphics.FromImage(bitmap);
            g.FillRectangle(new SolidBrush(bgcolor), f.ClientRectangle);
            g.DrawPath(new Pen(fgcolor, pensize), gp);
            g.Dispose();
            f.BackgroundImage = bitmap;
              };

              f.ShowDialog();

              return 0;
        }
开发者ID:dyama,项目名称:fwfw,代码行数:96,代码来源:drawer.cs

示例8: Draw3D

        public override void Draw3D(Graphics g)
        {
            float x0 = g.VisibleClipBounds.Width / 4;
            float y0 = g.VisibleClipBounds.Height / 4;
            float resultX1 = _v1.X + x0;
            float resultY1 = _v1.Y+y0;
            //float resultZ1 = _v1.Z + y0;

            float resultX2 = _v2.X +x0;
            float resultY2 = _v2.Y+y0;
            //float resultZ2 = _v2.Z + y0;

            PointF A;
            PointF B;
            System.Drawing.Drawing2D.GraphicsPath graphPath = new System.Drawing.Drawing2D.GraphicsPath();
            A = new PointF(resultX1+3, resultY1); B = new PointF(resultX2+3, resultY2);
            PointF[] arrayOfPoint =
                {
                    A,
                    B
                };
            graphPath.AddLines(arrayOfPoint);
            g.DrawPath(new Pen(Color.Black), graphPath);
        }
开发者ID:flufferok,项目名称:OOP,代码行数:24,代码来源:Line.cs

示例9: Paint

        /// <summary>
        /// Repaints the form with cool background and stuff
        /// </summary>
        /// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param>
        public virtual void Paint(Graphics graph)
        {
            //Sets up the colors to use
            Pen outlinePen = new Pen(MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.6 * Highlight), 1.75F);
            Color gradientTop = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.7 * Highlight);
            Color gradientBottom = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 1.0 * Highlight);

            //The path used for drop shadows
            System.Drawing.Drawing2D.GraphicsPath shadowPath = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.ColorBlend colorBlend = new System.Drawing.Drawing2D.ColorBlend(3);
            colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DarkGray), Color.FromArgb(180, Color.DimGray) };
            colorBlend.Positions = new float[] { 0f, 0.125f,1f};

            //Draws Rectangular Shapes
            if (Shape == ModelShapes.Rectangle)
            {
                //Draws the shadow
                shadowPath.AddPath(GetRoundedRect(new Rectangle(5, 5, this.Width, this.Height), 10), true);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the basic shape
                System.Drawing.Rectangle fillRectange = new Rectangle(0, 0, this.Width - 5, this.Height - 5);
                System.Drawing.Drawing2D.GraphicsPath fillArea = GetRoundedRect(fillRectange, 5);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillRectange, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillPath(myBrush, fillArea);
                graph.DrawPath(outlinePen, fillArea);
                
                //Draws the status light
                drawStatusLight(graph);
                
                //Draws the text
                SizeF textSize = graph.MeasureString(Name, Font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                fillArea.Dispose();
                myBrush.Dispose();
            }

            //Draws Ellipse Shapes
            if (_shape == ModelShapes.Ellipse)
            {
                //Draws the shadow
                shadowPath.AddEllipse(0, 5, this.Width+5, this.Height);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the Ellipse
                System.Drawing.Rectangle fillArea = new Rectangle(0, 0, this.Width, this.Height);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillEllipse(myBrush, 1, 1, this.Width - 5, this.Height - 5);
                graph.DrawEllipse(outlinePen, 1, 1, this.Width - 5, this.Height - 5);

                //Draws the text
                SizeF textSize = graph.MeasureString(_name, _font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                myBrush.Dispose();
            }

            //Draws Triangular Shapes
            if (_shape == ModelShapes.Triangle)
            {
                //Draws the shadow
                Point[] ptShadow = new Point[4];
                ptShadow[0] = new Point(5, 5);
                ptShadow[1] = new Point(this.Width + 5, ((this.Height - 5) / 2) + 5);
                ptShadow[2] = new Point(5, this.Height+2);
                ptShadow[3] = new Point(5, 5);
                shadowPath.AddLines(ptShadow);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);
//.........这里部分代码省略.........
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:101,代码来源:ModelElement.cs

示例10: RefreshAndStopDrawing

        /// <summary>
        /// Erase the trail of the gesture and stop drawing
        /// </summary>
        public void RefreshAndStopDrawing()
        {

            // the drawing of gestures was finished
            m_gestureDrawing = false;
            // drawing in thread timer tick should not continue
            m_drawingEnded = true;
            // stop the thread timer
            m_threadTimerDraw.Change(-1, -1);

            if (!m_threadDrawing)
            {
                int lastIndex = m_curvePoints.Count;
                PointF[] points = m_curvePoints.GetRange(m_lastIndex, lastIndex - m_lastIndex).ToArray();
                m_lastIndex = lastIndex - 1;
                if (points.Length > 1)
                    m_gp.DrawLines(m_pen, points);
            }

            List<PointF> allPoints = new List<PointF>(m_curvePoints.ToArray());
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddLines(allPoints.ToArray());
            RectangleF rect = path.GetBounds();
            int rectShift = m_penWidth * 6;
            rect.X -= rectShift;
            rect.Y -= rectShift;
            rect.Width += rectShift * 2;
            rect.Height += rectShift * 2;
            //Win32.RECT r = new Win32.RECT(rect);
            m_drawnRegion = new Win32.RECT(rect);
            //Rectangle r = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
            if (!m_threadDrawing)
            {
                Debug.WriteLine(String.Format("##### InvalidateRect in MOUSE UP left: {0}, top: {1}, right: {2}, bottom: {3} ######",
                    m_drawnRegion.left, m_drawnRegion.top, m_drawnRegion.right, m_drawnRegion.bottom));
                //Win32.InvalidateRect(m_hwndForm, ref m_drawnRegion, true);
                Win32.RedrawWindow(m_hwndForm, ref m_drawnRegion, IntPtr.Zero, Win32.RDW_ERASE | Win32.RDW_INVALIDATE | Win32.RDW_UPDATENOW);                
                MakeNonTopMost();
            }
            else
                m_redrawInTick = true;
            //this.Invalidate(r);
            //Win32.RedrawWindow(m_hwndForm, ref r, IntPtr.Zero, 0x2);
        }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:47,代码来源:Form_transparent.cs


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