FillPie() public method

public FillPie ( Brush brush, Rectangle rect, float startAngle, float sweepAngle ) : void
brush Brush
rect Rectangle
startAngle float
sweepAngle float
return void
Beispiel #1
0
 public void Draw(Graphics g)
 {
     if (isOpen)
     {
         g.FillEllipse(brush, X * 2 * RADIUS, Y * 2 * RADIUS, RADIUS * 2, RADIUS * 2);
     }
     else
     {
         if (Direction == DIRECTION.RIGHT)
         {
             g.FillPie(brush, X * 2 * RADIUS, Y * 2 * RADIUS, RADIUS * 2, RADIUS * 2, 45, 270);
         }
         else if (Direction == DIRECTION.LEFT)
         {
             g.FillPie(brush, X * 2 * RADIUS, Y * 2 * RADIUS, RADIUS * 2, RADIUS * 2, 225, 270);
         }
         else if (Direction == DIRECTION.UP)
         {
             g.FillPie(brush, X * 2 * RADIUS, Y * 2 * RADIUS, RADIUS * 2, RADIUS * 2, 315, 270);
         }
         else
         {
             g.FillPie(brush, X * 2 * RADIUS, Y * 2 * RADIUS, RADIUS * 2, RADIUS * 2, 135, 270);
         }
     }
 }
        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();
        }
        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();
        }
Beispiel #4
0
 public static void FillRoundedRectangle(Graphics g, Rectangle r, int d, Brush b)
 {
     SmoothingMode mode = g.SmoothingMode;
     g.SmoothingMode = SmoothingMode.HighSpeed;
     g.FillPie(b, r.X, r.Y, d, d, 180, 90);
     g.FillPie(b, r.X + r.Width - d, r.Y, d, d, 270, 90);
     g.FillPie(b, r.X, r.Y + r.Height - d, d, d, 90, 90);
     g.FillPie(b, r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90);
     g.FillRectangle(b, r.X + d / 2, r.Y, r.Width - d, d / 2);
     g.FillRectangle(b, r.X, r.Y + d / 2, r.Width, r.Height - d);
     g.FillRectangle(b, r.X + d / 2, r.Y + r.Height - d / 2, r.Width - d, d / 2);
     g.SmoothingMode = mode;
 }
        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);
            }
        }
            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);

            }
Beispiel #7
0
 public void drawWorld(System.Drawing.Graphics g, bool drawPie)
 {
     System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
     Draw(g);
     foreach (Predator a in Player)
     {
         if (drawPie)
         {
             float arc = 180F / a.sensors.Length;
             float f   = a.heading * (360f / (2 * (float)Math.PI)) - 90;
             for (int i = 0; i < a.sensors.Length; f += arc, i++)
             {
                 if (a.sensors[i] > 0)
                 {
                     ((SolidBrush)myBrush).Color = Color.FromArgb(255, (byte)(255 * (1 - a.sensors[i])), (byte)(255 * (1 - a.sensors[i])));
                     g.FillPie(myBrush, a.x - a.radius, Utilities.shiftDown + (a.y - a.radius), a.radius * 2, a.radius * 2, f, arc);
                     //g.DrawPie(Pens.Black, a.x - a.radius, a.y - a.radius, a.radius * 2, a.radius * 2, f, arc);
                 }
                 else
                 {
                     g.DrawPie(Pens.Black, a.x - a.radius, Utilities.shiftDown + (a.y - a.radius), a.radius * 2, a.radius * 2, f, arc);
                 }
             }
         }
         System.Drawing.Pen p = new Pen(System.Drawing.Color.Red, 5f);
         g.DrawLine(p, a.x, Utilities.shiftDown + a.y, a.x + (float)Math.Cos(a.heading) * (25), Utilities.shiftDown + a.y + (float)Math.Sin(a.heading) * (25));
         a.Draw(g);
     }
     foreach (Prey p in Enemy)
     {
         p.Draw(g);
     }
 }
Beispiel #8
0
        //##################################################################################

        public virtual void DrawSign(Graphics g, Font font, string sign, int x, int y)
        {
            var boxSize = TextRenderer.MeasureText(sign, font);
            int boxWidth = boxSize.Width + 4;
            int boxHeight = boxSize.Height + 8;

            g.FillPie(Brushes.SandyBrown,
                x - 16,
                y - 14,
                32,
                28,
                270 - 20,
                40);

            g.FillRectangle(Brushes.SandyBrown,
                x - boxWidth / 2,
                y - boxHeight - 8,
                boxWidth,
                boxHeight);

            g.DrawString(sign, font, Brushes.Black,
                x,
                y - boxHeight - 4,
                new StringFormat()
                {
                    Alignment = StringAlignment.Center
                });
        }
Beispiel #9
0
 public override void Draw(Graphics g, Tank t)
 {
     double ang1 = t.orientation + angleWithBase - viewAngle / 2;
     double ang2 = t.orientation + angleWithBase + viewAngle / 2;
     g.FillPie(new SolidBrush(Color.FromArgb(drawAlpha, color))
         , (int)t.pos.X - maxViewDistance, (int)t.pos.Y - maxViewDistance
         , 2 * maxViewDistance, 2 * maxViewDistance, (int)ang1, (int)ang2);
 }
Beispiel #10
0
        public void onManagedDraw(Graphics graphics)
        {
            float angle;
            if (this.shotCount < this.ShotCount) {
                angle = this.secondsElapsed >= this.ShotTime ? 360 : 360 * this.secondsElapsed / this.ShotTime;
                graphics.FillPie (Brushes.Silver, Options.CameraWidth / 2 - 100, 0, 200, 200, 0, angle);
            } else {
                if (this.RechargeTime != 0) {
                    angle = 360 * this.secondsElapsed / this.RechargeTime;
                    graphics.FillPie (Brushes.Black, Options.CameraWidth / 2 - 100, 0, 200, 200, 0, angle);
                }
            }

            graphics.DrawEllipse (Pens.Black, Options.CameraWidth / 2 - 100, 0, 200, 200);

            for (int i = 0; i < this.bullets.Count; ++i) {
                this.bullets [i].onManagedDraw (graphics);
            }
        }
