DrawPie() public method

public DrawPie ( Pen pen, Rectangle rect, float startAngle, float sweepAngle ) : void
pen Pen
rect Rectangle
startAngle float
sweepAngle float
return void
Esempio n. 1
0
 private void buttonPie_Click(object sender, System.EventArgs e)
 {
     ReloadImage();
     System.Drawing.Graphics g = imageXView1.Image.GetGraphics();
     g.DrawPie(System.Drawing.Pens.Honeydew, 0, 0, 50, 50, 50, 270);
     imageXView1.Image.ReleaseGraphics(true);
 }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            //设置返回类型
            context.Response.ContentType = "image/jpeg";

            //创建一幅图片
            using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(80, 37))
            {
                //创建画布
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
                {
                    //定义画的字符
                    Random rand    = new Random();
                    int    code    = rand.Next();
                    string codeStr = code.ToString().Substring(0, 4);
                    //此处要这样把值保存到session中,还要记得要继承IRequiresSessionState接口
                    HttpContext.Current.Session["code"] = codeStr;

                    Point pt = new Point(0, 0);
                    //将字符画到画布上
                    g.DrawString(codeStr, new System.Drawing.Font("楷书", 20), System.Drawing.Brushes.Red, pt);

                    Pen       p   = new Pen(Brushes.Red, 3);
                    Rectangle rec = new Rectangle(0, 0, 30, 20);
                    g.DrawPie(p, rec, 360, 360);

                    //将图片以指定格式保存到输出流中
                    bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                }
            }
        }
Esempio n. 3
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);
     }
 }
Esempio n. 4
0
 public void Render(Graphics graphics)
 {
     graphics.DrawPie(
         _pen,
         _rectangle,
         _startAngle,
         _endAngle);
 }
Esempio n. 5
0
        private void button6_Click(object sender, EventArgs e)
        {
            //Tort

            pictureBox1.Refresh();

            Pen purplePen = new Pen(Color.Purple, 3);

            Rectangle rectN = new Rectangle(0, 0, 160, 180);

            g.DrawPie(purplePen, rectN, 20, 50);
        }
Esempio n. 6
0
        private void butPie_Click(object sender, EventArgs e)
        {
            g = PictureBox1.CreateGraphics();
            int x      = 290;
            int y      = 70;
            int width  = 200;
            int height = 100;

            int startAngle = 0;
            int sweepAngle = 45;

            g.DrawPie(penGreen, x, y, width, height, startAngle, sweepAngle);
        }
Esempio n. 7
0
 void dataRcvd_Received(object serder, Event.dataRcvdEventArgs data)
 {
     double alpha = fft1.get_now_alpha(data.data, data.length, 27);
     double beta = fft1.get_now_beta(data.data, data.length, 27);
     if (alpha <= data.total_alpha && beta <= data.total_beta)
     {
         last_point = now_point;
         now_point.X = (int)(alpha * this.Width / data.total_alpha);
         now_point.Y = (int)(this.Width - beta * this.Width / data.total_beta);
     }
     g = panel1.CreateGraphics();
     g.DrawPie(new Pen(Color.Red), now_point.X - 5, now_point.Y - 5, 10, 10, 0, 360);
     g.DrawLine(new Pen(Color.Cyan), last_point, now_point);
 }
Esempio n. 8
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;
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
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();
            }
        }
Esempio n. 12
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;
            }
        }
Esempio n. 13
0
 private void btnPie_Click(object sender, EventArgs e)
 {
     g = pictureBox1.CreateGraphics();
     g.DrawPie(penRed, 200, 50, 50, 75, 30F, 180F);
 }
Esempio n. 14
0
 private void DrawPie(Graphics g)
 {
     g.SmoothingMode = SmoothingMode.AntiAlias;
     g.DrawPie(new Pen(outlineBrush, 30), x + this.ClientRectangle.Width/16 ,y + this.ClientRectangle.Height/16 , (this.ClientRectangle.Width -this.ClientRectangle.Width/8),((this.ClientRectangle.Height * 2)-this.ClientRectangle.Height/4), 0, -180);
 }
Esempio n. 15
0
 public new void RePain(float Dlg, float Dlv, bool Fill, float k, Graphics G)
 {
     if (TypeShape == Nows.Ellip)
     {
         if (Fill) G.FillEllipse(new SolidBrush(Col), (Xn - Dlg) * k, (Yn - Dlv) * k, Width * k, Height * k);
         G.DrawEllipse(new Pen(BorderCol, BorderWidth), (Xn - Dlg) * k, (Yn - Dlv) * k, Width * k, Height * k);
     }
     else
     {
         if (Fill) G.FillPie(new SolidBrush(Col), (Xn - Dlg) * k, (Yn - Dlv ) * k, Width * k, Height * k, startAngle, sweepAngle);
         G.DrawPie(new Pen(BorderCol, BorderWidth), (Xn - Dlg) * k, (Yn - Dlv) * k, Width * k, Height * k, startAngle, sweepAngle);
     }
 }
