DrawPolygon() public method

public DrawPolygon ( Pen pen, Point points ) : void
pen Pen
points Point
return void
Esempio n. 1
1
		internal override void Draw(Graphics g)
		{
			IsInvalidated = false;

			Rectangle r = BaseElement.GetUnsignedRectangle(new Rectangle(location, size));

			Point[] points = new Point[5];
			points[0] = new Point(r.X + 0, r.Y + 0);
			points[1] = new Point(r.X + 0, r.Y + r.Height);
			points[2] = new Point(r.X + r.Width, r.Y + r.Height);

			//Fold
			points[3] = new Point(r.X + r.Width, r.Y + foldSize.Height);
			points[4] = new Point(r.X + r.Width - foldSize.Width, r.Y + 0);

			//foreach(Point p in points) p.Offset(location.X, location.Y);

			g.FillPolygon(GetBrush(r), points, FillMode.Alternate);
			g.DrawPolygon(new Pen(borderColor, borderWidth), points);

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + foldSize.Height),
			           new Point(r.X + r.Width, r.Y + foldSize.Height));

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0 + foldSize.Height));
		}
Esempio n. 2
0
 private void draw(Graphics g)
 {
     foreach (TextObject text in textList)
     {
         Brush brush = new SolidBrush(text.color);
         g.DrawString(text.text, text.font, (Brush)brush, text.pos);
     }
     foreach (PolygonObject polygon in polygonList)
     {
         g.DrawPolygon(polygon.pen, polygon.list.ToArray());
     }
     if (startPoint != Point.Empty && currentPoint != Point.Empty)
     {
         switch (mode)
         {
             case Mode.SELECT:
                 break;
             case Mode.DRAW:
                 PolygonObject poly = new PolygonObject();
                 poly.rectangle(startPoint, currentPoint);
                 g.DrawPolygon(pen, poly.list.ToArray());
                 break;
             case Mode.LINE:
                 g.DrawLine(pen, startPoint, currentPoint);
                 break;
             case Mode.TEXT:
                 break;
         }
     }
 }
Esempio n. 3
0
        public void DrawBox(Box box)
        {
            System.Drawing.Graphics g = Graphics;

            if (box is Pack pack)
            {
                pack.Draw(this);
            }
            else
            {
                Brush brushPath = new SolidBrush(box.TopFace.ColorPath);
                Pen   penPath   = new Pen(brushPath);

                // get points
                Point[] pt = TransformPoint(box.TopFace.Points);

                // draw solid face
                Brush brushSolid = new SolidBrush(box.TopFace.ColorFill);
                g.FillPolygon(brushSolid, pt);
                g.DrawPolygon(penPath, pt);
                // draw box tape
                if (box.TapeWidth.Activated)
                {
                    // instantiate brush
                    Brush brushTape = new SolidBrush(box.TapeColor);
                    // fill polygon
                    Point[] pts = TransformPoint(box.TapePoints);
                    g.FillPolygon(brushTape, pts);
                    g.DrawPolygon(penPath, pts);
                }
            }
        }
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(10, 30, 60, 20);
     float[] pattern = {4f,4f};
     Pen rPen = new Pen(Color.Black);
     rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
     rPen.DashPattern = pattern;
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
     drawDestination.DrawLine(rPen,10,20,70,20);
     drawDestination.DrawLine(rPen,10,60,70,60);
     PointF[] capPolygon = new PointF[3];
     capPolygon[0] = new PointF(65, 19);
     capPolygon[1] = new PointF(69, 11);
     capPolygon[2] = new PointF(61, 11);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     capPolygon[0] = new PointF(65, 61);
     capPolygon[1] = new PointF(69, 69);
     capPolygon[2] = new PointF(61, 69);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     drawDestination.DrawLine(rPen,65,20,65,60);
     drawDestination.DrawString("Measure",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     rPen.Dispose();
     itemStringFormat.Dispose();
 }
Esempio n. 5
0
 public override void Draw(ref System.Drawing.Graphics g)
 {
     if (Nodes.Count != 0 && Check())
     {
         System.Drawing.Point[] PointArray = new System.Drawing.Point[Nodes.Count];
         for (int i = 0; i < Nodes.Count; i++)
         {
             PointArray[i] = CurrentLayer.CurrentMap.MapToScreen(Nodes[i]);
         }
         g.FillPolygon(Brush, PointArray);
         if (Selected)
         {
             Pen InvertPen = new Pen(Color.FromArgb(Pen.Color.A, 0xFF - Pen.Color.R, 0xFF - Pen.Color.G, 0xFF - Pen.Color.B), Pen.Width);
             InvertPen.DashStyle = Pen.DashStyle;
             g.DrawPolygon(InvertPen, PointArray);
         }
         else
         {
             g.DrawPolygon(Pen, PointArray);
         }
     }
     else
     {
         return;
     }
 }
        public override void Draw(Graphics g, TimeRuler ruler)
        {
            if (ruler.Orientation == enumOrientation.orHorizontal)
            {
                int iSecondPos = ruler.ScaleValueToPixel((double) _StartMillisecond);
                int x = iSecondPos - 1;
                int y1 = ruler.HeaderOffset/2, y2 = ruler.Height;
                g.DrawLine(new Pen(new SolidBrush(this.Color), 3), x, y1, x, y2);

                Point left = new Point(iSecondPos - y1, 1);
                Point right = new Point(iSecondPos + y1, 1);
                Point bottom = new Point(iSecondPos, ruler.HeaderOffset/2);
                Point[] trianglePoints = {left, right, bottom};
                g.FillPolygon(new SolidBrush(this.Color), trianglePoints, System.Drawing.Drawing2D.FillMode.Winding);

                g.DrawPolygon(new Pen(new SolidBrush(ruler.ForeColor)), trianglePoints);
            }
            else
            {
                int iSecondPos = ruler.ScaleValueToPixel((double) _StartMillisecond);
                int y = iSecondPos - 1;
                int x1 = ruler.HeaderOffset/2, x2 = ruler.Height;
                g.DrawLine(new Pen(new SolidBrush(this.Color), 3), x1, y, x2, y);

                Point left = new Point(1, iSecondPos - x1);
                Point right = new Point(1, iSecondPos + x1);
                Point bottom = new Point(ruler.HeaderOffset/2, iSecondPos);
                Point[] trianglePoints = {left, right, bottom};
                g.FillPolygon(new SolidBrush(this.Color), trianglePoints, System.Drawing.Drawing2D.FillMode.Winding);

                g.DrawPolygon(new Pen(new SolidBrush(ruler.ForeColor)), trianglePoints);
            }
        }
