AddLines() public method

public AddLines ( Point points ) : void
points Point
return void
Beispiel #1
0
		private void DrawPointerDown(Graphics g)
		{
			Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);
			Region region = new Region(path);
			g.Clip = region;

			if (ThumbState == 3 || !base.Enabled)
				ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
			else
				g.Clear(SystemColors.Control);

			g.ResetClip();
			region.Dispose();
			path.Dispose();
			Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLightLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
			points[0].Offset(0, -1);
			points[1].Offset(1, 0);
			points[2].Offset(1, 1);
			points[3].Offset(-1, 1);
			points[4].Offset(-1, 0);
			points[5] = points[0];
			pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDark, pointArray2);
		}
Beispiel #2
0
        /// <summary>
        /// Create the Top tab path
        /// </summary>
        /// <returns>GraphicsPath</returns>
        private GraphicsPath TopTabPath()
        {         
            GraphicsPath path = new GraphicsPath();

            Rectangle r = TabItem.DisplayRectangle;
            r.Width -= 1;
            r.Height -= 1;

            // Allow for the TabStrip border

            if (TabItem.IsSelected == true)
                r.Height += 2;

            // Create the path

            path.AddLines(new Point[]
            {
                new Point(r.X, r.Bottom), 
                new Point(r.X, r.Top),
                new Point(r.Right, r.Top),
                new Point(r.Right, r.Bottom),
            });

            return (path);
        }
