DrawArc() public method

public DrawArc ( Pen pen, Rectangle rect, float startAngle, float sweepAngle ) : void
pen Pen
rect Rectangle
startAngle float
sweepAngle float
return void
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Rectangle _rect = new Rectangle();
            _rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            int x = _rect.X;
            int y = _rect.Y;
            int w = _rect.Width;
            int h = _rect.Height;
            int hElipse = (w/5);
            int hArco = hElipse / 2;
            int hReta = h - hArco;

            // g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
            g.DrawArc(pen, x, y, w, hElipse, 0, 360);
            g.DrawArc(pen, x, y + hReta - hArco , w, hElipse, 360, 180);

            Point SE = new Point(x, y + hArco);             //SuperiorEsquerdo
            Point IE = new Point(x, y + hReta);     //InferioriEsquerdo

            Point SD = new Point(x + w, y + hArco);         //SuperiorDireito
            Point ID = new Point(x + w, y + hReta); //InferiorDireito

            g.DrawLine(pen, SE, IE);
            g.DrawLine(pen, SD, ID);

            //g.DrawRectangle(pen, x, y, w, h);

            pen.Dispose();
        }
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Rectangle _rect = new Rectangle();
            _rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            int x = _rect.X;
            int y = _rect.Y;
            int w = _rect.Width;
            int h = _rect.Height;
            int wArc = (w/6);
            int wArc2 = wArc * 2;
            int wReta = w - wArc;

            // g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
            g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
            g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);

            Point SE = new Point(x, y);          //SuperiorEsquerdo
            Point SD = new Point(x + wReta, y);             //SuperiorDireito

            Point IE = new Point(x, y + h);      //InferioriEsquerdo
            Point ID = new Point(x + wReta, y + h);         //InferiorDireito

            g.DrawLine(pen, SE, SD);
            g.DrawLine(pen, IE, ID);

            //g.DrawRectangle(pen, x, y, w, h);

            pen.Dispose();
        }
Example #3
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();
 }