Esempio n. 7
0
        public override void Draw(Graphics2D graphics)
        {
            System.Drawing.Graphics g = graphics.Graphics;
            Pen penPath = new Pen(new SolidBrush(TopFace.ColorPath));

            // get points
            Point[] ptsFace = graphics.TransformPoint(TopFace.Points);

            // draw solid face
            Brush brushSolid = new SolidBrush(TopFace.ColorFill);

            g.FillPolygon(brushSolid, ptsFace);
            g.DrawPolygon(penPath, ptsFace);
            // draw box tape
            if (TapeWidth.Activated)
            {
                // instantiate brush
                Brush brushTape = new SolidBrush(TapeColor);
                // fill polygon
                Point[] ptsTape = graphics.TransformPoint(TapePoints);
                g.FillPolygon(brushTape, ptsTape);
                g.DrawPolygon(penPath, ptsTape);
            }
            // orientation mark
            if (ShowOrientationMark)
            {
                Pen      penPathOrientationMark = new Pen(new SolidBrush(OrientationMarkColor), 5.0F);
                Vector3D pt0           = TopFace.Points[0];
                Vector3D pt1           = TopFace.Points[1];
                double   offset        = 0.1 * (pt1 - pt0).GetLength();
                Point[]  ptsOrientMark = graphics.TransformPoint(new Vector3D[] { pt0 + new Vector3D(offset, offset, 0.0), pt1 + new Vector3D(-offset, offset, 0.0) });
                g.DrawLine(penPathOrientationMark, ptsOrientMark[0], ptsOrientMark[1]);
            }
        }
        public void DrawIsometricView(Graphics g)
        {
            Point3[] ptsBottom = CircleCoordinates (-h / 2);
            var ptaBottom = new PointF[ptsBottom.Length];
            Point3[] ptsTop = CircleCoordinates (h / 2);
            var ptaTop = new PointF[ptsTop.Length];
            Matrix3 m = Matrix3.Axonometric (35.26f, -45);
            for (int i = 0; i < ptsBottom.Length; i++) {
                ptsBottom [i].Transform (m);
                ptaBottom [i] = Point2D (new CGPoint (ptsBottom [i].X, ptsBottom [i].Y));
                ptsTop [i].Transform (m);
                ptaTop [i] = Point2D (new CGPoint (ptsTop [i].X, ptsTop [i].Y));
            }

            var ptf = new PointF[4];
            for (int i = 1; i < ptsTop.Length; i++) {
                ptf [0] = ptaBottom [i - 1];
                ptf [1] = ptaTop [i - 1];
                ptf [2] = ptaTop [i];
                ptf [3] = ptaBottom [i];
                if (i < 5 || i > ptsTop.Length - 12) {
                    g.FillPolygon (Brushes.White, ptf);
                    g.DrawPolygon (Pens.Black, ptf);
                }
            }

            g.FillPolygon (Brushes.White, ptaTop);
            g.DrawPolygon (Pens.Black, ptaTop);
        }
Esempio n. 9
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            g = e.Graphics;

            Point[] Triangle =
            {
                new Point (100, 5),
                new Point(33, 108),
                new Point(167, 108),
            };
            g.DrawPolygon(p, Triangle);
            g.FillPolygon(b, Triangle);

            g.DrawRectangle(p, 33, 108, 134, 100);
            g.FillRectangle(b, 33, 108, 134, 100);
            
            g.FillEllipse(new SolidBrush(Color.Red), 85, 68, 30, 30);

            Point[] Door =
            {
                new Point(124, 167),
                new Point(124, 208),
                new Point(167, 167),
                new Point (167, 208),
            };
            g.DrawRectangle(p, 124, 167, 42, 41);
            g.FillRectangle(new SolidBrush (Color.Gray), 124, 167, 42, 41);

            g.DrawLine(p, 145, 190, 150, 190);

            g.DrawRectangle(p, 33, 130, 35, 35);
            g.FillRectangle(new SolidBrush(Color.White), 33, 130, 35, 35);
            g.DrawLine(p, 33, 148, 68, 148);
            g.DrawLine(p, 51, 130, 51, 165);

            g.DrawLine(p2, 334, 210, 334, 165);

            Point[] PolyPoints =
            {
                new Point (334, 165),
                new Point (334, 125),
                new Point (354, 136),
                new Point (354, 156),
                new Point (334, 165),
                new Point (314, 156),
                new Point (314, 136),
                new Point (334, 125),
            };
            g.DrawPolygon(p, PolyPoints);
            g.FillPolygon(new SolidBrush(Color.Yellow), PolyPoints);
            g.DrawPolygon(new Pen(Color.Red, 3), PolyPoints);

            g.DrawLine(new Pen (Color.Red, 3), 314, 136, 354, 156);
            g.DrawLine(new Pen(Color.Red, 3), 314, 156, 354, 136);
        }
Esempio n. 10
0
        /// <summary>
        /// Draws the shape.
        /// </summary>
        /// <param name="G">The g.</param>
        /// <param name="FillShape">The fill shape.</param>
        /// <param name="DrawShape">The draw shape.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// FillModes - null
        /// or
        /// FillModes - null
        /// or
        /// ShapeTypes - null
        /// </exception>
        public void DrawShape(System.Drawing.Graphics G, Brush FillShape, Pen DrawShape)
        {
            foreach (List <Point> points in Points)
            {
                switch (ShapeType)
                {
                case ShapeTypes.Polygon:
                    switch (FillMode)
                    {
                    case FillModes.Fill:
                        G.FillPolygon(FillShape, points.ToArray());
                        break;

                    case FillModes.Border:
                        G.DrawPolygon(DrawShape, points.ToArray());
                        break;

                    case FillModes.Both:
                        G.FillPolygon(FillShape, points.ToArray());
                        G.DrawPolygon(DrawShape, points.ToArray());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(FillModes), FillMode, null);
                    }

                    break;

                case ShapeTypes.Spline:
                    switch (FillMode)
                    {
                    case FillModes.Fill:
                        G.FillClosedCurve(FillShape, points.ToArray());
                        break;

                    case FillModes.Border:
                        G.DrawClosedCurve(DrawShape, points.ToArray());
                        break;

                    case FillModes.Both:
                        G.FillClosedCurve(FillShape, points.ToArray());
                        G.DrawClosedCurve(DrawShape, points.ToArray());
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(FillModes), FillMode, null);
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(ShapeTypes), ShapeType, null);
                }
            }
        }
        /// <summary>
        /// Draw Function.</summary>
        /// <param name="g">Graphics for Drawing</param>
        public void Draw(Graphics g)
        {
            g.FillRectangle(Brushes.Yellow, centerIndicator);
            g.DrawRectangle(Pens.Black, centerIndicator);

            g.FillPolygon(Brushes.Yellow, leftIndicator);
            g.DrawPolygon(Pens.Black, leftIndicator);

            g.FillPolygon(Brushes.Yellow, rightIndicator);
            g.DrawPolygon(Pens.Black, rightIndicator);
        }