Beispiel #3
0
        //------------------------------------------------------------------------------
        private static void DrawBezierCtrlLines(Graphics graphics,
      MultiPathSegment mps, uint color)
        {
            int cnt = mps.Count;
              if (cnt < 2) return;
              Pen pen = new Pen(MakeColor(color));
              GraphicsPath gpath = new GraphicsPath();
              PointF[] pts = new PointF[2];
              pts[0] = PathToPointF(mps[0]);
              pts[1] = PathToPointF(mps[1]);
              gpath.StartFigure();
              gpath.AddLines(pts);

              if (mps.IsValid())
            if (mps.curvetype == CurveType.CubicBezier)
            {
              pts[0] = PathToPointF(mps[2]);
              pts[1] = PathToPointF(mps[3]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }
            else
            {
              pts[0] = PathToPointF(mps[2]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }

              graphics.DrawPath(pen, gpath);
              pen.Dispose();
              gpath.Dispose();
        }
        public ProgressControl()
        {
            SetStyle(ControlStyles.UserPaint, true);
              SetStyle(ControlStyles.DoubleBuffer, true);
              SetStyle(ControlStyles.ResizeRedraw, true);
              SetStyle(ControlStyles.AllPaintingInWmPaint, true);

              pnOutln = new Pen(cOutln, iOutlln);
              rcArea = new Rectangle[5];
              for (int i = 0; i < 5; ++i) {
            rcArea[i].X = i * (iWidth + iPad);
            rcArea[i].Width = iWidth + iPad;
            rcArea[i].Height = iHeight;
              }

              //setup arrow shape
              gpBlock = new GraphicsPath();
              gpBlock.AddLines(new PointF[] {
            new PointF(0, 0),                   //TL
            new PointF(iWidth - iPad, 0),       //TR
            new PointF(iWidth, iHeight / 2),    //MR
            new PointF(iWidth - iPad, iHeight), //BR
            new PointF(0, iHeight),             //BL
            new PointF(iPad, iHeight / 2)       //ML
              });
              gpBlock.CloseFigure();
        }
       /// <summary>
       /// Draws the point symbol in the view
       /// </summary>
       /// <param name="g"></param>
       /// <param name="clip"></param>
       protected virtual void OnDraw(Graphics g, Rectangle clip)
       {
           if (_borderStyle == BorderStyle.Fixed3D)
           {
               g.DrawLine(Pens.White, 0, Height - 1, Width - 1, Height - 1);
               g.DrawLine(Pens.White, Width - 1, 0, Width - 1, Height - 1);
               g.DrawLine(Pens.Gray, 0, 0, 0, Height - 1);
               g.DrawLine(Pens.Gray, 0, 0, Width - 1, 0);
           }
           if (_borderStyle == BorderStyle.FixedSingle)
           {
               g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
           }
           int w = Width;
           int h = Height;
           if (_symbolizer == null) return;
           int lineWidth = Convert.ToInt32(_symbolizer.GetWidth());
           if (lineWidth > 128) lineWidth = 128;
           if (lineWidth < 1) lineWidth = 1;
 
           GraphicsPath gp = new GraphicsPath();
           gp.AddLines(new[]{new Point(lineWidth, (h * 2) / 3), new Point(w/3, h / 3), new Point((w * 2) / 3, (h*2)/3), new Point(w - lineWidth, h/3)});
           _symbolizer.DrawPath(g, gp, 1);
         
       }
Beispiel #6
0
 void paintshit(List<double> datta, int numPoints, double mulX, double mulY, int bw, int bh, Graphics g, LinearGradientBrush grad, Color cbase)
 {
     PointF[] points = new PointF[numPoints];
     lock (datta)
     {
         int s = 0;
         int samples = datta.Count;
         for (; s < (points.Length - 2) - samples; s++)
         {
             points[s + 1] = new PointF((float)(s * mulX), bh);
         }
         int ofs = (points.Length - 2) - samples;
         s = Math.Max(0, samples - (points.Length - 2));
         for (; s < samples; s++)
         {
             points[s + ofs + 1] = new PointF((float)((s + ofs) * mulX),
                 (float)(bh - datta[s] * mulY));
         }
         points[0] = new PointF(0f, bh);
         points[points.Length - 1] = new PointF(bw, bh);
     }
     GraphicsPath gp = new GraphicsPath();
     gp.AddLines(points);
     g.FillPath(grad, gp);
     g.DrawPath(new Pen(cbase, 2f), gp);
 }
        /// <summary>
        /// Initializes the control with default values
        /// </summary>
        public StarRatingControl()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
              SetStyle(ControlStyles.UserPaint, true);
              SetStyle(ControlStyles.DoubleBuffer, true);
              SetStyle(ControlStyles.ResizeRedraw, true);

              pnOutln = new Pen(cOutln, iOutThick);
              rcArea = new Rectangle[iStarCount];
              for (int i = 0; i < iStarCount; ++i) {
            rcArea[i].X = i * (iWidth + iPadding);
            rcArea[i].Width = iWidth + iPadding;
            rcArea[i].Height = iHeight;
              }

              //setup star shape (from top tip and in thirds)
              gpStar = new GraphicsPath();
              PointF[] pfStar = new PointF[10];
              pfStar[0] = new PointF(iWidth / 2, 0);											//12:00
              pfStar[1] = new PointF(2 * iWidth / 3, iHeight / 3);        //01:00
              pfStar[2] = new PointF(iWidth, iHeight / 3);                //02:00
              pfStar[3] = new PointF(4 * iWidth / 5, 4 * iHeight / 7);    //03:00
              pfStar[4] = new PointF(5 * iWidth / 6, iHeight);            //04:00
              pfStar[5] = new PointF(iWidth / 2, 4 * iHeight / 5);        //06:00
              pfStar[6] = new PointF(iWidth - pfStar[4].X, pfStar[4].Y);	//08:00
              pfStar[7] = new PointF(iWidth - pfStar[3].X, pfStar[3].Y);	//09:00
              pfStar[8] = new PointF(iWidth - pfStar[2].X, pfStar[2].Y);	//10:00
              pfStar[9] = new PointF(iWidth - pfStar[1].X, pfStar[1].Y);	//11:00
              gpStar.AddLines(pfStar);
              gpStar.CloseFigure();
        }
        private GraphicsPath GetCornerRect(RectangleF baseRect, float ratio)
        {
            GraphicsPath path   = new System.Drawing.Drawing2D.GraphicsPath();
            float        radius = Math.Min(baseRect.Width, baseRect.Height) * ratio;

            PointF[] points = new PointF[8];

            points[0].X = baseRect.Left;
            points[0].Y = baseRect.Top + radius;
            points[1].X = points[0].X + radius;
            points[1].Y = baseRect.Top;
            points[2].X = points[0].X + baseRect.Width - radius;
            points[2].Y = points[1].Y;
            points[3].X = points[0].X + baseRect.Width;
            points[3].Y = points[0].Y;
            points[4].X = points[3].X;
            points[4].Y = baseRect.Bottom - radius;
            points[5].X = points[2].X;
            points[5].Y = baseRect.Bottom;
            points[6].X = points[1].X;
            points[6].Y = points[5].Y;
            points[7].X = points[0].X;
            points[7].Y = points[4].Y;

            path.AddLines(points);
            path.CloseFigure();

            return(path);
        }
Beispiel #9
0
 public ColorPicker()
 {
     this.InitializeComponent();
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
     this.SetColorRGB(0, 0, 0);
     using (Graphics graphics = Graphics.FromImage(this.hues))
     {
         for (int i = 0; i < (this.hues.Height - 2); i++)
         {
             using (SolidBrush brush = new SolidBrush(HSVColor(0xff - i, 0xff, 0xff)))
             {
                 graphics.FillRectangle(brush, 0, i, this.hues.Width, 1);
             }
         }
     }
     using (Graphics graphics2 = Graphics.FromImage(this.leftArrow))
     {
         PointF[] points = new PointF[] { new Point(0, 0), new Point(5, 5), new Point(0, 10), new Point(0, 0) };
         GraphicsPath path = new GraphicsPath();
         path.AddLines(points);
         graphics2.FillPath(Brushes.Black, path);
     }
     using (Graphics graphics3 = Graphics.FromImage(this.rightArrow))
     {
         PointF[] tfArray2 = new PointF[] { new Point(5, 0), new Point(0, 5), new Point(5, 10), new Point(5, 0) };
         GraphicsPath path2 = new GraphicsPath();
         path2.AddLines(tfArray2);
         graphics3.FillPath(Brushes.Black, path2);
     }
     this.paletteBox.BackgroundImage = this.palette;
     this.hueSlider.BackgroundImage = this.hues;
     this.UpdatePalette();
 }
        protected override System.Drawing.Region OnCreateMaskRegion(Skybound.VisualTips.VisualTip tip, Skybound.VisualTips.Rendering.VisualTipLayout layout)
        {
            System.Drawing.Region region;

            System.Drawing.Rectangle rectangle = layout.WindowBounds;
            System.Drawing.Point[]   pointArr1 = GetArrowPoints(tip, rectangle);
            System.Drawing.Point[]   pointArr2 = new System.Drawing.Point[6];
            if (pointArr1[0].Y == rectangle.Y)
            {
                pointArr1.CopyTo(pointArr2, 0);
                System.Drawing.Point point1 = new System.Drawing.Point(rectangle.X + 10, rectangle.Bottom);
                pointArr2[5] = new System.Drawing.Point(rectangle.X + 10, rectangle.Bottom);
                System.Drawing.Point point2 = point1;
                pointArr2[4] = point1;
                pointArr2[3] = point2;
            }
            else
            {
                System.Drawing.Point point3 = new System.Drawing.Point(rectangle.X + 10, rectangle.Y);
                pointArr2[2] = new System.Drawing.Point(rectangle.X + 10, rectangle.Y);
                System.Drawing.Point point4 = point3;
                pointArr2[1] = point3;
                pointArr2[0] = point4;
                pointArr1.CopyTo(pointArr2, 3);
            }
            using (System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                System.Drawing.Point[] pointArr3 = new System.Drawing.Point[26];
                pointArr3[0]  = new System.Drawing.Point(rectangle.X, rectangle.Y + 5);
                pointArr3[1]  = new System.Drawing.Point(rectangle.X + 1, rectangle.Y + 3);
                pointArr3[2]  = new System.Drawing.Point(rectangle.X + 2, rectangle.Y + 2);
                pointArr3[3]  = new System.Drawing.Point(rectangle.X + 3, rectangle.Y + 1);
                pointArr3[4]  = new System.Drawing.Point(rectangle.X + 5, rectangle.Y);
                pointArr3[5]  = new System.Drawing.Point(pointArr2[0].X, pointArr2[0].Y);
                pointArr3[6]  = new System.Drawing.Point(pointArr2[1].X, pointArr2[1].Y);
                pointArr3[7]  = new System.Drawing.Point(pointArr2[1].X + 1, pointArr2[1].Y);
                pointArr3[8]  = new System.Drawing.Point(pointArr2[2].X + 1, pointArr2[2].Y);
                pointArr3[9]  = new System.Drawing.Point(rectangle.Right - 5, rectangle.Y);
                pointArr3[10] = new System.Drawing.Point(rectangle.Right - 2, rectangle.Y + 2);
                pointArr3[11] = new System.Drawing.Point(rectangle.Right - 1, rectangle.Y + 4);
                pointArr3[12] = new System.Drawing.Point(rectangle.Right, rectangle.Bottom - 7);
                pointArr3[13] = new System.Drawing.Point(rectangle.Right - 2, rectangle.Bottom - 3);
                pointArr3[14] = new System.Drawing.Point(rectangle.Right - 5, rectangle.Bottom - 1);
                pointArr3[15] = new System.Drawing.Point(rectangle.Right - 6, rectangle.Bottom);
                pointArr3[16] = new System.Drawing.Point(pointArr2[3].X + 1, pointArr2[3].Y);
                pointArr3[17] = new System.Drawing.Point(pointArr2[4].X + 1, pointArr2[4].Y);
                pointArr3[18] = new System.Drawing.Point(pointArr2[4].X, pointArr2[4].Y);
                pointArr3[19] = new System.Drawing.Point(pointArr2[5].X, pointArr2[5].Y);
                pointArr3[20] = new System.Drawing.Point(rectangle.X + 5, rectangle.Bottom);
                pointArr3[21] = new System.Drawing.Point(rectangle.X + 5, rectangle.Bottom - 1);
                pointArr3[22] = new System.Drawing.Point(rectangle.X + 4, rectangle.Bottom - 1);
                pointArr3[23] = new System.Drawing.Point(rectangle.X + 2, rectangle.Bottom - 3);
                pointArr3[24] = new System.Drawing.Point(rectangle.X + 1, rectangle.Bottom - 4);
                pointArr3[25] = new System.Drawing.Point(rectangle.X, rectangle.Bottom - 6);
                graphicsPath.AddLines(pointArr3);
                region = new System.Drawing.Region(graphicsPath);
            }
            return(region);
        }
Beispiel #11
0
            /// <summary>
            ///     Adds a series of lines to the end of the path.
            /// </summary>
            /// <param name="points">The points of the lines to add.</param>
            /// <returns>This <see cref="IGraphicsPath" />.</returns>
            public IGraphicsPath AddLines([NotNull] params Vector2[] points)
            {
                if (points == null)
                {
                    throw new ArgumentNullException(nameof(points));
                }
                PointF[] pointFs = new PointF[points.Length + 1];
                pointFs[0] = _lastPoint;

                for (int i = 1; i <= points.Length; i++)
                {
                    pointFs[i] = _lastPoint = points[i].ToPointF();
                }

                _pathGeometry?.AddLines(pointFs);
                return(this);
            }
 private GraphicsPath GetDiamondPath(Rectangle rectangle)
 {
     Point[] points = new Point[] { new Point(rectangle.Left + (rectangle.Width / 2), rectangle.Top), new Point(rectangle.Right - 1, rectangle.Top + (rectangle.Height / 2)), new Point(rectangle.Left + (rectangle.Width / 2), rectangle.Bottom - 1), new Point(rectangle.Left, rectangle.Top + (rectangle.Height / 2)), new Point(rectangle.Left + (rectangle.Width / 2), rectangle.Top) };
     GraphicsPath path = new GraphicsPath();
     path.AddLines(points);
     path.CloseFigure();
     return path;
 }
Beispiel #13
0
 /// <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, ILineString line, System.Drawing.Pen pen, SharpMap.Map map)
 {
     if (line.Coordinates.Length > 1)
     {
         System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
         gp.AddLines(Transform.TransformToImage(line, map));
         g.DrawPath(pen, gp);
     }
 }
Beispiel #14
0
		/// <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, ILineString line, System.Drawing.Pen pen, SharpMap.Map map)
		{
			if (line.Coordinates.Length > 1)
			{
				System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
				gp.AddLines(Transform.TransformToImage(line, map));
				g.DrawPath(pen, gp);
			}
		}
Beispiel #15
0
        public void AddLines(IEnumerable <PointF> points)
        {
            var sdpoints = from p in points select p.ToSD();

            var pointArray = sdpoints.ToArray();

            Control.AddLines(pointArray);
            position = pointArray.Last();
        }
Beispiel #16
0
		/// <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);
			}
		}
		public void NextMarker_Null ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLines (pts_2f);
				using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
					Assert.AreEqual (0, gpi.NextMarker (null));
				}
			}
		}
 public static void DrawLineString(Graphics graphics, LineString line, Pen pen, IViewport viewport)
 {
     if (line.Vertices.Count > 1)
     {
         var gp = new GraphicsPath();
         gp.AddLines(ConvertPoints(WorldToView(line, viewport)));
         graphics.DrawPath(pen, gp);
     }
 }
		private void CreateMarkPen()
		{
			GraphicsPath path = new GraphicsPath();
			path.AddLines(new Point[] { new Point(0, 0), new Point(1, 1), new Point(-1, 1), new Point(0, 0) });
			CustomLineCap cap = new CustomLineCap(null, path);
			cap.WidthScale = 1.0f;

			_markPen = new Pen(_dragDropMarkColor, _dragDropMarkWidth);
			_markPen.CustomStartCap = cap;
			_markPen.CustomEndCap = cap;
		}
 public override void Draw(Graphics g)
 {
     var path = new GraphicsPath();
     var vertices = _lineString.ToVertices();
     if (vertices.Count() > 1)
     {
         path.AddLines(PointFUtil.ToPointFArray(vertices));
     }
     if (path.PointCount > 0)
         g.DrawPath(Pen, path);
 }
		public void CopyData_NullPoints ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLines (pts_2f);
				using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
					PointF [] points = null;
					byte [] types = new byte [1];
					Assert.AreEqual (0, gpi.CopyData (ref points, ref types, 0, 1));
				}
			}
		}
		public void NextSubpath_Null ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLines (pts_2f);
				using (GraphicsPathIterator gpi = new GraphicsPathIterator (gp)) {
					bool closed;
					Assert.AreEqual (0, gpi.NextSubpath (null, out closed));
					Assert.IsTrue (closed, "Closed");
				}
			}
		}
    ///<summary>
    /// Creates a <see cref="GraphicsPath"/> representing a polygon ring
    /// having the given coordinate sequence.
    ///</summary>
    /// <remarks>
    /// Uses <see cref="FillMode.Alternate"/> winding rule
    /// </remarks>
    /// <param name="coordinates">A coordinate sequence</param>
    /// <returns>The path for the coordinate sequence</returns>
    private static GraphicsPath ToPath(Coordinate[] coordinates)
    {
        var path = new GraphicsPath(FillMode.Alternate);

        path.StartFigure();
        if (coordinates.Length > 0)
            path.AddLines(ToPointF(coordinates));
        path.CloseFigure();

        return path;
    }