Beispiel #11
0
 public override void Draw(Graphics g, Rectangle r, Brush bg, Brush fg, uint seed, bool fliphorizontal)
 {
     switch ((seed + (fliphorizontal ? 2 : 0)) % 4)
     {
         case 0: //  ◞
             g.FillPie(fg, new Rectangle(r.Left - r.Width, r.Top - r.Height, r.Width * 2, r.Height * 2), 0, 90);
             break;
         case 1: //  ◜
             g.FillPie(fg, new Rectangle(r.Left, r.Top, r.Width * 2, r.Height * 2), -90, -90);
             break;
         case 2: //  ◟
             g.FillPie(fg, new Rectangle(r.Left, r.Top - r.Height, r.Width * 2, r.Height * 2), 90, 90);
             break;
         case 3: //  ◝
         default:
             g.FillPie(fg, new Rectangle(r.Left - r.Width, r.Top, r.Width * 2, r.Height * 2), 0, -90);
             break;
     }
 }
 public override void Draw(Graphics g)
 {
     Pen pen = new Pen(Brushes.Black,3);
        UpdateBounds();
        g.FillEllipse(Brushes.Red, X,Y, 10, 10);
        g.DrawEllipse(pen, X - 3, Y - 3, 13, 13);
        g.FillPie(Brushes.White,X,Y, 10, 10, 0, 180);
        g.DrawEllipse(pen, X + 3, Y + 3, 2, 2);
     Y = Y - BallInterval;
 }
Beispiel #13
0
 public void Render(Graphics graphics)
 {
     graphics.FillPie(
         _brush,
         _rectangle.X,
         _rectangle.Y,
         _rectangle.Width,
         _rectangle.Height,
         _startAngle,
         _endAngle);
 }
Beispiel #14
0
 public void Deseneaza_interior(System.Drawing.Graphics Zona_desenare, System.Drawing.Pen Creion_n, System.Drawing.SolidBrush Pensula_n, int unghi, int Unghi_start, Point Tangent_cerc, Point Centru_cerc)
 {
     cateta_x       = Convert.ToInt32(Math.Sin(unghi) * (Diametrul / 2));
     cateta_y       = Convert.ToInt32(Math.Cos(unghi) * (Diametrul / 2));
     Tangent_cerc.X = x0 + Diametrul / 2 - cateta_x;
     Tangent_cerc.Y = y0 + Diametrul / 2 + cateta_y;
     Centru_cerc.X  = x0 + Diametrul / 2;
     Centru_cerc.Y  = y0 + Diametrul / 2;
     Zona_desenare.DrawLine(Creion_n, Tangent_cerc, Centru_cerc);
     Zona_desenare.FillPie(Pensula_n, x0, y0, Diametrul, Diametrul, Unghi_start, 140);
 }
 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);
     }
 }
Beispiel #16
0
		private void DrawGlowCorner(Graphics g)
		{
			using (var graphicsPath = new GraphicsPath())
			using (var graphicsPath2 = new GraphicsPath())
			{
				var rect = new Rectangle(-GlowSize, -1, GlowSize * 2, GlowSize * 2);
				var rect2 = new Rectangle(-GlowSize, Owner.Height, GlowSize * 2, GlowSize * 2);
				graphicsPath.AddEllipse(rect);
				graphicsPath2.AddEllipse(rect2);
				using (var pathGradientBrush = new PathGradientBrush(graphicsPath))
				using (var pathGradientBrush2 = new PathGradientBrush(graphicsPath2))
				{
					pathGradientBrush.CenterColor = GlowAlphaColor;
					pathGradientBrush.SurroundColors = new[] { Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent };
					pathGradientBrush2.CenterColor = GlowAlphaColor;
					pathGradientBrush2.SurroundColors = new[] { Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent };
					g.FillPie(pathGradientBrush, rect, 270, 90);
					g.FillPie(pathGradientBrush2, rect2, 0, 90);
				}
			}
		}
Beispiel #17
0
        public void Dibujar_Diente()
        {
            Bitmap area_de_dibujo = new Bitmap(pictureBox.Width, pictureBox.Height);
            g = Graphics.FromImage(area_de_dibujo);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.FillPie(new SolidBrush(colores_partes[1]), 0, 0, 40, 40, 225, 90);
            g.FillPie(new SolidBrush(colores_partes[2]), 0, 0, 40, 40, -45, 90);
            g.FillPie(new SolidBrush(colores_partes[3]), 0, 0, 40, 40, 45, 90);
            g.FillPie(new SolidBrush(colores_partes[4]), 0, 0, 40, 40, 135, 90);

            Pen p = new Pen(Color.Black);

            g.DrawPie(p, 0, 0, 40, 40, 225, 90);
            g.DrawPie(p, 0, 0, 40, 40, -45, 90);
            g.DrawPie(p, 0, 0, 40, 40, 45, 90);
            g.DrawPie(p, 0, 0, 40, 40, 135, 90);

            g.FillEllipse(new SolidBrush(colores_partes[0]), 11.5f, 11.5f, 17f, 17f);
            g.DrawEllipse(Pens.Black, 11.5f, 11.5f, 17.0f, 17.0f);

            pictureBox.Image = area_de_dibujo;
        }
Beispiel #18
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);
        }
Beispiel #19
0
        public Datum Draw(Graphics g, Rectangle rect, int x, int y)
        {
            _values.Sort(BySize);

            float hilite = ToAngle(rect, x, y);
            double last = 0;
            Datum hilited = null;
            foreach (Datum d in _values)
            {
                double next = last + d.Value;
                float angle = ToAngle(last);
                float sweep = ToAngle(next-last);
                if (hilite >= angle && hilite < (angle + sweep))
                {
                    hilited = d;
                    g.FillPie(Brushes.Red, rect, angle, sweep);
                    DrawTitle(g,rect,d);
                }
                else
                    g.FillPie(GetBrush(d), rect, angle, sweep);
                last = next;
            }
            return hilited;
        }
