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();
        }
Example #2
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();
        }
Example #3
0
        /// <summary>
        /// Methods the 0.
        /// </summary>
        /// <param name="int_2">The int 2.</param>
        private void method_0(int int_2)
        {
            int width = base.Size.Width;

            System.Drawing.Size size = base.Size;
            Bitmap bitmap            = new Bitmap(width, size.Height);

            System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap);
            graphic.SmoothingMode = SmoothingMode.HighQuality;
            graphic.Clear(Color.Transparent);
            Pen pen = new Pen(this.color_0, (float)this.int_1);

            size = base.Size;
            int num  = size.Width - this.int_1 * 2;
            int int1 = this.int_1;

            size = base.Size;
            Rectangle rectangle = new Rectangle(int1, size.Height / 4, num, num);
            Pen       pen1      = new Pen(this.color_1, (float)this.int_1);

            System.Drawing.Graphics graphic1 = System.Drawing.Graphics.FromImage(bitmap);
            graphic1.SmoothingMode = SmoothingMode.HighQuality;
            graphic1.DrawArc(pen, rectangle, 180f, 180f);
            this.lblpass.Text = string.Concat(int_2, this.Suffix);
            graphic1.DrawArc(pen1, rectangle, 180f, (float)this.method_1(int_2));
            this.BackgroundImage = bitmap;
        }
        /// <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 #5
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 #6
0
 public override void Draw(System.Drawing.Graphics g)
 {
     g.DrawArc(pen, Shape_Point.X, Shape_Point.Y, Width / 2, Height / 2, StartAngle, SweepAngle);
     g.DrawArc(pen, (MouseDown_Point.X + MouseUp_Point.X) / 2, Shape_Point.Y, Width / 2, Height / 2, StartAngle, SweepAngle);
     g.DrawBezier(pen, new Point(Shape_Point.X, Shape_Point.Y + Height / 4), new Point(Shape_Point.X + Width / 10, Shape_Point.Y + Height / 4 * 3), new Point(Shape_Point.X + Width / 10 * 4, Shape_Point.Y + Height), new Point(Width / 2 + Shape_Point.X, Shape_Point.Y + Height));
     g.DrawBezier(pen, new Point(Shape_Point.X + Width, Shape_Point.Y + Height / 4), new Point(Shape_Point.X + Width - Width / 10, Shape_Point.Y + Height / 4 * 3), new Point(Shape_Point.X + Width - Width / 10 * 4, Shape_Point.Y + Height), new Point(Width / 2 + Shape_Point.X, Shape_Point.Y + Height));
 }
        private void MakeBackgroundBitmap()
        {
            BackgroundImage = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
            System.Drawing.Graphics TheGraphics = System.Drawing.Graphics.FromImage((Image)BackgroundImage);

            TheGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            //draw gradient
            float RadiusSquared = (float)Math.Pow(Radius - 1, 2);
            float HalfHeight    = (float)(this.Height - 2) / 2.0f;
            float ChordWidth;
            float HeightMiddle = ((float)this.Height / 2.0f) - (Radius);

            for (double i = 0; i < this.Height; i++)
            {
                ChordWidth = (float)Math.Sqrt(RadiusSquared - Math.Pow(HalfHeight - i, 2));

                if ((i >= HeightMiddle) && (i < this.Height - HeightMiddle))
                {
                    GradientPen.Color = GradientColors[(int)i - (int)HeightMiddle];
                    TheGraphics.DrawLine(GradientPen, Radius - ChordWidth, (float)i + 1, this.Width - ((Radius - ChordWidth) + 1), (float)i + 1);
                }
            }

            TheGraphics.DrawArc(BorderPen, 1, HeightMiddle, Diameter, Diameter, -90, -180);
            TheGraphics.DrawArc(BorderPen, this.Width - (Diameter + 2), HeightMiddle, Diameter, Diameter, -90, 180);
            TheGraphics.DrawLine(BorderPen, Radius + 1, HeightMiddle, this.Width - (Radius + 2), HeightMiddle);
            TheGraphics.DrawLine(BorderPen, Radius + 1, HeightMiddle + Diameter, this.Width - (Radius + 2), HeightMiddle + Diameter);
        }
 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);
     }
 }