Esempio n. 12
0
        public static void DrawBone(Bone b, Graphics graph, PointF rootPos, bool selected = false)
        {
            if (b.IsRoot)
            {
                if (selected)
                {
                    graph.DrawEllipse(Pens.Orange, rootPos.X - 30, rootPos.Y - 30, 60, 60);
                }
                else
                {
                    graph.DrawEllipse(Pens.Black, rootPos.X - 30, rootPos.Y - 30, 60, 60);
                }
            }
            else
            {
                PointV p0 = new PointV(b.StartPoint);
                PointV p3 = new PointV(b.EndPoint);
                PointV p1 = p3 - p0;
                PointV p2 = p1.Rotate(-0.2745);
                p1 = p1.Rotate(0.2745);
                p2.Length = p2.Length * 0.2;
                p1.Length = p1.Length * 0.2;
                p2 = p2 + p0;
                p1 = p1 + p0;
                Pen pen0 = new Pen(Color.Black);
                Brush brush0 = new SolidBrush(Color.FromArgb(180, Color.DarkGray));
                Pen pen1 = new Pen(Color.Black);
                pen1.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                PointF[] pts = new PointF[] { p0.Add(rootPos).Point, p1.Add(rootPos).Point,
                        p3.Add(rootPos).Point, p2.Add(rootPos).Point };
                if (selected)
                {
                    brush0 = new SolidBrush(Color.FromArgb(180, Color.Orange));
                    pen1.Color = Color.Orange;
                    pen0.Color = Color.Orange;
                    graph.DrawPolygon(pen0, pts);
                    graph.FillPolygon(brush0, pts);
                    graph.DrawLine(pen1, PointV.Add(rootPos, b.StartPoint), PointV.Add(rootPos, b.Parent.EndPoint));

                }
                else
                {
                    graph.DrawPolygon(pen0, pts);
                    graph.FillPolygon(brush0, pts);
                    graph.DrawLine(pen1, PointV.Add(rootPos, b.StartPoint), PointV.Add(rootPos, b.Parent.EndPoint));
                }

            }
        }
        /// <summary>
        /// Renders a polygon to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="pol">Polygon to render</param>
        /// <param name="brush">Brush used for filling (null or transparent for no filling)</param>
        /// <param name="pen">Outline pen style (null if no outline)</param>
        /// <param name="clip">Specifies whether polygon clipping should be applied</param>
        /// <param name="map">Map reference</param>
        public static void DrawPolygon(System.Drawing.Graphics g, IPolygon pol, System.Drawing.Brush brush, System.Drawing.Pen pen, bool clip, IMap map)
        {
            try
            {
                if (pol.Shell == null)
                {
                    return;
                }

                if (pol.Shell.Coordinates.Length > 2)
                {
                    var points = Transform.TransformToImage(pol.Shell, map, SimplifyGeometryDuringRendering);

                    var solidBrush = brush as SolidBrush;
                    if (solidBrush != null && solidBrush.Color.A != 0)
                    {
                        g.FillPolygon(brush, points, FillMode.Alternate);
                    }

                    if (pen != null)
                    {
                        g.DrawPolygon(pen, points);
                    }

                    for (int i = 0; i < pol.Holes.Length; i++)
                    {
                        points = Transform.TransformToImage(pol.Holes[i], map, SimplifyGeometryDuringRendering);
                        if (solidBrush != null && solidBrush.Color.A != 0)
                        {
                            g.FillPolygon(brush, points);
                        }

                        if (pen != null)
                        {
                            g.DrawPolygon(pen, points);
                        }
                    }
                }
            }
            catch (InvalidOperationException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
            catch (OverflowException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
        }
Esempio n. 14
0
        void initGraph()
        {
            BorderPoints = new System.Drawing.Point[8];

            int psetBorderClear = 7;

            BorderPoints[0].X = psetBorderClear;
            BorderPoints[0].Y = 0;
            BorderPoints[1].X = 0;
            BorderPoints[1].Y = psetBorderClear;
            BorderPoints[2].X = 0;
            BorderPoints[2].Y = this.Height - psetBorderClear;
            BorderPoints[3].X = psetBorderClear;
            BorderPoints[3].Y = this.Height;
            BorderPoints[4].X = this.Width - psetBorderClear;
            BorderPoints[4].Y = this.Height;
            BorderPoints[5].X = this.Width;
            BorderPoints[5].Y = this.Height - psetBorderClear;
            BorderPoints[6].X = this.Width;
            BorderPoints[6].Y = psetBorderClear;
            BorderPoints[7].X = this.Width - psetBorderClear;
            BorderPoints[7].Y = 0;

            System.Drawing.Drawing2D.GraphicsPath shape = new System.Drawing.Drawing2D.GraphicsPath();
            shape.AddPolygon(BorderPoints);
            this.Region = new System.Drawing.Region(shape);

            BackgroundImage = new Bitmap(this.Width, this.Height);
            graphicsmain    = Graphics.FromImage(BackgroundImage);
            BorderPen       = new Pen(System.Drawing.Brushes.Black, 2);
            graphicsmain.Clear(Color.Gainsboro);
            graphicsmain.DrawPolygon(BorderPen, BorderPoints);
        }
Esempio n. 15
0
        /// <summary>
        /// Renders the contour into a graphic object
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="rect"></param>
        public void Draw(System.Drawing.Graphics gr, Rectangle rect)
        {
            gr.DrawRectangle(Pens.SteelBlue, rect);
            rect = new Rectangle(rect.Left, rect.Top, rect.Width - 24, rect.Height);

            var contour  = this.contour.Clone();
            var autoCorr = this.autoCorr.Clone();

            autoCorr.Normalize();

            Rectangle r = new Rectangle(rect.X, rect.Y, rect.Width / 2, rect.Height);

            r.Inflate(-20, -20);
            var       points    = contour.GetPoints(startPoint);
            Rectangle boundRect = Rectangle.Round(contour.GetBoundsRect());

            double w   = boundRect.Width;
            double h   = boundRect.Height;
            float  k   = (float)Math.Min(r.Width / w, r.Height / h);
            int    dx  = startPoint.X - contour.SourceBoundingRect.Left;
            int    dy  = startPoint.Y - contour.SourceBoundingRect.Top;
            int    ddx = -(int)(boundRect.Left * k);
            int    ddy = (int)(boundRect.Bottom * k);

            for (int i = 0; i < points.Length; i++)
            {
                points[i] = new Point(r.Left + ddx + (int)((points[i].X - contour.SourceBoundingRect.Left - dx) * k), r.Top + ddy +
                                      (int)((points[i].Y - contour.SourceBoundingRect.Top - dy) * k));
            }
            gr.DrawPolygon(Pens.Red, points);
        }
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(5, 15, 30, 15);
     RectangleF itemBox2 = new RectangleF(5, 35, 70, 15);
     itemStringFormat.Alignment = StringAlignment.Near;
     itemStringFormat.LineAlignment = StringAlignment.Near;
     PointF[] statePolygon = new PointF[5];
     statePolygon[0] = new PointF(5,15);
     statePolygon[1] = new PointF(40,15);
     statePolygon[2] = new PointF(40,25);
     statePolygon[3] = new PointF(35,30);
     statePolygon[4] = new PointF(5,30);
     drawDestination.FillPolygon(Brushes.White,statePolygon);
     drawDestination.DrawPolygon(Pens.LightGray,statePolygon);
     drawDestination.DrawRectangle(Pens.LightGray,5,15,70,50);
     drawDestination.DrawString("frag",new Font("Arial",8,FontStyle.Regular),Brushes.LightGray,itemBox,itemStringFormat);
     Pen rPen = new Pen(Color.Black);
     float[] pattern = {4f,4f};
     rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
     rPen.DashPattern = pattern;
     itemStringFormat.Alignment = StringAlignment.Center;
     drawDestination.DrawString("separator",new Font("Arial",8,FontStyle.Italic),Brushes.Black,itemBox2,itemStringFormat);
     drawDestination.DrawLine(rPen, 5, 50, 75, 50);
     rPen.Dispose();
     itemStringFormat.Dispose();
 }
Esempio n. 17
0
        private void renderShape(Shape shape)
        {
            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(0, 0, 0, 0);

            switch (shape.ShapeType)
            {
            case "Circle":
            case "Ellipse":
                rectangle = new System.Drawing.Rectangle(shape.point1.X, shape.point1.Y, shape.width, shape.length);
                graphicsObj.DrawEllipse(pen, rectangle);
                break;

            case "Rectangle":
            case "Square":
                rectangle = new System.Drawing.Rectangle(shape.point1.X, shape.point1.Y, shape.width, shape.length);
                graphicsObj.DrawRectangle(pen, rectangle);
                break;

            case "Triangle":
                System.Drawing.Point[] points =
                {
                    new System.Drawing.Point(shape.point1.X, shape.point1.Y),
                    new System.Drawing.Point(shape.point2.X, shape.point2.Y),
                    new System.Drawing.Point(shape.point3.X, shape.point3.Y)
                };
                graphicsObj.DrawPolygon(pen, points);
                break;

            case "Embedded Image":
                Image        image  = new Bitmap(shape.filepath);
                TextureBrush tBrush = new TextureBrush(image);
                graphicsObj.FillRectangle(tBrush, new System.Drawing.Rectangle(shape.point1.X, shape.point1.Y, shape.width, shape.length));
                break;
            }
        }
Esempio n. 18
0
        public void Draw(Graphics g)
        {
            g.DrawPolygon(Pens.Brown, points);
            foreach (var i in points)
                g.FillEllipse(Brushes.Black, i.X-3, i.Y-3, 6, 6);

        }
Esempio n. 19
0
        //функција за испртување на скалилото
        public void Draw(Graphics g)
        {
            Point p1 = new Point(20, 200);
            Point p2 = new Point(20, 220);
            Point p3 = new Point(560, 220);
            Point p4 = new Point(560, 50);

            Point p7 = new Point(21, 200);
            Point p8 = new Point(21, 220);
            Point p5 = new Point(Xcoef, Ycoef);
            Point p6 = new Point(Xcoef, 220);

            Brush brush = new SolidBrush(Color.Black);
            Brush brush2 = new SolidBrush(Color);

            Pen pen = new Pen(brush);

            Point[] points1 = { p1, p2, p3, p4 };
            Point[] points2 = { p7, p8, p6, p5 };

            g.DrawPolygon(pen, points1);
            g.FillPolygon(brush2, points2);

            brush.Dispose();
            brush2.Dispose();
        }
Esempio n. 20
0
		public override void Draw(Graphics graphics)
		{
			if (graphics == null) return;
			
			#region Panel
			graphics.FillRectangle(shadowBrush, 1, 14, 10.5f, 1.5f);
			graphics.FillRectangle(shadowBrush, 10, 6, 1.5f, 9);
			
			graphics.FillRectangle(panelBrush, 0, 5, 10, 9);
			graphics.DrawRectangle(panelPen, 0, 5, 10, 9);
			
			graphics.FillRectangle(linesBrush, 1.5f, 9, 2, 1);
			graphics.FillRectangle(linesBrush, 5, 9, 3, 1);

			graphics.FillRectangle(linesBrush, 1.5f, 11, 2, 1);
			graphics.FillRectangle(linesBrush, 5, 11, 3, 1);
			#endregion
			
			#region Hand
			//TODO - improve the hand, choose better colors
			graphics.FillPolygon(handBrush, handPoints);
			graphics.DrawPolygon(handPen, handPoints);
			graphics.DrawLine(handPen, 6, 6, 8, 4);
			graphics.DrawLine(handPen, 7, 7, 9.5f, 4.5f);
			graphics.DrawLine(handPen, 8, 8, 11, 5);
			graphics.FillRectangle(sleeveBrush, 13, 2, 2, 4);
			graphics.DrawRectangle(sleevePen, 13, 2, 2, 4);
			#endregion
		}
Esempio n. 21
0
        public void Render(Graphics g, Vector2D translation)
        {
            Pen pen = new Pen(new SolidBrush(color));
            Vector2D z = new Vector2D((float)Math.Sqrt(RADIUS * RADIUS - RADIUS * Math.Sin(ToRadians(60))), (float)(RADIUS * Math.Sin(ToRadians(60))));

            Vector2D upRight = new Vector2D(z.X, 2 * -z.Y);
            Vector2D horRight = new Vector2D(2 * z.X, 0);
            Vector2D botRight = new Vector2D(z.X, 2 * z.Y);
            Vector2D botLeft = new Vector2D(-z.X, 2 * z.Y);
            Vector2D horLeft = new Vector2D(-2 * z.X, 0);
            Vector2D upLeft = new Vector2D(-z.X, 2 * -z.Y);

            Vector2D posUpRight = center + upRight + translation;
            Vector2D posHorRight = center + horRight + translation;
            Vector2D posBotRight = center + botRight + translation;
            Vector2D posBotLeft = center + botLeft + translation;
            Vector2D posHorLeft = center + horLeft + translation;
            Vector2D posUpLeft = center + upLeft + translation;

            PointF[] points = new PointF[]
            {
                new PointF(posUpRight.X, posUpRight.Y),
                new PointF(posHorRight.X, posHorRight.Y),
                new PointF(posBotRight.X, posBotRight.Y),
                new PointF(posBotLeft.X, posBotLeft.Y),
                new PointF(posHorLeft.X, posHorLeft.Y),
                new PointF(posUpLeft.X, posUpLeft.Y)
            };

            g.DrawPolygon(pen, points);
        }
Esempio n. 22
0
        /// <summary>
        /// Renders the key in the specified surface.
        /// </summary>
        /// <param name="g">The GDI+ surface to render on.</param>
        /// <param name="scrollCount">The number of times the direction has been scrolled within the timeout.</param>
        public void Render(Graphics g, int scrollCount)
        {
            var pressed = scrollCount > 0;
            var style = GlobalSettings.CurrentStyle.TryGetElementStyle<KeyStyle>(this.Id)
                            ?? GlobalSettings.CurrentStyle.DefaultKeyStyle;
            var defaultStyle = GlobalSettings.CurrentStyle.DefaultKeyStyle;
            var subStyle = pressed ? style?.Pressed ?? defaultStyle.Pressed : style?.Loose ?? defaultStyle.Loose;

            var text = pressed ? scrollCount.ToString() : this.Text;
            var txtSize = g.MeasureString(text, subStyle.Font);
            var txtPoint = new TPoint(
                this.TextPosition.X - (int)(txtSize.Width / 2),
                this.TextPosition.Y - (int)(txtSize.Height / 2));

            // Draw the background
            var backgroundBrush = this.GetBackgroundBrush(subStyle, pressed);
            g.FillPolygon(backgroundBrush, this.Boundaries.ConvertAll<Point>(x => x).ToArray());

            // Draw the text
            g.SetClip(this.GetBoundingBox());
            g.DrawString(text, subStyle.Font, new SolidBrush(subStyle.Text), (Point)txtPoint);
            g.ResetClip();

            // Draw the outline.
            if (subStyle.ShowOutline)
                g.DrawPolygon(new Pen(subStyle.Outline, 1), this.Boundaries.ConvertAll<Point>(x => x).ToArray());
        }
Esempio n. 23
0
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(15, 30, 50, 20);
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,40,10,40,70);
     if (mMscStyle == MscStyle.SDL){
         PointF[] statePolygon = new PointF[6];
         statePolygon[0] = new PointF(5,40);
         statePolygon[1] = new PointF(15,30);
         statePolygon[2] = new PointF(65,30);
         statePolygon[3] = new PointF(75,40);
         statePolygon[4] = new PointF(65,50);
         statePolygon[5] = new PointF(15,50);
         drawDestination.FillPolygon(Brushes.White,statePolygon);
         drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
         drawDestination.DrawPolygon(Pens.Black,statePolygon);
     }
     else if(mMscStyle == MscStyle.UML2){
             drawDestination.FillRectangle(Brushes.White,itemBox);
             drawDestination.FillEllipse(Brushes.White,5,30,20,20);
             drawDestination.FillEllipse(Brushes.White,55,30,20,20);
             drawDestination.DrawLine(Pens.Black,15,30,65,30);
             drawDestination.DrawLine(Pens.Black,15,50,65,50);
             drawDestination.DrawArc(Pens.Black,5,30,20,20,90,180);
             drawDestination.DrawArc(Pens.Black,55,30,20,20,270,180);
             drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     }
     itemStringFormat.Dispose();
 }