Beispiel #20
0
        public override void Show(Graphics g)
        {
            Pen whitePen = new Pen(Color.White, 3);
                int x = LeftTop.X;
                int y = LeftTop.Y;
                int width = RightBottom.X - LeftTop.X;
                int height = RightBottom.Y - LeftTop.Y;

                Random pie_ran = new Random();
                int startAngle = pie_ran.Next(1,360);
                int sweepAngle = pie_ran.Next(1,360);

            g.DrawPie(whitePen, x, y, width, height, startAngle, sweepAngle);
            g.FillPie(Brushes.Black, x, y, width, height, startAngle, sweepAngle);
        }
Beispiel #21
0
            public void setval(System.Drawing.Graphics zona_des, double val)
            {
                int Unghi_grade = 140 - System.Convert.ToInt16(100 * val / vm);; //unghiul in grade

                int lg   = 17;
                int xc   = x0 + Latime / 2;
                int yc   = y0 + Latime / 2;
                int raza = Latime / 2;

                System.Drawing.SolidBrush radiera = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                zona_des.FillPie(radiera, x0 + 2 * lg - 1, y0 + 2 * lg - 1, Latime - 4 * lg + 2, Latime - 4 * lg + 2, 10, -180);
                double Unghi_radiani = 2 * System.Math.PI * (Unghi_grade) / 360;// unghiul in radiani
                int    x             = System.Convert.ToInt16(xc + (raza - 2 * lg) * System.Math.Cos(Unghi_radiani));
                int    y             = System.Convert.ToInt16(yc - (raza - 2 * lg) * System.Math.Sin(Unghi_radiani));

                zona_des.DrawLine(Creion_rosu, x, y, xc, yc);
                Unghi_grade = 40;
                zona_des.DrawRectangle(Creion_rosu, xc - raza, yc - raza - 2, 2 * raza, 5 * raza / 4);
            }
Beispiel #22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;

            //Уровень
            //Line[] lines = m.GetLines();
            //for (var i = 0; i < lines.Length; i++)
            //{
            //    g.DrawLine(Pens.Black, lines[i].p0.ToPoint, lines[i].p1.ToPoint);
            //}
            g.DrawLines(Pens.Red, testCountur.Points.Select(x => x.ToPoint).ToArray());

            foreach (var item in OffsetList.Select(x => x.ToPoint).ToList())
            {
                g.FillPie(Brushes.Black, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360);
            }


            //Видимость
            //if (TEstsss != null)
            //{
            //    g.FillPolygon(Brushes.Salmon, TEstsss.Points.Select(x => x.ToPoint).ToArray());
            //    // g.FillPolygon(Brushes.Salmon, con.Points.Select(x => x.ToPoint).ToArray());
            //    foreach (var item in TEstsss.Points.Select(x => x.ToPoint).ToList())
            //    {
            //        g.FillPie(Brushes.Blue, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360);
            //    }
            //    foreach (var item in m.NovigationVertex.Select(x => x.ToPoint).ToList())
            //    {
            //        g.FillPie(Brushes.Black, new Rectangle((int)item.X - 5 / 2, (int)item.Y - 5 / 2, 5, 5), 0, 360);
            //    }
            //}

            // g.FillPolygon(Brushes.Salmon, con.Points.Select(x => x.ToPoint).ToArray());
            //Другие объекты
            //foreach (SceneObject item in SceneObjects)
            //{
            //    item.Draw(g);
            //}
        }
Beispiel #23
0
        public void Draw(
            System.Drawing.Graphics g,
            System.Drawing.Pen pen,
            System.Drawing.Brush brush,
            float StartAngle,
            float SweepAngle)
        {
            if (g == null)
            {
                return;
            }
            if (pen == null && brush == null)
            {
                return;
            }
            if (brush != null)
            {
                g.FillPie(
                    brush,
                    myBounds.Left,
                    myBounds.Top,
                    myBounds.Width,
                    myBounds.Height,
                    StartAngle,
                    SweepAngle);
            }

            if (pen != null)
            {
                g.DrawPie(
                    pen,
                    myBounds.Left,
                    myBounds.Top,
                    myBounds.Width,
                    myBounds.Height,
                    StartAngle,
                    SweepAngle);
            }
        }
Beispiel #24
0
        public void DrawPie(Pen pen, double x, double y, double width, double height, double startAngle, double sweepAngle, bool fill = false)
        {
            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;
                    if (fill)
                    {
                        g.FillPie(pen.Brush, (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
                    }
                    else
                    {
                        g.DrawPie(pen, (float)x, (float)y, (float)width, (float)height, (float)startAngle, (float)sweepAngle);
                    }
                }
                Texturize();
            }
        }