Example #4
0
        public static void RenderClock(RectangleF area, Graphics graphics, bool isPreview)
        {
            int tempBrushWeight = isPreview ? 2 : brushWeight;
            int tempSpacing = isPreview ? 4 : spacing;

            Pen penSecond = new Pen(new SolidBrush(Color.FromArgb(alpha, secondColor)), tempBrushWeight);
            Pen penMinute = new Pen(new SolidBrush(Color.FromArgb(alpha, minuteColor)), tempBrushWeight);
            Pen penHour = new Pen(new SolidBrush(Color.FromArgb(alpha, hourColor)), tempBrushWeight);

            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            // Formula
            // 1. Subdivide the circle by the total count of each sec, min or hours
            // 2. Multiply the value from 1. by the current sec, min or hour
            // 3.  ==> For ex, for sec (360/60)*current second

            DateTime now = DateTime.Now;

            // Draw second arc
            // For smooth animation consider the current seconds in terms of floating point number like below instead of this --> graphics.DrawArc(penSecond, area, -90f, 6*now.Second);
            graphics.DrawArc(penSecond, area, -90f, 6F * ((now.Second + now.Millisecond / 1000F)));

            // Draw minute arc
            graphics.DrawArc(penMinute, new RectangleF(area.X + tempSpacing * 2, area.Y + tempSpacing * 2, area.Width - tempSpacing * 4, area.Height - tempSpacing * 4), -90f, 6F * (now.Minute + now.Second / 60F));

            int hour = enable24HourFormat ? int.Parse(now.ToString("HH")) : int.Parse(now.ToString("%h"));
            float hourMultiplier = enable24HourFormat ? 360 / 24f : 360 / 12f;

            // Draw hour arc
            graphics.DrawArc(penHour, new RectangleF(area.X + tempSpacing * 4, area.Y + tempSpacing * 4, area.Width - tempSpacing * 8, area.Height - tempSpacing * 8), -90f, hourMultiplier * (hour + now.Minute / 60F));

            graphics.Flush();
        }
 public static void DrawInsetCircle(ref Graphics g, Rectangle r, Pen p)
 {
     Pen p1 = new Pen(getDarkColor(p.Color, 50));
     Pen p2 = new Pen(getLightColor(p.Color, 50));
     for (int i = 0; i < p.Width; i++) {
         Rectangle r1 = new Rectangle(r.X + i, r.Y + i, r.Width - i * 2, r.Height - i * 2);
         g.DrawArc(p2, r1, -45, 180);
         g.DrawArc(p1, r1, 135, 180);
     }
 }
        public static void RepertoryImage(Graphics drawDestination)
        {
            if (mMscStyle==MscStyle.UML2){
                StringFormat itemStringFormat = new StringFormat();
                RectangleF itemBox = new RectangleF(5, 20, 30, 15);
                itemStringFormat.Alignment = StringAlignment.Near;
                itemStringFormat.LineAlignment = StringAlignment.Near;
                PointF[] statePolygon = new PointF[5];
                statePolygon[0] = new PointF(5,20);
                statePolygon[1] = new PointF(40,20);
                statePolygon[2] = new PointF(40,30);
                statePolygon[3] = new PointF(35,35);
                statePolygon[4] = new PointF(5,35);
                drawDestination.FillRectangle(Brushes.White,5,20,70,40);
                drawDestination.DrawString("ref",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawPolygon(Pens.Black,statePolygon);
                itemBox = new RectangleF(5, 30, 70, 30);
                itemStringFormat.Alignment = StringAlignment.Center;
                itemStringFormat.LineAlignment = StringAlignment.Center;
                drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawRectangle(Pens.Black,5,20,70,40);
                itemStringFormat.Dispose();
            }
            else if (mMscStyle==MscStyle.SDL){
                StringFormat itemStringFormat = new StringFormat();
                RectangleF itemBox = new RectangleF(10, 25, 60, 30);
                itemStringFormat.Alignment = StringAlignment.Center;
                itemStringFormat.LineAlignment = StringAlignment.Center;

                drawDestination.FillPie(Brushes.White,5,20,10,10,180,90);
                drawDestination.FillPie(Brushes.White,5,50,10,10,90,90);
                drawDestination.FillPie(Brushes.White,65,20,10,10,270,90);
                drawDestination.FillPie(Brushes.White,65,50,10,10,0,90);

                drawDestination.FillRectangle(Brushes.White, 5, 25, 5, 30);
                drawDestination.FillRectangle(Brushes.White, 70, 25, 5, 30);
                drawDestination.FillRectangle(Brushes.White, 10, 20, 60, 40);

                drawDestination.DrawLine(Pens.Black,10,20,70,20);
                drawDestination.DrawLine(Pens.Black,5,25,5,55);
                drawDestination.DrawLine(Pens.Black,10,60,70,60);
                drawDestination.DrawLine(Pens.Black,75,25,75,55);

                drawDestination.DrawArc(Pens.Black,5,20,10,10,180,90);
                drawDestination.DrawArc(Pens.Black,5,50,10,10,90,90);
                drawDestination.DrawArc(Pens.Black,65,20,10,10,270,90);
                drawDestination.DrawArc(Pens.Black,65,50,10,10,0,90);

                drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
            }
        }
Example #7
0
        public static void DrawInsetCircle(ref Graphics g, Rectangle r, Pen p)
        {
            Pen p1 = new Pen(getDarkColor(p.Color, 50));
            Pen p2 = new Pen(getLightColor(p.Color, 50));
            for (int i = 0; i < p.Width; i++)
            {
                Rectangle r1 = new Rectangle(r.X + i, r.Y + i, r.Width - i * 2, r.Height - i * 2);
                g.DrawArc(p2, r1, -45, 180);
                g.DrawArc(p1, r1, 135, 180);

                SolidBrush pointer = new SolidBrush(Color.DarkSlateGray);
                g.FillEllipse(pointer, r1);
            }
        }
Example #8
0
        private void DrawGearOutline(Graphics g, PointF center, float scale, float radius, 
            float baseRadius, float addendum, float dedendum, int numTeeth, float toothPhase)
        {
            g.DrawArc(Pens.Yellow,
                new RectangleF(
                    center.X - baseRadius * scale,
                    center.Y - baseRadius * scale,
                    baseRadius * 2 * scale,
                    baseRadius * 2 * scale),
                0, 360);
            g.DrawArc(Pens.Black,
                new RectangleF(
                    center.X - radius * scale,
                    center.Y - radius * scale,
                    radius * 2 * scale,
                    radius * 2 * scale),
                0, 360);
            g.DrawArc(Pens.LightGray,
                new RectangleF(
                    center.X - (radius - dedendum) * scale,
                    center.Y - (radius - dedendum) * scale,
                    (radius * 2 - dedendum * 2) * scale,
                    (radius * 2 - dedendum * 2) * scale),
                0, 360);
            g.DrawArc(Pens.LightGray,
                new RectangleF(
                    center.X - (radius + addendum) * scale,
                    center.Y - (radius + addendum) * scale,
                    (radius * 2 + addendum * 2) * scale,
                    (radius * 2 + addendum * 2) * scale),
                0, 360);
            g.DrawLine(Pens.Magenta, new PointF(center.X - 3, center.Y - 3), new PointF(center.X + 3, center.Y + 3));
            g.DrawLine(Pens.Magenta, new PointF(center.X - 3, center.Y + 3), new PointF(center.X + 3, center.Y - 3));
            for (int i = 0; i < numTeeth; ++i)
            {
                double dx = Math.Sin((i + toothPhase) * Math.PI * 2 / numTeeth);
                double dy = -Math.Cos((i + toothPhase) * Math.PI * 2 / numTeeth);
                g.DrawLine(
                    Pens.LightGray, 
                    new PointF(
                        (float)(center.X + dx * (radius - dedendum) * scale),
                        (float)(center.Y + dy * (radius - dedendum) * scale)),
                    new PointF(
                        (float)(center.X + dx * (radius + addendum) * scale),
                        (float)(center.Y + dy * (radius + addendum) * scale)));

            }
        }
            public override void OnRender(Graphics g)
            {
                base.OnRender(g);

                if (wprad == 0 || Overlay.Control == null)
                    return;

                // if we have drawn it, then keep that color
                if (!initcolor.HasValue)
                    Color = Color.White;

                //wprad = 300;

                // undo autochange in mouse over
                //if (Pen.Color == Color.Blue)
                //  Pen.Color = Color.White;

                double width = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Width, 0)) * 1000.0);
                double height = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Height, 0)) * 1000.0);
                double m2pixelwidth = Overlay.Control.Width / width;
                double m2pixelheight = Overlay.Control.Height / height;

                GPoint loc = new GPoint((int)(LocalPosition.X - (m2pixelwidth * wprad * 2)), LocalPosition.Y);// MainMap.FromLatLngToLocal(wpradposition);

                //if (m2pixelheight > 0.5)
                    g.DrawArc(Pen, new System.Drawing.Rectangle(LocalPosition.X - Offset.X - (int)(Math.Abs(loc.X - LocalPosition.X) / 2), LocalPosition.Y - Offset.Y - (int)Math.Abs(loc.X - LocalPosition.X) / 2, (int)Math.Abs(loc.X - LocalPosition.X), (int)Math.Abs(loc.X - LocalPosition.X)), 0, 360);

                    g.FillPie(new SolidBrush(Color.FromArgb(25,Color.Red)), LocalPosition.X - Offset.X - (int)(Math.Abs(loc.X - LocalPosition.X) / 2), LocalPosition.Y - Offset.Y - (int)Math.Abs(loc.X - LocalPosition.X) / 2,  Math.Abs(loc.X - LocalPosition.X), Math.Abs(loc.X - LocalPosition.X), 0, 360);

            }