Esempio n. 24
0
 /// <summary>
 /// 绘制方法
 /// </summary>
 /// <param name="g">画布</param>
 /// <param name="center">地图中心点</param>
 /// <param name="zoom">地图缩放级别</param>
 /// <param name="screen_size">地图大小</param>
 public override void Draw(System.Drawing.Graphics g, LatLngPoint center, int zoom, System.Drawing.Size screen_size)
 {
     if (Points != null && Points.Count >= 2)
     {
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
         List <Point> l = new List <Point>();
         foreach (LatLngPoint p in Points)
         {
             l.Add(MapHelper.GetScreenLocationByLatLng(p, center, zoom, screen_size));
         }
         using (Pen pen = new Pen(Color.FromArgb(150, Color.Blue), 4))
         {
             if (Points.Count == 2)
             {
                 g.DrawLine(pen, l[0], l[1]);
             }
             else
             {
                 using (SolidBrush sb = new SolidBrush(Color.FromArgb(30, Color.Blue)))
                 {
                     g.FillPolygon(sb, l.ToArray());
                 }
                 g.DrawPolygon(pen, l.ToArray());
             }
         }
     }
 }
Esempio n. 25
0
        Bitmap drawBattleDice(Graphics gDice, Bitmap diceBitmap, Pen myPen, Brush myBrush, int level, int randomNumber)
        {
            gDice.Clear(Color.Transparent);
            PointF[] Verticies;
                Verticies = new PointF[3];
                Verticies[0] = new PointF(0, pbDice.Height - 1);
                Verticies[1] = new PointF(pbDice.Width - 1, pbDice.Height - 1);
                Verticies[2] = new PointF(pbDice.Width / 2.0f, (float)(pbDice.Height - 1 - pbDice.Height / 2 * Math.Sqrt(3)));

                if (level == 1)
                    gDice.FillPolygon(new SolidBrush(Color.Green), Verticies);
                else if(level==2)
                    gDice.FillPolygon(new SolidBrush(Color.Red), Verticies);
                else if (level == 3)
                    gDice.FillPolygon(new SolidBrush(Color.Blue), Verticies);
                else if (level == 4)
                    gDice.FillPolygon(new SolidBrush(Color.Purple), Verticies);
                myPen.Color = Color.Black;
                gDice.DrawPolygon(myPen, Verticies);
            Font font = new Font("Times New Roman", 16, FontStyle.Bold);
            StringFormat format = new StringFormat();
            Brush whiteBrush = new SolidBrush(Color.White);
            format.Alignment = StringAlignment.Center;
            RectangleF rect = new RectangleF(pbDice.Width / 2 - 20 , pbDice.Height / 2 - 4 , 40 , 25);
            if (randomNumber == 0)
            {
                rect.Y = pbDice.Height / 2 + 6;
                gDice.DrawString("Roll", new Font("Times New Roman", 14, FontStyle.Italic), whiteBrush, rect, format);
            }
            else
            {
                gDice.DrawString(randomNumber.ToString(), font, whiteBrush, rect, format);
            }
            return diceBitmap;
        }