Beispiel #25
0
        public static void DrawPieDiagram(Graphics gr, Rectangle rect, Color[] colors, double[] values)
        {
            UInt64 sum = 0;
            foreach (UInt64 val in values) sum += val;
            if (sum == 0)
                sum = 1;

            Pen pen = new Pen(Color.Black, 2);

            float angle = 0;
            for (int i = 0; i < values.Length; i++)
            {
                float portion = (((float)values[i]) * 360) / sum;

                float newAngle = angle + portion;

                gr.FillPie(new SolidBrush(colors[i % colors.Length]), rect, angle, portion);
                //gr.DrawPie(pen, rect, angle, portion);
                angle = newAngle;
            }

            gr.DrawEllipse(pen, rect);
        }
     private void GenerateCircle(Graphics g, float x, float y, float width, float height, int heading)
     {
         var outerRect = new RectangleF(x, y, width, height);

         // Fill the background of the whole control
         using (var bg = new SolidBrush(BackColor))
             g.FillRectangle(bg, outerRect);

         // Fill the background of the circle
         var circleRect = outerRect;
         circleRect.Inflate((_borderWidth/-2), (_borderWidth/-2));
         
         using (var white = new LinearGradientBrush(outerRect, _barBgLightColour, _barBgDarkColor, 0F))
                {
                  g.FillEllipse(white, circleRect);
                }
     
         var gp = new GraphicsPath();
         gp.AddEllipse(circleRect);

         var pgb = new PathGradientBrush(gp);

         pgb.CenterPoint = new PointF(circleRect.Width/2, circleRect.Height/2);
         pgb.CenterColor = _sweepDarkColour;
         pgb.SurroundColors = new[] {_sweepLightColour};

         heading = (heading + 270  -5)   %360;

         g.FillPie(pgb, circleRect.Left, circleRect.Top, circleRect.Width, circleRect.Height, heading, 10);

         pgb.Dispose();

         using (var borderPen = new Pen(_borderColor, _borderWidth))
         {
             g.DrawEllipse(borderPen, circleRect);
         }
     }
Beispiel #27
0
        private static void DrawPie(Lbl.Charts.Serie Serie, System.Drawing.Graphics Canvas, System.Drawing.Size Size)
        {
            decimal Sum = Serie.GetSum();

            Rectangle PieRect = new Rectangle(0, 0, Size.Width, Size.Height);

            if (PieRect.Width > PieRect.Height)
            {
                PieRect.X    += (PieRect.Width - PieRect.Height) / 2;
                PieRect.Width = PieRect.Height;
            }
            else
            {
                PieRect.Y     += (PieRect.Height - PieRect.Width) / 2;
                PieRect.Height = PieRect.Width;
            }

            float LastAngle = 0;

            foreach (Lbl.Charts.Element El in Serie.Elements)
            {
                float ElementAngle = (float)(El.Value / Sum * 360);

                Canvas.FillPie(System.Drawing.Brushes.Tomato, PieRect, LastAngle, LastAngle + ElementAngle);
                LastAngle += ElementAngle;
            }

            LastAngle = 0;
            foreach (Lbl.Charts.Element El in Serie.Elements)
            {
                float ElementAngle = (float)(El.Value / Sum * 360);

                Canvas.DrawPie(System.Drawing.Pens.Black, PieRect, LastAngle, LastAngle + ElementAngle);
                LastAngle += ElementAngle;
            }
        }
 private void RenderLeft(Graphics g, int x, int y)
 {
     g.FillPie(m_brChar, GetRect(x, y), 180 + Degrees / 2, 360 - Degrees);
 }
 public void RenderRight(Graphics g, int x, int y)
 {
     g.FillPie(m_brChar, GetRect(x, y), Degrees / 2, 360 - Degrees);
 }
 public void DrawHover(Graphics graphics, Rectangle bounds, double hoverDone)
 {
     int x =  bounds.X + (bounds.Width / 2);
     int y =  bounds.Y + (bounds.Height / 2);
     if (mFill) {
         using (Brush b = new SolidBrush(mHoverColour))
             graphics.FillPie(b, x - mR, y - mR, mR * 2, mR * 2, -90, (int)(hoverDone * 360f));
     } else
         using (Pen p = new Pen(mHoverColour))
             graphics.DrawPie(p, x - mR, y - mR, mR * 2, mR * 2, -90, (int)(hoverDone * 360f));
 }