Esempio n. 16
0
        /*public void AddLabel(string str)
        {
            labelList.Clear();
            labelList.Add(str);
        }

        public void AddExplode(int nOffset)
        {
            explodeList.Clear();
            explodeList.Add(nOffset);
        }*/
        public void AddPie(Graphics g, ChartStyle cs)
        {
            SolidBrush aBrush = new SolidBrush(Color.Black);
            Pen aPen = new Pen(BorderColor);
            int nData = DataList.Count;
            float fSum = 0;
            for (int i = 0; i < nData; i++)
            {
                fSum = fSum + (float)DataList[i];
            }
            float startAngle = 0;
            float sweepAngle = 0;
            Rectangle rect = cs.SetPieArea();

            for (int i = 0; i < nData; i++)
            {
                Color fillColor = Color.FromArgb(CMap[i, 0], CMap[i, 1],
                    CMap[i, 2], CMap[i, 3]);
                aBrush = new SolidBrush(fillColor);
                int explode = (int)ExplodeList[i];

                if (fSum < 1)
                {
                    startAngle = startAngle + sweepAngle;
                    sweepAngle = 360 * (float)DataList[i];
                }
                else if (fSum >= 1)
                {
                    startAngle = startAngle + sweepAngle;
                    sweepAngle = 360 * (float)DataList[i] / fSum;

                }

                int xshift = (int)(explode * Math.Cos((startAngle +
                    sweepAngle / 2) * Math.PI / 180));
                int yshift = (int)(explode * Math.Sin((startAngle +
                    sweepAngle / 2) * Math.PI / 180));
                Rectangle rect1 = new Rectangle(rect.X + xshift, rect.Y + yshift,
                    rect.Width, rect.Height);
                g.FillPie(aBrush, rect1, startAngle, sweepAngle);
                g.DrawPie(aPen, rect1, startAngle, sweepAngle);
            }
        }
Esempio n. 17
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     if (fill)
         g.FillPie(BrushWhenCxt(dcxt).Brush, dcxt.X_V2S(x-w/2), dcxt.Y_V2S(y-h/2), dcxt.W_V2S(w), dcxt.W_V2S(h), startagl, sweepagl);
     else
         g.DrawPie(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x - w / 2), dcxt.Y_V2S(y - h / 2), dcxt.W_V2S(w), dcxt.W_V2S(h), startagl, sweepagl);
 }
Esempio n. 18
0
 private void DrawChessShadow(Graphics g, Rectangle r)
 {
     if (panelBoard.Cursor != Cursors.Hand)
     {
         return;
     }
     if (m_ShadowChessX == -1 || m_ShadowChessY == -1)
     {
         return;
     }
     int radius = 18 - 2;
     Point p = CalculateChessLocation(m_ShadowChessX, m_ShadowChessY);
     g.DrawPie(new Pen(Color.Blue), p.X - radius, p.Y - radius, 2*radius +1, 2 *radius +1, 0, 360);
 }
Esempio n. 19
0
 /// <summary>
 ///   Draws the top of the pie slice.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> used to draw the pie slice.
 /// </param>
 internal void DrawTop(Graphics graphics) {
     graphics.FillPie(m_brushSurface, m_boundingRectangle.X, m_boundingRectangle.Y, m_boundingRectangle.Width, m_boundingRectangle.Height, m_startAngle, m_sweepAngle);
     graphics.DrawPie(m_pen, m_boundingRectangle, m_startAngle, m_sweepAngle);
 }
Esempio n. 20
0
        public override void Draw( Graphics g, GraphPane pane, int pos, float scaleFactor )
		{
			if ( pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0 )
			{
				_slicePath = null;
			}
			else
			{
				CalcRectangle( g, pane, scaleFactor, pane.Chart._rect );

				_slicePath = new GraphicsPath();

				if ( !_isVisible )
					return;

				RectangleF tRect = _boundingRectangle;

				if ( tRect.Width >= 1 && tRect.Height >= 1 )
				{
					SmoothingMode sMode = g.SmoothingMode;
					g.SmoothingMode = SmoothingMode.AntiAlias;

					_slicePath.AddPie( tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle );

					float avgAngle = 90 - ((SweepAngle/2) + StartAngle);
					RectangleF gradientrect = new RectangleF(tRect.X-10, tRect.Y-10, tRect.Width+20, tRect.Height+20);

                    using (LinearGradientBrush linearBrush = new LinearGradientBrush(gradientrect, RegionColorStart, RegionColorEnd, avgAngle))
                    {
                        using (Pen regionPen = new Pen(linearBrush, pane.GasGaugeRegionWidth))
                        {
                            g.DrawArc(regionPen, tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle);
                        }
                    }
					
					if ( this.Border.IsVisible )
					{
                        using (Pen borderPen = _border.GetPen(pane, scaleFactor))
                        {
                            g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle);
                        }
					}
					
					//draw labels for the region limits
                    if (pane.HasLabel || HasLabel)
                    {
                        double absmax = 0;
                        double absmin = MinValue;
                        foreach (object gg in pane.CurveList)
                        {
                            if (gg is GasGaugeRegion)
                            {
                                GasGaugeRegion ggr = (GasGaugeRegion)gg;
                                if (absmax < ggr.MaxValue)
                                    absmax = ggr.MaxValue;
                                if (absmin > ggr.MinValue)
                                    absmin = ggr.MinValue;
                            }
                        }

                        DrawLabelValue(pane, (StartAngle + SweepAngle), ref m_LabelMin, MinValue);
                        DrawLabelValue(pane, StartAngle, ref m_LabelMax, MaxValue);
                    }
                    else
                    {
                        if (m_LabelMin != null)
                            m_LabelMin.IsVisible = false;
                        if (m_LabelMax != null)
                            m_LabelMax.IsVisible = false;
                    }

					g.SmoothingMode = sMode;
				}
			}
		}