Example #9
0
        void IView.Draw(System.Drawing.Graphics g)
        {
            Pen          p  = new Pen(color, width);
            GraphicsPath gp = new GraphicsPath();

            gp.AddLines(new Point[] { new Point(-2, -5), new Point(0, 0), new Point(2, -5) });
            CustomLineCap clp = new System.Drawing.Drawing2D.CustomLineCap(null, gp);

            clp.SetStrokeCaps(LineCap.Square, LineCap.Square);
            clp.WidthScale   = 1;
            p.CustomStartCap = clp;


            Point T = new Point(point1.X, point1.Y);

            if (point1 != point2)
            {
                double ab = Math.Sqrt((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y));
                double r  = ab / Math.Sqrt(2);
                double b  = Math.PI / 4 - Math.Atan2(point2.X - Point1.X, point2.Y - Point1.Y);
                Point  O  = new Point((int)(point1.X + r * Math.Cos(b) - r), (int)(point1.Y + r * Math.Sin(b) - r));
                int    sa = (int)(180 + b * 180 / Math.PI);



                int a = 90 - (int)((Math.Acos((2 * r * r - radius * radius) / (2 * r * r)) * 180 / Math.PI) * 1.3);
                if ((int)r * 2 > 0)
                {
                    g.DrawArc(p, O.X, O.Y, (int)r * 2, (int)r * 2, sa - a, a);
                }



                T.X += (int)(r * 0.7 * Math.Cos(b + 70 * Math.PI / 180));
                T.Y += (int)(r * 0.7 * Math.Sin(b + 70 * Math.PI / 180)) - 15;
            }
            else
            {
                g.DrawArc(p, point1.X - 60, point1.Y - 30, 60, 60, 40, 280);
                T.X -= 40;
            }

            SolidBrush Sel = new SolidBrush(Color.Silver);

            if (isOver)
            {
                Sel.Color = Color.DarkTurquoise;
            }

            g.DrawString(Val, new Font("Roboto Condensed", 18, FontStyle.Bold), Sel, T.X, T.Y, VertexView.stringFormat);

            valR.Size     = g.MeasureString(Val, new Font("Roboto Condensed", 18, FontStyle.Bold));
            valR.Location = new Point(T.X - (int)valR.Size.Width / 2, T.Y - (int)valR.Size.Height / 2);
        }
        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 #11
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 #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            var fill   = Enabled ? System.Drawing.Brushes.Black : System.Drawing.Brushes.LightGray;
            var top    = new Pen(Color.FromArgb(167, 166, 170), 4);
            var bottom = new Pen(Color.White, 4);

            var x = Width - 38;

            g.DrawArc(bottom, x, 2, 36, 36, 315, 180);
            g.DrawArc(top, x, 2, 36, 36, 135, 180);
            g.FillEllipse(fill, x, 2, 36, 36);
            UpdateAngle(g);
        }
Example #13
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)));

            }
        }
Example #14
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));
 }
 public override void Draw(Graphics g)
 {
     using(Pen p = new Pen(penColor,penWidth))
     {
         g.DrawArc(p, bounding, angle1, angle2);
     }
 }
Example #16
0
 public override void Draw(System.Drawing.Graphics g)
 {
     if (IsVisible)
     {
         g.DrawArc(new System.Drawing.Pen(new SolidBrush(Color.FromArgb(Convert.ToInt32(255 * Animation), Color.Blue)), 8), new RectangleF(Location, new Size(128, 128)), -90, Animation * 360);
     }
 }
            protected override void Render(GH_Canvas canvas, System.Drawing.Graphics graphics, GH_CanvasChannel channel)
            {
                base.Render(canvas, graphics, channel);

                if (channel == GH_CanvasChannel.Objects)
                {
                    Rectangle rectangle = new Rectangle();
                    int       diameter  = 30;

                    rectangle.Y      = (int)Bounds.Y - 40 - diameter / 2;
                    rectangle.X      = (int)Bounds.X + (int)Bounds.Width / 2 - diameter / 2;
                    rectangle.Width  = diameter;
                    rectangle.Height = diameter;

                    Pen pen = new Pen(Color.Black, 1);
                    pen.DashPattern = new float[] { 1.0f, 3.0f };
                    graphics.DrawArc(pen, rectangle, 0, 360);

                    var          font   = new Font(FontFamily.GenericSansSerif, 4.0f, FontStyle.Regular);
                    StringFormat format = new StringFormat();
                    format.LineAlignment = StringAlignment.Center;
                    format.Alignment     = StringAlignment.Center;
                    graphics.DrawString("place\r\ncomponent\r\nhere", font, Brushes.Black, rectangle, format);
                }
            }