Beispiel #31
0
 /// <summary>
 /// ���ݻ�����ռ�ٷֱȻ���ͼ
 /// </summary>
 /// <param name="objgraphics">Graphics�����</param>
 /// <param name="M_str_sqlstr">SQL���</param>
 /// <param name="M_str_table">����</param>
 /// <param name="M_str_Num">���ݱ��л�����</param>
 /// <param name="M_str_tbGName">���ݱ��л�������</param>
 /// <param name="M_str_title">��ͼ����</param>
 public void drawPic(Graphics objgraphics, string M_str_sqlstr, string M_str_table, string M_str_Num, string M_str_tbGName, string M_str_title)
 {
     DataSet myds = PartParameter.QueryPartPara(M_str_sqlstr);
     float M_flt_total = 0.0f, M_flt_tmp;
     int M_int_iloop;
     for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
     {
         M_flt_tmp = Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]);
         M_flt_total += M_flt_tmp;
     }
     Font fontlegend = new Font("verdana", 9), fonttitle = new Font("verdana", 10, FontStyle.Bold);//��������
     int M_int_width = 275;//��ɫ������
     const int Mc_int_bufferspace = 15;
     int M_int_legendheight = fontlegend.Height * (myds.Tables[0].Rows.Count + 1) + Mc_int_bufferspace;
     int M_int_titleheight = fonttitle.Height + Mc_int_bufferspace;
     int M_int_height = M_int_width + M_int_legendheight + M_int_titleheight + Mc_int_bufferspace;//��ɫ������
     int M_int_pieheight = M_int_width;
     Rectangle pierect = new Rectangle(0, M_int_titleheight, M_int_width, M_int_pieheight);
     //���ϸ������ɫ
     Bitmap objbitmap = new Bitmap(M_int_width, M_int_height);//����һ��bitmapʵ��
     objgraphics = Graphics.FromImage(objbitmap);
     ArrayList colors = new ArrayList();
     Random rnd = new Random();
     for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
         colors.Add(new SolidBrush(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))));
     objgraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, M_int_width, M_int_height);//��һ����ɫ����
     objgraphics.FillRectangle(new SolidBrush(Color.LightYellow), pierect);//��һ������ɫ����
     //����Ϊ����ͼ(�м���row������)
     float M_flt_currentdegree = 0.0f;
     for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
     {
         objgraphics.FillPie((SolidBrush)colors[M_int_iloop], pierect, M_flt_currentdegree,
           Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360);
         M_flt_currentdegree += Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360;
     }
     //��������������
     SolidBrush blackbrush = new SolidBrush(Color.Black);
     StringFormat stringFormat = new StringFormat();
     stringFormat.Alignment = StringAlignment.Center;
     stringFormat.LineAlignment = StringAlignment.Center;
     objgraphics.DrawString(M_str_title, fonttitle, blackbrush, new Rectangle(0, 0, M_int_width, M_int_titleheight), stringFormat);
     objgraphics.DrawRectangle(new Pen(Color.Black, 2), 0, M_int_height - M_int_legendheight, M_int_width, M_int_legendheight);
     for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
     {
         objgraphics.FillRectangle((SolidBrush)colors[M_int_iloop], 5, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 5, 10, 10);
         objgraphics.DrawString(((String)myds.Tables[0].Rows[M_int_iloop][M_str_tbGName]) + " ���� "
             + Convert.ToString(Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) * 100 / M_flt_total) + "%", fontlegend, blackbrush,
         20, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 1);
     }
     objgraphics.DrawString("�ܻ������ǣ�" + Convert.ToString(M_flt_total), fontlegend, blackbrush, 5, M_int_height - fontlegend.Height);
     string P_str_imagePath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,
         Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
     P_str_imagePath += @"\Image\image\" + DateTime.Now.ToString("yyyyMMddhhmss") + ".jpg";
     objbitmap.Save(P_str_imagePath, ImageFormat.Jpeg);
     objgraphics.Dispose();
     objbitmap.Dispose();
 }
        /// <summary>
        /// Reload radar image
        /// </summary>
        /// <param name="sender">object sender</param>
        /// <param name="e">Event args</param>
        public void ReloadRadar(object sender, EventArgs e)
        {
            G = Graphics.FromImage(Bmp);

            DrawRadarBody();

            //we have shadow with 8 lines
            _shadowArray.Add(new Point(_refresherX, _refresherY));

            int i = _shadowArray.Count - 1;
            //draw Shadow
            foreach (var point in _shadowArray)
            {
                //first line is for landscape
                if (point == _shadowArray.First())
                {
                    i--;
                    continue;
                }

                var color = ColorTranslator.FromHtml(Constans.SHADOW_COLORS[i]);

                //    G.DrawLine(pen, new Point(_centerX, _centerY), point);
                G.FillPie(new SolidBrush(color), new Rectangle(_offset, _offset, Constans.RADAR_WIDTH, Constans.RADAR_HEIGHT), _currentDegree - 90 - i, 1f);
                i--;
            }

            if (_shadowArray.Count == 9)
            {
                var needToEraseLinePoint = _shadowArray.First();

                //Eraser line
                G.FillPie(new SolidBrush(_clearPen.Color), new Rectangle(_offset-6, _offset-6, Constans.RADAR_WIDTH+12, Constans.RADAR_HEIGHT+12), _currentDegree - 90 - 8 + 0.5f, 1f);
                //landscape filter
                G.DrawLine(_clearPen, _centerX, _centerY, needToEraseLinePoint.X, needToEraseLinePoint.Y);

                _shadowArray.Remove(needToEraseLinePoint);

                //draw landscape
                if (_currentDegree - 9 >= 0)
                    DrawLandscape(_currentDegree - 9, needToEraseLinePoint);
                else
                    DrawLandscape(_currentDegree + 9, needToEraseLinePoint);

                //draw targets
                foreach (var target in Targets)
                {
                    if (LineIntersectsTarget(new Point(_centerX, _centerY),
                        new Point(needToEraseLinePoint.X, needToEraseLinePoint.Y), target.TargetZone))
                    {
                        target.IsDetected = true;

                        if (Math.Abs(target.Distance) > 0.01 & (target.Distance - GetDistanse(new Point(_centerX, _centerY), new Point(target.X, target.Y))) > 0.01)
                        {
                            var speed = (target.Distance -
                                         GetDistanse(new Point(_centerX, _centerY), new Point(target.X, target.Y))) * Constans.RADAR_FREQUENCY;
                            target.Speed = speed;
                        }

                        target.Distance = GetDistanse(new Point(_centerX, _centerY), new Point(target.X, target.Y));
                        target.Angle = Convert.ToInt32(GetAngle(new Point(target.X, target.Y)));

                        var color = Color.FromArgb(target.TargetColor.A, target.TargetColor.R, target.TargetColor.G,
                            target.TargetColor.B);

                        G.FillRectangle(new SolidBrush(color), target.TargetZone);

                        //if (target.Angle >= 0 & target.Angle < 90)
                        //{
                        //    G.DrawString(target.Angle + "*", new Font("Arial", 8), new SolidBrush(color),
                        //        target.X - 10, target.Y - 10);
                        //}
                        //else if (target.Angle >= 90 & target.Angle < 180)
                        //{
                        //    G.DrawString(target.Angle + "*", new Font("Arial", 8), new SolidBrush(color),
                        //       target.X + 10, target.Y - 10);
                        //}
                        //else if (target.Angle >= 180 & target.Angle < 270)
                        //{
                        //    G.DrawString(target.Angle + "*", new Font("Arial", 8), new SolidBrush(color),
                        //      target.X + 10, target.Y + 10);
                        //}
                        //else
                        //{
                        //    G.DrawString(target.Angle + "*", new Font("Arial", 8), new SolidBrush(color),
                        //      target.X - 10, target.Y + 10);
                        //}

                    }

                }

            }

            //draw HAND
            //G.DrawLine(Constans.REFRESHER_PEN, new Point(_centerX, _centerY), new Point(_refresherX, _refresherY));
            G.FillPie(new SolidBrush(Constans.REFRESHER_PEN.Color), new Rectangle(_offset, _offset, Constans.RADAR_WIDTH, Constans.RADAR_HEIGHT), _currentDegree - 90, 1);

            //load bitmap in picturebox1
            ImageBox.Source = BitmapToImageSource(Bmp);

            //dispose
            G.Dispose();

            //update
            if (IsReverted)
            {
                _currentDegree--;
                if (_currentDegree == 0)
                {
                    _currentDegree = 360;
                }
            }
            else
            {
                _currentDegree++;
                if (_currentDegree == 360)
                {
                    _currentDegree = 0;
                }
            }
        }
        private void DrawOne(Graphics g, int xmin, int xmax, int ymin, int ymax)
        {
            var shape = Shape.Arc;
            var color = new Color();
            var randomValue = RandomProvider.RandomGenerator.NextDouble();
            foreach (var probabilitiesOfShape in ProbabilitiesOfShapes)
            {
                if (randomValue < probabilitiesOfShape.Probability)
                {
                    shape = probabilitiesOfShape.Value;
                    break;
                }
            }

            randomValue = RandomProvider.RandomGenerator.NextDouble();

            foreach (var colorProbabilityPair in colorsCDFs)
            {
                if (randomValue < colorProbabilityPair.probability)
                {
                    color = colorProbabilityPair.color;
                    break;
                }
            }

            var pen = new Pen(color);

            var x1 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
            var y1 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);

            var x2 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
            var y2 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);

            var x3 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
            var y3 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);

            var x4 = RandomProvider.RandomGenerator.Next(xmin, xmax + 1);
            var y4 = RandomProvider.RandomGenerator.Next(ymin, ymax + 1);

            var w1 = RandomProvider.RandomGenerator.Next(x1, xmax + 1);
            var h1 = RandomProvider.RandomGenerator.Next(y1, ymax + 1);

            var angle1 = RandomProvider.RandomGenerator.Next(0, 360);

            switch (shape)
            {
                case Shape.Arc:
                    g.DrawArc(pen, x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
                        RandomProvider.RandomGenerator.Next(0, 360));
                    break;
                case Shape.Bezier:
                    g.DrawBezier(pen, x1, y1, x2, y2, x3, y3, x4, y4);
                    break;
                case Shape.ClosedCurve:
                    g.DrawClosedCurve(pen,
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.Curve:
                    g.DrawCurve(pen,
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.Ellipse:
                    g.DrawEllipse(pen, x1, y1, w1, h1);
                    break;
                case Shape.Line:
                    g.DrawLine(pen, x1, y1, x2, y2);
                    break;
                case Shape.Lines:
                    g.DrawLines(pen,
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.Pie:
                    g.DrawPie(pen, x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
                        RandomProvider.RandomGenerator.Next(0, 360));
                    break;
                case Shape.Polygon:
                    g.DrawPolygon(pen,
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.Rectangle:
                    g.DrawRectangle(pen, x1, y1, w1, h1);
                    break;
                case Shape.String:
                    g.DrawString(EnglishWordsDictionary.GetRandomWord(),
                        new Font("Cambria", RandomProvider.RandomGenerator.Next(1, 50)), new SolidBrush(color),
                        new PointF(x1, y1));
                    break;
                case Shape.FillClosedCurve:
                    g.FillClosedCurve(new SolidBrush(color),
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.FillEllipse:
                    g.FillEllipse(new SolidBrush(color), x1, y1, w1, h1);
                    break;
                case Shape.FillPie:
                    g.FillPie(new SolidBrush(color), x1, y1, w1, h1, RandomProvider.RandomGenerator.Next(0, 360),
                        RandomProvider.RandomGenerator.Next(0, 360));
                    break;
                case Shape.FillPolygon:
                    g.FillPolygon(new SolidBrush(color),
                        new[] {new PointF(x1, y1), new PointF(x2, y2), new PointF(x3, y3), new PointF(x4, y4)});
                    break;
                case Shape.FillRectangle:
                    g.FillRectangle(new SolidBrush(color), x1, y1, w1, h1);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            // g.Save();
        }
Beispiel #34
0
 public void Cerc_interior(System.Drawing.Graphics Zona_desenare, System.Drawing.SolidBrush Pensula_fond, int x1, int y1, int diametrul, int unghi_start)
 {
     Zona_desenare.FillPie(Pensula_fond, x1, y1, diametrul, diametrul, unghi_start, 140);
 }
Beispiel #35
0
		// renders a radio button with the Flat and Popup FlatStyle
		protected virtual void DrawFlatStyleRadioButton (Graphics graphics, Rectangle rectangle, RadioButton radio_button)
		{
			int	lineWidth;
			
			if (radio_button.Enabled) {
				
				// draw the outer flatstyle arcs
				if (radio_button.FlatStyle == FlatStyle.Flat) {
					graphics.DrawArc (SystemPens.ControlDarkDark, rectangle, 0, 359);
					
					// fill in the area depending on whether or not the mouse is hovering
					if ((radio_button.is_entered || radio_button.Capture) && !radio_button.is_pressed) {
						graphics.FillPie (SystemBrushes.ControlLight, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
					} else {
						graphics.FillPie (SystemBrushes.ControlLightLight, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
					}
				} else {
					// must be a popup radio button
					// fill the control
					graphics.FillPie (SystemBrushes.ControlLightLight, rectangle, 0, 359);

					if (radio_button.is_entered || radio_button.Capture) {
						// draw the popup 3d button knob
						graphics.DrawArc (SystemPens.ControlLight, rectangle.X+1, rectangle.Y+1, rectangle.Width-2, rectangle.Height-2, 0, 359);

						graphics.DrawArc (SystemPens.ControlDark, rectangle, 135, 180);
						graphics.DrawArc (SystemPens.ControlLightLight, rectangle, 315, 180);
						
					} else {
						// just draw lighter flatstyle outer circle
						graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);						
					}										
				}
			} else {
				// disabled
				// fill control background color regardless of actual backcolor
				graphics.FillPie (SystemBrushes.Control, rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2, 0, 359);
				// draw the ark as control dark
				graphics.DrawArc (SystemPens.ControlDark, rectangle, 0, 359);
			}

			// draw the check
			if (radio_button.Checked) {
				lineWidth = Math.Max (1, Math.Min(rectangle.Width, rectangle.Height)/3);
				
				Pen dot_pen = SystemPens.ControlDarkDark;
				Brush dot_brush = SystemBrushes.ControlDarkDark;

				if (!radio_button.Enabled || ((radio_button.FlatStyle == FlatStyle.Popup) && radio_button.is_pressed)) {
					dot_pen = SystemPens.ControlDark;
					dot_brush = SystemBrushes.ControlDark;
				} 
				
				if (rectangle.Height >  13) {
					graphics.FillPie (dot_brush, rectangle.X + lineWidth, rectangle.Y + lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height - lineWidth * 2, 0, 359);
				} else {
					int x_half_pos = (rectangle.Width / 2) + rectangle.X;
					int y_half_pos = (rectangle.Height / 2) + rectangle.Y;
					
					graphics.DrawLine (dot_pen, x_half_pos - 1, y_half_pos, x_half_pos + 2, y_half_pos);
					graphics.DrawLine (dot_pen, x_half_pos - 1, y_half_pos + 1, x_half_pos + 2, y_half_pos + 1);
					
					graphics.DrawLine (dot_pen, x_half_pos, y_half_pos - 1, x_half_pos, y_half_pos + 2);
					graphics.DrawLine (dot_pen, x_half_pos + 1, y_half_pos - 1, x_half_pos + 1, y_half_pos + 2);
				}
			}
		}
Beispiel #36
0
		// draws one day in the calendar grid
		private void DrawMonthCalendarDate (Graphics dc, Rectangle rectangle, MonthCalendar mc,	DateTime date, DateTime month, int row, int col) {
			Color date_color = mc.ForeColor;
			Rectangle interior = new Rectangle (rectangle.X, rectangle.Y, Math.Max(rectangle.Width - 1, 0), Math.Max(rectangle.Height - 1, 0));

			// find out if we are the lead of the first calendar or the trail of the last calendar						
			if (date.Year != month.Year || date.Month != month.Month) {
				DateTime check_date = month.AddMonths (-1);
				// check if it's the month before 
				if (check_date.Year == date.Year && check_date.Month == date.Month && row == 0 && col == 0) {
					date_color = mc.TrailingForeColor;
				} else {
					// check if it's the month after
					check_date = month.AddMonths (1);
					if (check_date.Year == date.Year && check_date.Month == date.Month && row == mc.CalendarDimensions.Height-1 && col == mc.CalendarDimensions.Width-1) {
						date_color = mc.TrailingForeColor;
					} else {
						return;
					}
				}
			} else {
				date_color = mc.ForeColor;
			}

			const int inflate = -1;

			if (date == mc.SelectionStart.Date && date == mc.SelectionEnd.Date) {
				// see if the date is in the start of selection
				date_color = mc.BackColor;
				// draw the left hand of the back ground
				Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);				
				dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 0, 360);
			} else if (date == mc.SelectionStart.Date) {
				// see if the date is in the start of selection
				date_color = mc.BackColor;
				// draw the left hand of the back ground
				Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);				
				dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 90, 180);
				// fill the other side as a straight rect
				if (date < mc.SelectionEnd.Date) 
				{
					// use rectangle instead of rectangle to go all the way to edge of rect
					selection_rect.X = (int) Math.Floor((double)(rectangle.X + rectangle.Width / 2));
					selection_rect.Width = Math.Max(rectangle.Right - selection_rect.X, 0);
					dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
				}
			} else if (date == mc.SelectionEnd.Date) {
				// see if it is the end of selection
				date_color = mc.BackColor;
				// draw the left hand of the back ground
				Rectangle selection_rect = Rectangle.Inflate (rectangle, inflate, inflate);
				dc.FillPie (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect, 270, 180);
				// fill the other side as a straight rect
				if (date > mc.SelectionStart.Date) {
					selection_rect.X = rectangle.X;
					selection_rect.Width = rectangle.Width - (rectangle.Width / 2);
					dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
				}
			} else if (date > mc.SelectionStart.Date && date < mc.SelectionEnd.Date) {
				// now see if it's in the middle
				date_color = mc.BackColor;
				// draw the left hand of the back ground
				Rectangle selection_rect = Rectangle.Inflate (rectangle, 0, inflate);
				dc.FillRectangle (ResPool.GetSolidBrush (mc.TitleBackColor), selection_rect);
			}

			// establish if it's a bolded font
			Font font = mc.IsBoldedDate (date) ? mc.bold_font : mc.Font;

			// just draw the date now
			dc.DrawString (date.Day.ToString(), font, ResPool.GetSolidBrush (date_color), rectangle, mc.centered_format);

			// today circle if needed
			if (mc.ShowTodayCircle && date == DateTime.Now.Date) {
				DrawTodayCircle (dc, interior);
			}

			// draw the selection grid
			if (mc.is_date_clicked && mc.clicked_date == date) {
				Pen pen = ResPool.GetDashPen (Color.Black, DashStyle.Dot);
				dc.DrawRectangle (pen, interior);
			}
		}
Beispiel #37
0
 public override void Draw(System.Drawing.Graphics g)
 {
     g.FillPie(Brushes.Blue, new Rectangle((int)Position.x - GRADIUS / 2, (int)Position.y - GRADIUS / 2, GRADIUS, GRADIUS), 0, 360);
 }
Beispiel #38
0
 public void Umple_cerc(System.Drawing.Graphics Zona_desenare, System.Drawing.SolidBrush Pensula_neagra, int x, int y, int latime, int inaltime, int Unghi_start, int Unghi_final)
 {
     Zona_desenare.FillPie(Pensula_neagra, x, y, latime, inaltime, Unghi_start, Unghi_final);
 }
Beispiel #39
0
        private float DrawPip(Graphics g, Color col, RectangleF rect, int type,
            int idx, int numChildren, float startSeg, float segWidth, string text)
        {
            var subRect = GetSubrect(rect, startSeg, segWidth);
            subRect.X += pipRadius;
            subRect.Y += pipPaddingY;
            subRect.Width -= pipRadius * 2;
            subRect.Height = pipRadius * 2;

            float delta = (float)(idx + 1) / (float)(numChildren + 1);

            float x = subRect.X - pipRadius + delta * Math.Max(0, subRect.Width);

            float y = subRect.Y;
            float width = pipRadius * 2;
            float height = pipRadius * 2;

            if (type == 0)
            {
                using(var brush = new SolidBrush(col))
                    g.FillPie(brush, x, y, width, height, 0.0f, 360.0f);
            }
            else if(type < 999)
            {
                height += 2;
                width += 4;
                x -= 2;

                PointF[] uptri = { new PointF(x, y+height-2),
                                      new PointF(x+width, y+height-2),
                                      new PointF(x+width/2.0f, y+2) };

                bool update = true;

                if (type > 2)
                {
                    if (type == 3)
                    {
                        uptri[1] = new PointF(x + width / 2.0f, y + height - 2);
                        update = false;
                        type = 1;
                    }
                    if (type == 4)
                    {
                        uptri[0] = new PointF(x + width / 2.0f, y + height - 2);
                        type = 1;
                    }
                    if (type == 5)
                    {
                        update = false;
                        type = 1;
                    }
                    if (type == 6)
                    {
                        update = false;
                        type = 2;
                    }
                }

                if (x - lastPipX[type] > pipRadius*2.0f)
                {
                    if (type == 2)
                    {
                        using (var pen = new Pen(col, 2))
                            g.DrawPolygon(pen, uptri);
                    }
                    else
                    {
                        using (var brush = new SolidBrush(col))
                            g.FillPolygon(brush, uptri);
                    }

                    if(update)
                        lastPipX[type] = x;
                }
            }

            return x + width / 2;
        }
Beispiel #40
0
 public void fillArc(float x, float y, float width, float height, float startAngle, float arcAngle)
 {
     dg.FillPie(pen.Brush, x, y, width, height, startAngle, arcAngle);
 }
Beispiel #41
0
        private void DrawPie(PagePie pp, Graphics g, RectangleF r)
        {
            StyleInfo si = pp.SI;
            if (!si.BackgroundColor.IsEmpty)
            {
                g.FillPie(new SolidBrush(si.BackgroundColor), (int)r.X, (int)r.Y, (int)r.Width, (int)r.Height, (float)pp.StartAngle, (float)pp.SweepAngle);
            }

            if (si.BStyleTop != BorderStyleEnum.None)
            {
                Pen p = new Pen(si.BColorTop, si.BWidthTop);
                switch (si.BStyleTop)
                {
                    case BorderStyleEnum.Dashed:
                        p.DashStyle = DashStyle.Dash;
                        break;
                    case BorderStyleEnum.Dotted:
                        p.DashStyle = DashStyle.Dot;
                        break;
                    case BorderStyleEnum.Double:
                    case BorderStyleEnum.Groove:
                    case BorderStyleEnum.Inset:
                    case BorderStyleEnum.Solid:
                    case BorderStyleEnum.Outset:
                    case BorderStyleEnum.Ridge:
                    case BorderStyleEnum.WindowInset:
                    default:
                        p.DashStyle = DashStyle.Solid;
                        break;
                }
                g.DrawPie(p, r, pp.StartAngle, pp.SweepAngle);
            }
        }
Beispiel #42
0
    private void CalculateWheel()
    {
        List <PointF> points;
        List <System.Drawing.Color> colors;

        points = new List <PointF>();
        colors = new List <System.Drawing.Color>();

        PointF centerPoint;
        float  radius;

        if (imageWidth > 16 && imageHeight > 16)
        {
            int w = imageWidth;
            int h = imageHeight;

            centerPoint = new PointF(w / 2.0f, h / 2.0f);
            radius      = GetRadius(centerPoint);

            for (double angle = 0; angle < 360; angle += colorStep)
            {
                double angleR;
                PointF location;
                angleR   = angle * (System.Math.PI / 180f);
                location = GetColorLocation(centerPoint, angleR, radius);

                points.Add(location);

                colors.Add(new HslColor(angle + 240, s, l).ToRgbColor());
                //colors.Add(ColorFromHSL(angle, s, l));
            }
        }
        else
        {
            return;
        }

        Brush result;

        if (points.Count != 0 && points.Count == colors.Count)
        {
            result = new System.Drawing.Drawing2D.PathGradientBrush(points.ToArray(), System.Drawing.Drawing2D.WrapMode.Clamp)
            {
                CenterPoint    = centerPoint,
                CenterColor    = System.Drawing.Color.White,
                SurroundColors = colors.ToArray(),
            };
        }
        else
        {
            result = null;
        }

        if (result == null)
        {
            return;
        }

        Image image;
        int   halfSize;

        halfSize = imageWidth / 2;
        image    = new Bitmap(imageWidth + 2, imageWidth + 2);

        System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image);
        graphics.FillPie(result, new Rectangle(0, 0, imageWidth, imageHeight), 0, 360);

        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        //using (Pen pen = new Pen(System.Drawing.Color.Black, 2))
        //{
        //    graphics.DrawEllipse(pen, new RectangleF(centerPoint.X - radius, centerPoint.Y - radius, radius * 2, radius * 2));
        //}

        Texture2D texture = new Texture2D(imageWidth + 2, imageHeight + 2, TextureFormat.RGBA32, false);

        texture.LoadRawTextureData(imageToByteArray(image));
        texture.Apply();
        colorPickerImage.sprite = Sprite.Create(texture, new Rect(0, 0, imageWidth + 2, imageHeight + 2), Vector2.one);
    }