Beispiel #24
0
        public void DrawLine(Line line, Graphics graphs)
        {
            var path = new GraphicsPath();
            path.AddLines(line.Vertices.ToPoints());

            using (var p = new Pen(line.OutlineColor, line.OutlineWidth))
            {
                p.DashStyle = line.OutlineDash;
                graphs.DrawPath(p, path);
            }
        }
Beispiel #25
0
        public override void GetIsoline(System.Drawing.Drawing2D.GraphicsPath g, Logical3D r0, Logical3D r1)
        {
            double ax0, ax1, ay0, ay1;

            if (LogicalToLayerCoordinates(r0, out ax0, out ay0) && LogicalToLayerCoordinates(r1, out ax1, out ay1))
            {
                // add a line when this is a radial ray
                if (((r0.RX == r1.RX) && !_isXYInterchanged) || ((r0.RY == r1.RY) && _isXYInterchanged))
                {
                    g.AddLine((float)ax0, (float)ay0, (float)ax1, (float)ay1);
                }
                // add an arc if this is a tangential ray
                else if (((r0.RY == r1.RY) && !_isXYInterchanged) || ((r0.RX == r1.RX) && _isXYInterchanged))
                {
                    double startAngle = 180 * Math.Atan2(_midY - ay0, ax0 - _midX) / Math.PI;
                    double sweepAngle;
                    if (_isXYInterchanged)
                    {
                        sweepAngle = (r1.RY - r0.RY) * 360;
                        if (_isYreverse)
                        {
                            sweepAngle = -sweepAngle;
                        }
                    }
                    else
                    {
                        sweepAngle = (r1.RX - r0.RX) * 360;
                        if (_isXreverse)
                        {
                            sweepAngle = -sweepAngle;
                        }
                    }
                    double r = Calc.RMath.Hypot(_midY - ay0, ax0 - _midX);
                    if (r > 0)
                    {
                        g.AddArc((float)(_midX - r), (float)(_midY - r), (float)(2 * r), (float)(2 * r), (float)-startAngle, (float)-sweepAngle);
                    }
                }
                else // if it is neither radial nor tangential
                {
                    int points = _isXYInterchanged ? (int)(Math.Abs(r1.RY - r0.RY) * 360) : (int)(Math.Abs(r1.RX - r0.RX) * 360);
                    points = Math.Max(1, Math.Min(points, 3600)); // in case there is a rotation more than one turn limit the number of points
                    PointF[] pts = new PointF[points + 1];
                    for (int i = 0; i <= points; i++)
                    {
                        Logical3D r = new Logical3D(r0.RX + i * (r1.RX - r0.RX) / points, r0.RY + i * (r1.RY - r0.RY) / points);
                        double    ax, ay;
                        LogicalToLayerCoordinates(r, out ax, out ay);
                        pts[i] = new PointF((float)ax, (float)ay);
                    }
                    g.AddLines(pts);
                }
            }
        }
		static GraphicsPath InitizlizePath()
		{
			GraphicsPath path = new GraphicsPath();
			path.AddLines( new PointF[]
			              {
							new PointF(0.0f, 0.0f),
							new PointF(5.0f, 9.0f),
							new PointF(-5.0f, 9.0f)
			              });
			path.CloseFigure();
			return path;
		}
 public void DrawBackground(ProgressBarRenderEventArgs e)
 {
     Point[] points = new Point[] { new Point(e.Bounds.Left + 3, e.Bounds.Top + 1), new Point(e.Bounds.Right - 3, e.Bounds.Top + 1), new Point(e.Bounds.Right - 2, e.Bounds.Top + 2), new Point(e.Bounds.Right - 1, e.Bounds.Top + 3), new Point(e.Bounds.Right - 1, e.Bounds.Bottom - 4), new Point(e.Bounds.Right - 2, e.Bounds.Bottom - 3), new Point(e.Bounds.Right - 3, e.Bounds.Bottom - 2), new Point(e.Bounds.Left + 3, e.Bounds.Bottom - 1), new Point(e.Bounds.Left + 2, e.Bounds.Bottom - 3), new Point(e.Bounds.Left + 1, e.Bounds.Bottom - 4), new Point(e.Bounds.Left + 1, e.Bounds.Top + 3), new Point(e.Bounds.Left + 2, e.Bounds.Top + 2) };
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddLines(points);
         using (Brush brush = new SolidBrush(this.BarBackgroundColor))
         {
             e.Graphics.FillPath(brush, path);
         }
     }
     DrawBorder(e.Graphics, e.Bounds);
 }