Example #10
0
 public override void DrawOn(Graphics graphics)
 {
     // WARNING!  If you end up using graphics.DrawArc() to draw your ovals,
     // be careful that you don't give it a zero width and height.  If you do,
     // you'll see an ugly red "X" instead of your pretty drawing canvas.
     graphics.DrawArc(_pen, _center.X - _radius, _center.Y - _radius, _diameter, _diameter, 0, 360);
 }
 public override void Draw(Graphics g)
 {
     using(Pen p = new Pen(penColor,penWidth))
     {
         g.DrawArc(p, bounding, angle1, angle2);
     }
 }
Example #12
0
 public static void DrawArc(Graphics G, Pen P, double X, double Y, double R, double beta0, double alpha)
 {
     RectangleF Rect = new RectangleF(
         (float)(X - Math.Abs(R)), (float)(Y - Math.Abs(R)),
         (float)(2 * Math.Abs(R)), (float)(2 * Math.Abs(R)));
     G.DrawArc(P, Rect, (float)(beta0 * 180 / Math.PI), (float)(alpha * 180 / Math.PI));
 }
Example #13
0
        public override void Draw(Graphics g)
        {
            RectangleF rect = rectComponent.TopLeftCorner.CloneAndAdd(0, offSet).MakeRectangleFTill(rectComponent.BottomRightCorner.CloneAndAdd(0, -offSet));
            RectangleF upperRect = rectComponent.TopLeftCorner.MakeRectangleFTill(rectComponent.TopLeftCorner.CloneAndAdd(rectComponent.Width, 2 * offSet));
            RectangleF lowerRect = rectComponent.BottomRightCorner.CloneAndAdd(-rectComponent.Width, -2 * offSet).MakeRectangleFTill(rectComponent.BottomRightCorner);

            using (LinearGradientBrush brush =
                new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillRectangle(brush, rect);
                g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
            }


            using (LinearGradientBrush brush =
                new LinearGradientBrush(upperRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillEllipse(brush, upperRect);
                g.DrawEllipse(ViewFactory.BorderPen, upperRect.X, upperRect.Y, upperRect.Width, upperRect.Height);
            }

            using (LinearGradientBrush brush =
                new LinearGradientBrush(lowerRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
            {
                g.FillEllipse(brush, lowerRect);
                g.DrawArc(ViewFactory.BorderPen, lowerRect, 0, 180);
            }
            base.Draw(g);
        }
        public override void Draw(RectangleF rect)
        {
            Graphics g = new Graphics();

            //g.Clear(Color.White);

            // Create a pen object:
            Pen aPen = new Pen(Color.Blue, 1 / g.DpiX);
            // Create a brush object with a transparent red color:
            SolidBrush aBrush = new SolidBrush(Color.Red);

            g.PageUnit = GraphicsUnit.Inch;
            g.PageScale = 2;
            g.RenderingOrigin = new PointF(0.5f,0.0f);

            // Draw a rectangle:
            g.DrawRectangle(aPen, .20f, .20f, 1.00f, .50f);
            // Draw a filled rectangle:
            g.FillRectangle(aBrush, .20f, .90f, 1.00f, .50f);
            // Draw ellipse:
            g.DrawEllipse(aPen, new RectangleF(.20f, 1.60f, 1.00f, .50f));
            // Draw filled ellipse:
            g.FillEllipse(aBrush, new RectangleF(1.70f, .20f, 1.00f, .50f));
            // Draw arc:
            g.DrawArc(aPen, new RectangleF(1.70f, .90f, 1.00f, .50f), -90, 180);

            // Draw filled pie pieces
            g.FillPie(aBrush, 1.70f, 1.60f, 1.00f, 1.00f, -90, 90);
            g.FillPie(Brushes.Green, 1.70f, 1.60f, 1.00f, 1.00f, -90, -90);

            g.Dispose();
        }
Example #15
0
 public override void Draw(Graphics G)
 {
     SFPoint P1;
     float rd1, rd2;
     if (radPt.X == 0)
     {
         rd1 = Math.Abs(radius * ratio);
         rd2 = radius;
     }
     else
     {
         rd1 = radius;
         rd2 = Math.Abs(radius * ratio);
     }
     P1 = Converter.GetPoint(Point1);
     rd1 = rd1 * Converter.FScale;
     rd2 = rd2 * Converter.FScale;
     P1.X = P1.X - rd1;
     P1.Y = P1.Y - rd2;
     Color RealColor = DXFConst.EntColor(this, Converter.FParams.Insert);
     if (RealColor == DXFConst.clNone) RealColor = Color.Black;
     float sA = startAngle, eA = endAngle;
     //if(endAngle < startAngle) sA = Conversion_Angle(sA);
     eA -= sA;
     if (FVisible)
     {
         if (eA == 0) G.DrawEllipse(new Pen(RealColor, 1), P1.X, P1.Y, rd1 * 2, rd2 * 2);
         else G.DrawArc(new Pen(RealColor, 1), P1.X, P1.Y, rd1 * 2, rd2 * 2, 0, 360);//sA, eA);
     }
 }
 public void DrawPlatform(Graphics g, float newAngleLocation)
 {
     startAngle = MainWindow.AngleTo360DegreeSystem(newAngleLocation - sweepAngle / 2);
     endAngle = MainWindow.AngleTo360DegreeSystem(startAngle + sweepAngle);
     centerAngle = newAngleLocation;
     
     g.DrawArc(penPlatform, new RectangleF(center.X - radius, center.Y - radius, radius * 2, radius * 2), startAngle, sweepAngle);
 }
 /// <summary>
 /// 
 /// </summary>
 public static void DrawRoundedRectangle(Graphics graphics, int xAxis, int yAxis, int width, int height, int diameter, Color color)
 {
     Pen pen = new Pen(color);
     var BaseRect = new RectangleF(xAxis, yAxis, width, height);
     var ArcRect = new RectangleF(BaseRect.Location, new SizeF(diameter, diameter));
     graphics.DrawArc(pen, ArcRect, 180, 90);
     graphics.DrawLine(pen, xAxis + (int)(diameter / 2), yAxis, xAxis + width - (int)(diameter / 2), yAxis);
     ArcRect.X = BaseRect.Right - diameter;
     graphics.DrawArc(pen, ArcRect, 270, 90);
     graphics.DrawLine(pen, xAxis + width, yAxis + (int)(diameter / 2), xAxis + width, yAxis + height - (int)(diameter / 2));
     ArcRect.Y = BaseRect.Bottom - diameter;
     graphics.DrawArc(pen, ArcRect, 0, 90);
     graphics.DrawLine(pen, xAxis + (int)(diameter / 2), yAxis + height, xAxis + width - (int)(diameter / 2), yAxis + height);
     ArcRect.X = BaseRect.Left;
     graphics.DrawArc(pen, ArcRect, 90, 90);
     graphics.DrawLine(pen, xAxis, yAxis + (int)(diameter / 2), xAxis, yAxis + height - (int)(diameter / 2));
 }
 public override void Draw(Graphics g)
 {
     if (this.Pen != null)
         g.DrawArc(
             this.Pen,
             CalcDrawingRect(),
             (float)(_arc.Angle2X.Degrees - 90),
             (float)_arc.Angle.Degrees);
 }
Example #19
0
        public override void Draw(Graphics Graphics, Pen Pen, CanvasView View)
        {
            float R = (float)(Radius * View.Zoom);
            PointF C = View.TranslateF(Center);
            RectangleF RectangleF = new RectangleF(C.X - R, C.Y - R, 2 * R, 2 * R);

            Graphics.DrawArc(Pen, RectangleF,
                (float)(View.Translate(Center).Phi * 180 / Math.PI),
                -(View.Mirrow ? -1 : 1) * (float)(Alpha * 180 / Math.PI));
        }
        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            Graphics g = new Graphics();

            g.Clear(Color.White);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            // Create a pen object:
            Pen aPen = new Pen(Color.Blue, 2);
            // Create a brush object with a transparent red color:
            SolidBrush aBrush = new SolidBrush(Color.Red);
            HatchBrush hBrush = new HatchBrush(HatchStyle.Shingle, Color.Blue, Color.LightCoral);
            HatchBrush hBrush2 = new HatchBrush(HatchStyle.Cross, Color.Blue, Color.LightCoral);
            HatchBrush hBrush3 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Blue, Color.LightCoral);
            HatchBrush hBrush4 = new HatchBrush(HatchStyle.Sphere, Color.Blue, Color.LightCoral);

            // Draw a rectangle:
            g.DrawRectangle(aPen, 20, 20, 100, 50);
            // Draw a filled rectangle:
            g.FillRectangle(hBrush, 20, 90, 100, 50);
            // Draw ellipse:
            g.DrawEllipse(aPen, new Rectangle(20, 160, 100, 50));
            // Draw filled ellipse:
            g.FillEllipse(hBrush2, new Rectangle(170, 20, 100, 50));
            // Draw arc:
            g.DrawArc(aPen, new Rectangle(170, 90, 100, 50), -90, 180);

            // Draw filled pie pieces
            g.FillPie(aBrush, new Rectangle(170, 160, 100, 100), -90, 90);
            g.FillPie(hBrush4, new Rectangle(170, 160, 100, 100), -90, -90);

            // Create pens.
            Pen redPen   = new Pen(Color.Red, 3);
            Pen greenPen = new Pen(Color.Green, 3);
            greenPen.DashStyle = DashStyle.DashDotDot;
            SolidBrush transparentBrush = new SolidBrush(Color.FromArgb(150, Color.Wheat));

            // define point array to draw a curve:
            Point point1 = new Point(300, 250);
            Point point2 = new Point(350, 125);
            Point point3 = new Point(400, 110);
            Point point4 = new Point(450, 210);
            Point point5 = new Point(500, 300);
            Point[] curvePoints ={ point1, point2, point3, point4, point5};

            // Draw lines between original points to screen.
            g.DrawLines(redPen, curvePoints);

            // Fill Curve
            g.FillClosedCurve(transparentBrush, curvePoints);

            // Draw closed curve to screen.
            g.DrawClosedCurve(greenPen, curvePoints);

            g.Dispose();
        }
 private void DrawLowerRollRing(Graphics myGraphics, Pen myPen)
 {
     myPen.Color = GroundColor;
     myPen.Width = ScaledRingWidth;
     myGraphics.DrawArc(myPen, UpperLeftCornerX + ScaledRingWidth / 2,
         UpperLeftCornerY + ScaledRingWidth / 2,
         GaugeWidth - ScaledRingWidth,
         GaugeWidth - ScaledRingWidth,
         roll,
         180f);
 }
Example #22
0
        private void DrawSphericalCap(Graphics g, SphericLens.SphericalCap cap)
        {
            float angle = (float)(cap.Angle * 180.0 / Math.PI);
            float startAngle = (cap.Convex ? 360.0f : 180.0f) - angle;
            float sweepAngle = 2.0f * angle;
            g.DrawArc(Pens.Red, (float)-cap.Radius, (float)-cap.Radius, (float)(2 * cap.Radius), (float)(2 * cap.Radius), startAngle, sweepAngle);

            //float x = (float)((cap.Convex ? cap.Radius : -cap.Radius) - (cap.Convex ? cap.Thickness : -cap.Thickness));
            //float y = (float)cap.Aperture;
            //g.DrawLine(Pens.Black, x, -y, x, y);
        }
 public void DrawOn(Graphics graphics)
 {
     if (_flag == true)
     {
         graphics.FillPie(_brush, _center.X - _radius, _center.Y - _radius, _diameter, _diameter, _floatStartAngle,
                         _floatArcAngle);
     }
     else
     {
         graphics.DrawArc(_pen, _center.X - _radius, _center.Y - _radius, _diameter, _diameter, 0, 360);
     }
 }
Example #24
0
        public override void Draw(Graphics g)
        {
            const int paddingTop = 5;
            const int paddingSide = 5;
            Size rect;
            while ((rect = Size.Round(g.MeasureString(Text, Font))).Width > PlayArea.DEFAULTSIZE.Width)
                CutupString(g);
            //draw top, bottom and middle in 1 rectangle
            g.FillRectangle(BalloonBrush, Location.X, Location.Y - paddingTop, rect.Width, rect.Height + paddingTop * 2);
            g.DrawLine(BalloonBorderPen, Location.X, Location.Y - paddingTop, Location.X + rect.Width, Location.Y - paddingTop);
            g.DrawLine(BalloonBorderPen, Location.X, Location.Y + rect.Height + paddingTop, Location.X + rect.Width, Location.Y + rect.Height + paddingTop);

            //draw left
            g.FillRectangle(BalloonBrush, Location.X - paddingSide, Location.Y, paddingSide, rect.Height);
            g.DrawLine(BalloonBorderPen, Location.X - paddingSide, Location.Y, Location.X - paddingSide, Location.Y + rect.Height);
            //draw right
            g.FillRectangle(BalloonBrush, Location.X + rect.Width, Location.Y, paddingSide, rect.Height);
            g.DrawLine(BalloonBorderPen, Location.X + rect.Width + paddingSide, Location.Y, Location.X + rect.Width + paddingSide, Location.Y + rect.Height);
            //draw rounded TopLeft corner
            var topLeft = new Rectangle(Location.X - paddingSide, Location.Y - paddingTop, paddingSide * 2, paddingTop * 2);
            g.FillPie(BalloonBrush, topLeft, 180, 90);
            g.DrawArc(BalloonBorderPen, topLeft, 180, 90);
            //draw rounded BottomLeft corner
            var bottomLeft = new Rectangle(Location.X - paddingSide, Location.Y + rect.Height - paddingTop, topLeft.Width, topLeft.Height);
            g.FillPie(BalloonBrush, bottomLeft, 90, 90);
            g.DrawArc(BalloonBorderPen, bottomLeft, 90, 90);
            //draw rounded TopRight corner
            var topRight = new Rectangle(Location.X + rect.Width - paddingSide, Location.Y - paddingTop, paddingSide * 2, paddingTop * 2);
            g.FillPie(BalloonBrush, topRight, 270, 90);
            g.DrawArc(BalloonBorderPen, topRight, 270, 90);
            //draw rounded BottomRight corner
            var bottomRight = new Rectangle(Location.X + rect.Width - paddingSide, Location.Y + rect.Height - paddingTop, paddingSide * 2, paddingTop * 2);
            g.FillPie(BalloonBrush, bottomRight, 0, 90);
            g.DrawArc(BalloonBorderPen, bottomRight, 0, 90);
            //draw string in balloon
            g.DrawString(Text, Font, Brush, Location);
        }
Example #25
0
 public override void Draw(Graphics G)
 {
     SFPoint P1;
     float rd1 = radius;
     P1 = Converter.GetPoint(Point1);
     rd1 = rd1 * Converter.FScale;
     P1.X = P1.X - rd1;
     P1.Y = P1.Y - rd1;
     Color RealColor = DXFConst.EntColor(this, Converter.FParams.Insert);
     float sA = -startAngle, eA = -endAngle;
     if (endAngle < startAngle) sA = Conversion_Angle(sA);
     eA -= sA;
     if (FVisible)
         G.DrawArc(new Pen(RealColor, 1), P1.X, P1.Y, rd1 * 2, rd1 * 2, sA, eA);
 }
        public override void Draw(Graphics g)
        {
            try
            {
                var bounds = RectangleFUtil.ToRectangleF(_circle.BoundingBox);

                if (this.FillBrush != null)
                    g.FillEllipse(this.FillBrush, bounds);
                if (this.Pen != null)
                    g.DrawArc(this.Pen, bounds, 0, 360);
            }
            catch (Exception)
            {
                //ignore
            }
        }
        /// <summary>
        /// Draws an arc.
        /// </summary>
        public void Draw(C2DArc Arc, Graphics graphics, Pen pen)
        {
            C2DRect Rect = new C2DRect();
            int nStartAngle = 0;
            int nSweepAngle = 0;

            GetArcParameters(Arc, Rect, ref nStartAngle, ref nSweepAngle);

            if (nSweepAngle == 0)
                nSweepAngle = 1;

            int Width = (int)Rect.Width();
            if (Width == 0)
                Width = 1;
            int Height = (int)Rect.Height();
            if (Height == 0)
                Height = 1;

            graphics.DrawArc(pen, (int)Rect.TopLeft.x, (int)Rect.BottomRight.y,
                Width, Height, nStartAngle, nSweepAngle);
        }
Example #28
0
        public override void OnRender(Graphics g)
        {
            base.OnRender(g);

            if (wprad == 0 || MainMap == null)
                return;

            // undo autochange in mouse over
            if (Pen.Color == Color.Blue)
                Pen.Color = Color.White;

            double width = (MainMap.MapProvider.Projection.GetDistance(MainMap.FromLocalToLatLng(0, 0), MainMap.FromLocalToLatLng(MainMap.Width, 0)) * 1000.0);
            double height = (MainMap.MapProvider.Projection.GetDistance(MainMap.FromLocalToLatLng(0, 0), MainMap.FromLocalToLatLng(MainMap.Height, 0)) * 1000.0);
            double m2pixelwidth = MainMap.Width / width;
            double m2pixelheight = MainMap.Height / height;

            GPoint loc = new GPoint((int)(LocalPosition.X - (m2pixelwidth * wprad * 2)), LocalPosition.Y);// MainMap.FromLatLngToLocal(wpradposition);
            try
            {
                g.DrawArc(Pen, new System.Drawing.Rectangle((int)(LocalPosition.X - Offset.X - (Math.Abs(loc.X - LocalPosition.X) / 2)), (int)(LocalPosition.Y - Offset.Y - Math.Abs(loc.X - LocalPosition.X) / 2), (int)(Math.Abs(loc.X - LocalPosition.X)), (int)(Math.Abs(loc.X - LocalPosition.X))), 0, 360);
            }
            catch { }

        }
Example #29
0
        public override void OnRender(Graphics g)
        {
            Matrix temp = g.Transform;
            g.TranslateTransform(LocalPosition.X, LocalPosition.Y);

            g.RotateTransform(-Overlay.Control.Bearing);

            int length = 500;
            // anti NaN
            try
            {
                //g.DrawLine(new Pen(Color.Red, 2), 0.0f, 0.0f, (float)Math.Cos((heading - 90) * deg2rad) * length, (float)Math.Sin((heading - 90) * deg2rad) * length);
            }
            catch { }
            //g.DrawLine(new Pen(Color.Green, 2), 0.0f, 0.0f, (float)Math.Cos((nav_bearing - 90) * deg2rad) * length, (float)Math.Sin((nav_bearing - 90) * deg2rad) * length);
               // g.DrawLine(new Pen(Color.Black, 2), 0.0f, 0.0f, (float)Math.Cos((cog - 90) * deg2rad) * length, (float)Math.Sin((cog - 90) * deg2rad) * length);
            g.DrawLine(new Pen(Color.White, 2), 0.0f, 0.0f, (float)Math.Cos((target - 90) * deg2rad) * length, (float)Math.Sin((target - 90) * deg2rad) * length);
            // anti NaN
            try
            {

                float desired_lead_dist = 100;

                double width = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Width, 0)) * 1000.0);
                double m2pixelwidth = Overlay.Control.Width / width;

                float alpha = ((desired_lead_dist * (float)m2pixelwidth) / MainV2.comPort.MAV.cs.radius) * rad2deg;

                if (MainV2.comPort.MAV.cs.radius < -1)
                {
                    // fixme

                    float p1 = (float)Math.Cos((cog) * deg2rad) * MainV2.comPort.MAV.cs.radius + MainV2.comPort.MAV.cs.radius;

                    float p2 = (float)Math.Sin((cog) * deg2rad) * MainV2.comPort.MAV.cs.radius + MainV2.comPort.MAV.cs.radius;

                    g.DrawArc(new Pen(Color.HotPink, 2), p1, p2, Math.Abs(MainV2.comPort.MAV.cs.radius) * 2, Math.Abs(MainV2.comPort.MAV.cs.radius) * 2, cog, alpha);

                }

                else if (MainV2.comPort.MAV.cs.radius > 1)
                {
                    // correct

                    float p1 = (float)Math.Cos((cog - 180) * deg2rad) * MainV2.comPort.MAV.cs.radius + MainV2.comPort.MAV.cs.radius;

                    float p2 = (float)Math.Sin((cog - 180) * deg2rad) * MainV2.comPort.MAV.cs.radius + MainV2.comPort.MAV.cs.radius;

                    g.DrawArc(new Pen(Color.HotPink, 2), -p1, -p2, MainV2.comPort.MAV.cs.radius * 2, MainV2.comPort.MAV.cs.radius * 2, cog - 180, alpha);
                }

            }

            catch { }

            try
            {
                g.RotateTransform(heading);
            }
            catch { }
            g.DrawImageUnscaled(icon, icon.Width / -2, icon.Height / -2);

            g.Transform = temp;
        }
Example #30
0
 static void RenderConnector(Graphics graphics, RectangleF bounds, RenderState state)
 {
     using (var brush = new SolidBrush(GetArrowLineColor(state)))
     {
         graphics.FillEllipse(brush, bounds);
     }
     if (state == RenderState.None)
     {
         graphics.DrawEllipse(Pens.Black, bounds);
     } else
     {
         graphics.DrawArc(Pens.Black, bounds, 90, 180);
         using (var pen = new Pen(GetArrowLineColor(state)))
         {
             graphics.DrawArc(pen, bounds, 270, 180);
         }
     }
 }