Esempio n. 21
0
 public static void DrawPie(Graphics g, DiagramView view, System.Drawing.Pen pen, System.Drawing.Brush brush, float x, float y, float width, float height, float startangle, float sweepangle)
 {
     if (brush != null)
     {
         g.FillPie(brush, x, y, width, height, startangle, sweepangle);
     }
     if (pen != null)
     {
         g.DrawPie(pen, x, y, width, height, startangle, sweepangle);
     }
 }
Esempio n. 22
0
 /// <summary>
 /// draw the coordinate system
 /// </summary>
 /// <param name="graphics">form graphic</param>
 /// <param name="pen">pen used to draw line in pictureBox</param>
 /// <param name="matrix4">Matrix used to transform 3d to 2d 
 /// and make picture in right scale </param>
 public override void Draw2D(Graphics graphics, Pen pen, Matrix4 matrix4)
 {
     graphics.Transform = new System.Drawing.Drawing2D.Matrix(
         1, 0, 0, 1, 0, 0);
     //draw X axis
     graphics.DrawLine(pen, new Point(20, 280), new Point(400, 280));
     graphics.DrawPie(pen, 400, 265, 30, 30, 165, 30);
     //draw Y axis
     graphics.DrawLine(pen, new Point(20, 280), new Point(20, 50));
     graphics.DrawPie(pen, 5, 20, 30, 30, 75, 30);
     //draw scale
     graphics.DrawLine(pen, new Point(120, 275), new Point(120, 285));
     graphics.DrawLine(pen, new Point(220, 275), new Point(220, 285));
     graphics.DrawLine(pen, new Point(320, 275), new Point(320, 285));
     graphics.DrawLine(pen, new Point(15, 80), new Point(25, 80));
     graphics.DrawLine(pen, new Point(15, 180), new Point(25, 180));
     //dimension
     Font font = new Font("Verdana", 10, FontStyle.Regular);
     graphics.DrawString("100'", font, Brushes.Blue, new PointF(122, 266));
     graphics.DrawString("200'", font, Brushes.Blue, new PointF(222, 266));
     graphics.DrawString("300'", font, Brushes.Blue, new PointF(322, 266));
     graphics.DrawString("100'", font, Brushes.Blue, new PointF(22, 181));
     graphics.DrawString("200'", font, Brushes.Blue, new PointF(22, 81));
     graphics.DrawString("(0,0)", font, Brushes.Blue, new PointF(10, 280));
 }
Esempio n. 23
0
        //##################################################################################

        public virtual void DrawClickCount(Graphics g, int count, int x, int y)
        {
            using (Pen pen = new Pen(Color.DarkBlue, 3.0f))
            {
                g.DrawPie(pen, x, y, 32.0f, 32.0f,
                    65.0f, count * 36.0f);
            }
        }
Esempio n. 24
0
 /// <summary>
 ///   Draws the bottom of the pie slice.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> used to draw the pie slice.
 /// </param>
 internal void DrawBottom(Graphics graphics)
 {
     graphics.FillPie(m_brushSurface, BoundingRectangle.X, BoundingRectangle.Y + SliceHeight,
         BoundingRectangle.Width, BoundingRectangle.Height, StartAngle, SweepAngle);
     graphics.DrawPie(m_pen, BoundingRectangle.X, BoundingRectangle.Y + SliceHeight, BoundingRectangle.Width,
         BoundingRectangle.Height, StartAngle, SweepAngle);
 }