Esempio n. 26
0
		public override void Draw(Graphics graphics)
		{
			if (graphics == null) return;
			base.Draw(graphics);
			graphics.FillPolygon (fill , plusPoints);
			graphics.DrawPolygon (stroke, plusPoints);
		}
Esempio n. 27
0
        private void CreatePointImage(PointF[] alignmentShape1, string srcFilename, string outfilename, bool shape = false)
        {
            var stream = File.OpenRead(srcFilename);
            var bmp    = new DWG.Bitmap(stream);

            stream.Close();
            var font = new DWG.Font(DWG.FontFamily.GenericSansSerif, 12);

            using (DWG.Graphics g = DWG.Graphics.FromImage(bmp))
            {
                g.InterpolationMode = DWG.Drawing2D.InterpolationMode.HighQualityBicubic;
                if (shape)
                {
                    g.DrawPolygon(new DWG.Pen(DWG.Brushes.LightGray, 4), alignmentShape1.Select(p => new DWG.PointF(p.X, p.Y)).ToArray());
                }
                else
                {
                    for (int i = 0; i < alignmentShape1.Length; i++)
                    {
                        var pnt = alignmentShape1[i];
                        g.FillEllipse(GetPointColor(i), pnt.X - 1.5f, pnt.Y - 1.5f, 3, 3);
                        g.DrawString(i.ToString(), font, DWG.Brushes.LightGray, new DWG.PointF(pnt.X - 12f, pnt.Y - 6f));
                    }
                }
            }

            bmp.Save(outfilename, IMG.ImageFormat.Jpeg);
            bmp.Dispose();
        }
Esempio n. 28
0
        //protected override void OnPaint(PaintEventArgs e)
        //{
        //    Graphics graphics = PolygonPanel.CreateGraphics();
        //    Brush blackpen = new SolidBrush(Color.Black);
        //    Pen pen = new Pen(blackpen, 1);
        //    Point[] point = new Point[6];
        //    point[0] = polygon.PointOne;
        //    point[1] = polygon.PointTwo;
        //    point[2] = polygon.PointThree;
        //    point[3] = polygon.PointFour;
        //    point[4] = polygon.PointFive;
        //    point[5] = polygon.PointSix;

        //    graphics.DrawPolygon(pen,point);
        //    //base.OnPaint(e);
        //}
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Graphics graphics = PolygonPanel.CreateGraphics();
            Brush blackpen = new SolidBrush(Color.Black);
            Pen   pen      = new Pen(blackpen, 1);

            Point[] point = new Point[6];
            int     cx = (int)circle.CentreX, cy = (int)circle.CentreX;
            int     R = (int)circle.Radius, N = 6;

            for (int i = 0; i < 6; i++)
            {
                point[i].X = (int)(cx + R * Math.Cos(Math.PI / N * (1 + 2 * i)));
                point[i].Y = (int)(cy + R * Math.Sin(Math.PI / N * (1 + 2 * i)));
            }
            graphics.DrawPolygon(pen, point);
            //int cx = 550, cy = 550;
            //int R = 100, N = 6;
            //int[,] points = new int[6, 2];
            //for (int i = 0; i < 6; i++)
            //{

            //    points[i, 0] = (int)(cx + R * Math.Cos(Math.PI / N * (1 + 2 * i)));
            //    points[i, 1] = (int)(cy + R * Math.Sin(Math.PI / N * (1 + 2 * i)));

            //    //po
            //    //graphics.
            //    //base.OnPaint(e);
            //}
        }
        public override void Redraw(Graphics g)
        {
            if (txt == null)
                return;

            Point position = txt.GetPositionFromCharIndex(startIndex);
            Point centerPos = new Point(position.X, (int)(position.Y + (txt.Font.Size * 0.75)));
            float thirdFontSize = txt.Font.Size / 3;

            centerPos.Offset((int)thirdFontSize, 0);
            centerPos.Offset((int)thirdFontSize, 0);
            Brush brush = new SolidBrush(BrushColor);
            Pen pen = new Pen(brush);

            //the horizontal line
            Point lineEnd = new Point((int)(centerPos.X + thirdFontSize), centerPos.Y);
            g.DrawLine(pen, centerPos, lineEnd);

            //the verical line from top
            PointF verticalLineStart = new PointF(lineEnd.X, (lineEnd.Y - thirdFontSize));
            g.DrawLine(pen, verticalLineStart, lineEnd);

            //the arrow on the left pointing left
            PointF topArrowHead = new PointF(centerPos.X, (centerPos.Y - thirdFontSize));
            PointF bottomArrowHead = new PointF(centerPos.X, (centerPos.Y + thirdFontSize));
            PointF middleArrowHead = new PointF(centerPos.X - thirdFontSize, centerPos.Y);

            g.DrawPolygon(pen, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
            g.FillPolygon(brush, new PointF[] { topArrowHead, bottomArrowHead, middleArrowHead });
        }
Esempio n. 30
0
        public override void DrawSelf(Graphics gfx, Pen pen)
        {
            base.DrawSelf(gfx, pen);

            PointF a = new PointF(Center.X + Width / 2, Center.Y);
            PointF b = new PointF(Center.X - Width / 2, Center.Y + Height / 2);
            PointF c = new PointF(Center.X - Width / 2, Center.Y - Height / 2);

            PointF a1 = Calc.RotatePoint(Center, a, Angle);
            PointF b1 = Calc.RotatePoint(Center, b, Angle);
            PointF c1 = Calc.RotatePoint(Center, c, Angle);

            Brush brush = Brushes.Blue;
            gfx.FillPolygon(brush, new PointF[4] { a1, b1, c1, a1 });
            gfx.DrawPolygon(pen, new PointF[4] { a1, b1, c1, a1 });

            if (!Dummy)
            {

                Pen penn = new Pen(Color.LightBlue, 1);
                gfx.DrawEllipse(penn, Center.X - Range, Center.Y - Range, Range * 2, Range * 2);
            }
            if (Dummy)
            {
                gfx.DrawString((1000 / FireDelayMilis * TeslaBullet.DamageDefault).ToString(), new Font("Arial", 7), Brushes.Black, Center.X - (Width / 2), Center.Y - 15);
            }
        }
Esempio n. 31
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Pen p = new Pen(Color.Red, 3);

            Point[] points = { new Point(30, 30), new Point(60, 30), new Point(60, 100), new Point(30, 100) };
            g.DrawPolygon(p, points);
        }