Beispiel #28
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            //if (scythians.Count <= 2) return;
            GraphicsPath path = new GraphicsPath();
            Pen pen = new Pen(Color.Black, 3F);
            foreach(KeyValuePair<int, List<PointF>> list in scythians)
            {
                path.AddLines(list.Value.ToArray());
                path.CloseFigure();
                e.Graphics.DrawPath(pen, path);
                e.Graphics.DrawString(list.Key.ToString() + " год", Font, Brushes.Maroon, list.Value[0].X+50, list.Value[0].Y);
                path.Reset();
                pen.Color = Color.FromArgb(pen.Color.R + 10, pen.Color.G + 10, pen.Color.G + 10);
            }

            path.Reset();
            pen.Color = Color.Red;
            pen.Width = 5;
            path.AddLines(scythians[trackBar1.Value].ToArray());
            path.CloseFigure();
            e.Graphics.DrawPath(pen, path);
        }
        public override void DrawShadow(Graphics graphics)
        {
            Guard.NotNull(graphics, nameof(graphics));

            using (var path = new GraphicsPath())
            {
                using (var arrowPen = new Pen(Brushes.Gray, 6) { EndCap = LineCap.ArrowAnchor })
                {
                    path.AddLines(shadowPoints);
                    graphics.DrawPath(arrowPen, path);
                }
            }
        }
 public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
 {
     GraphicsPath path;
     int num = Math.Max(0, (bounds.Width - bounds.Height) / 2);
     int num2 = Math.Max(0, (bounds.Height - bounds.Width) / 2);
     bounds.Inflate(-num, -num2);
     if ((bounds.Width % 2) == 1)
     {
         bounds.Width--;
     }
     if ((bounds.Height % 2) == 1)
     {
         bounds.Height--;
     }
     if (bounds.Width > bounds.Height)
     {
         bounds.Width = bounds.Height;
     }
     if (bounds.Height > bounds.Width)
     {
         bounds.Height = bounds.Width;
     }
     bounds.Inflate(-2, -2);
     int width = bounds.Width;
     int num4 = width / 3;
     int num5 = width / 4;
     int num6 = bounds.X + (bounds.Width / 2);
     float x = bounds.X + (0.5f * (bounds.Width + 3));
     float num8 = x - 3f;
     SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
     e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
     using (path = new GraphicsPath())
     {
         Point[] points = new Point[] { new Point(bounds.Left + num4, bounds.Bottom), new Point(bounds.Right - num4, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num4), new Point(bounds.Right, bounds.Top + num4), new Point(bounds.Right - num4, bounds.Top), new Point(bounds.Left + num4, bounds.Top), new Point(bounds.Left, bounds.Top + num4), new Point(bounds.Left, bounds.Bottom - num4) };
         path.AddLines(points);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.Red, path);
         e.Graphics.DrawPath(Pens.DarkGray, path);
     }
     using (path = new GraphicsPath())
     {
         PointF[] tfArray = new PointF[] { new PointF(num8, (float) ((bounds.Top + num5) - 1)), new PointF(x, (float) ((bounds.Top + num5) - 1)), new PointF(num6 + 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)), new PointF(num6 - 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)) };
         path.AddLines(tfArray);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.White, path);
     }
     RectangleF rect = new RectangleF((float) num6, (float) (bounds.Bottom - num5), 0f, 0f);
     rect.Inflate(1.5f, 1.5f);
     e.Graphics.FillEllipse(Brushes.White, rect);
     e.Graphics.SmoothingMode = smoothingMode;
 }
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            int diam = 10;
            GraphicsPath path = new GraphicsPath();
            path.AddArc(0, 0, diam, diam, -90, -90);
            path.AddLines(new Point[] {new Point(0,diam), new Point(0, Height),
                new Point(Width, Height), new Point(Width, diam)});
            path.AddArc(Width - diam, 0, diam, diam, 0, -90);
            path.CloseFigure();

            this.Region = new Region(path);
        }
        void InitLeft(out GraphicsPath path)
        {
            List<Point> list = new List<Point>();
            list.Add(new Point(3, 0));
            list.Add(new Point(6, 0));
            list.Add(new Point(6, Height - 1));
            list.Add(new Point(3, Height - 1));
            list.Add(new Point(0, Height - 5));
            list.Add(new Point(0, 4));
            list.Add(new Point(2, 1));
            list.Add(new Point(3, 0));

            path = new GraphicsPath();
            path.AddLines(list.ToArray());
        }
        public override void DrawFill(Graphics graphics)
        {
            Guard.NotNull(graphics, nameof(graphics));

            using (var path = new GraphicsPath())
            {
                using (Brush fillBrush = new SolidBrush(GetColorForState()))
                {
                    using (var arrowPen = new Pen(fillBrush, 6) { EndCap = LineCap.ArrowAnchor })
                    {
                        path.AddLines(arrowPoints);
                        graphics.DrawPath(arrowPen, path);
                    }
                }
            }
        }
        void InitBorder(out GraphicsPath path)
        {
            List<Point> list = new List<Point>();
            list.Add(new Point(3, 0));
            list.Add(new Point(Width - 1, 0));
            list.Add(new Point(Width - 1, Height - 1));
            list.Add(new Point(3, Height - 1));
            list.Add(new Point(0, Height - 5));
            list.Add(new Point(0, 4));
            list.Add(new Point(2, 1));
            list.Add(new Point(3, 0));
            border = list.ToArray();

            path = new GraphicsPath();
            path.AddLines(border);
        }
Beispiel #35
0
 public bool ShowInScreen(Graphics canvas, Point location)
 {
     Pen pen = new Pen(Color.Red);
     SolidBrush bsh = new SolidBrush(Color.Red);
     ChangeVehiclePoint(location);
     Point[] tranglePts = new Point[3];
     tranglePts[0] = location;
     ComputeVehicleShape(location, tranglePts);
     GraphicsPath path = new GraphicsPath();
     path.AddLines(tranglePts);
     canvas.DrawPath(pen, path);
     canvas.FillPath(bsh, path);
     pen.Dispose();
     bsh.Dispose();
     //            Debug.WriteLine(string.Format("trangelePts {0},{1},{2}", tranglePts[0], tranglePts[1], tranglePts[2]));
     return false;
 }
Beispiel #36
0
        public void DrawLeadHeadArrow(Graphics.Rectangle bounds, SolidColor startColor, SolidColor endColor)
        {
            using (System.Drawing.Drawing2D.GraphicsPath leadHeadPath = new System.Drawing.Drawing2D.GraphicsPath())
            {
                leadHeadPath.AddLines(new System.Drawing.PointF[] { new Point(bounds.Right - 4, bounds.Y + 4),
                                                                    new Point(bounds.Right - 4, bounds.Bottom - 4),
                                                                    new Point(bounds.Right - bounds.Height + 4, bounds.Bottom - 4) });

                leadHeadPath.CloseAllFigures();

                using (System.Drawing.Drawing2D.LinearGradientBrush lgb
                           = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, startColor, endColor, 90f))
                {
                    base.PlatformGraphics.FillPath(lgb, leadHeadPath);
                }
            }
        }
 public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
 {
     GraphicsPath path;
     Point[] pointArray;
     SolidBrush brush;
     int num = Math.Max(0, (bounds.Height - bounds.Width) / 2);
     bounds.Inflate(0, -num);
     bounds.Inflate(-2, -2);
     int num2 = Math.Min(bounds.Width, bounds.Height);
     int num3 = 2;
     int num4 = num2 / 4;
     int x = bounds.X + (bounds.Width / 2);
     int num6 = bounds.X + ((bounds.Width + 2) / 2);
     int num7 = num6 - 2;
     SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
     e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
     using (path = new GraphicsPath())
     {
         pointArray = new Point[] { new Point(bounds.Left + num3, bounds.Bottom), new Point(bounds.Right - num3, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num3), new Point(num6, bounds.Top), new Point(num7, bounds.Top), new Point(bounds.Left, bounds.Bottom - num3) };
         path.AddLines(pointArray);
         path.CloseAllFigures();
         using (brush = new SolidBrush(Color.FromArgb(120, Color.Gold)))
         {
             using (Pen pen = new Pen(Color.FromArgb(150, Color.Goldenrod)))
             {
                 e.Graphics.FillPath(brush, path);
                 e.Graphics.DrawPath(pen, path);
             }
         }
     }
     using (path = new GraphicsPath())
     {
         pointArray = new Point[] { new Point(num7, bounds.Top + num4), new Point(num6, bounds.Top + num4), new Point(x, bounds.Top + ((bounds.Height * 2) / 3)) };
         path.AddLines(pointArray);
         path.CloseAllFigures();
         using (brush = new SolidBrush(Color.FromArgb(40, 40, 40)))
         {
             e.Graphics.FillPath(brush, path);
         }
     }
     Rectangle rect = new Rectangle(x, bounds.Bottom - num4, 0, 0);
     rect.Inflate(1, 1);
     e.Graphics.FillEllipse(Brushes.Black, rect);
     e.Graphics.SmoothingMode = smoothingMode;
 }