Example #18
0
        /// <summary>
        /// Method used to draw outer arc.
        /// </summary>
        /// <param name="e">Paintevent arguement</param>
        /// <param name="m_GaugeArcStart">Arc start position</param>
        /// <param name="m_GaugeArcEnd">Arc end position</param>
        /// <param name="m_Center">Center point for gauge</param>
        public void DrawOuterArc(System.Drawing.Graphics e, int m_GaugeArcStart, int m_GaugeArcEnd, System.Drawing.Point m_Center, int GaugeRadius)
        {
            e.SmoothingMode   = SmoothingMode.AntiAlias;
            e.PixelOffsetMode = PixelOffsetMode.HighQuality;
            GraphicsPath pth = new GraphicsPath();
            Color        c   = this.RadialGauge.Parent != null ? this.RadialGauge.Parent.BackColor : Color.Empty;
            Rectangle    r   = new Rectangle(0, 0, this.RadialGauge.Width, this.RadialGauge.Height);

            System.Drawing.Drawing2D.GraphicsPath basePath = new System.Drawing.Drawing2D.GraphicsPath();

            int x = this.RadialGauge.Width;
            int y = this.RadialGauge.Height;

            //Define rectangles inside which we will draw circles.

            Rectangle rect      = new Rectangle(0 + 10, 0 + 10, (int)x - 20, (int)y - 20);
            Rectangle rectrim   = new Rectangle(0 + 23, 0 + 23, (int)x - 46, (int)y - 46);
            Rectangle rectinner = new Rectangle(0 + 40, 0 + 40, (int)x - 80, (int)y - 80);

            if (GaugeRadius > 0)
            {
                e.DrawArc(new Pen(this.RadialGauge.GaugeArcColor, 7), new Rectangle(m_Center.X - GaugeRadius, m_Center.Y - GaugeRadius,
                                                                                    2 * GaugeRadius, 2 * GaugeRadius), m_GaugeArcStart, m_GaugeArcEnd);
            }
        }
Example #19
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);
 }
        /// <summary>
        /// Methods the 2.
        /// </summary>
        /// <param name="int_7">The int 7.</param>
        private void method_2(int int_7)
        {
            Bitmap bitmap = new Bitmap(base.Size.Width, base.Size.Height);

            System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap);
            graphic.SmoothingMode = SmoothingMode.HighQuality;
            graphic.Clear(Color.Transparent);
            Rectangle rectangle = new Rectangle(rectangleParameters.HorizontalShift, rectangleParameters.VerticalShift, base.Width - rectangleParameters.WidthShift, base.Width - rectangleParameters.HeightShift);
            Pen       pen       = new Pen(this.color_1)
            {
                Width = (float)this.int_0
            };

            graphic.DrawArc(pen, rectangle, 0f, 360f);
            System.Drawing.Graphics smoothingMode = System.Drawing.Graphics.FromImage(bitmap);
            smoothingMode.SmoothingMode = graphic.SmoothingMode;
            Rectangle rectangle1 = new Rectangle(rectangleParameters.HorizontalShift, rectangleParameters.VerticalShift, base.Width - rectangleParameters.WidthShift, base.Width - rectangleParameters.HeightShift);
            Pen       pen1       = new Pen(this.color_0)
            {
                Width = (float)this.int_1
            };

            smoothingMode.DrawArc(pen1, rectangle1, (float)this.int_5, (float)this.method_0(int_7));
            this.BackgroundImage = bitmap;
            this.method_1();
        }
Example #21
0
            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 #22
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);
     }
 }
Example #23
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);
        }
Example #24
0
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            PointF p1 = ToPointF(ControlPoints[0]);
            PointF p2 = ToPointF(ControlPoints[1]);
            float  r  = (float)Dist(p1, p2);

            Pen   pen        = LinePen.GetPen();
            float StartAngle = 0;

            if (p2.Y < p1.Y)
            {
                StartAngle = 180;
            }

            if (r > 0)
            {
                foreach (float f in split)
                {
                    g.DrawArc(pen, new RectangleF(p1.X - r * f, p1.Y - r * f, r * 2 * f, r * 2 * f), StartAngle, 180);
                }
            }

            g.DrawLine(pen, p1, p2);
        }
        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();
        }
 /// <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 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);
 }
 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 #29