Esempio n. 32
0
        private void RysujKwadrat(Klocek K, int X = 0, int Y = 0)
        {
            PointF[] currentPoints =
            {
                this.P1,
                this.P2,
                this.P3,
                this.P4
            };
            this.P1 = new PointF(X + 12.5f, Y + 12.5f);
            this.P2 = new PointF(X + 12.5f, Y - 12.5f);
            this.P3 = new PointF(X - 12.5f, Y - 12.5f);
            this.P4 = new PointF(X - 12.5f, Y + 12.5f);

            switch (K.Ksztalt)
            {
            case 1:
                pen1.Color = Color.FromArgb(26, 236, 15);
                break;

            case 2:
                pen1.Color = Color.FromArgb(255, 80, 80);
                break;

            case 3:
                pen1.Color = Color.FromArgb(255, 171, 56);
                break;

            case 4:
                pen1.Color = Color.FromArgb(111, 111, 111);
                break;

            case 5:
                pen1.Color = Color.FromArgb(241, 255, 73);
                break;

            case 6:
                pen1.Color = Color.FromArgb(81, 175, 255);
                break;

            case 7:
                pen1.Color = Color.FromArgb(156, 65, 164);
                break;
            }
            g.DrawPolygon(pen1, currentPoints);
        }
Esempio n. 33
0
 public void Draw(System.Drawing.Pen p, System.Drawing.Graphics g, int x, int y)
 {
     Point[] points = new Point[] {
         new Point(x, y),
         new Point(x + 10, y - 10),
         new Point(x - 10, y - 10),
     };
     g.DrawPolygon(p, points);
 }
Esempio n. 34
0
 private static void DrawScrollDockButton(Graphics g, Point[] points, Color color, bool fill)
 {
     if (fill)
         using (var brush = new SolidBrush(color))
             g.FillPolygon(brush, points);
     else
         using (var pen = new Pen(color))
             g.DrawPolygon(pen, points);
 }
Esempio n. 35
0
 public override void Draw(Graphics2D graphics)
 {
     System.Drawing.Graphics g = graphics.Graphics;
     // get points
     Point[] ptOuter = graphics.TransformPoint(MaxRadiusPoints);
     // max radius / top view
     g.FillPolygon(new SolidBrush(Color), ptOuter);
     // bottom (draw only path)
     g.DrawPolygon(new Pen(new SolidBrush(ColorPath)), ptOuter);
 }
Esempio n. 36
0
 public override void Draw(Graphics graphic, Pen pen)
 {
     Point A = startPoint;
     Point B = startPoint;
     B.X = endPoint.X;
     Point C = endPoint;
     C.X = startPoint.X + Math.Abs(startPoint.X - endPoint.X) / 2;
     Point[] triagl = new Point[3] {A, B, C };
     graphic.DrawPolygon(pen, triagl);
 }
Esempio n. 37
0
        private void button1_Click(object sender, EventArgs e)
        {
            Point [] Triunghi = new Point []
            {
                new Point {X = 190, Y = 65}, new Point {X = 105, Y = 290},
                new Point {X = 290, Y = 290}, new Point {X= 190, Y=65}
            };
            Desen.DrawPolygon(Creion_albastru, Triunghi);

        }
Esempio n. 38
0
 public void draw(Graphics g)//drawing
 {
     for (short i = 0; i < 10; i++)
     {
         delta_i += 0.02;
         BonusRec = new Rectangle(BonusRec.X + 4, BonusRec.Y, a, a);//sets rectangle
         g.DrawPolygon(new Pen(colour), new Point[] { trin_coord(2), trin_coord(4), trin_coord(6) });//Drawing triangle
         g.DrawString("♆", new Font("Arial", 24), new SolidBrush(Color.White), BonusRec.X - 2, BonusRec.Y + a / 5, new StringFormat());//drawing icon inside
     }
 }
Esempio n. 39
0
 public void Draw(System.Drawing.Graphics g, System.Drawing.Pen p, PointF [] points)
 {
     points    = new PointF[4];
     points[0] = new PointF((A1.Nx + B1.Nx) / 2, 0);
     points[1] = new PointF((A1.Nx + B1.Nx) / 2, B1.Ny);
     points[2] = new PointF(B1.Ny, A1.Ny);
     points[3] = new PointF(A1.Ny, (A1.Nx + B1.Nx) / 2);
     g.DrawRectangle(p, A1.Nx, A1.Ny, B1.Nx, B1.Ny);
     g.DrawPolygon(p, points);
 }
Esempio n. 40
0
 public override void Draw(Graphics g, Rectangle clip)
 {
     var points = new[]
         {
             new Point(clip.X, clip.Y),
             new Point(clip.Right - 1, clip.Y + 2 * clip.Height / 3),
             new Point(clip.X + 2 * clip.Width / 3, clip.Bottom - 1),
         };
     g.DrawPolygon(_pen, points);
 }
Esempio n. 41
0
        public override void Draw(Graphics graphics)
        {
            if (_bulletSprite != null && IsActive)
            {
                _bulletSprite.Polygon = new Point[] { new Point(-1 + _location.X, -1 + _location.Y), new Point(-1 + _location.X, 1 + _location.Y), new Point(1 + _location.X, _location.Y), new Point(-1 + _location.X, -1 + _location.Y) };

                Point[] clone = _bulletSprite.Polygon.ClonePolygon();

                graphics.DrawPolygon(Pens.Red, clone);
            }
        }
Esempio n. 42
0
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(10, 30, 60, 30);
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
     drawDestination.DrawLine(Pens.Black,10,30,65,30);
     PointF[] capPolygon = new PointF[3];
     capPolygon[0] = new PointF(65, 30);
     capPolygon[1] = new PointF(70, 25);
     capPolygon[2] = new PointF(60, 25);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     capPolygon[0] = new PointF(65, 30);
     capPolygon[1] = new PointF(70, 35);
     capPolygon[2] = new PointF(60, 35);
     drawDestination.DrawPolygon(Pens.Black,capPolygon);
     drawDestination.DrawString("SetTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     itemStringFormat.Dispose();
 }