Esempio n. 25
0
        /// <summary>
        /// Do all rendering associated with this <see cref="GasGaugeRegion"/> item to the specified
        /// <see cref="Graphics"/> device. This method is normally only
        /// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/>
        /// collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="pos">Not used for rendering GasGaugeNeedle</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects. This is calculated and
        /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>	
        public override void Draw(Graphics g, GraphPane pane, int pos, float scaleFactor)
        {
            if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0) {
                _slicePath = null;
            }
            else {
                CalcRectangle(g, pane, scaleFactor, pane.Chart._rect);

                _slicePath = new GraphicsPath();

                if (!_isVisible)
                    return;

                RectangleF tRect = _boundingRectangle;

                if (tRect.Width >= 1 && tRect.Height >= 1) {
                    SmoothingMode sMode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    _slicePath.AddPie(tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                      -0.0f, -180.0f);

                    g.FillPie(Fill.MakeBrush(_boundingRectangle), tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle);

                    if (this.Border.IsVisible) {
                        Pen borderPen = _border.GetPen(pane, scaleFactor);
                        g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                  -0.0f, -180.0f);
                        borderPen.Dispose();
                    }

                    g.SmoothingMode = sMode;
                }
            }
        }
Esempio n. 26
0
		/// <summary>
		/// Do all rendering associated with this <see cref="GasGaugeNeedle"/> item to the specified
		/// <see cref="Graphics"/> device. This method is normally only
		/// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/>
		/// collection object.
		/// </summary>
		/// <param name="g">
		/// A graphic device object to be drawn into. This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="pane">
		/// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="pos">Not used for rendering GasGaugeNeedle</param>
		/// <param name="scaleFactor">Not used for rendering GasGaugeNeedle</param>
		public override void Draw(Graphics g, GraphPane pane, int pos, float scaleFactor)
		{
			if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0) {
				_slicePath = null;
			}
			else {
				CalcRectangle(g, pane, scaleFactor, pane.Chart._rect);

				_slicePath = new GraphicsPath();

				if (!_isVisible)
					return;

				RectangleF tRect = _boundingRectangle;

				if (tRect.Width >= 1 && tRect.Height >= 1) {
					SmoothingMode sMode = g.SmoothingMode;
					g.SmoothingMode = SmoothingMode.AntiAlias;

					Matrix matrix = new Matrix();

					matrix.Translate(tRect.X + (tRect.Width/2), tRect.Y + (tRect.Height/2), MatrixOrder.Prepend);

					PointF[] pts = new PointF[2];
					pts[0] = new PointF(((tRect.Height*.10f)/2.0f)*(float) Math.Cos(-SweepAngle*Math.PI/180.0f),
					                    ((tRect.Height*.10f)/2.0f)*(float) Math.Sin(-SweepAngle*Math.PI/180.0f));
					pts[1] = new PointF((tRect.Width/2.0f)*(float) Math.Cos(-SweepAngle*Math.PI/180.0f),
					                    (tRect.Width/2.0f)*(float) Math.Sin(-SweepAngle*Math.PI/180.0f));

					matrix.TransformPoints(pts);

					Pen p = new Pen(NeedleColor, ((tRect.Height*.10f)/2.0f));
					p.EndCap = LineCap.ArrowAnchor;
					g.DrawLine(p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);

					//Fill center 10% with Black dot;
					Fill f = new Fill(Color.Black);
					RectangleF r = new RectangleF((tRect.X + (tRect.Width/2)) - 1.0f, (tRect.Y + (tRect.Height/2)) - 1.0f, 1.0f, 1.0f);
					r.Inflate((tRect.Height*.10f), (tRect.Height*.10f));
					Brush b = f.MakeBrush(r);
					g.FillPie(b, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f);

					Pen borderPen = new Pen(Color.White, 2.0f);
					g.DrawPie(borderPen, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f);

					g.SmoothingMode = sMode;
				}
			}
		}
Esempio n. 27
0
        /// <summary>
        /// Draws the radar to the screen.
        /// </summary>
		public void draw(Graphics g, CoordinateFrame frame)
        {
            Brush b = new SolidBrush(Color.Green);
            Size s = new Size((int)((MaxRange) / frame.Scale), (int)((MaxRange) / frame.Scale));

            if (Type == "directedVoiceNOTASENSOR") // Special drawing rules for this Type of sensor (used for showing communication)
            {   
                if (Activation < 0.1)
                {
                    s = new Size((int)((MaxRange * 1.0) / frame.Scale), (int)((MaxRange * 1.0) / frame.Scale));
                    b = new SolidBrush(Color.FromArgb((int)(0), 128, 128, 128));
                }
                else
                {
                    s = new Size((int)((MaxRange * Activation) / frame.Scale), (int)((MaxRange * Activation) / frame.Scale));
                    b = new SolidBrush(Color.FromArgb((int)(80), 200, 0, 200));
                }
                g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle));
                return;
            }

            Rectangle r = new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)),s);
            if (Activation == 0)
            {
                if(Type == "goal")
                    g.DrawPie(EngineUtilities.GreendPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle));
                else
                    g.DrawPie(EngineUtilities.RedPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle));
                
            }
            else
            {
                if (Type == "goal")
                {
                    b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 0, 255, 0));
                    g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle));
                }
                else
                {
                    b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 255, 0, 0));
                    
                    g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle));
                }
            }
		}