0
        public override void childPaint(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font FontText, System.Drawing.Font FontData)
        {
            //绘制Pie自定义标题
            if (IsDrawPieTiTle)
            {
                Brush pieTitleBrush = new SolidBrush(pieTitleColor);
                ReportViewUtils.drawString(g, LocationModel.Location_Right_Right, pieTitle, pieTitleFont, pieTitleBrush, 0, 3, this.Width, padding);

                pieTitleBrush.Dispose();
            }

            int length = this.Height > this.Width ? (this.Width / 2) : (this.Height / 2);
            int startX = (this.Width - length) / 2;
            int startY = (this.Height - length) / 2;

            if (Data is DetailDataModel)
            {
                DetailDataModel data  = (DetailDataModel)Data;
                string[]        datas = data.TextAndData;
                linePen = new Pen(Color.FromArgb(180, 71, 85, 182), 60);
                //7/12的效果最好看
                piePenWidth = 7 * length / 12;
                Rectangle rectangle = new Rectangle(startX, startY, length, length);

                IsFirst    = true;
                sweepAngle = 0;
                float startAngle = 360;
                for (int i = 0; i < datas.Length / 2; i++)
                {
                    string str       = datas[2 * i + 1];
                    float  realAngle = 360 * int.Parse(str) * 1.0f / allNum;

                    linePen.Width = piePenWidth * int.Parse(str) / maxNum;
                    int realX      = startX + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realY      = startY + (int)(piePenWidth - linePen.Width + 0.5f) / 2;
                    int realLength = length - (int)(piePenWidth - linePen.Width);

                    rectangle     = new Rectangle(realX, realY, realLength, realLength);
                    linePen.Color = ReportViewUtils.PerferColors[i % ReportViewUtils.PerferColors.Length];
                    startAngle   -= (realAngle - 0.5f);
                    g.DrawArc(linePen, rectangle, startAngle, realAngle + 0.7f);

                    if (IsDrawLineNote)
                    {
                        DrawLineNote(g, linePen.Color, data, 2 * i + 1, startAngle, realAngle, realLength / 2);
                    }
                }
            }

            linePen.Dispose();
            lineBrush.Dispose();
            TextBrush.Dispose();
            DataBrush.Dispose();
            FontText.Dispose();
            FontData.Dispose();
        }
Example #30
0
        public override void childPaint(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font font_Text, System.Drawing.Font font_Data)
        {
            if (isFirst)
            {
                oldColor = linePen.Color;
                isFirst  = false;
            }
            if (Data != null)
            {
                ///建议把绘制的直接写在这里
                if (Data.Area.IsMouseIn)
                {
                    linePen.Color = ReportViewUtils.perferRed;
                }
                else
                {
                    linePen.Color = oldColor;
                }
                ChildDataModel data = Data as ChildDataModel;
                //圆点的大小
                int        startX      = data.Area.left;
                int        startY      = data.Area.top;
                int        width       = data.Area.right - startX;
                int        height      = data.Area.bottom - startY;
                int        CircleRaius = 10;
                SolidBrush sbrush1     = new SolidBrush(Color.FromArgb(150, 1, 77, 103));
                SolidBrush sf          = new SolidBrush(linePen.Color);
                Rectangle  rect        = new Rectangle(startX, startY, width, height);
                float      realAngle   = 360 * data.mainData * 1.0f / MaxNum;
                //顺时针绘制
                float startAngle = 360 - realAngle;
                g.DrawArc(linePen, rect, startAngle, realAngle);
                //绘制圆弧内的字体
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Down, data.mainText, font_Text, TextBrush, startX, startY, width, height / 2, 5);
                //绘制圆弧内的数据
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Up, data.mainData + "", font_Data, DataBrush, startX, startY + height / 2, width, height / 2, 5);

                //绘制圆弧外的字体
                Rectangle    Arc_Out = new Rectangle(startX, startY + height + height / 2, width, 30);
                GraphicsPath path    = ReportViewUtils.CreateRoundedRectanglePath(Arc_Out, 15);
                g.FillPath(sbrush1, path);
                path.Dispose();
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Center, data.childText + "" + data.childData, font_Data, DataBrush, startX, startY + height + height / 2, width, 30, 8);


                //定位圆点
                int       y           = (int)(Math.Sin(startAngle / 180 * Math.PI) * width / 2);
                int       x           = (int)(Math.Cos(startAngle / 180 * Math.PI) * height / 2);
                Rectangle rect_Circle = new Rectangle(startX + width / 2 - CircleRaius / 2 + x, startY + height / 2 - CircleRaius / 2 + y, CircleRaius, CircleRaius);
                //绘制圆点
                g.FillEllipse(sf, rect_Circle);

                sf.Dispose();
                sbrush1.Dispose();
            }
        }