Esempio n. 43
0
 /// <summary>
 /// Draw the triangle to the specified graphics object.
 /// </summary>
 /// <param name="gfx">The graphics device to draw to.</param>
 /// <param name="color">The color to draw the shape.</param>
 /// <param name="fill">Whether or not to fill the shape.</param>
 public override void Draw(Graphics gfx, Color color, bool fill)
 {
     if (fill)
     {
         gfx.FillPolygon(new SolidBrush(color), new Point[] { Position, PositionB, PositionC, Position });
     }
     else
     {
         gfx.DrawPolygon(new Pen(color), new Point[] { Position, PositionB, PositionC, Position });
     }
 }
Esempio n. 44
0
 public override void Paint(System.Drawing.Graphics g)
 {
     getVertex();
     Point[] p = new Point[4];
     for (int i = 0; i < p.Length; ++i)
     {
         p[i] = new Point(point.X + vertex[i].X, point.Y + vertex[i].Y);
     }
     g.FillPolygon(brush, p);
     g.DrawPolygon(pen, p);
 }
Esempio n. 45
0
        public static void DrawPolygon(System.Drawing.Graphics g, List <List <Vector2> > polygons, System.Drawing.Color color, float x, float y, float max, int bmp_size)
        {
            Pen pen  = new Pen(color);
            int size = polygons.Count;

            for (int i = 0; i < size; ++i)
            {
                Point[] dat = ResizeData(polygons[i], x, y, max, max, bmp_size);
                g.DrawPolygon(pen, dat);
            }
            pen.Dispose();
        }
Esempio n. 46
0
 override public void Draw(System.Drawing.Graphics graphics)
 {
     graphics.DrawPolygon(new Pen(Color.Black), CoordReceiver);
     foreach (Ray index in RayList)
     {
         index.Draw(graphics);
     }
     foreach (Ray index in RefractRayList)
     {
         index.Draw(graphics);
     }
 }
Esempio n. 47
0
        public override void DrFigure(Graphics g)
        {
            len = DrowText(g, Position.X + len.Width / 2, Position.Y + len.Height / 2);

            Width = len.Width > 30 ? 2 * len.Width : 60;
            Height = len.Height > 30 ? 2 * len.Height : 60;

            SerediniStoronMethPoints();

            Pen pen = new Pen(ColorFigure, 2);
            g.DrawPolygon(pen, SerediniStoron);
        }
Esempio n. 48
0
        public override void DrFigure(Graphics g)
        {
            len = DrowText(g, Position.X + 10, Position.Y);
            Width = len.Width > 40 ? len.Width + 20 : 60;
            Height = len.Height > 40 ? len.Height : 40;

            SerediniStoronMethPoints();
            UgliParallelogramma();

            Pen pen = new Pen(ColorFigure, 2);
            g.DrawPolygon(pen, UgliParallelogrammaPoints);
        }
Esempio n. 49
0
        public static void DrawPolygon(System.Drawing.Graphics g, List <Vector2> polygon, System.Drawing.Color color)
        {
            Pen pen = new Pen(color);

            Point[] points = new Point[polygon.Count];
            for (int i = 0; i < polygon.Count; ++i)
            {
                points[i] = Convert(polygon[i]);
            }
            g.DrawPolygon(pen, points);
            pen.Dispose();
        }
Esempio n. 50
0
        public void Draw(Graphics g)
        {
            g.ResetTransform();

            g.ScaleTransform(1 + (float)Math.Cos(angle/200f)/1f, 1+ (float)Math.Cos(angle/200f)/1f);
            g.TranslateTransform(g.VisibleClipBounds.Width / 2f, g.VisibleClipBounds.Height / 2f);

            angle += 10;
            g.RotateTransform(angle);

            g.DrawPolygon(new Pen(new SolidBrush(Color.Black), 3), vertices);
        }
        public void Marshall(PointF[] vertexBuffer, System.Drawing.Graphics gr)
        {
            // The three Point structures represent the upper-left, upper-right, and lower-left corners of the parallelogram.
            // The fourth point is extrapolated from the first three to form a parallelogram.

            if (primitive == PRIM_TEXT)
            {
                gr.DrawString(text, font, new SolidBrush(color), vertexBuffer[firstIndex]);
            }
            else if (primitive == PRIM_FILL_RECT)
            {
                gr.FillRectangle(new SolidBrush(color), new Rectangle(
                                     (int)vertexBuffer[firstIndex + 0].X,
                                     (int)vertexBuffer[firstIndex + 0].Y,
                                     (int)(vertexBuffer[firstIndex + 1].X - vertexBuffer[firstIndex + 0].X),
                                     (int)(vertexBuffer[firstIndex + 1].Y - vertexBuffer[firstIndex + 0].Y))
                                 );
            }
            else if (primitive == PRIM_RECT)
            {
                gr.DrawRectangle(new Pen(color), new Rectangle(
                                     (int)vertexBuffer[firstIndex + 0].X,
                                     (int)vertexBuffer[firstIndex + 0].Y,
                                     (int)(vertexBuffer[firstIndex + 1].X - vertexBuffer[firstIndex + 0].X),
                                     (int)(vertexBuffer[firstIndex + 1].Y - vertexBuffer[firstIndex + 0].Y))
                                 );
            }
            else if (image != null)
            {
                var       imageAttr           = new ImageAttributes();
                float     r                   = (float)color.R / 255.0f;
                float     g                   = (float)color.G / 255.0f;
                float     b                   = (float)color.B / 255.0f;
                float     a                   = (float)color.A / 255.0f;
                float[][] colorMatrixElements =
                {
                    new float[] { r, 0, 0, 0, 0 },         // red scaling factor of 2
                    new float[] { 0, g, 0, 0, 0 },         // green scaling factor of 1
                    new float[] { 0, 0, b, 0, 0 },         // blue scaling factor of 1
                    new float[] { 0, 0, 0, a, 0 },         // alpha scaling factor of 1
                    new float[] { 0, 0, 0, 0, 1 }
                };                                         // three translations of 0.2
                ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
                imageAttr.SetColorMatrix(colorMatrix);
                gr.DrawImage(image, vertexBuffer.Skip(firstIndex).Take(3).ToArray(), texcoords, GraphicsUnit.Pixel, imageAttr);
            }
            else
            {
                gr.DrawPolygon(new Pen(color), vertexBuffer.Skip(firstIndex).Take(numVerts).ToArray());
            }
        }
Esempio n. 52
0
        /// <summary>
        /// Remove the current algorithm but leave the polygons
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void continueButton_Click(object sender, EventArgs e)
        {
            if (totalPolygons == 1)
            {
                g.Clear(Color.White);
                maxDiameterButton.Enabled  = true;
                minAreaButton.Enabled      = true;
                nextButton.Enabled         = false;
                maxDist2PolyButton.Enabled = false;
                addPolygonButton.Enabled   = false;
                ClosePolygonButton.Enabled = false;
                intersectionButton.Enabled = false;
                minimumPermButton.Enabled  = true;
                minWidthButton.Enabled     = true;

                CalipersBaseClass.TotalRotatedAngleAmount = 0;
                g.DrawPolygon(Utility.bluePen, firstPolygon.points.ToArray());
            }
            else if (totalPolygons == 2)
            {
                g.Clear(Color.White);

                maxDiameterButton.Enabled     = false;
                minWidthButton.Enabled        = false;
                minAreaButton.Enabled         = false;
                nextButton.Enabled            = false;
                maxDist2PolyButton.Enabled    = true;
                addPolygonButton.Enabled      = false;
                ClosePolygonButton.Enabled    = false;
                minimumPermButton.Enabled     = false;
                mergeConvexHullButton.Enabled = true;
                intersectionButton.Enabled    = true;

                CalipersBaseClass.TotalRotatedAngleAmount = 0;
                g.DrawPolygon(Utility.bluePen, firstPolygon.points.ToArray());
                g.DrawPolygon(Utility.bluePen, secondPolygon.points.ToArray());
            }
        }
 public override void Paint(System.Drawing.Graphics g)
 {
     if (nSide < 0 || radius < 0)
     {
         throw new Exception("Uncorrect Data");
     }
     else
     {
         p = new PointF[nSide];
         SearchPoint((float)360 / nSide);
         g.DrawPolygon(pen, p);
         g.FillPolygon(brush, p);
     }
 }