Esempio n. 28
0
 public void draw(Graphics g)
 {
     g.DrawPie(pen, rainRec, 60, 60);
 }
Esempio n. 29
0
 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));
 }
Esempio n. 30
0
        /// <summary>
        /// Do all rendering associated with this <see cref="PieItem"/> item to the specified
        /// <see cref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/>
        /// collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="pos">Not used for rendering Pies</param>param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>				
        public override void Draw( Graphics g, GraphPane pane, int pos, float scaleFactor )
        {
            if ( pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0 )
            {
                //pane.PieRect = RectangleF.Empty;
                _slicePath = null;
            }
            else
            {
                //pane.PieRect = CalcPieRect( g, pane, scaleFactor, pane.ChartRect );
                CalcPieRect( g, pane, scaleFactor, pane.Chart._rect );

                _slicePath = new GraphicsPath();

                if ( !_isVisible )
                    return;

                RectangleF tRect = _boundingRectangle;

                if ( tRect.Width >= 1 && tRect.Height >= 1 )
                {
                    SmoothingMode sMode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    Fill tFill = _fill;
                    Border tBorder = _border;
                    if ( this.IsSelected )
                    {
                        tFill = Selection.Fill;
                        tBorder = Selection.Border;
                    }

                    using ( Brush brush = tFill.MakeBrush( _boundingRectangle ) )
                    {
                        g.FillPie( brush, tRect.X, tRect.Y, tRect.Width, tRect.Height, this.StartAngle, this.SweepAngle );

                        //add GraphicsPath for hit testing
                        _slicePath.AddPie( tRect.X, tRect.Y, tRect.Width, tRect.Height,
                            this.StartAngle, this.SweepAngle );

                        if ( this.Border.IsVisible )
                        {
                            using ( Pen borderPen = tBorder.GetPen( pane, scaleFactor ) )
                            {
                                g.DrawPie( borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                    this.StartAngle, this.SweepAngle );
                            }
                        }

                        if ( _labelType != PieLabelType.None )
                            DrawLabel( g, pane, tRect, scaleFactor );

                        //brush.Dispose();
                    }

                    g.SmoothingMode = sMode;
                }
            }
        }