Example #31
0
File: Form1.cs Project: JX25/GK_01
        private void button5_Click_2(object sender, EventArgs e)
        {
            pictureBox1.Refresh();
            int x      = (int)Double.Parse(textBox1.Text);
            int y      = (int)Double.Parse(textBox2.Text);
            int width  = (int)Double.Parse(textBox3.Text);
            int height = (int)Double.Parse(textBox4.Text);

            g.DrawArc(pen1, x, y, width, height, 36, 220);
        }
Example #32
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));
        }
Example #33
0
        /// <summary>
        /// 画图方法
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(System.Drawing.Graphics g)
        {
            base.Draw(g);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Pen pen = new Pen(base.Color, base.PenWidth);

            Rectangle rect = DrawRectanlge.GetNormalizedRectangle(base.rectangle);
            int       x    = rect.X;
            int       y    = rect.Y;
            float     d    = (float)rect.Width / 6;
            float     b    = (float)rect.Height / 6;

            g.TranslateTransform(x + 3 * d, y + 3 * b);
            g.RotateTransform(Angle);
            g.TranslateTransform(-x - 3 * d, -y - 3 * b);

            g.DrawLine(pen, new PointF(x + 0 * d, y + 3 * b), new PointF(x + 1 * d, y + 3 * b));
            g.DrawLine(pen, new PointF(x + 1 * d, y + 2 * b), new PointF(x + 1 * d, y + 4 * b));
            g.DrawLine(pen, new PointF(x + 1 * d, y + 2 * b), new PointF(x + 5 * d, y + 2 * b));
            g.DrawLine(pen, new PointF(x + 1 * d, y + 4 * b), new PointF(x + 5 * d, y + 4 * b));
            g.DrawLine(pen, new PointF(x + 5 * d, y + 2 * b), new PointF(x + 5 * d, y + 4 * b));
            g.DrawLine(pen, new PointF(x + 5 * d, y + 3 * b), new PointF(x + 6 * d, y + 3 * b));
            pen.Dispose();
            //需要学生填写
            //DrawName(g);

            Pen   pen1 = new Pen(Color.Red, 1);
            Point p;

            switch (Node)
            {
            case 1:
                p = GetNode(1);
                g.DrawArc(pen1, new RectangleF(p.X - 5, p.Y - 5, 10, 10), 0, 360);
                break;

            case 2:
                p = GetNode(2);
                g.DrawArc(pen1, new RectangleF(p.X - 5, p.Y - 5, 10, 10), 0, 360);
                break;
            }
            pen1.Dispose();
        }
        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();
        }
Example #35
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);
        }
 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 #37
0
        private void button3_Click(object sender, EventArgs e)
        {
            //łuk

            pictureBox1.Refresh();

            Pen greenPen = new Pen(Color.Green, 3);

            Rectangle rect = new Rectangle(0, 0, 100, 100);

            g.DrawArc(greenPen, rect, 100, 200);
        }
 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 #39
0
        private void DrawIt()
        {
            System.Drawing.Pen myPen;
            myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
            System.Drawing.Graphics formGraphics = this.CreateGraphics();
            formGraphics.DrawLine(myPen, 50, 350, 650, 350);
            formGraphics.DrawLine(myPen, 350, 50, 350, 350);
            formGraphics.DrawArc(myPen, 50, 50, 600, 600, 180, 180);

            myPen.Dispose();
            formGraphics.Dispose();
        }