Beispiel #38
0
        public static GraphicsPath Convert(Path2D path)
        {
            GdiPath gdiPath = new GdiPath(FillMode.Winding);

            foreach (Figure2D figure in path.Figures)
            {
                gdiPath.StartFigure();

                gdiPath.AddLines(Convert(figure.Points));

                if (figure.IsClosed)
                {
                    gdiPath.CloseFigure();
                }
            }

            return(gdiPath);
        }
        private void DrawFunction(Graphics g)
        {
            var pointListsList = new List <List <PointF> >();

            pointListsList.Clear();

            var points = new List <PointF>();

            for (var x = 0; x < Width; x++)
            {
                var fx  = ToHorizontalUnit(x);
                var fy  = MathFunction(fx);
                var fdy = Derivative(MathFunction, fx);

                if (Math.Abs(fdy) > 500)
                {
                    pointListsList.Add(points);
                    points = new List <PointF>();
                }

                points.Add(new PointF((float)fx, (float)fy));
            }

            if (points.Count > 1)
            {
                pointListsList.Add(points);
            }

            foreach (var p in pointListsList)
            {
                if (p.Count > 2)
                {
                    var path = new System.Drawing.Drawing2D.GraphicsPath();
                    path.AddLines(p.Select(x => new PointF(ToHorizontalPixel(x.X), ToVerticalPixel(x.Y))).ToArray());
                    g.DrawPath(GraphPen, path);
                }
            }
        }
Beispiel #40
0
        private static void CalculateLabelAroundOnLineString(SharpMap.Geometries.LineString line, ref BaseLabel label, Map map, System.Drawing.Graphics g, System.Drawing.SizeF textSize)
        {
            IList <SharpMap.Geometries.Point> sPoints = line.Vertices;

            // only get point in enverlop of map
            Collection <System.Drawing.PointF> colPoint = new Collection <System.Drawing.PointF>();
            bool bCheckStarted = false;

            for (int j = 0; j < sPoints.Count; j++)
            {
                if (map.Envelope.Grow(map.PixelSize * 10).Contains(sPoints[j]))
                {
                    //points[j] = map.WorldToImage(sPoints[j]);
                    colPoint.Add(map.WorldToImage(sPoints[j]));
                    bCheckStarted = true;
                }
                else if (bCheckStarted == true)
                {
                    // fix bug curved line out of map in center segment of line
                    break;
                }
            }

            if (colPoint.Count > 1)
            {
                label.TextOnPathLabel = new SharpMap.Rendering.TextOnPath();
                switch (label.Style.HorizontalAlignment)
                {
                case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left:
                    label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                    break;

                case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right:
                    label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                    break;

                case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center:
                    label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                    break;

                default:
                    label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                    break;
                }
                switch (label.Style.VerticalAlignment)
                {
                case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Bottom:
                    label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.UnderPath;
                    break;

                case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Top:
                    label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.OverPath;
                    break;

                case SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Middle:
                    label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath;
                    break;

                default:
                    label.TextOnPathLabel.TextPathPathPosition = SharpMap.Rendering.TextPathPosition.CenterPath;
                    break;
                }
                int idxStartPath = 0;
                int numberPoint  = colPoint.Count;
                // start Optimzes Path points
                int step = 100;
                if (colPoint.Count >= step * 2)
                {
                    numberPoint = step * 2;;
                    switch (label.Style.HorizontalAlignment)
                    {
                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Left;
                        idxStartPath = 0;
                        break;

                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Right;
                        idxStartPath = colPoint.Count - step;
                        break;

                    case SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;

                    default:
                        //label.TextOnPathLabel.TextPathAlignTop = SharpMap.Rendering.TextPathAlign.Center;
                        idxStartPath = (int)colPoint.Count / 2 - step;
                        break;
                    }
                }
                // end optimize path point
                System.Drawing.PointF[] points = new System.Drawing.PointF[numberPoint];
                int count = 0;
                if (colPoint[0].X <= colPoint[colPoint.Count - 1].X)
                {
                    for (int l = idxStartPath; l < numberPoint + idxStartPath; l++)
                    {
                        points[count] = colPoint[l];
                        count++;
                    }
                }
                else
                {
                    //reverse the path
                    for (int k = numberPoint - 1 + idxStartPath; k >= idxStartPath; k--)
                    {
                        points[count] = colPoint[k];
                        count++;
                    }
                }
                //get text size in page units ie pixels
                float textheight = label.Style.Font.Size;
                switch (label.Style.Font.Unit)
                {
                case System.Drawing.GraphicsUnit.Display:
                    textheight = textheight * g.DpiY / 75;
                    break;

                case System.Drawing.GraphicsUnit.Document:
                    textheight = textheight * g.DpiY / 300;
                    break;

                case System.Drawing.GraphicsUnit.Inch:
                    textheight = textheight * g.DpiY;
                    break;

                case System.Drawing.GraphicsUnit.Millimeter:
                    textheight = (float)(textheight / 25.4 * g.DpiY);
                    break;

                case System.Drawing.GraphicsUnit.Pixel:
                    //do nothing
                    break;

                case System.Drawing.GraphicsUnit.Point:
                    textheight = textheight * g.DpiY / 72;
                    break;
                }
                System.Drawing.Font topFont = new System.Drawing.Font(label.Style.Font.FontFamily, textheight, label.Style.Font.Style);
                //
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddLines(points);

                label.TextOnPathLabel.PathColorTop          = System.Drawing.Color.Transparent;
                label.TextOnPathLabel.Text                  = label.Text;
                label.TextOnPathLabel.LetterSpacePercentage = 90;
                label.TextOnPathLabel.FillColorTop          = new System.Drawing.SolidBrush(label.Style.ForeColor);
                label.TextOnPathLabel.Font                  = topFont;
                label.TextOnPathLabel.PathDataTop           = path.PathData;
                label.TextOnPathLabel.Graphics              = g;
                //label.TextOnPathLabel.ShowPath=true;
                //label.TextOnPathLabel.PathColorTop = System.Drawing.Color.YellowGreen;
                if (label.Style.Halo != null)
                {
                    label.TextOnPathLabel.ColorHalo = label.Style.Halo;
                }
                else
                {
                    label.TextOnPathLabel.ColorHalo = null;// new System.Drawing.Pen(label.Style.ForeColor, (float)0.5);
                }
                path.Dispose();

                // MeasureString to get region
                label.TextOnPathLabel.MeasureString = true;
                label.TextOnPathLabel.DrawTextOnPath();
                label.TextOnPathLabel.MeasureString = false;
                // Get Region label for CollissionDetection here.
                System.Drawing.Drawing2D.GraphicsPath pathRegion = new System.Drawing.Drawing2D.GraphicsPath();

                if (label.TextOnPathLabel.RegionList.Count > 0)
                {
                    //int idxCenter = (int)label.TextOnPathLabel.PointsText.Count / 2;
                    //System.Drawing.Drawing2D.Matrix rotationMatrix = g.Transform.Clone();// new Matrix();
                    //rotationMatrix.RotateAt(label.TextOnPathLabel.Angles[idxCenter], label.TextOnPathLabel.PointsText[idxCenter]);
                    //if (label.TextOnPathLabel.PointsTextUp.Count > 0)
                    //{
                    //    for (int up = label.TextOnPathLabel.PointsTextUp.Count - 1; up >= 0; up--)
                    //    {
                    //        label.TextOnPathLabel.PointsText.Add(label.TextOnPathLabel.PointsTextUp[up]);
                    //    }

                    //}
                    pathRegion.AddRectangles(label.TextOnPathLabel.RegionList.ToArray());

                    // get box for detect colission here
                    label.Box = new LabelBox(pathRegion.GetBounds());
                    //g.FillRectangle(System.Drawing.Brushes.YellowGreen, label.Box);
                }
                pathRegion.Dispose();
            }
        }