Esempio n. 31
0
        public override void Draw( Graphics g, GraphPane pane, int pos, float scaleFactor )
		{
			if ( pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0 )
			{
				_slicePath = null;
			}
			else
			{
				CalcRectangle( g, pane, scaleFactor, pane.Chart._rect );

				_slicePath = new GraphicsPath();

				if ( !_isVisible )
					return;

				RectangleF tRect = _boundingRectangle;

				if ( tRect.Width >= 1 && tRect.Height >= 1 )
				{
					SmoothingMode sMode = g.SmoothingMode;
					g.SmoothingMode = SmoothingMode.AntiAlias;
					
					RectangleF r = new RectangleF( ( tRect.X + ( tRect.Width / 2 ) ) - 1.0f, ( tRect.Y + ( tRect.Height / 2 ) ) - 1.0f, 1.0f, 1.0f );

                    using (LinearGradientBrush borderGradient = new LinearGradientBrush(tRect, Color.LightGray, Color.DarkGray, (360 - pane.Angle) / 2, true))
                    {
                        float offset = 0f;
                        using (Pen borderPen = new Pen(Color.Black, 3.0f))
                        {
                            //draw a full black circle around the gauge		
                            offset = pane.GasGaugeRegionWidth - borderPen.Width;
                            if (pane.GasGaugeBorder)
                                g.DrawArc(borderPen, (tRect.X - offset / 2), (tRect.Y - offset / 2), (tRect.Width + offset), (tRect.Height + offset), 0, 360);
                        }

                        PointF[] pts = new PointF[2];
                        using (Matrix matrix = new Matrix())
                        {
                            matrix.Translate(tRect.X + (tRect.Width / 2), tRect.Y + (tRect.Height / 2), MatrixOrder.Prepend);

                            pts[0] = new PointF(((tRect.Height * -.40f) / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f),
                            ((tRect.Height * -.40f) / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f));
                            pts[1] = new PointF((tRect.Width / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f),
                            (tRect.Width / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f));

                            matrix.TransformPoints(pts);
                        }

                        //check which region is being pointed and take its color for the needle
                        if (_dynamicColor)
                        {
                            foreach (CurveItem curve in pane.CurveList)
                            {
                                if (curve is GasGaugeRegion)
                                {
                                    GasGaugeRegion gg = (GasGaugeRegion)curve;
                                    if (NeedleValue >= gg.MinValue && NeedleValue <= gg.MaxValue)
                                        NeedleColor = gg.RegionColorStart;
                                }
                            }
                        }

                        //draw a black needle behind the needle
                        //to simulate a border
                        using (Pen pEdge = new Pen(Color.Black, ((tRect.Height * .10f) / 2.0f)))
                        {
                            pEdge.EndCap = LineCap;
                            pEdge.Width = NeedleWidth + 2;
                            using (Pen p = new Pen(NeedleColor, ((tRect.Height * .10f) / 2.0f)))
                            {
                                p.EndCap = LineCap;
                                p.Width = NeedleWidth;

                                g.DrawLine(pEdge, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);
                                g.DrawLine(p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);
                            }
                        }

                        //Fill center 10% with a gray gradient dot with a border;
                        using (Fill f = new Fill(Color.White, Color.Gray))
                        {
                            r.Inflate((tRect.Height * .10f), (tRect.Height * .10f));

                            using (LinearGradientBrush fillBrush = new LinearGradientBrush(r, Color.Gray, Color.White, (360 - pane.Angle) / 2, true))
                            {
                                using (Pen borderPen = new Pen(borderGradient, 10))
                                {
                                    g.DrawPie(borderPen, r.X, r.Y, r.Width, r.Height, 90.0f, 360.0f);
                                    g.FillPie(fillBrush, r.X, r.Y, r.Width, r.Height, 90.0f, 360.0f);
                                }

                                //draw the label of the value in the middle of the dot
                                //take a big fontsize but reduce if the text doesn't fit the dot
                                if (pane.ShowGasGaugeValueLabel)
                                {
                                    TextObj valueLabel = new TextObj(NeedleValue.ToString(), 0.5, (r.Top + (r.Bottom - r.Top) / 2) / pane.Rect.Bottom, ZedGraph.CoordType.PaneFraction);
                                    valueLabel.FontSpec.Size = 40;
                                    SizeF textsize = valueLabel.FontSpec.MeasureString(g, NeedleValue.ToString(), scaleFactor);
                                    while (textsize.Height > r.Width || textsize.Width > r.Height)
                                    {
                                        valueLabel.FontSpec.Size--;
                                        textsize = valueLabel.FontSpec.MeasureString(g, NeedleValue.ToString(), scaleFactor);
                                    }

                                    valueLabel.FontSpec.Border.IsVisible = false;
                                    valueLabel.FontSpec.Fill.IsVisible = false;

                                    foreach (Object o in pane.GraphObjList)
                                    {
                                        if (o is TextObj)
                                        {
                                            TextObj to = (TextObj)o;
                                            if (to.Location.TopLeft == valueLabel.Location.TopLeft)
                                            {
                                                pane.GraphObjList.Remove(to);
                                                break;
                                            }
                                        }
                                    }

                                    pane.GraphObjList.Add(valueLabel);
                                }
                            }
                        }
                    }					

					g.SmoothingMode = sMode;
				}
			}
		}
Esempio n. 32
0
 public new void RePain(float Dlg, float Dlv, Color Cl, float BorWd, float k, Graphics G)
 {
     if (TypeShape == Nows.Ellip)
         G.DrawEllipse(new Pen(Cl, BorWd), (Xn - Dlg) * k, (Yn - Dlv) * k, Width * k, Height * k);
     else
         G.DrawPie(new Pen(Cl, BorWd), (Xn - Dlg) * k, (Yn - Dlv) * k, Width * k, Height * k, startAngle, sweepAngle);
 }