Example #40
0
        private void butArc_Click(object sender, EventArgs e)
        {
            g = PictureBox1.CreateGraphics();
            float x      = 25;
            float y      = 50;
            float width  = 100;
            float height = 200;

            float startAngle = 45;
            float sweepAngle = 250;

            g.DrawArc(penBrown, x, y, width, height, startAngle, sweepAngle);
        }
        public override void OnRenderNormalView(System.Drawing.Graphics g, Model.DataModel Data, System.Drawing.Pen linePen, System.Drawing.Brush lineBrush, System.Drawing.Brush TextBrush, System.Drawing.Brush DataBrush, System.Drawing.Font TextFont, System.Drawing.Font DataFont)
        {
            if (isFirst)
            {
                oldColor = linePen.Color;
                isFirst  = false;
            }
            if (Data != null)
            {
                ///建议把绘制的直接写在这里
                if (Data.Area.IsMouseIn)
                {
                    linePen.Color = MouseMoveInColor;
                }
                else
                {
                    linePen.Color = oldColor;
                }
                DetailDataModel data = Data as DetailDataModel;

                System.Drawing.SolidBrush sbrush1 = new System.Drawing.SolidBrush(Color.FromArgb(150, 1, 77, 103));
                System.Drawing.SolidBrush sf      = new System.Drawing.SolidBrush(linePen.Color);
                System.Drawing.Rectangle  rect    = new System.Drawing.Rectangle(EStartX, EStartY, EViewWidth, EViewHeight);
                float realAngle = 360 * int.Parse(data.TextAndData[1]) * 1.0f / MaxNum;
                //顺时针绘制
                float startAngle = 360 - realAngle;
                g.DrawArc(linePen, rect, startAngle, realAngle);
                //绘制圆弧内的字体
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Down, data.TextAndData[0], TextFont, TextBrush, EStartX, EStartY, EViewWidth, EViewHeight / 2, 5);
                //绘制圆弧内的数据
                ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Up, data.TextAndData[1] + "", DataFont, DataBrush, EStartX, EStartY + EViewHeight / 2, EViewWidth, EViewHeight / 2, 5);

                //绘制圆弧外的字体
                //Rectangle Arc_Out = new Rectangle(StartX, StartY + ViewHeight + bottomLegendHeight, ViewWidth, bottomLegendHeight);
                //GraphicsPath path = ReportViewUtils.CreateRoundedRectanglePath(Arc_Out, bottomLegendHeight / 2);
                // g.FillPath(sbrush1, path);
                //path.Dispose();
                //ReportViewUtils.drawStringWithLimiteText(g, LocationModel.Location_Center, data.TextAndData[2] + "" + data.TextAndData[3], DataFont, DataBrush, StartX, StartY + ViewHeight + bottomLegendHeight, ViewWidth, bottomLegendHeight, 8);


                //定位圆点
                float      y           = (float)(Math.Sin(startAngle / 180 * Math.PI) * EViewWidth / 2);
                float      x           = (float)(Math.Cos(startAngle / 180 * Math.PI) * EViewHeight / 2);
                RectangleF rect_Circle = new RectangleF((EStartX + EViewWidth / 2 - CircleRaius / 2 + x), (EStartY + EViewHeight / 2 - CircleRaius / 2) + y, CircleRaius, CircleRaius);
                //绘制圆点
                g.FillEllipse(sf, rect_Circle);

                sf.Dispose();
                sbrush1.Dispose();
            }
        }