Esempio n. 54
0
        //worst case O(nlogn)
        public void Solve(List <System.Drawing.PointF> pointList)
        {
            //sort points
            pointList = pointList.OrderByDescending(p => p.X).ToList();

            //call the recursive convexHull function, retrieve final list
            Hull finalHUll = convexHUll(pointList);

            pointList = finalHUll.getList();

            //prepare list and draw it
            PointF[] pointArray = pointList.ToArray();
            g.DrawPolygon(new Pen(Color.Red), pointArray);
        }
Esempio n. 55
0
        private void button3_Click(object sender, EventArgs e)
        {
            Point pt1 = new Point(270, 100);
            Point pt2 = new Point(220, 170);
            Point pt3 = new Point(320, 170);

            Point[] vertices = { pt1, pt2, pt3 };

            Pen pen = new Pen(Color.Blue);

            formGraphics = this.CreateGraphics();
            formGraphics.DrawPolygon(pen, vertices);
            pen.Dispose();
            formGraphics.Dispose();
        }
Esempio n. 56
0
        public void DrawCylinder(Cylinder cyl)
        {
            System.Drawing.Graphics g = Graphics;

            // get points
            Point[] pt = TransformPoint(cyl.TopPoints);
            // bottom (draw only path)
            Brush brushSolid = new SolidBrush(cyl.ColorTop);

            g.FillPolygon(brushSolid, pt);
            Brush brushPath = new SolidBrush(cyl.ColorPath);
            Pen   penPath   = new Pen(brushPath);

            g.DrawPolygon(penPath, pt);
        }
Esempio n. 57
0
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Graphics g = TrianglePanel.CreateGraphics();
            Brush black = new SolidBrush(Color.Black);
            Pen   bpen  = new Pen(black, 1);

            Point[] point = new Point[3];
            point[0] = triangle.PointOne;
            point[1] = triangle.PointTwo;
            point[2] = triangle.PointThree;
            //point[3] = triangle.PointOne;
            //g.DrawLines(bpen, point);
            g.DrawPolygon(bpen, point);
            //base.OnPaint(e);
        }
Esempio n. 58
0
        //2.2.Visualizar el sector en el espacio aéreo.
        private void Panel1_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i < mySectorList.Number; i++)
            {
                //Xo,Yo (Left top corner)
                Point x0y0 = new Point(Convert.ToInt32(mySectorList.Sector[i].PositionX), Convert.ToInt32(mySectorList.Sector[i].PositionY));
                //Xo,Yf (Left bottom corner)
                Point x0yF = new Point(Convert.ToInt32(mySectorList.Sector[i].PositionX), Convert.ToInt32(mySectorList.Sector[i].PositionY + mySectorList.Sector[i].Height));
                //Xf,Yf (Right bottom corner)
                Point xFyF = new Point(Convert.ToInt32(mySectorList.Sector[i].PositionX + mySectorList.Sector[i].Width), Convert.ToInt32(mySectorList.Sector[i].PositionY + mySectorList.Sector[i].Height));
                //Xo,Yo (Right top corner)
                Point xFy0 = new Point(Convert.ToInt32(mySectorList.Sector[i].PositionX + mySectorList.Sector[i].Width), Convert.ToInt32(mySectorList.Sector[i].PositionY));

                System.Drawing.Graphics graphics = e.Graphics;
                // Points that define the rectangle
                Point[] polygonPoints = new Point[4];
                polygonPoints[0] = x0y0;
                polygonPoints[1] = x0yF;
                polygonPoints[2] = xFyF;
                polygonPoints[3] = xFy0;

                int ocupacion = mySectorList.Sector[i].GetTraffic(myFlightsList);
                if (mySectorList.Sector[i].Capacity <= ocupacion)
                {
                    //Call to 0.3.Helper
                    graphics.DrawPolygon(Painting("Red"), polygonPoints);
                    Painting("Red").Dispose();
                }
                else
                {
                    //Call to 0.3.Helper
                    graphics.DrawPolygon(Painting("Green"), polygonPoints);
                    Painting("Green").Dispose();
                }
            }
        }
Esempio n. 59
0
        public override void Draw(Graphics2D graphics)
        {
            System.Drawing.Graphics g = graphics.Graphics;
            Pen penPath = new Pen(new SolidBrush(TopFace.ColorPath));

            // get points
            Point[] pt = graphics.TransformPoint(TopFace.Points);

            // draw solid face
            Brush brushSolid = new SolidBrush(TopFace.ColorFill);

            g.FillPolygon(brushSolid, pt);
            g.DrawPolygon(penPath, pt);
            // draw box tape
            if (TapeWidth.Activated)
            {
                // instantiate brush
                Brush brushTape = new SolidBrush(TapeColor);
                // fill polygon
                Point[] pts = graphics.TransformPoint(TapePoints);
                g.FillPolygon(brushTape, pts);
                g.DrawPolygon(penPath, pts);
            }
        }
Esempio n. 60
-1
 public static void RepertoryImage(Graphics drawDestination)
 {
     StringFormat itemStringFormat = new StringFormat();
     RectangleF itemBox = new RectangleF(10, 30, 60, 20);
     itemStringFormat.Alignment = StringAlignment.Center;
     itemStringFormat.LineAlignment = StringAlignment.Center;
     drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
     if (mMscStyle==MscStyle.SDL){
         drawDestination.DrawLine(Pens.Black,10,20,65,20);
         drawDestination.DrawLine(Pens.Black,10,60,65,60);
         PointF[] capPolygon = new PointF[3];
         capPolygon[0] = new PointF(65, 20);
         capPolygon[1] = new PointF(70, 15);
         capPolygon[2] = new PointF(60, 15);
         drawDestination.DrawPolygon(Pens.Black,capPolygon);
         capPolygon[0] = new PointF(65, 20);
         capPolygon[1] = new PointF(70, 25);
         capPolygon[2] = new PointF(60, 25);
         drawDestination.DrawPolygon(Pens.Black,capPolygon);
         drawDestination.DrawLine(Pens.Black,65,25,65,60);
         drawDestination.DrawLine(Pens.Black,62,57,68,63);
         drawDestination.DrawLine(Pens.Black,62,63,68,57);
     }
     else if(mMscStyle==MscStyle.UML2){
         drawDestination.DrawLine(Pens.Black,10,20,25,20);
         drawDestination.DrawLine(Pens.Black,10,60,25,60);
         drawDestination.DrawLine(Pens.Black,20,20,20,60);
         drawDestination.DrawLine(Pens.Black,20,21,23,27);
         drawDestination.DrawLine(Pens.Black,20,21,17,27);
         drawDestination.DrawLine(Pens.Black,17,57,23,63);
         drawDestination.DrawLine(Pens.Black,17,63,23,57);
     }
     drawDestination.DrawString("Timer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
     itemStringFormat.Dispose();
 }