Esempio n. 33
0
		public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
		{
			if (Bars == null)
				return;

			byte bRed	= (byte)~(ChartControl.BackColor.R);
			byte bGreen	= (byte)~(ChartControl.BackColor.G);
			byte bBlue	= (byte)~(ChartControl.BackColor.B);

			Color borderColor = Color.FromArgb(bRed, bGreen, bBlue);

			if (lineWidth > 0)
			{
				// draw back lines
				Pen linePen = new Pen(lineBrush, lineWidth);
				double lineSpace = 100;

				{
					double y = (bounds.Y + bounds.Height) - ((0 - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height;
					graphics.DrawLine(linePen, ChartControl.CanvasLeft, (int)y, ChartControl.CanvasRight, (int)y);
				}
				while (max > lineSpace || min < lineSpace * -1)
				{
					double y = (bounds.Y + bounds.Height) - ((lineSpace - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height;
					graphics.DrawLine(linePen, ChartControl.CanvasLeft, (int)y, ChartControl.CanvasRight, (int)y);
					y = (bounds.Y + bounds.Height) - (((lineSpace * -1) - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height;
					graphics.DrawLine(linePen, ChartControl.CanvasLeft, (int)y, ChartControl.CanvasRight, (int)y);

					lineSpace += 100;
				}
			}

			int bars			= ChartControl.BarsPainted;
			int barPaintWidth	= ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);

			if (ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + bars - Bars.Count != 0)
				bars--;

			while (bars >= 0)
			{
				int index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) + 1) + bars;

				if (ChartControl.ShowBarsRequired || index - Displacement >= BarsRequired)
					try
					{
						double cciVal = CciPlot.Get(index);
						int x = (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) -
								 ((ChartControl.BarsPainted - 1) * ChartControl.BarSpace)) + (bars * ChartControl.BarSpace);
						int y1 = (bounds.Y + bounds.Height) - ((int)(((cciVal - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));

						double alertVal = dotSeries.Get(index);

						if (!double.IsNaN(alertVal) && !double.IsNaN(cciVal))
						{
							int y = (bounds.Y + bounds.Height) - ((int)(((0 - min) / ChartControl.MaxMinusMin(max, min)) * bounds.Height));

							Color dotColor = Color.Transparent;

							if (Math.Abs(1 - alertVal) < double.Epsilon)
								dotColor = ChartControl.ChartStyle.UpColor;
							else if (Math.Abs(-1 - alertVal) < double.Epsilon)
								dotColor = ChartControl.ChartStyle.DownColor;
							else if (Math.Abs(2 - alertVal) < double.Epsilon)
								dotColor = Color.Gray;

							if (dotColor != Color.Transparent)
							{
								int barOffset = (int)((double)(barWidth - 1) / 2);

								// draw bars
								if (y1 - y > 0)
									graphics.FillRectangle(new SolidBrush(dotColor), x - barOffset, y, barWidth, y1 - y);
								else
									graphics.FillRectangle(new SolidBrush(dotColor), x - barOffset, y1, barWidth, y - y1);

								if (showDots)
								{
									// draw dots
									SmoothingMode smoothingMode = graphics.SmoothingMode;
									graphics.SmoothingMode = SmoothingMode.AntiAlias;

									Pen pen = new Pen(borderColor, 7) { DashStyle = DashStyle.Dot, DashCap = DashCap.Round };
									graphics.DrawPie(pen, x - 1, y, 2, 2, 0, 360);
									pen = new Pen(dotColor, 5) { DashStyle = DashStyle.Dot, DashCap = DashCap.Round };
									graphics.DrawRectangle(pen, x - 2, y - 1, 2, 2);
									graphics.SmoothingMode = smoothingMode;
								}
							}
						}
					}
					catch (Exception)
					{
					}
				bars--;
			}

			// Default plotting in base class. 
			base.Plot(graphics, bounds, min, max);
		}
Esempio n. 34
0
        void DrawPie(Graphics g, Report rpt, Brush brush, System.Drawing.Rectangle rect, int iRow, int iCol, float startAngle, float endAngle)
        {
            if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Exploded)
            {
                // Need to adjust the rectangle
                int side = (int) (rect.Width * .75);	// side needs to be smaller to account for exploded pies
                int offset = (int) (side * .1);			//  we add a little to the left and top
                int adjX, adjY;
                adjX = adjY = (int) (side * .1);

                float midAngle = startAngle + (endAngle - startAngle)/2;

                if (midAngle < 90)
                {
                }
                else if (midAngle < 180)
                {
                    adjX = -adjX;
                }
                else if (midAngle < 270)
                {
                    adjX = adjY = -adjX;
                }
                else
                {
                    adjY = - adjY;
                }
                rect = new System.Drawing.Rectangle(rect.Left + adjX + offset, rect.Top + adjY + offset, side, side);
            }

            g.FillPie(brush, rect, startAngle, endAngle - startAngle);
            g.DrawPie(Pens.Black, rect, startAngle, endAngle - startAngle);

            return;
        }
Esempio n. 35
0
 /// <summary>
 ///   Draws the top of the pie slice.
 /// </summary>
 /// <param name = "graphics">
 ///   <c>Graphics</c> used to draw the pie slice.
 /// </param>
 internal void DrawTop(Graphics graphics)
 {
     graphics.FillPie(
         BrushSurface,
         BoundingRectangle.X,
         BoundingRectangle.Y,
         BoundingRectangle.Width,
         BoundingRectangle.Height,
         StartAngle,
         SweepAngle);
     graphics.DrawPie(Pen, BoundingRectangle, StartAngle, SweepAngle);
 }
        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();
        }
Esempio n. 37
0
        protected override void drawChart(Graphics g, Rectangle bound) {			
            foreach(Series series in DataSource.SeriesCollection)
			{
                if (series == null) {
                    return;
                }
                int size = series.DataPoints.Count;
                if (size == 0 || series.Total <= 0) {
                    return; // No data to draw.
                }

                // Make circle.				
				if(bound.Width <0) 
				{					
					bound.Width =3*Math.Abs(bound.Width);   
				}

				if(bound.Height  <0) 
				{					
					bound.Height  =3*Math.Abs(bound.Height); 
				}

				
				if (bound.Width < bound.Height) 
					{
						bound.Height = bound.Width;
						bound.Y = (this.Height - bound.Height) / 2;
					} 
					else 
					{
						bound.Width = bound.Height;
						bound.X = (this.Width - bound.Width) / 2;
					}				

				if (this.Enable3D) 
				{
					for (int index = 0; index < size; index++) 
					{
						DataPoint data = (DataPoint) series.DataPoints[index];
						bool isExplode = false;
						if (data is PieDataPoint) 
						{
							isExplode = ((PieDataPoint) data).IsExplode;
						}
						int dx = 10;
						int dy = 10;
						if (isExplode) 
						{
							Point p = convertPolarToRect(m_startAngles[index] + m_sweepAngles[index] / 2, bound);
							dx += (p.X - (bound.X + bound.Width / 2)) / 4;
							dy += (p.Y - (bound.Y + bound.Height / 2)) / 4;
						}
						Color darker = ControlPaint.Dark(data.Color);
						g.TranslateTransform(dx, dy);
						using (Brush brush = new SolidBrush(darker)) 
						{
							g.FillPie(brush, bound, -1 * m_startAngles[index], -1 * m_sweepAngles[index]);							
						}
						g.TranslateTransform(-1 * dx, -1 * dy);

					}
				}
                for (int index = 0; index < size; index++) {
                    DataPoint data = (DataPoint) series.DataPoints[index];
                    bool isExplode = false;
                    if (data is PieDataPoint) {
                        isExplode = ((PieDataPoint) data).IsExplode;
                    }
                    int dx = 0;
                    int dy = 0;
                    if (isExplode) {
                        Point p = convertPolarToRect(m_startAngles[index] + m_sweepAngles[index] / 2, bound);
                        dx = (p.X - (bound.X + bound.Width / 2)) / 4;
                        dy = (p.Y - (bound.Y + bound.Height / 2)) / 4;
                    }
                    g.TranslateTransform(dx, dy);
                    
                    Color darker = ControlPaint.Light(data.Color);
                    using (LinearGradientBrush brush = new LinearGradientBrush(bound, data.Color, darker, LinearGradientMode.Vertical)) {
                        g.FillPie(brush, bound, -1 * m_startAngles[index], -1 * m_sweepAngles[index]);
                    }

                    if (m_enableOutline) {
                        using (Pen pen = new Pen(new SolidBrush(data.OutlineColor))) {
                            g.DrawPie(pen, bound, -1 * m_startAngles[index], -1 * m_sweepAngles[index]);
                        }

                    }
					//if(!bOverSpanning)
					{
						if (m_labels != null) 
						{
							int angle = m_startAngles[index] + m_sweepAngles[index]  / 2;

							Rectangle rect = new Rectangle( bound.X,  bound.Y,  bound.Width + Depth,  bound.Height + Depth);

							Point pt = convertPolarToRect(angle, rect);
							if (angle < 180) 
							{
								m_labels[index].VerticalAlign = VerticalAlign.Bottom;
								if (angle < 90) 
								{
									m_labels[index].HorizontalAlign = HorizontalAlign.Left;
								} 
								else 
								{
									m_labels[index].HorizontalAlign = HorizontalAlign.Right;
								}
							} 
							else 
							{
								m_labels[index].VerticalAlign = VerticalAlign.Top;
								if (angle < 270) 
								{
									m_labels[index].HorizontalAlign = HorizontalAlign.Right;
								} 
								else 
								{
									m_labels[index].HorizontalAlign = HorizontalAlign.Left;
								}
							}
							//m_labels[index].HorizontalAlign = HorizontalAlign.Center;
							m_labels[index].Position = pt;
							m_labels[index].draw(g);						

						}
						g.TranslateTransform(-1 * dx, -1 * dy);
					}

                }
           }
        }
Esempio n. 38
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);
            }
        }
		/// <summary>ビュー座標系に変換された図形をグラフィクスに描き出します。(IVirtualShapeの実装)</summary>
		/// <param name="g"></param>
		public override void RenderToView(Graphics g)
			{
			PointD c = ParentGraphics.FromGlobalToView( Center );
			SizeD s = DoesGlobalScale ? new SizeD( Math.Abs( ParentGraphics.ViewScale.W * Radius.W ), Math.Abs( ParentGraphics.ViewScale.H * Radius.H ) ) : Radius;
			if( s.W == 0 || s.H == 0 ) return;

			PointD p = c - s;
			float startAngle = (float)StartAngle,
				sweepAngle = (float)SweepAngle;

			if( ParentGraphics.ViewScale.W < 0 )
				{
				startAngle = 180 - startAngle;
				sweepAngle = -sweepAngle;
				}
			if( ParentGraphics.ViewScale.H < 0 )
				{
				startAngle = -startAngle;
				sweepAngle = -sweepAngle;
				}


			g.FillPie( ShapeFill, (float)p.X, (float)p.Y, (float)( 2.0 * s.W ), (float)( 2.0 * s.H ), startAngle, sweepAngle );
			g.DrawPie( ShapeBorder, new RectangleF( p, 2 * s ), startAngle, sweepAngle );
			}