Example #42
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 #43
0
        public override void Draw(System.Drawing.Graphics g)
        {
            if (IsVisible)
            {
                g.TranslateTransform(Location.X + 50, Location.Y + 50);

                g.DrawArc(new System.Drawing.Pen(new SolidBrush(Color.FromArgb(Convert.ToInt32(255 * Animation), Color.Blue)), 8), new RectangleF(-50, -50, 100, 100), -90, Animation * 360);

                nearestItem = GetNearestItem();
                for (int i = 0; i < actions.Count; i++)
                {
                    g.RotateTransform(-360 * i / actions.Count);

                    g.TranslateTransform(100, 0);
                    g.RotateTransform(360 * i / actions.Count);
                    if (i != nearestItem)
                    {
                        g.ScaleTransform(0.75f, 0.75f);
                    }
                    Actions[i].Draw(g, Animation);
                    if (i != nearestItem)
                    {
                        g.ScaleTransform(1f / 0.75f, 1f / 0.75f);
                    }
                    g.RotateTransform(-360 * i / actions.Count);
                    g.TranslateTransform(-100, 0);
                    g.RotateTransform(360 * i / actions.Count);
                }
                float  angle           = Game.GetPointAngle(new Point(Convert.ToInt32(Location.X) + 50, Convert.ToInt32(Location.Y) + 50), Program.game.MousePosition);
                float  length          = Game.GetPointLength(new Point(Convert.ToInt32(Location.X) + 50, Convert.ToInt32(Location.Y) + 50), Program.game.MousePosition);
                PointF translateLength = Game.LengthDir(64, -angle);
                if (length > 50)
                {
                    g.TranslateTransform(translateLength.X, translateLength.Y);
                    g.RotateTransform(-angle);
                    g.TranslateTransform(-16, -16);
                    g.DrawImageUnscaledAndClipped(Properties.Resources.Arrow, new Rectangle(0, 0, Properties.Resources.Arrow.Width, Properties.Resources.Arrow.Height));
                    g.TranslateTransform(16, 16);
                    g.RotateTransform(angle);
                    g.TranslateTransform(-translateLength.X, -translateLength.Y);
                }
                //g.DrawImageUnscaledAndClipped()
                //g.DrawString(nearestItem.ToString(), new Font("Segoe UI", 14), Brushes.Blue, new PointF(0, 0));


                g.TranslateTransform(-Location.X, -Location.Y);
                g.ResetTransform();
            }
        }
Example #44
0
        public void DrawArc(Coordinate point, double radius, double startAngle, double sweepAngle)
        {
            var   p = ToGdiPointF(point);
            float r = (float)transfomer.ScaleOnX(radius);

            Drawing.RectangleF rect = new Drawing.RectangleF(p.X - r,
                                                             p.Y - r,
                                                             2.0f * r,
                                                             2.0f * r);

            float a = (float)Algorithms.ToDegrees(startAngle);
            float b = (float)Algorithms.ToDegrees(sweepAngle);

            graphics.DrawArc(currentPen, rect, a, b);
        }
Example #45
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);
 }
Example #46
0
 public void HighlightArc(System.Drawing.Graphics graphics, bool highlighted)
 {
     Pen pen;
     Rectangle rect;
     int height = difference * 50;
     if (highlighted == true)
         pen = new Pen(Color.Yellow, 1);
     else
         pen = new Pen(Color.Black, 1);
     if (height > 0)
     {
         rect = new Rectangle(50 + (current * 200), 100 - height / 2, difference * 200, height);
         float startAngle = 0.0F;
         float sweepAngle = -180.0F;
         graphics.DrawArc(pen, rect, startAngle, sweepAngle);
     }
     else
     {
         rect = new Rectangle(50 + (next * 200), 200 + height / 2, difference * -200, height * -1);
         float startAngle = 0.0F;
         float sweepAngle = 180.0F;
         graphics.DrawArc(pen, rect, startAngle, sweepAngle);
     }
 }
Example #47
0
    public void DrawArc(System.Drawing.Graphics graphics)
    {
        //int height = 35 + (int)(Math.Pow(10, difference));
        int height = difference * 50;
        Pen blackPen = new Pen(Color.Black, 1);
        Rectangle rect;
        if (height > 0)
        {

            rect = new Rectangle(50 + (current * 200), 100 - height / 2, difference * 200, height);
            float startAngle = 0.0F;
            float sweepAngle = -180.0F;
            graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
            //graphics.DrawRectangle(blackPen, rect);
        }
        else
        {
            rect = new Rectangle(50 + (next * 200), 200 + height / 2, difference * -200, height * -1);
            float startAngle = 0.0F;
            float sweepAngle = 180.0F;
            graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
            //graphics.DrawRectangle(blackPen, rect);
        }
    }
Example #48
0
        public void DrawArc(Pen pen, double x, double y, double width, double height, double startAngle, double sweepAngle)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            lock (bitmapLock) {
                TryExpand(x, y, width, height, pen.Width);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap)) {
                    g.SmoothingMode = (Antialiasing) ? SmoothingMode.AntiAlias : SmoothingMode.None;
                    g.DrawArc(pen, (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
                }
                Texturize();
            }
        }
        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
            }
        }