Beispiel #41
0
 /// <summary>
 /// Draw line for given points
 /// </summary>
 protected void SetPathFromPoints(PointF[] points)
 {
     _path = new GraphicsPath();
     _path.AddLines(points);
 }
Beispiel #42
0
        private static void RenderLines(IGraphics ig)
        {
            ig.SmoothingMode = SmoothingMode.AntiAlias;

            var ow = new Pen(Color.Purple, 12.6f)
            {
                EndCap     = LineCap.Round,
                StartCap   = LineCap.Round,
                MiterLimit = 6f,
                LineJoin   = LineJoin.Miter
            };

            ig.SmoothingMode = SmoothingMode.None;

            var tp = new Pen(Color.Red, 2.7f)
            {
                DashStyle = DashStyle.DashDot
            };

            ig.DrawLine(tp, 70, 20, 190, 20);

            tp.DashStyle = DashStyle.Dash;

            ig.DrawLine(tp, 70, 30, 190, 30);

            tp.DashStyle   = DashStyle.Custom;
            tp.DashPattern = new float[] { 1, 8, 2, 2 };

            ig.DrawLine(tp, 70, 40, 190, 40);

            ig.SmoothingMode = SmoothingMode.AntiAlias;

            var pts = new PointF[4];

            pts[0] = new PointF(20, 50);
            pts[1] = new PointF(30, 90);
            pts[2] = new PointF(65, 60);
            pts[3] = new PointF(50, 40);
            ig.DrawLines(ow, pts);

            var polly = new Point[]
            {
                new Point(200, 40),
                new Point(220, 140),
                new Point(240, 100),
                new Point(290, 70),
                new Point(230, 10)
            };

            ig.DrawPolygon(tp, polly);

            //arrows
            var arr = new Pen(Color.DarkGoldenrod, 5.7f);

            {
                arr.Width    = 2;
                arr.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                const float arrowWidth   = 11.0f; // TUNE:
                const float arrowHeight  = 14f;   // TUNE:
                var         arrowOutline = new System.Drawing.Drawing2D.GraphicsPath();
                arrowOutline.AddLines(new PointF[] {
                    new PointF(-(arrowWidth / 2), -arrowHeight),
                    new PointF(0, 0),
                    new PointF(arrowWidth / 2, -arrowHeight),
                    new PointF(-(arrowWidth / 2), -arrowHeight)
                });
                var generalizationArrow = new System.Drawing.Drawing2D.CustomLineCap(null, arrowOutline);
                generalizationArrow.SetStrokeCaps(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round);
                generalizationArrow.BaseInset = arrowHeight;
                arr.CustomEndCap = generalizationArrow;
                ig.DrawLine(arr, 0, 120, 100, 200);
            }

            arr.Width = 5;
            var aac = new AdjustableArrowCap(5, 3, false);

            arr.EndCap       = LineCap.Custom;
            arr.CustomEndCap = aac;
            arr.StartCap     = LineCap.ArrowAnchor;
            ig.DrawLine(arr, 50, 120, 150, 200);

            arr.Width    = 7f;
            arr.EndCap   = LineCap.RoundAnchor;
            arr.StartCap = LineCap.SquareAnchor;
            ig.DrawLine(arr, 100, 120, 200, 200);

            arr.Width    = 9;
            arr.EndCap   = LineCap.DiamondAnchor;
            arr.StartCap = LineCap.ArrowAnchor;
            ig.DrawLine(arr, 150, 120, 250, 200);

            var al = new Point[]
            {
                new Point(200, 100),
                new Point(300, 200),
                new Point(300, 150)
            };

            arr.Width    = 9;
            arr.EndCap   = LineCap.DiamondAnchor;
            arr.StartCap = LineCap.DiamondAnchor;
            ig.DrawLines(arr, al);
        }