Example #50
0
        public override void Draw(System.Drawing.Graphics g)
        {
            Point point1 = _entity1.GetOuterPoint(_entity1.Position, _entity2.Position);
            Point point2 = _entity2.GetOuterPoint(_entity2.Position, _entity1.Position);

            int       w    = Math.Abs(point1.X - point2.X);
            int       h    = Math.Abs(point1.Y - point2.Y);
            Size      size = new Size(w, h);
            Rectangle R    = new Rectangle(point1, size);

            if (DrawingHelperFunctions.Distance(_entity1.Position, point1) + DrawingHelperFunctions.Distance(_entity2.Position, point2) <=
                DrawingHelperFunctions.Distance(_entity1.Position, _entity2.Position)
                )
            {
                g.DrawArc(new System.Drawing.Pen(Color.Blue), R, (float)Math.PI / 5, (float)Math.PI / 6);
            }
            //g.DrawArc(new System.Drawing.Pen(Color.Blue), R, 0, 30);
        }
Example #51
0
        public static void DrawToPreview(System.Drawing.Graphics g, IReadOnlyPreviewDisplayEnvironment env, NoteBase note)
        {
            var   diff = note.Timing - env.TimingOffset;
            float r    = 1 - (float)(diff / env.TimingLength).BarRatio;

            if (r <= 0 || r > 1)
            {
                return;
            }
            var   lane1    = note.Lane.NormalizedLane;
            float startDeg = CalcCsDeg(6 * lane1);
            float degSize  = CalcCsDegSize(6 * note.NoteSize.Size);

            using (var p = new Pen(NoteGraphicsGenerator.GetColor(note.NoteType), 5))
            {
                r *= env.Radius;
                g.DrawArc(p, env.CenterPoint.X - r, env.CenterPoint.Y - r, 2 * r, 2 * r, startDeg, degSize);
            }
        }
Example #52
0
        private void DrawArc(ref Arc a_arc)
        {
            if (!a_arc.IsDefined)
            {
                return;
            }

            int parsed_start_angle = Convert.ToInt32(a_arc.StartAngle * RAD_TO_DEG);
            int parsed_end_angle   = Convert.ToInt32(a_arc.EndAngle * RAD_TO_DEG);

            m_graphics.DrawArc(
                m_pen,
                a_arc.Center.X - Convert.ToInt32(a_arc.Radius),
                a_arc.Center.Y - Convert.ToInt32(a_arc.Radius),
                Convert.ToInt32(2 * a_arc.Radius),
                Convert.ToInt32(2 * a_arc.Radius),
                parsed_start_angle,
                parsed_end_angle
                );
        }
        /// <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 #54
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            //定义圆弧所在椭圆的外接矩形
            Rectangle r  = new Rectangle(50, 50, 300, 200);
            Pen       p1 = new Pen(Color.Black, 3);//用于绘制坐标系的画笔

            p1.EndCap = LineCap.ArrowAnchor;
            Pen p2 = new Pen(Color.Blue);     //绘制外接矩形
            Pen p3 = new Pen(Color.Brown, 5); //用于绘制弧线的画笔
            //确定坐标系原点,即矩形的中心点坐标
            float centerX = (float)((r.Width / 2.0 + r.Left));
            float centerY = (float)((r.Height / 2.0 + r.Top));

            //绘制坐标系
            g.DrawLine(p1, new PointF(centerX - 150, centerY), new PointF(centerX + 150, centerY));
            g.DrawLine(p1, new PointF(centerX, centerY + 100), new PointF(centerX, centerY - 100));
            //绘制外接矩形
            g.DrawRectangle(p2, r);
            g.DrawArc(p3, r, 0, 90);
        }
Example #55
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 #56
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 #57
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);
         }
     }
 }
Example #58
0
 private void btnArc_Click(object sender, EventArgs e)
 {
     g = pictureBox1.CreateGraphics();
     g.DrawArc(penGreen, 0, 0, 100, 200, 45F, 270F);
 }
Example #59
0
 private void button6_Click(object sender, EventArgs e)
 {
     g.DrawArc(pen1, 5, 5, 125, 250, 45, 135);
 }
Example #60
0
 public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
 {
     dg.DrawArc(pen, x, y, width, height, startAngle, arcAngle);
 }