Beispiel #43
0
        private void Render(IGraphics ig)
        {
            string s = cbWhat.Text;

            if (string.IsNullOrEmpty(s))
            {
            }
            else if (s == "Clipping")
            {
                Pen pn  = new Pen(Color.LightGray, 5.6f);
                Pen pn2 = new Pen(Color.Yellow, 1.2f);

                ig.Clear(Color.Black);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.SetClip(new Rectangle(35, 35, 120, 120));

                ig.DrawRectangle(pn, 5, 5, 45, 70);
                ig.DrawRectangle(pn, 15, 25, 90, 120);
                ig.DrawRectangle(pn, 50, 30, 100, 170);
                ig.DrawRectangle(pn, 5, 80, 180, 30);
                ig.DrawRectangle(pn, 75, 10, 40, 160);

                ig.EndContainer(cnt);

                ig.DrawRectangle(pn2, 5, 5, 45, 70);
                ig.DrawRectangle(pn2, 15, 25, 90, 120);
                ig.DrawRectangle(pn2, 50, 30, 100, 170);
                ig.DrawRectangle(pn2, 5, 80, 180, 30);
                ig.DrawRectangle(pn2, 75, 10, 40, 160);
            }
            else if (s == "Transforms")
            {
                ig.Clear(Color.Black);

                ig.RotateTransform(15);
                ig.DrawRectangle(new Pen(Color.Red, 2.7f), 260, 80, 50, 40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.Red, 2.7f), 260, 80, 50, 40);

                ig.TranslateTransform(15, -5);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.RotateTransform(5);
                ig.FillEllipse(new SolidBrush(Color.Orange), 100, 100, 80, 40);
                ig.DrawRectangle(new Pen(Color.Orange, 2), 60, 80, 40, 40);

                GraphicsContainer cnt2 = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.None;

                ig.RotateTransform(5);
                ig.ScaleTransform(1.1f, 1.2f);

                ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130, 180, 80, 40);
                ig.DrawRectangle(new Pen(Color.YellowGreen, 2.7f), 62, 80, 40, 40);

                GraphicsContainer cnt3 = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                Matrix mm = new Matrix();
                mm.Shear(0.3f, 0f);
                ig.Transform = mm;

                ig.FillEllipse(new SolidBrush(Color.Green), 180, 120, 80, 40);
                ig.DrawRectangle(new Pen(Color.Green, 2), 62, 84, 40, 40);

                ig.EndContainer(cnt3);

                ig.EndContainer(cnt2);

                ig.FillEllipse(new SolidBrush(Color.Blue), 120, 150, 80, 40);
                ig.DrawRectangle(new Pen(Color.Blue, 2), 64, 80, 40, 40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80, 210, 80, 40);
                ig.DrawRectangle(new Pen(Color.Indigo, 2), 66, 80, 40, 40);

                ig.DrawRectangle(new Pen(Color.White, 2), 270, 30, 50, 40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White, 2), 270, 30, 50, 40);
            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12.6f);
                ow.EndCap     = LineCap.Round;
                ow.StartCap   = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin   = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;

                Pen tp = new Pen(Color.Red, 2.7f);
                tp.DashStyle = DashStyle.DashDot;

                ig.DrawLine(tp, 70, 20, 190, 20);

                tp.DashStyle = DashStyle.Dash;

                ig.DrawLine(tp, 70, 30, 190, 30);

                tp.DashStyle   = DashStyle.Custom;
                tp.DashPattern = new float[] { 1, 8, 2, 2 };

                ig.DrawLine(tp, 70, 40, 190, 40);

                ig.SmoothingMode = SmoothingMode.AntiAlias;

                PointF[] pts = new PointF[4];
                pts[0] = new PointF(20, 50);
                pts[1] = new PointF(30, 90);
                pts[2] = new PointF(65, 60);
                pts[3] = new PointF(50, 40);
                ig.DrawLines(ow, pts);

                Point[] polly = new Point[]
                {
                    new Point(200, 40),
                    new Point(220, 140),
                    new Point(240, 100),
                    new Point(290, 70),
                    new Point(230, 10)
                };

                ig.DrawPolygon(tp, polly);

                //arrows
                Pen arr = new Pen(Color.DarkGoldenrod, 5.7f);

                {
                    arr.Width    = 2;
                    arr.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                    const float arrowWidth   = 11.0f; // TUNE:
                    const float arrowHeight  = 14f;   // TUNE:
                    var         arrowOutline = new System.Drawing.Drawing2D.GraphicsPath();
                    arrowOutline.AddLines(new PointF[] {
                        new PointF(-(arrowWidth / 2), -arrowHeight),
                        new PointF(0, 0),
                        new PointF((arrowWidth / 2), -arrowHeight),
                        new PointF(-(arrowWidth / 2), -arrowHeight)
                    });
                    var generalizationArrow = new System.Drawing.Drawing2D.CustomLineCap(null, arrowOutline);
                    generalizationArrow.SetStrokeCaps(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round);
                    generalizationArrow.BaseInset = arrowHeight;
                    arr.CustomEndCap = generalizationArrow;
                    ig.DrawLine(arr, 0, 120, 100, 200);
                }

                arr.Width = 5;
                AdjustableArrowCap aac = new AdjustableArrowCap(5, 3, false);
                arr.EndCap       = LineCap.Custom;
                arr.CustomEndCap = aac;
                arr.StartCap     = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 50, 120, 150, 200);

                arr.Width    = 7f;
                arr.EndCap   = LineCap.RoundAnchor;
                arr.StartCap = LineCap.SquareAnchor;
                ig.DrawLine(arr, 100, 120, 200, 200);

                arr.Width    = 9;
                arr.EndCap   = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 150, 120, 250, 200);

                Point[] al = new Point[]
                {
                    new Point(200, 100),
                    new Point(300, 200),
                    new Point(300, 150)
                };

                arr.Width    = 9;
                arr.EndCap   = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.DiamondAnchor;
                ig.DrawLines(arr, al);
            }
            else if (s == "Curves")
            {
                PointF[] bezzie = new PointF[]
                {
                    new PointF(20, 150),

                    new PointF(110, 190),
                    new PointF(120, 200),
                    new PointF(50, 220),

                    new PointF(60, 200),
                    new PointF(140, 180),
                    new PointF(100, 160),

                    new PointF(180, 260),
                    new PointF(200, 210),
                    new PointF(190, 210)
                };

                Pen bpn = new Pen(Color.MediumSeaGreen, 2.3f);
                bpn.DashStyle   = DashStyle.Custom;
                bpn.DashPattern = new float[] { 6, 1, 5, 2, 4, 3, 3, 4, 2, 5, 6, 1 };
                ig.DrawBeziers(bpn, bezzie);

                PointF[] curvy = new PointF[]
                {
                    new PointF(130, 40),
                    new PointF(70, 70),
                    new PointF(50, 20),
                    new PointF(120, 120),
                    new PointF(150, 80),
                    new PointF(80, 150),
                    new PointF(80, 110)
                };

                ig.DrawCurve(new Pen(Color.Blue, 5.7f), curvy);
                ig.DrawCurve(new Pen(Color.Red, 2.7f), curvy, 2, 3);
                ig.DrawCurve(new Pen(Color.Yellow, 1.7f), curvy, 1f);

                Point[] ccurvy = new Point[]
                {
                    new Point(280, 30),
                    new Point(260, 60),
                    new Point(200, 20),
                    new Point(290, 120),
                    new Point(290, 80),
                    new Point(230, 150),
                    new Point(150, 50)
                };
                ig.DrawClosedCurve(new Pen(Color.Green, 3.7f), ccurvy, 1f, FillMode.Alternate);
                ig.DrawClosedCurve(new Pen(Color.Purple, 1.7f), ccurvy, 0f, FillMode.Alternate);

                Point[] fcc = new Point[]
                {
                    new Point(160, 350),
                    new Point(190, 370),
                    new Point(130, 390),
                    new Point(190, 400),
                    new Point(195, 410),
                    new Point(100, 430),
                    new Point(160, 450)
                };
                ig.FillClosedCurve(new SolidBrush(Color.Red), fcc, FillMode.Winding, 1f);
                ig.FillClosedCurve(new SolidBrush(Color.Aquamarine), fcc, FillMode.Alternate, .2f);
            }
            else if (s == "Transparency")
            {
                Point[] fillpoly = new Point[]
                {
                    new Point(20, 130),
                    new Point(60, 90),
                    new Point(30, 20),
                    new Point(80, 20),
                    new Point(15, 90),
                    new Point(100, 50),
                    new Point(0, 50)
                };

                Color col = Color.FromArgb(96, 255, 0, 0);

                ig.FillEllipse(new SolidBrush(Color.Ivory), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(Color.Ivory), fillpoly, FillMode.Winding);

                ig.TranslateTransform(10, 10);
                ig.FillEllipse(new SolidBrush(col), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(col), fillpoly, FillMode.Alternate);
                ig.ResetTransform();

                ig.FillPie(new SolidBrush(Color.FromArgb(100, 255, 0, 0)), 10, 200, 200, 80, 315, 90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 128, 128, 0)), 10, 200, 200, 80, 250, -90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 128, 0, 128)), 15, 205, 190, 70, 180, 270);
                ig.FillPie(new SolidBrush(Color.FromArgb(100, 200, 60, 60)), 20, 210, 180, 60, 45, -270);
            }
            else if (s == "Fills")
            {
                LinearGradientBrush gbr1 = new LinearGradientBrush(new Point(0, 0), new Point(30, 20), Color.Blue, Color.Plum);

                ColorBlend blend = new ColorBlend(3);
                blend.Colors             = new Color[] { Color.Red, Color.Yellow, Color.MediumSlateBlue };
                blend.Positions          = new float[] { 0, .3f, 1f };
                gbr1.InterpolationColors = blend;

                Point[] sp = new Point[]
                {
                    new Point(145, 145),
                    new Point(305, 250),
                    new Point(220, 250),
                    new Point(180, 250)
                };
                ig.FillPolygon(gbr1, sp);

                LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0, 0), new Point(10, 20), Color.WhiteSmoke, Color.CornflowerBlue);
                gbr2.WrapMode = WrapMode.TileFlipXY;
                Point[] sp2 = new Point[]
                {
                    new Point(25, 205),
                    new Point(75, 150),
                    new Point(110, 110),
                    new Point(40, 80)
                };
                ig.FillPolygon(gbr2, sp2);

                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalBrick, Color.Khaki, Color.Peru), 000, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Vertical, Color.Bisque, Color.Peru), 020, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DarkVertical, Color.Tan, Color.Peru), 040, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalCross, Color.Chocolate, Color.Peru), 060, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.WideDownwardDiagonal, Color.BurlyWood, Color.Peru), 080, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LargeConfetti, Color.Wheat, Color.Peru), 100, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.ZigZag, Color.SaddleBrown, Color.Peru), 120, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.HorizontalBrick, Color.Linen, Color.Peru), 140, 5, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LightHorizontal, Color.Maroon, Color.Peru), 160, 5, 20, 20);
                ig.FillRectangle(gbr1, 200, 5, 20, 20);
                ig.FillRectangle(gbr2, 220, 5, 20, 20);

                ig.FillRectangle(new HatchBrush(HatchStyle.Percent05, Color.CornflowerBlue, Color.LemonChiffon), 000, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent10, Color.CornflowerBlue, Color.LemonChiffon), 020, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent20, Color.CornflowerBlue, Color.LemonChiffon), 040, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent25, Color.CornflowerBlue, Color.LemonChiffon), 060, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent30, Color.CornflowerBlue, Color.LemonChiffon), 080, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent40, Color.CornflowerBlue, Color.LemonChiffon), 100, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent50, Color.CornflowerBlue, Color.LemonChiffon), 120, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent60, Color.CornflowerBlue, Color.LemonChiffon), 140, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent70, Color.CornflowerBlue, Color.LemonChiffon), 160, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent75, Color.CornflowerBlue, Color.LemonChiffon), 180, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent80, Color.CornflowerBlue, Color.LemonChiffon), 200, 30, 20, 20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent90, Color.CornflowerBlue, Color.LemonChiffon), 220, 30, 20, 20);
            }
            else if (s == "Arcs/Pies")
            {
                //GDI does not seem to draw arcs correctly except when the ellipse is a circle.
                //These arcs demonstrate the problem.  SVGGraphics calculates arcs correctly.
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 5 * 3, 120, 110 * 3, 110, 0, 240);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 10 * 3, 125, 100 * 3, 100, 0, 210);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 15 * 3, 130, 90 * 3, 90, 0, 180);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 20 * 3, 135, 80 * 3, 80, 0, 150);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 25 * 3, 140, 70 * 3, 70, 0, 120);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 30 * 3, 145, 60 * 3, 60, 0, 90);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 35 * 3, 150, 50 * 3, 50, 0, 60);
                ig.DrawArc(new Pen(Color.Black, 2.7f), 120 + 40 * 3, 155, 40 * 3, 40, 0, 270);

                ig.DrawPie(new Pen(Color.Pink, 2.7f), 110, 50, 100, 100, 315, 90);
                ig.DrawPie(new Pen(Color.Purple, 2.7f), 110, 50, 100, 100, 250, -90);
                ig.DrawPie(new Pen(Color.DarkRed, 2.7f), 115, 55, 90, 90, 180, 270);
                ig.DrawPie(new Pen(Color.Red, 2.7f), 120, 60, 80, 80, 45, -270);
            }
            else if (s == "Text")
            {
                Font fnt1 = new Font("Helvetica", 12, FontStyle.Italic | FontStyle.Bold);
                Font fnt2 = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold);
                Font fnt3 = new Font("", 40, FontStyle.Underline);

                Rectangle    rc1  = new Rectangle(30, 30, 220, 20);
                StringFormat fmt1 = new StringFormat();
                fmt1.Alignment = StringAlignment.Near;

                ig.DrawRectangle(new Pen(Color.Blue), rc1);
                ig.DrawString("Text...1", fnt1, new SolidBrush(Color.DarkGreen), rc1, fmt1);

                Rectangle    rc2  = new Rectangle(0, 0, 120, 20);
                StringFormat fmt2 = new StringFormat();
                fmt2.Alignment = StringAlignment.Center;

                ig.TranslateTransform(30, 160);
                ig.RotateTransform(90);

                ig.DrawRectangle(new Pen(Color.Blue), rc2);
                ig.DrawString("Text...2", fnt2, new SolidBrush(Color.DarkGreen), rc2, fmt2);

                ig.ResetTransform();

                Rectangle    rc3  = new Rectangle(30, 90, 300, 30);
                StringFormat fmt3 = new StringFormat();
                fmt3.Alignment = StringAlignment.Far;

                ig.DrawRectangle(new Pen(Color.Blue), rc3);
                ig.DrawString("Text...3", fnt3, new SolidBrush(Color.DarkGreen), rc3, fmt3);

                //measurestring
                const string mme = "MeasureString Is Impossible To Emulate";
                SizeF        siz = ig.MeasureString(mme, fnt1);
                ig.DrawRectangle(new Pen(Color.Red), 20, 200, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, 150);
                ig.DrawRectangle(new Pen(Color.Orange), 20, 230, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, new SizeF(150, 150), new StringFormat(StringFormatFlags.DirectionVertical));
                ig.DrawRectangle(new Pen(Color.Yellow), 20, 200, siz.Width, siz.Height);
            }
            else if (s == "Rect-aligned Text")
            {
                ig.Clear(Color.White);
                ig.ScaleTransform(
                    (float)panel1.ClientSize.Width / RectAlignedTextTest.CanvasSize,
                    (float)panel1.ClientSize.Height / RectAlignedTextTest.CanvasSize);
                RectAlignedTextTest.DrawTest(ig);
            }
            else if (s == "Images")
            {
                Icon ike = new Icon(GetType(), "App.ico");
                ig.DrawIcon(ike, 10, 10);
                //ig.DrawIcon(ike, new Rectangle(270, 400, 30, 40));

                Bitmap bmp = new Bitmap(GetType(), "test.bmp");
                ig.DrawImage(bmp, 100f, 150f);
                GraphicsContainer cnt = ig.BeginContainer();
                ig.RotateTransform(5);
                ig.DrawImage(bmp, 160f, 50f, 120f, 70f);
                ig.EndContainer(cnt);
                //ig.DrawImageUnscaled(bmp, 270, 450, 20, 20);
            }
            else if (s == "Path")
            {
                /* The following example GraphicsPath code comes from the MSDN docs on the GraphicsPathIterator class
                 * https://msdn.microsoft.com/en-us/library/79k451ts.aspx
                 *
                 */
                // Create a graphics path.
                GraphicsPath myPath = new GraphicsPath();

                // Set up primitives to add to myPath.
                Point[]   myPoints = { new Point(20, 20), new Point(120, 120), new Point(20, 120), new Point(20, 20) };
                Rectangle myRect   = new Rectangle(120, 120, 100, 100);

                // Add 3 lines, a rectangle, an ellipse, and 2 markers.
                myPath.AddLines(myPoints);
                myPath.SetMarkers();
                myPath.AddRectangle(myRect);
                myPath.SetMarkers();
                myPath.AddEllipse(220, 220, 100, 100);
                ig.DrawPath(new Pen(Color.Black, 1.7f), myPath);
                LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0, 0), new Point(10, 20), Color.WhiteSmoke, Color.CornflowerBlue);
                gbr2.WrapMode = WrapMode.TileFlipXY;
                ig.FillPath(gbr2, myPath);

                GraphicsPath myPath2 = new GraphicsPath();
                myPath2.AddLine(100, 100, 130, 120);
                myPath2.AddEllipse(120, 120, 120, 140);
                myPath2.AddBezier(130, 160, 170, 160, 150, 130, 200, 110);
                ig.DrawPath(new Pen(Color.Blue, 1.7f), myPath2);
            }
            else if (s == "Path 2 (Slow)")
            {
                SolidBrush   mySolidBrush   = new SolidBrush(Color.Aqua);
                GraphicsPath myGraphicsPath = new GraphicsPath();

                Point[] myPointArray =
                {
                    new Point(15, 20),
                    new Point(20, 40),
                    new Point(50, 30)
                };

                FontFamily   myFontFamily   = new FontFamily("Times New Roman");
                PointF       myPointF       = new PointF(50, 20);
                StringFormat myStringFormat = new StringFormat();

                myGraphicsPath.AddArc(0, 0, 30, 20, -90, 180);
                myGraphicsPath.AddCurve(myPointArray);
                myGraphicsPath.AddString("a string in a path filled", myFontFamily,
                                         0, 24, myPointF, myStringFormat);
                myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110);
                ig.FillPath(mySolidBrush, myGraphicsPath);
                ig.DrawPath(new Pen(Color.Green, 1.7f), myGraphicsPath);
            }
            else
            {
                throw new NotImplementedException();
            }
        }