Beispiel #1
0
        /// <summary>
        /// Used to draw the tick marks of the gauge
        /// </summary>
        /// <param name="graphics">Graphics</param>
        /// <param name="gp">Graphics Path</param>
        /// <param name="m_GaugeArcRadius">Radius of the arc</param>
        /// <param name="m_GaugeArcStart">Start poistion of the arc</param>
        /// <param name="m_GaugeArcEnd">End position of the arc</param>
        /// <param name="m_MajorTickMarkWidth">Tick mark width</param>
        /// <param name="m_Center">Center of the gauge</param>
        public void DrawTickMarks(Graphics graphics, GraphicsPath gp, Int32 m_GaugeArcRadius, Int32 m_GaugeArcStart, Int32 m_GaugeArcEnd, Int32 m_MajorTickMarkWidth, Point m_Center, int m_ScaleNumbersRadius)
        {
            String valueText = "";
            SizeF  boundingBox;
            Single countValue         = 0;
            int    TempGaugeArcRadius = m_GaugeArcRadius;

            TempGaugeArcRadius     = m_GaugeArcRadius + 2;
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            while (countValue <= (RadialGauge.MaximumValue - RadialGauge.MinimumValue))
            {
                valueText = (RadialGauge.MinimumValue + countValue).ToString();
                graphics.ResetTransform();
                boundingBox = graphics.MeasureString(valueText, RadialGauge.Font, -1, StringFormat.GenericTypographic);

                Int32 linevalue      = TempGaugeArcRadius - RadialGauge.MajorTickMarkHeight;
                Int32 lineminervalue = TempGaugeArcRadius - RadialGauge.MinorTickMarkHeight;
                gp.Reset();
                gp.AddEllipse(new Rectangle(m_Center.X - TempGaugeArcRadius, m_Center.Y - TempGaugeArcRadius, 2 * TempGaugeArcRadius, 2 * TempGaugeArcRadius));
                gp.Reverse();
                gp.AddEllipse(new Rectangle(m_Center.X - linevalue, m_Center.Y - linevalue, 2 * linevalue, 2 * linevalue));
                gp.Reverse();
                graphics.SetClip(gp);
                if (countValue > 5)
                {
                    graphics.DrawLine(new Pen(this.RadialGauge.MajorTickMarkColor, m_MajorTickMarkWidth),
                                      (Single)(m_Center.X),
                                      (Single)(m_Center.Y),
                                      (Single)(m_Center.X + 2 * lineminervalue * Math.Cos((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)),
                                      (Single)(m_Center.Y + 2 * lineminervalue * Math.Sin((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)));
                }
                else
                {
                    graphics.DrawLine(new Pen(ColorTranslator.FromHtml("#1b8fcf"), m_MajorTickMarkWidth),
                                      (Single)(m_Center.X),
                                      (Single)(m_Center.Y),
                                      (Single)(m_Center.X + 2 * lineminervalue * Math.Cos((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)),
                                      (Single)(m_Center.Y + 2 * lineminervalue * Math.Sin((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)));
                }

                gp.Reset();

                gp.AddEllipse(new Rectangle(m_Center.X - TempGaugeArcRadius, m_Center.Y - TempGaugeArcRadius, 2 * TempGaugeArcRadius, 2 * TempGaugeArcRadius));
                gp.Reverse();

                graphics.SetClip(gp);
                graphics.SetClip(RadialGauge.ClientRectangle);

                //graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                graphics.TranslateTransform((Single)(m_Center.X + m_ScaleNumbersRadius * Math.Cos((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0f)),
                                            (Single)(m_Center.Y + m_ScaleNumbersRadius * Math.Sin((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0f)),
                                            System.Drawing.Drawing2D.MatrixOrder.Append);

                graphics.DrawString(valueText, RadialGauge.Font, new SolidBrush(this.RadialGauge.ScaleLabelColor), -boundingBox.Width / 2, -fontBoundY1 - (fontBoundY2 - fontBoundY1 + 1) / 2, StringFormat.GenericTypographic);

                countValue += RadialGauge.MajorDifference;
            }
        }
Beispiel #2
0
 private void FillLastSeriesGradient(ChartGraphics graph)
 {
     if (areaPath != null)
     {
         areaPath.AddLine(areaPath.GetLastPoint().X, areaPath.GetLastPoint().Y, areaPath.GetLastPoint().X, areaBottomPath.GetLastPoint().Y);
     }
     if (gradientFill && areaPath != null)
     {
         graph.SetClip(area.PlotAreaPosition.ToRectangleF());
         GraphicsPath graphicsPath = new GraphicsPath();
         graphicsPath.AddPath(areaPath, connect: true);
         areaBottomPath.Reverse();
         graphicsPath.AddPath(areaBottomPath, connect: true);
         Brush gradientBrush = graph.GetGradientBrush(graphicsPath.GetBounds(), series.Color, series.BackGradientEndColor, series.BackGradientType);
         graph.FillPath(gradientBrush, graphicsPath);
         gradientFill = false;
         graph.ResetClip();
     }
     if (areaPath != null)
     {
         areaPath.Dispose();
         areaPath = null;
     }
     areaBottomPath.Reset();
 }
Beispiel #3
0
        private void DrawMarking(Graphics e, Rectangle outBound, Rectangle inBound)
        {
            // e.SmoothingMode = SmoothingMode.HighQuality;
            GraphicsState state = e.Save();

            e.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.SmoothingMode     = SmoothingMode.HighQuality;
            Matrix mat = new Matrix();
            Point  sp  = new Point(inBound.Left + inBound.Width / 2, outBound.Top);
            Point  ep  = new Point(inBound.Left + inBound.Width / 2, inBound.Top);

            if (_collection.Count > 0)
            {
                float angle = 0;
                for (int i = 0; i < _collection.Count; i++)
                {
                    mat.RotateAt(_distance, _center);
                    //   Console.WriteLine("rotate " + i + " : " + _distance + " collection value=" + _collection[i].Value);
                    angle      += _distance;
                    e.Transform = mat;
                    if (_markingType == Marking.CONT || _markingType == Marking.BOTH)
                    {
                        GraphicsPath p = new GraphicsPath();
                        p.AddLine(sp, ep);
                        p.AddArc(inBound, 270, _distance);
                        p.Reverse();
                        GraphicsPath p2 = new GraphicsPath();
                        p2.AddArc(outBound, 270, _distance);
                        p2.AddLine(
                            AlgorithmHelper.LocationToCenter(_center, outBound.Width / 2, AlgorithmHelper.NormalizeDegreeFromX(270 + _distance)),
                            AlgorithmHelper.LocationToCenter(_center, inBound.Width / 2, AlgorithmHelper.NormalizeDegreeFromX(270 + _distance)));
                        p2.AddPath(p, true);
                        e.FillPath(new SolidBrush(_collection[i].MainColor), p2);
                    }
                    if (_markingType == Marking.LINE || _markingType == Marking.BOTH)
                    {
                        e.DrawLine(new Pen(_fontColor, 2), sp, ep);
                    }
                    Size z = new Size(0, 0);
                    if (_markingImage == MarkingImage.FONT)
                    {
                        String text = _collection[i].Desc;
                        z = TextRenderer.MeasureText(text, _f);
                        Point fp = new Point(inBound.Left + inBound.Width / 2 - z.Width / 2, outBound.Top - z.Height);
                        e.DrawString(text, _f, new SolidBrush(_fontColor), fp);
                        //TextEffectHelper.HaloEffect(_f, new SolidBrush(_fontColor), e, fp, text);
                    }
                    if (_markingImage == MarkingImage.IMAGE)
                    {
                        if (_collection[i].Image != null)
                        {
                            e.DrawImage(_collection[i].Image, new Rectangle(inBound.Left + inBound.Width / 2 - 6, outBound.Top - z.Height - 14, 12, 12),
                                        new Rectangle(0, 0, _collection[i].Image.Width, _collection[i].Image.Height), GraphicsUnit.Pixel);
                        }
                    }
                }
            }
            e.Restore(state);
        }
Beispiel #4
0
        private void DrawMarking(Graphics e, Rectangle inBound, Rectangle outBound)
        {
            GraphicsState state = e.Save();

            e.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            float startAngle = _sweepAngle + _startGapAngle;

            startAngle = Helper.AlgorithmHelper.NormalizeDegree(270f, startAngle);
            Matrix m = new Matrix();
            //Console.WriteLine("Interval =" + _interval);

            int i = _collection.Count - 1;

            foreach (MeterLabel ml in _collection)
            {
                //   Console.WriteLine(ml.Desc + " : " + startAngle);
                Size z = TextRenderer.MeasureText(ml.Desc, _font);
                m.RotateAt(startAngle, _center);
                e.Transform = m;
                e.DrawString(ml.Desc, _font, new SolidBrush(_fontColor),
                             new PointF(outBound.Left + outBound.Width / 2 - z.Width / 2,
                                        outBound.Top - z.Height));
                if (_marking == Marking.LINE)
                {
                    PointF p1 = new PointF(_center.X, outBound.Top);
                    PointF p2 = new PointF(_center.X, inBound.Top);
                    Pen    p  = new Pen(ml.MainColor, 2);
                    e.DrawLine(p, p1, p2);
                    p.Dispose();
                }
                else if (_marking == Marking.CONT)
                {
                    if (i > 0)
                    {
                        GraphicsPath gp = new GraphicsPath();
                        PointF       p1 = new PointF(_center.X, outBound.Top);
                        PointF       p2 = new PointF(_center.X, inBound.Top);
                        gp.AddArc(outBound, 270, _interval);
                        gp.Reverse();
                        gp.AddLine(p1, p2);
                        gp.AddArc(inBound, 270, _interval);
                        float  Angle = Helper.AlgorithmHelper.NormalizeDegreeFromX(270 + _interval);
                        PointF p3    = Helper.AlgorithmHelper.LocationToCenter(_center, outBound.Width / 2, Angle);
                        PointF p4    = Helper.AlgorithmHelper.LocationToCenter(_center, inBound.Width / 2, Angle);
                        gp.AddLine(p4, p3);
                        gp.CloseFigure();
                        e.FillPath(new SolidBrush(ml.MainColor), gp);
                    }
                }

                startAngle = _interval;
                i--;
            }
            e.Restore(state);
        }
Beispiel #5
0
 void IData.Draw(Graphics g, RectangleF plotRectangle)
 {
     if (points.Length > 1)
     {
         if (BarStyle != BarStyle.None)
         {
             if (BarFillColor.A > 0)
             {
                 g.FillRectangles(new SolidBrush(BarFillColor), bars);
             }
             if (BarLineColor.A > 0)
             {
                 g.DrawRectangles(new Pen(BarLineColor), bars);
             }
         }
         if (FillStyle != FillStyle.None)
         {
             GraphicsPath fillPath = new GraphicsPath();
             if (FillStyle == FillStyle.ToNInfitity)
             {
                 fillPath.AddPath(GraphicsPath, true);
                 fillPath.AddLine(points[0].X, points[0].Y, points[0].X, plotRectangle.Bottom);
                 fillPath.AddLine(points[0].X, plotRectangle.Bottom, points[points.Length - 1].X, plotRectangle.Bottom);
                 fillPath.AddLine(points[points.Length - 1].X, plotRectangle.Bottom, points[points.Length - 1].X, points[points.Length - 1].Y);
             }
             else if (FillStyle == FillStyle.ToPInfinity)
             {
                 fillPath.AddPath(GraphicsPath, true);
                 fillPath.AddLine(points[0].X, points[0].Y, points[0].X, plotRectangle.Top);
                 fillPath.AddLine(points[0].X, plotRectangle.Top, points[points.Length - 1].X, plotRectangle.Top);
                 fillPath.AddLine(points[points.Length - 1].X, plotRectangle.Top, points[points.Length - 1].X, points[points.Length - 1].Y);
             }
             else if (FillStyle == FillStyle.ToValue)
             {
                 float fillValue = (float)VerticalAxis.Transform(FillValue);
                 fillPath.AddPath(GraphicsPath, true);
                 fillPath.AddLine(points[0].X, points[0].Y, points[0].X, fillValue);
                 fillPath.AddLine(points[0].X, fillValue, points[points.Length - 1].X, fillValue);
                 fillPath.AddLine(points[points.Length - 1].X, fillValue, points[points.Length - 1].X, points[points.Length - 1].Y);
             }
             else if (FillStyle == FillStyle.ToPlot && FillPlot != null)
             {
                 fillPath.AddPath(GraphicsPath, true);
                 fillPath.Reverse();
                 fillPath.AddPath(FillPlot.GraphicsPath, true);
             }
             g.FillPath(new SolidBrush(FillColor), fillPath);
             fillPath.Flatten();
             flattenFill = fillPath.PathPoints;
         }
         Line.DrawPath(g, LineColor, LineStyle, LineWidth, GraphicsPath);
         Marker.Draw(g, MarkColor, MarkStyle, MarkSize, points);
     }
 }
        private static void ArcRenderRange(this Graphics Graphics, Rectangle ClientRectangle, Point Center, Int32 ArcStart, Int32 ArcSweep, Single MinimumValue, Single MaximumValue, ArcRangeDef Range)
        {
            Graphics.SetClip(ClientRectangle);
            Graphics.SmoothingMode   = SmoothingMode.HighQuality;
            Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

            using (var graphicsPath = new GraphicsPath()) {
                if (Range.EndValue > Range.StartValue && Range.Enabled)
                {
                    var rangeStartAngle = ArcStart + (Range.StartValue - MinimumValue) * ArcSweep / (MaximumValue - MinimumValue);
                    var rangeSweepAngle = (Range.EndValue - Range.StartValue) * ArcSweep / (MaximumValue - MinimumValue);
                    graphicsPath.Reset();
                    graphicsPath.AddPie(new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
                    graphicsPath.Reverse();
                    graphicsPath.AddPie(new Rectangle(Center.X - Range.InnerRadius, Center.Y - Range.InnerRadius, 2 * Range.InnerRadius, 2 * Range.InnerRadius), rangeStartAngle, rangeSweepAngle);
                    graphicsPath.Reverse();
                    Graphics.SetClip(graphicsPath);
                    using (var solidBrush = new SolidBrush(Range.ForeColor)) {
                        Graphics.FillPie(solidBrush, new Rectangle(Center.X - Range.OuterRadius, Center.Y - Range.OuterRadius, 2 * Range.OuterRadius, 2 * Range.OuterRadius), rangeStartAngle, rangeSweepAngle);
                    }
                }
            }
        }
Beispiel #7
0
        public void Draw(Graphics e)
        {
            e.SmoothingMode = SmoothingMode.HighQuality;
            Rectangle ori = new Rectangle(_clientRect.X, _clientRect.Y, _clientRect.Width, _clientRect.Width);

            _center = new PointF(ori.X + ori.Width / 2, ori.Top + ori.Height / 2);
            Rectangle    r  = Helper.RectangleHelper.Shrink(ori, 1);
            GraphicsPath gp = new GraphicsPath();

            gp.AddEllipse(r);
            if (_border)
            {
                Border.Border border = new Border.Inner3D();
                border.DrawBorder(e, gp);
            }
            Rectangle    r2  = Helper.RectangleHelper.Shrink(r, 15);
            Pen          p   = new Pen(_outlineColor);
            GraphicsPath gp2 = new GraphicsPath();

            gp2.AddArc(r2, _startGapAngle + _sweepAngle, 360 - _sweepAngle);
            gp2.Reverse();
            Rectangle r3   = Helper.RectangleHelper.Shrink(r2, 5);
            PointF    out1 = Helper.AlgorithmHelper.LocationToCenter(_center, r2.Width / 2, _startGapAngle);
            PointF    in1  = Helper.AlgorithmHelper.LocationToCenter(_center, r3.Width / 2, _startGapAngle);
            PointF    out2 = Helper.AlgorithmHelper.LocationToCenter(_center, r2.Width / 2, _startGapAngle + _sweepAngle);
            PointF    in2  = Helper.AlgorithmHelper.LocationToCenter(_center, r3.Width / 2, _startGapAngle + _sweepAngle);

            gp2.AddLine(out2, in2);
            gp2.AddArc(r3, _startGapAngle + _sweepAngle, 360 - _sweepAngle);
            gp2.AddLine(in1, out1);
            gp2.CloseAllFigures();

            DrawMarking(e, r3, r2);
            PointF point = Helper.AlgorithmHelper.LocationToCenter(_center, 50, _curAngle);

            e.DrawLine(new Pen(_pointerColor, 2), _center, point);
            Rectangle           r4 = Helper.RectangleHelper.Shrink(r3, 30);
            LinearGradientBrush lb = new LinearGradientBrush(r4, _pointerHandleColor, Color.LightGray, 45f);

            e.FillEllipse(lb, r4);
            e.DrawPath(p, gp2);
            //Draw the pointer
            //Rectangle ptr = Helper.RectangleHelper.Shrink(r4, 20);
            //e.DrawEllipse(new Pen(Color.Black), ptr);
        }
Beispiel #8
0
        public GraphicsPath FillPath(Rectangle re_out, Rectangle re_in, Rectangle re_up, Rectangle re_down, int C_Angle, int LC_startAngle, bool isflase)
        {
            GraphicsPath myPath_Dout  = new GraphicsPath(); //建立GraphicsPath()类对象
            GraphicsPath myPath_Dup   = new GraphicsPath(); //建立GraphicsPath()类对象
            GraphicsPath myPath_Ddown = new GraphicsPath(); //建立GraphicsPath()类对象
            GraphicsPath myPath_Din   = new GraphicsPath(); //建立GraphicsPath()类对象

            myPath_Dup.AddArc(re_up, LC_startAngle, 185);   //追加一椭圆
            myPath_Dout.AddArc(re_out, -270, C_Angle);      //追加一椭圆
            myPath_Ddown.AddArc(re_down, -90, 185);         //追加一椭圆
            myPath_Din.AddArc(re_in, -270, C_Angle);        //追加一椭圆
            myPath_Din.Reverse();
            myPath_Dout.AddPath(myPath_Dup, true);
            myPath_Dout.AddPath(myPath_Din, true);
            myPath_Dout.AddPath(myPath_Ddown, true);

            return(myPath_Dout);
        }
Beispiel #9
0
        // End DrawPoints
        // </snippet24>

        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPath.Reverse
        // <snippet25>
        public void GraphicsPathReverseExample(PaintEventArgs e)
        {
            // Create a path and add a line, ellipse, and arc.
            GraphicsPath myPath = new GraphicsPath();

            myPath.AddLine(new Point(0, 0), new Point(100, 100));
            myPath.AddEllipse(100, 100, 200, 250);
            myPath.AddArc(300, 250, 100, 100, 0, 90);

            // Draw the first set of points to the screen.
            DrawPoints2(e, myPath.PathPoints, 20);

            // Call GraphicsPath.Reverse.
            myPath.Reverse();

            // Draw the reversed set of points to the screen.
            DrawPoints2(e, myPath.PathPoints, 150);
        }
Beispiel #10
0
 public void RenderLines(RequestedTileInformation ti, Graphics g, Way way, RenderInfo ri)
 {
     if (way.WayDataBlocks != null && way.WayDataBlocks.Count > 0)
     {
         bool  nDone = false;
         float f     = getPaintZoomLevel(ti.Zoom);
         foreach (Way.WayData wd in way.WayDataBlocks)
         {
             System.Drawing.PointF[] pa = (from p in wd.DataBlock[0].CoordBlock select new System.Drawing.PointF((float)toRelTileX(p.Longitude, ti.X, ti.Zoom), (float)toRelTileY(p.Latitude, ti.Y, ti.Zoom))).ToArray();
             using (GraphicsPath gp = new GraphicsPath())
             {
                 for (int i = 0; i < pa.Length - 1; i++)
                 {
                     gp.AddLine(pa[i], pa[i + 1]);
                 }
                 Pen p = ri.Pen ?? new Pen(Color.Black);
                 p.Width = ri.fstroke_width * f;
                 g.DrawPath(p, gp);
                 if (ri.FillPen != null)
                 {
                     ri.FillPen.Width = ri.fstroke_width * f * 0.8f;
                     g.DrawPath(ri.FillPen, gp);
                 }
                 if (!string.IsNullOrEmpty(way.Name) && p.Width > 6.0f && !nDone)
                 {
                     nDone = true; //only once per tile is enough I think
                     using (Font fnt = new Font(FontFamily.GenericSerif, p.Width))
                     {
                         //determine angle of polyline (use start and endpoint?)
                         //if wrong (text upside down), then reverse polyline
                         PointF p1 = pa[0];
                         PointF p2 = pa[pa.Length - 1];
                         if (p1.X > p2.X)
                         {
                             gp.Reverse();
                         }
                         g.DrawString(way.Name, fnt, _fixedTextBrush, TextPathAlign.Center, TextPathPosition.CenterPath, 100, 0, gp);
                     }
                 }
             }
         }
     }
 }
Beispiel #11
0
        private void DrawRingsUntextured(Graphics g, RingsAppearance rings, int half, double scale)
        {
            float startAngle = -180 * half + ((rings.B > 0) ? 180 : 0) - 1e-2f;

            // three rings
            for (int r = 0; r < 3; r++)
            {
                float aOut = (float)(rings.GetRingSize(r, RingEdge.Outer, RingAxis.Major) * scale);
                float bOut = (float)(rings.GetRingSize(r, RingEdge.Outer, RingAxis.Minor) * scale);

                float aIn = (float)(rings.GetRingSize(r, RingEdge.Inner, RingAxis.Major) * scale);
                float bIn = (float)(rings.GetRingSize(r, RingEdge.Inner, RingAxis.Minor) * scale);

                GraphicsPath gp = new GraphicsPath();
                gp.AddArc(-aOut, -bOut, aOut * 2, bOut * 2, startAngle, 180 + 1e-2f * 2);
                gp.Reverse();
                gp.AddArc(-aIn, -bIn, aIn * 2, bIn * 2, startAngle, 180 + 1e-2f * 2);
                g.FillPath(brushRings[r], gp);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Used to draw the tick marks of the gauge
        /// </summary>
        /// <param name="graphics">Graphics</param>
        /// <param name="gp">Graphics Path</param>
        /// <param name="m_GaugeArcRadius">Radius of the arc</param>
        /// <param name="m_GaugeArcStart">Start poistion of the arc</param>
        /// <param name="m_GaugeArcEnd">End position of the arc</param>
        /// <param name="m_MajorTickMarkWidth">Tick mark width</param>
        /// <param name="m_Center">Center of the gauge</param>
        public void DrawTickMarks(Graphics graphics, GraphicsPath gp, Int32 m_GaugeArcRadius, Int32 m_GaugeArcStart, Int32 m_GaugeArcEnd, Int32 m_MajorTickMarkWidth, Point m_Center, int m_ScaleNumbersRadius)
        {
            String valueText = "";
            SizeF  boundingBox;
            Single countValue         = 0;
            int    TempGaugeArcRadius = m_GaugeArcRadius;

            TempGaugeArcRadius     = m_GaugeArcRadius + 12;
            boundingBox            = graphics.MeasureString("E", RadialGauge.Font, -1, StringFormat.GenericTypographic);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            graphics.DrawString("E", RadialGauge.Font, new SolidBrush(this.RadialGauge.ScaleLabelColor), m_Center.X - 75, m_Center.Y - 75, StringFormat.GenericTypographic);
            while (countValue <= (RadialGauge.MaximumValue - RadialGauge.MinimumValue))
            {
                valueText = (RadialGauge.MinimumValue + countValue).ToString();
                graphics.ResetTransform();
                boundingBox = graphics.MeasureString(valueText, RadialGauge.Font, -1, StringFormat.GenericTypographic);

                Int32 linevalue           = TempGaugeArcRadius - RadialGauge.MajorTickMarkHeight;
                Int32 lineminervalue      = TempGaugeArcRadius - RadialGauge.MinorTickMarkHeight;
                Int32 lineminerintervalue = TempGaugeArcRadius - RadialGauge.MinorInnerLinesHeight;
                gp.Reset();
                gp.AddEllipse(new Rectangle(m_Center.X - TempGaugeArcRadius, m_Center.Y - TempGaugeArcRadius, 2 * TempGaugeArcRadius, 2 * TempGaugeArcRadius));
                gp.Reverse();
                gp.AddEllipse(new Rectangle(m_Center.X - linevalue, m_Center.Y - linevalue, 2 * linevalue, 2 * linevalue));
                gp.Reverse();
                graphics.SetClip(gp);

                graphics.DrawLine(new Pen(this.RadialGauge.MajorTickMarkColor, m_MajorTickMarkWidth),
                                  (Single)(m_Center.X),
                                  (Single)(m_Center.Y),
                                  (Single)(m_Center.X + 2 * lineminervalue * Math.Cos((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)),
                                  (Single)(m_Center.Y + 2 * lineminervalue * Math.Sin((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0)));

                gp.Reset();

                gp.AddEllipse(new Rectangle(m_Center.X - (linevalue + RadialGauge.MinorTickMarkHeight), m_Center.Y - (linevalue + RadialGauge.MinorTickMarkHeight), 2 * (linevalue + RadialGauge.MinorTickMarkHeight), 2 * (linevalue + RadialGauge.MinorTickMarkHeight)));
                gp.Reverse();
                gp.AddEllipse(new Rectangle(m_Center.X - linevalue, m_Center.Y - linevalue, 2 * linevalue, 2 * linevalue));
                gp.Reverse();
                graphics.SetClip(gp);

                graphics.SetClip(RadialGauge.ClientRectangle);

                if (RadialGauge.ShowScaleLabel)
                {
                    if (this.RadialGauge.TextOrientation != TextOrientation.Horizontal)
                    {
                        graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                        graphics.RotateTransform(90.0F + m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue));
                    }

                    graphics.TranslateTransform((Single)(m_Center.X + m_ScaleNumbersRadius * Math.Cos((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0f)),
                                                (Single)(m_Center.Y + m_ScaleNumbersRadius * Math.Sin((m_GaugeArcStart + countValue * m_GaugeArcEnd / (RadialGauge.MaximumValue - RadialGauge.MinimumValue)) * Math.PI / 180.0f)),
                                                System.Drawing.Drawing2D.MatrixOrder.Append);



                    graphics.DrawString(valueText, RadialGauge.Font, new SolidBrush(this.RadialGauge.ScaleLabelColor), -boundingBox.Width / 2, -fontBoundY1 - (fontBoundY2 - fontBoundY1 + 1) / 2, StringFormat.GenericTypographic);
                }

                countValue += RadialGauge.MajorDifference;
            }
            Image newImage = Image.FromFile("Fuel.png");

            graphics.DrawImage(newImage, new Point(m_Center.X + 52, m_Center.Y - 85));
        }
Beispiel #13
0
        public void DrawConnection(PointF pointA, PointF pointB, GH_WireDirection directionA, GH_WireDirection directionB, bool selectedA, bool selectedB, GH_WireType type, Color colorinput, GH_Canvas canvas, Graphics graphics)
        {
            if (ConnectionVisible(pointA, pointB, canvas))
            {
                Color color = colorinput;
                if (selectedA || selectedB)
                {
                    color.SolidenColor(Owner.SelectWireSolid);
                }

                GraphicsPath graphicsPath = new GraphicsPath();
                switch (Owner.WireType)
                {
                case 0:
                    graphicsPath = GH_Painter.ConnectionPath(pointA, pointB, directionA, directionB);
                    break;

                case 1:
                    float moveMent = (pointA.X - pointB.X) * (float)Owner.PolywireParam;
                    moveMent = Math.Max(moveMent, 20);
                    PointF C = new PointF(pointA.X - moveMent, pointA.Y);
                    PointF D = new PointF(pointB.X + moveMent, pointB.Y);
                    graphicsPath.AddLine(pointA, C);
                    graphicsPath.AddLine(C, D);
                    graphicsPath.AddLine(D, pointB);
                    graphicsPath.Reverse();
                    break;

                case 2:
                    graphicsPath.AddLine(pointA, pointB);
                    graphicsPath.Reverse();
                    break;

                default:
                    graphicsPath = GH_Painter.ConnectionPath(pointA, pointB, directionA, directionB);
                    break;
                }

                if (graphicsPath == null)
                {
                    graphicsPath = new GraphicsPath();
                    graphicsPath.AddLine(pointA, pointB);
                }

                Pen pen = GenerateWirePen(pointA, pointB, selectedA, selectedB, type, color, canvas);

                if (selectedA || selectedB)
                {
                    pen.Width += (float)Owner.SelectWireThickness;
                }

                if (pen == null)
                {
                    pen = new Pen(Color.Black);
                }
                try
                {
                    graphics.DrawPath(pen, graphicsPath);
                }
                catch (Exception ex)
                {
                    ProjectData.SetProjectError(ex);
                    Exception ex2 = ex;
                    Tracing.Assert(new Guid("{72303320-11AD-484e-BE32-8BDAA7377BE0}"), "Connection could not be drawn:" + Environment.NewLine + ex2.Message + Environment.NewLine + Environment.NewLine + $"A: ({pointA.X}, {pointA.Y})" + Environment.NewLine + $"B: ({pointB.X}, {pointB.Y})" + Environment.NewLine + $"A_Dir: {directionA}" + Environment.NewLine + $"B_Dir: {directionB}" + Environment.NewLine + $"A_Selected: {selectedA}" + Environment.NewLine + $"B_Selected: {selectedB}" + Environment.NewLine + $"Type: {type}");
                    ProjectData.ClearProjectError();
                }
                graphicsPath.Dispose();
                pen.Dispose();
            }
        }
Beispiel #14
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * draw a map object.
         * @param mapObject the map object to be drawing.
         * @param drawBoundary the drawing boundry.
         * @param zoomLevel the current zoomLevel.
         */
        public override void DrawMapObject(MapObject mapObject, GeoLatLngBounds drawBoundary,
                                           int zoomLevel)
        {
            GeoLatLng drawPt = new GeoLatLng();

            _sutherlandHodgman = new SutherlandHodgman(drawBoundary);
            _mapZoomLevel      = zoomLevel;
            _mapCenterPt.X     = drawBoundary.GetCenterX();
            _mapCenterPt.Y     = drawBoundary.GetCenterY();
            bool pointFound = false;

            Point[] plinePoints = null;
            switch (mapObject.GetMapObjectType())
            {
            case MapObject.NONE:
                break;

            case MapObject.POINT:
            {
                MapPoint mapPoint = (MapPoint)mapObject;
                DrawPoint(mapPoint);
                drawPt.X   = mapPoint.Point.X;
                drawPt.Y   = mapPoint.Point.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIPOINT:
            {
                MapMultiPoint mapMultiPoint = (MapMultiPoint)mapObject;
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    MapPoint mapPoint = new MapPoint
                    {
                        SymbolType = mapMultiPoint.SymbolType,
                        Point      = new GeoLatLng(mapMultiPoint.Points[i])
                    };
                    DrawPoint(mapPoint);
                }
                for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                {
                    if (drawBoundary.Contains(mapMultiPoint.Points[i]))
                    {
                        drawPt.X   = mapMultiPoint.Points[i].X;
                        drawPt.Y   = mapMultiPoint.Points[i].Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.PLINE:
            {
                MapPline mapPline = (MapPline)mapObject;
                plinePoints = DrawPline(mapPline.PenStyle, mapPline.Pline);
                for (int i = 0; i < mapPline.Pline.GetVertexCount(); i++)
                {
                    if (drawBoundary.Contains(mapPline.Pline.GetVertex(i)))
                    {
                        drawPt.X   = mapPline.Pline.GetVertex(i).X;
                        drawPt.Y   = mapPline.Pline.GetVertex(i).Y;
                        pointFound = true;
                        break;
                    }
                }
            }
            break;

            case MapObject.MULTIPLINE:
            {
                MapMultiPline mapMultiPline = (MapMultiPline)mapObject;
                for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                {
                    DrawPline(mapMultiPline.PenStyle,
                              mapMultiPline.Plines[i]);
                    for (int j = 0; j < mapMultiPline.Plines[i].GetVertexCount(); j++)
                    {
                        if (drawBoundary.Contains(mapMultiPline.Plines[i].GetVertex(j)))
                        {
                            drawPt.X   = mapMultiPline.Plines[i].GetVertex(j).X;
                            drawPt.Y   = mapMultiPline.Plines[i].GetVertex(j).Y;
                            pointFound = true;
                            break;
                        }
                    }
                }
            }
            break;

            case MapObject.REGION:
            {
                MapRegion mapRegion = (MapRegion)mapObject;
                DrawRegion(mapRegion.PenStyle, mapRegion.BrushStyle,
                           mapRegion.Region);
                drawPt.X   = mapRegion.CenterPt.X;
                drawPt.Y   = mapRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.MULTIREGION:
            {
                MapMultiRegion mapMultiRegion = (MapMultiRegion)mapObject;
                for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                {
                    DrawRegion(mapMultiRegion.PenStyle,
                               mapMultiRegion.BrushStyle,
                               mapMultiRegion.Regions[i]);
                }
                drawPt.X   = mapMultiRegion.CenterPt.X;
                drawPt.Y   = mapMultiRegion.CenterPt.Y;
                pointFound = true;
            }
            break;

            case MapObject.COLLECTION:
            {
                MapCollection mapCollection = (MapCollection)mapObject;
                if (mapCollection.MultiRegion != null)
                {
                    MapMultiRegion mapMultiRegion = mapCollection.MultiRegion;
                    for (int i = 0; i < mapMultiRegion.Regions.Length; i++)
                    {
                        DrawRegion(mapMultiRegion.PenStyle,
                                   mapMultiRegion.BrushStyle,
                                   mapMultiRegion.Regions[i]);
                    }
                }
                if (mapCollection.MultiPline != null)
                {
                    MapMultiPline mapMultiPline = mapCollection.MultiPline;
                    for (int i = 0; i < mapMultiPline.Plines.Length; i++)
                    {
                        DrawPline(mapMultiPline.PenStyle,
                                  mapMultiPline.Plines[i]);
                    }
                }
                if (mapCollection.MultiPoint != null)
                {
                    MapMultiPoint mapMultiPoint = mapCollection.MultiPoint;
                    for (int i = 0; i < mapMultiPoint.Points.Length; i++)
                    {
                        MapPoint mapPoint = new MapPoint
                        {
                            SymbolType = mapMultiPoint.SymbolType,
                            Point      = new GeoLatLng(mapMultiPoint.Points[i])
                        };
                        DrawPoint(mapPoint);
                    }
                }
                pointFound = true;
                drawPt.X   = mapCollection.Bounds.X + mapCollection.Bounds.Width / 2;
                drawPt.Y   = mapCollection.Bounds.Y + mapCollection.Bounds.Height / 2;
            }
            break;

            case MapObject.TEXT:
            {
                MapText mapText = (MapText)mapObject;
                drawPt.X   = mapText.Point.X;
                drawPt.Y   = mapText.Point.Y;
                pointFound = true;
            }
            break;
            }
            if (!(mapObject.Name.ToLower().Equals("unknown") || mapObject.Name.Length == 0) && pointFound)
            {
                MapText mapName = new MapText {
                    Font = _font
                };
                mapName.SetForeColor(_fontColor);
                mapName.TextString = mapObject.Name;
                GeoPoint screenPt = FromLatLngToMapPixel(drawPt);
                mapName.Point.X  = screenPt.X;
                mapName.Point.Y  = screenPt.Y;
                mapName.Bounds.X = mapName.Point.X;
                mapName.Bounds.Y = mapName.Point.Y;
                Font font = null;
                if (_font != null)
                {
                    font = (Font)_font.GetNativeFont();
                    SizeF sizeF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font);
                    mapName.Bounds.Height = sizeF.Height;
                    mapName.Bounds.Width  = sizeF.Width;
                }
                TextPosInfo textPosInfo = new TextPosInfo();
                textPosInfo._mapText = mapName;
                if (mapObject.GetMapObjectType() == MapObject.PLINE)
                {
                    if (plinePoints != null)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        graphicsPath.AddLines(plinePoints);
                        RectangleF [] rectangleF;
                        double        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);
                        if (angle < 180)
                        {
                            graphicsPath.Reverse();
                        }
                        angle = GetAngle(plinePoints[0], plinePoints[plinePoints.Length - 1]);

                        float rotateAngle = GetRotateAngle(angle);
                        rectangleF = SharedGraphics2D.Graphics.MeasureString(mapName.TextString, font,
                                                                             new SolidBrush(
                                                                                 Color.FromArgb(_fontColor)),
                                                                             TextPathAlign.Center,
                                                                             TextPathPosition.CenterPath, 100, rotateAngle,
                                                                             graphicsPath);

                        textPosInfo._graphicsPath = graphicsPath;
                        textPosInfo._rectangles   = rectangleF;



                        if (rectangleF.Length == mapName.TextString.Length)
                        {
                            //RectangleF[] rectangleFs = new RectangleF[rectangleF.Length];
                            //Array.Copy(rectangleF, rectangleFs, rectangleF.Length);
                            //for (int i = 0; i < rectangleFs.Length;i++ )
                            //{
                            //    for(int j=0;j<rectangleF.Length;j++)
                            //    {
                            //        if(i!=j)
                            //        {
                            //            if(rectangleFs[i].IntersectsWith(rectangleF[j]))
                            //            {
                            //                return;
                            //            }
                            //        }
                            //    }
                            //}


                            AddMapName(textPosInfo);
                        }
                    }
                }
                else
                {
                    textPosInfo._graphicsPath = null;
                    textPosInfo._rectangles   = new[] { new RectangleF((float)textPosInfo._mapText.Bounds.X, (float)textPosInfo._mapText.Bounds.Y,
                                                                       (float)textPosInfo._mapText.Bounds.Width,
                                                                       (float)textPosInfo._mapText.Bounds.Height) };
                    AddMapName(textPosInfo);
                }
            }
        }
        /// <summary>
        /// Paints the axis break line.
        /// </summary>
        /// <param name="graph">Chart graphics to use.</param>
        /// <param name="nextSegment">Axis scale segment next to current.</param>
        internal void PaintBreakLine(ChartGraphics graph, AxisScaleSegment nextSegment)
        {
            // Get break line position
            RectangleF breakPosition = this.GetBreakLinePosition(graph, nextSegment);

            // Get top line graphics path
            GraphicsPath breakLinePathTop    = this.GetBreakLinePath(breakPosition, true);
            GraphicsPath breakLinePathBottom = null;

            // Clear break line space using chart color behind the area
            if (breakPosition.Width > 0f && breakPosition.Height > 0f)
            {
                // Get bottom line graphics path
                breakLinePathBottom = this.GetBreakLinePath(breakPosition, false);

                // Clear plotting area background
                using (GraphicsPath fillPath = new GraphicsPath())
                {
                    // Create fill path out of top and bottom break lines
                    fillPath.AddPath(breakLinePathTop, true);
                    fillPath.Reverse();
                    fillPath.AddPath(breakLinePathBottom, true);
                    fillPath.CloseAllFigures();

                    // Use chart back color to fill the area
                    using (Brush fillBrush = this.GetChartFillBrush(graph))
                    {
                        graph.FillPath(fillBrush, fillPath);

                        // Check if shadow exsits in chart area
                        if (this.axis.ChartArea.ShadowOffset != 0 && !this.axis.ChartArea.ShadowColor.IsEmpty)
                        {
                            // Clear shadow
                            RectangleF shadowPartRect = breakPosition;
                            if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                            {
                                shadowPartRect.Y      += this.axis.ChartArea.ShadowOffset;
                                shadowPartRect.Height -= this.axis.ChartArea.ShadowOffset;
                                shadowPartRect.X       = shadowPartRect.Right - 1;
                                shadowPartRect.Width   = this.axis.ChartArea.ShadowOffset + 2;
                            }
                            else
                            {
                                shadowPartRect.X     += this.axis.ChartArea.ShadowOffset;
                                shadowPartRect.Width -= this.axis.ChartArea.ShadowOffset;
                                shadowPartRect.Y      = shadowPartRect.Bottom - 1;
                                shadowPartRect.Height = this.axis.ChartArea.ShadowOffset + 2;
                            }
                            graph.FillRectangle(fillBrush, shadowPartRect);

                            // Draw new shadow
                            using (GraphicsPath shadowPath = new GraphicsPath())
                            {
                                shadowPath.AddPath(breakLinePathTop, false);

                                // Define maximum size
                                float size = this.axis.ChartArea.ShadowOffset;
                                if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                                {
                                    size = Math.Min(size, breakPosition.Height);
                                }
                                else
                                {
                                    size = Math.Min(size, breakPosition.Width);
                                }

                                // Define step to increase transperancy
                                int transparencyStep = (int)(this.axis.ChartArea.ShadowColor.A / size);

                                // Set clip region to achieve spacing of the shadow
                                // Start with the plotting rectangle position
                                RectangleF clipRegion = graph.GetAbsoluteRectangle(this.axis.PlotAreaPosition.ToRectangleF());
                                if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                                {
                                    clipRegion.X     += this.axis.ChartArea.ShadowOffset;
                                    clipRegion.Width += this.axis.ChartArea.ShadowOffset;
                                }
                                else
                                {
                                    clipRegion.Y      += this.axis.ChartArea.ShadowOffset;
                                    clipRegion.Height += this.axis.ChartArea.ShadowOffset;
                                }
                                graph.SetClip(graph.GetRelativeRectangle(clipRegion));

                                // Draw several lines to form shadow
                                for (int index = 0; index < size; index++)
                                {
                                    using (Matrix newMatrix = new Matrix())
                                    {
                                        // Shift top break line by 1 pixel
                                        if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                                        {
                                            newMatrix.Translate(0f, 1f);
                                        }
                                        else
                                        {
                                            newMatrix.Translate(1f, 0f);
                                        }
                                        shadowPath.Transform(newMatrix);
                                    }

                                    // Get line color
                                    Color color = Color.FromArgb(
                                        this.axis.ChartArea.ShadowColor.A - transparencyStep * index,
                                        this.axis.ChartArea.ShadowColor);

                                    using (Pen shadowPen = new Pen(color, 1))
                                    {
                                        // Draw shadow
                                        graph.DrawPath(shadowPen, shadowPath);
                                    }
                                }

                                graph.ResetClip();
                            }
                        }
                    }
                }
            }

            // Draw Separator Line(s)
            if (this.axis.ScaleBreakStyle.BreakLineStyle != BreakLineStyle.None)
            {
                using (Pen pen = new Pen(this.axis.ScaleBreakStyle.LineColor, this.axis.ScaleBreakStyle.LineWidth))
                {
                    // Set line style
                    pen.DashStyle = graph.GetPenStyle(this.axis.ScaleBreakStyle.LineDashStyle);

                    // Draw break lines
                    graph.DrawPath(pen, breakLinePathTop);
                    if (breakPosition.Width > 0f && breakPosition.Height > 0f)
                    {
                        graph.DrawPath(pen, breakLinePathBottom);
                    }
                }
            }

            // Dispose break line paths
            breakLinePathTop.Dispose();
            breakLinePathTop = null;
            if (breakLinePathBottom != null)
            {
                breakLinePathBottom.Dispose();
                breakLinePathBottom = null;
            }
        }
        public void PaintBreakLine(ChartGraphics graph, AxisScaleSegment nextSegment)
        {
            RectangleF   breakLinePosition = this.GetBreakLinePosition(graph, nextSegment);
            GraphicsPath breakLinePath     = this.GetBreakLinePath(breakLinePosition, true);
            GraphicsPath graphicsPath      = null;

            if (breakLinePosition.Width > 0.0 && breakLinePosition.Height > 0.0)
            {
                graphicsPath = this.GetBreakLinePath(breakLinePosition, false);
                using (GraphicsPath graphicsPath2 = new GraphicsPath())
                {
                    graphicsPath2.AddPath(breakLinePath, true);
                    graphicsPath2.Reverse();
                    graphicsPath2.AddPath(graphicsPath, true);
                    graphicsPath2.CloseAllFigures();
                    using (Brush brush = this.GetChartFillBrush(graph))
                    {
                        graph.FillPath(brush, graphicsPath2);
                        if (this.axis.chartArea.ShadowOffset != 0 && !this.axis.chartArea.ShadowColor.IsEmpty)
                        {
                            RectangleF rect = breakLinePosition;
                            if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                            {
                                rect.Y      += (float)this.axis.chartArea.ShadowOffset;
                                rect.Height -= (float)this.axis.chartArea.ShadowOffset;
                                rect.X       = (float)(rect.Right - 1.0);
                                rect.Width   = (float)(this.axis.chartArea.ShadowOffset + 2);
                            }
                            else
                            {
                                rect.X     += (float)this.axis.chartArea.ShadowOffset;
                                rect.Width -= (float)this.axis.chartArea.ShadowOffset;
                                rect.Y      = (float)(rect.Bottom - 1.0);
                                rect.Height = (float)(this.axis.chartArea.ShadowOffset + 2);
                            }
                            graph.FillRectangle(brush, rect);
                            using (GraphicsPath graphicsPath3 = new GraphicsPath())
                            {
                                graphicsPath3.AddPath(breakLinePath, false);
                                float val = (float)this.axis.chartArea.ShadowOffset;
                                val = ((this.axis.AxisPosition != AxisPosition.Right && this.axis.AxisPosition != 0) ? Math.Min(val, breakLinePosition.Width) : Math.Min(val, breakLinePosition.Height));
                                int        num = (int)((float)(int)this.axis.chartArea.ShadowColor.A / val);
                                RectangleF absoluteRectangle = graph.GetAbsoluteRectangle(this.axis.PlotAreaPosition.ToRectangleF());
                                if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                                {
                                    absoluteRectangle.X     += (float)this.axis.chartArea.ShadowOffset;
                                    absoluteRectangle.Width += (float)this.axis.chartArea.ShadowOffset;
                                }
                                else
                                {
                                    absoluteRectangle.Y      += (float)this.axis.chartArea.ShadowOffset;
                                    absoluteRectangle.Height += (float)this.axis.chartArea.ShadowOffset;
                                }
                                graph.SetClip(graph.GetRelativeRectangle(absoluteRectangle));
                                for (int i = 0; (float)i < val; i++)
                                {
                                    using (Matrix matrix = new Matrix())
                                    {
                                        if (this.axis.AxisPosition == AxisPosition.Right || this.axis.AxisPosition == AxisPosition.Left)
                                        {
                                            matrix.Translate(0f, 1f);
                                        }
                                        else
                                        {
                                            matrix.Translate(1f, 0f);
                                        }
                                        graphicsPath3.Transform(matrix);
                                    }
                                    Color color = Color.FromArgb(this.axis.chartArea.ShadowColor.A - num * i, this.axis.chartArea.ShadowColor);
                                    using (Pen pen = new Pen(color, 1f))
                                    {
                                        graph.DrawPath(pen, graphicsPath3);
                                    }
                                }
                                graph.ResetClip();
                            }
                        }
                    }
                }
            }
            if (this.axis.ScaleBreakStyle.BreakLineType != 0)
            {
                using (Pen pen2 = new Pen(this.axis.ScaleBreakStyle.LineColor, (float)this.axis.ScaleBreakStyle.LineWidth))
                {
                    pen2.DashStyle = graph.GetPenStyle(this.axis.ScaleBreakStyle.LineStyle);
                    graph.DrawPath(pen2, breakLinePath);
                    if (breakLinePosition.Width > 0.0 && breakLinePosition.Height > 0.0)
                    {
                        graph.DrawPath(pen2, graphicsPath);
                    }
                }
            }
            breakLinePath.Dispose();
            breakLinePath = null;
            if (graphicsPath != null)
            {
                graphicsPath.Dispose();
                graphicsPath = null;
            }
        }
        protected override void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
        {
            ArrayList arrayList  = null;
            ArrayList arrayList2 = null;

            if (area.Area3DStyle.Enable3D)
            {
                base.ProcessChartType(selection, graph, common, area, seriesToDraw);
                return;
            }
            bool flag  = area.IndexedSeries((string[])area.GetSeriesFromChartType(Name).ToArray(typeof(string)));
            bool flag2 = false;
            bool flag3 = false;
            int  num   = -1;

            foreach (Series item in common.DataManager.Series)
            {
                if (string.Compare(item.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item.ChartArea != area.Name || !item.IsVisible())
                {
                    continue;
                }
                if (areaPath != null)
                {
                    areaPath.Dispose();
                    areaPath = null;
                }
                areaBottomPath.Reset();
                if (num == -1)
                {
                    num = item.Points.Count;
                }
                else if (num != item.Points.Count)
                {
                    throw new ArgumentException(SR.ExceptionStackedAreaChartSeriesDataPointsNumberMismatch);
                }
                hAxis     = area.GetAxis(AxisName.X, item.XAxisType, item.XSubAxisName);
                vAxis     = area.GetAxis(AxisName.Y, item.YAxisType, item.YSubAxisName);
                hAxisMin  = hAxis.GetViewMinimum();
                hAxisMax  = hAxis.GetViewMaximum();
                vAxisMin  = vAxis.GetViewMinimum();
                vAxisMax  = vAxis.GetViewMaximum();
                axisPos.X = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos.Y = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos   = graph.GetAbsolutePoint(axisPos);
                if (arrayList2 == null)
                {
                    arrayList2 = new ArrayList(item.Points.Count);
                }
                else
                {
                    arrayList  = arrayList2;
                    arrayList2 = new ArrayList(item.Points.Count);
                }
                if (!selection)
                {
                    common.EventsManager.OnBackPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                }
                int    num2    = 0;
                float  num3    = axisPos.Y;
                float  y       = axisPos.Y;
                PointF pointF  = PointF.Empty;
                PointF pointF2 = PointF.Empty;
                foreach (DataPoint point in item.Points)
                {
                    point.positionRel = new PointF(float.NaN, float.NaN);
                    double num4 = point.Empty ? 0.0 : GetYValue(common, area, item, point, num2, 0);
                    double num5 = flag ? ((double)num2 + 1.0) : point.XValue;
                    if (arrayList != null && num2 < arrayList.Count)
                    {
                        num4 += (double)arrayList[num2];
                    }
                    arrayList2.Insert(num2, num4);
                    float y2 = (float)vAxis.GetPosition(num4);
                    float x  = (float)hAxis.GetPosition(num5);
                    point.positionRel = new PointF(x, y2);
                    num4 = vAxis.GetLogValue(num4);
                    num5 = hAxis.GetLogValue(num5);
                    if (pointF == PointF.Empty)
                    {
                        pointF.X = x;
                        pointF.Y = y2;
                        if (arrayList != null && num2 < arrayList.Count)
                        {
                            num3 = (float)vAxis.GetPosition((double)arrayList[num2]);
                            num3 = graph.GetAbsolutePoint(new PointF(num3, num3)).Y;
                        }
                        pointF = graph.GetAbsolutePoint(pointF);
                        num2++;
                        continue;
                    }
                    pointF2.X = x;
                    pointF2.Y = y2;
                    if (arrayList != null && num2 < arrayList.Count)
                    {
                        y = (float)vAxis.GetPosition((double)arrayList[num2]);
                        y = graph.GetAbsolutePoint(new PointF(y, y)).Y;
                    }
                    pointF2   = graph.GetAbsolutePoint(pointF2);
                    pointF.X  = (float)Math.Round(pointF.X);
                    pointF2.X = (float)Math.Round(pointF2.X);
                    GraphicsPath graphicsPath = new GraphicsPath();
                    graphicsPath.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y);
                    graphicsPath.AddLine(pointF2.X, pointF2.Y, pointF2.X, y);
                    graphicsPath.AddLine(pointF2.X, y, pointF.X, num3);
                    graphicsPath.AddLine(pointF.X, num3, pointF.X, pointF.Y);
                    if (common.ProcessModePaint)
                    {
                        if (!point.Empty)
                        {
                            GetYValue(common, area, item, item.Points[num2 - 1], num2 - 1, 0);
                        }
                        double num6 = flag ? ((double)num2) : item.Points[num2 - 1].XValue;
                        if ((num5 <= hAxisMin && num6 <= hAxisMin) || (num5 >= hAxisMax && num6 >= hAxisMax))
                        {
                            pointF = pointF2;
                            num3   = y;
                            num2++;
                            continue;
                        }
                        Brush brush = null;
                        if (point.BackHatchStyle != 0)
                        {
                            brush = graph.GetHatchBrush(point.BackHatchStyle, point.Color, point.BackGradientEndColor);
                        }
                        else if (point.BackGradientType == GradientType.None)
                        {
                            brush = ((point.BackImage.Length > 0 && point.BackImageMode != ChartImageWrapMode.Unscaled && point.BackImageMode != ChartImageWrapMode.Scaled) ? graph.GetTextureBrush(point.BackImage, point.BackImageTransparentColor, point.BackImageMode, point.Color) : ((!point.Empty || !(point.Color == Color.Empty)) ? new SolidBrush(point.Color) : new SolidBrush(item.Color)));
                        }
                        else
                        {
                            gradientFill = true;
                            series       = point.series;
                        }
                        if (point.BorderColor != Color.Empty && point.BorderWidth > 0)
                        {
                            flag2 = true;
                        }
                        if (point.Label.Length > 0 || point.ShowLabelAsValue)
                        {
                            flag3 = true;
                        }
                        if (!gradientFill)
                        {
                            graph.StartAnimation();
                            graph.StartHotRegion(point);
                            SmoothingMode smoothingMode = graph.SmoothingMode;
                            graph.SmoothingMode = SmoothingMode.None;
                            graph.FillPath(brush, graphicsPath);
                            graph.SmoothingMode = smoothingMode;
                            Pen pen = new Pen(brush, 1f);
                            if (pointF.X != pointF2.X && pointF.Y != pointF2.Y)
                            {
                                graph.DrawLine(pen, pointF.X, pointF.Y, pointF2.X, pointF2.Y);
                            }
                            if (pointF.X != pointF2.X && y != num3)
                            {
                                graph.DrawLine(pen, pointF2.X, y, pointF.X, num3);
                            }
                            graph.EndHotRegion();
                            graph.StopAnimation();
                        }
                        if (areaPath == null)
                        {
                            areaPath = new GraphicsPath();
                        }
                        areaPath.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y);
                        areaBottomPath.AddLine(pointF.X, num3, pointF2.X, y);
                    }
                    if (common.ProcessModeRegions)
                    {
                        PointF   empty      = PointF.Empty;
                        float[]  array      = new float[graphicsPath.PointCount * 2];
                        PointF[] pathPoints = graphicsPath.PathPoints;
                        for (int i = 0; i < graphicsPath.PointCount; i++)
                        {
                            empty            = graph.GetRelativePoint(pathPoints[i]);
                            array[2 * i]     = empty.X;
                            array[2 * i + 1] = empty.Y;
                        }
                        common.HotRegionsList.AddHotRegion(graph, graphicsPath, relativePath: false, array, point, item.Name, num2);
                        if (point.BorderWidth > 1 && point.BorderStyle != 0 && point.BorderColor != Color.Empty)
                        {
                            GraphicsPath graphicsPath2 = new GraphicsPath();
                            graphicsPath2.AddLine(pointF.X, pointF.Y, pointF2.X, pointF2.Y);
                            ChartGraphics.Widen(graphicsPath2, new Pen(point.Color, point.BorderWidth + 2));
                            empty = PointF.Empty;
                            array = new float[graphicsPath2.PointCount * 2];
                            for (int j = 0; j < graphicsPath2.PointCount; j++)
                            {
                                empty            = graph.GetRelativePoint(graphicsPath2.PathPoints[j]);
                                array[2 * j]     = empty.X;
                                array[2 * j + 1] = empty.Y;
                            }
                            common.HotRegionsList.AddHotRegion(graph, graphicsPath2, relativePath: false, array, point, item.Name, num2);
                        }
                    }
                    pointF = pointF2;
                    num3   = y;
                    num2++;
                }
                if (gradientFill && areaPath != null)
                {
                    GraphicsPath graphicsPath3 = new GraphicsPath();
                    graphicsPath3.AddPath(areaPath, connect: true);
                    areaBottomPath.Reverse();
                    graphicsPath3.AddPath(areaBottomPath, connect: true);
                    Brush gradientBrush = graph.GetGradientBrush(graphicsPath3.GetBounds(), series.Color, series.BackGradientEndColor, series.BackGradientType);
                    graph.FillPath(gradientBrush, graphicsPath3);
                    areaPath.Dispose();
                    areaPath     = null;
                    gradientFill = false;
                }
                areaBottomPath.Reset();
                if (!selection)
                {
                    common.EventsManager.OnPaint(item, new ChartPaintEventArgs(graph, common, area.PlotAreaPosition));
                }
            }
            if (flag2)
            {
                arrayList  = null;
                arrayList2 = null;
                foreach (Series item2 in common.DataManager.Series)
                {
                    if (string.Compare(item2.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item2.ChartArea != area.Name || !item2.IsVisible())
                    {
                        continue;
                    }
                    hAxis     = area.GetAxis(AxisName.X, item2.XAxisType, item2.XSubAxisName);
                    vAxis     = area.GetAxis(AxisName.Y, item2.YAxisType, item2.YSubAxisName);
                    axisPos.X = (float)vAxis.GetPosition(vAxis.Crossing);
                    axisPos.Y = (float)vAxis.GetPosition(vAxis.Crossing);
                    axisPos   = graph.GetAbsolutePoint(axisPos);
                    if (arrayList2 == null)
                    {
                        arrayList2 = new ArrayList(item2.Points.Count);
                    }
                    else
                    {
                        arrayList  = arrayList2;
                        arrayList2 = new ArrayList(item2.Points.Count);
                    }
                    int    num7    = 0;
                    float  num8    = axisPos.Y;
                    float  num9    = axisPos.Y;
                    PointF pointF3 = PointF.Empty;
                    PointF pointF4 = PointF.Empty;
                    foreach (DataPoint point2 in item2.Points)
                    {
                        double num10     = point2.Empty ? 0.0 : GetYValue(common, area, item2, point2, num7, 0);
                        double axisValue = flag ? ((double)num7 + 1.0) : point2.XValue;
                        if (arrayList != null && num7 < arrayList.Count)
                        {
                            num10 += (double)arrayList[num7];
                        }
                        arrayList2.Insert(num7, num10);
                        float y3 = (float)vAxis.GetPosition(num10);
                        float x2 = (float)hAxis.GetPosition(axisValue);
                        if (pointF3 == PointF.Empty)
                        {
                            pointF3.X = x2;
                            pointF3.Y = y3;
                            if (arrayList != null && num7 < arrayList.Count)
                            {
                                num8 = (float)vAxis.GetPosition((double)arrayList[num7]);
                                num8 = graph.GetAbsolutePoint(new PointF(num8, num8)).Y;
                            }
                            pointF3 = graph.GetAbsolutePoint(pointF3);
                            pointF4 = pointF3;
                            num9    = num8;
                        }
                        else
                        {
                            pointF4.X = x2;
                            pointF4.Y = y3;
                            if (arrayList != null && num7 < arrayList.Count)
                            {
                                num9 = (float)vAxis.GetPosition((double)arrayList[num7]);
                                num9 = graph.GetAbsolutePoint(new PointF(num9, num9)).Y;
                            }
                            pointF4 = graph.GetAbsolutePoint(pointF4);
                        }
                        if (num7 != 0)
                        {
                            pointF3.X = (float)Math.Round(pointF3.X);
                            pointF4.X = (float)Math.Round(pointF4.X);
                            graph.StartAnimation();
                            graph.DrawLineRel(point2.BorderColor, point2.BorderWidth, point2.BorderStyle, graph.GetRelativePoint(pointF3), graph.GetRelativePoint(pointF4), point2.series.ShadowColor, point2.series.ShadowOffset);
                            graph.StopAnimation();
                        }
                        pointF3 = pointF4;
                        num8    = num9;
                        num7++;
                    }
                }
            }
            if (!flag3)
            {
                return;
            }
            arrayList  = null;
            arrayList2 = null;
            foreach (Series item3 in common.DataManager.Series)
            {
                if (string.Compare(item3.ChartTypeName, Name, StringComparison.OrdinalIgnoreCase) != 0 || item3.ChartArea != area.Name || !item3.IsVisible())
                {
                    continue;
                }
                hAxis     = area.GetAxis(AxisName.X, item3.XAxisType, item3.XSubAxisName);
                vAxis     = area.GetAxis(AxisName.Y, item3.YAxisType, item3.YSubAxisName);
                axisPos.X = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos.Y = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos   = graph.GetAbsolutePoint(axisPos);
                if (arrayList2 == null)
                {
                    arrayList2 = new ArrayList(item3.Points.Count);
                }
                else
                {
                    arrayList  = arrayList2;
                    arrayList2 = new ArrayList(item3.Points.Count);
                }
                int    num11   = 0;
                float  num12   = axisPos.Y;
                float  num13   = axisPos.Y;
                PointF pointF5 = PointF.Empty;
                PointF pointF6 = PointF.Empty;
                foreach (DataPoint point3 in item3.Points)
                {
                    double num14      = point3.Empty ? 0.0 : GetYValue(common, area, item3, point3, num11, 0);
                    double axisValue2 = flag ? ((double)num11 + 1.0) : point3.XValue;
                    if (arrayList != null && num11 < arrayList.Count)
                    {
                        num14 += (double)arrayList[num11];
                    }
                    arrayList2.Insert(num11, num14);
                    float y4 = (float)vAxis.GetPosition(num14);
                    float x3 = (float)hAxis.GetPosition(axisValue2);
                    if (pointF5 == PointF.Empty)
                    {
                        pointF5.X = x3;
                        pointF5.Y = y4;
                        if (arrayList != null && num11 < arrayList.Count)
                        {
                            num12 = (float)vAxis.GetPosition((double)arrayList[num11]);
                            num12 = graph.GetAbsolutePoint(new PointF(num12, num12)).Y;
                        }
                        pointF5 = graph.GetAbsolutePoint(pointF5);
                        pointF6 = pointF5;
                        num13   = num12;
                    }
                    else
                    {
                        pointF6.X = x3;
                        pointF6.Y = y4;
                        if (arrayList != null && num11 < arrayList.Count)
                        {
                            num13 = (float)vAxis.GetPosition((double)arrayList[num11]);
                            num13 = graph.GetAbsolutePoint(new PointF(num13, num13)).Y;
                        }
                        pointF6 = graph.GetAbsolutePoint(pointF6);
                    }
                    if (!point3.Empty && (item3.ShowLabelAsValue || point3.ShowLabelAsValue || point3.Label.Length > 0))
                    {
                        StringFormat stringFormat = new StringFormat();
                        stringFormat.Alignment     = StringAlignment.Center;
                        stringFormat.LineAlignment = StringAlignment.Center;
                        string text;
                        if (point3.Label.Length == 0)
                        {
                            double value = GetYValue(common, area, item3, point3, num11, 0);
                            if (hundredPercentStacked && point3.LabelFormat.Length == 0)
                            {
                                value = Math.Round(value, 2);
                            }
                            text = ValueConverter.FormatValue(item3.chart, point3, value, point3.LabelFormat, item3.YValueType, ChartElementType.DataPoint);
                        }
                        else
                        {
                            text = point3.ReplaceKeywords(point3.Label);
                            if (item3.chart != null && item3.chart.LocalizeTextHandler != null)
                            {
                                text = item3.chart.LocalizeTextHandler(point3, text, point3.ElementId, ChartElementType.DataPoint);
                            }
                        }
                        Region clip = graph.Clip;
                        graph.Clip = new Region();
                        graph.StartAnimation();
                        PointF empty2 = PointF.Empty;
                        empty2.X = pointF6.X;
                        empty2.Y = pointF6.Y - (pointF6.Y - num13) / 2f;
                        empty2   = graph.GetRelativePoint(empty2);
                        SizeF      relativeSize = graph.GetRelativeSize(graph.MeasureString(text, point3.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)));
                        RectangleF empty3       = RectangleF.Empty;
                        SizeF      sizeF        = new SizeF(relativeSize.Width, relativeSize.Height);
                        sizeF.Height += relativeSize.Height / 8f;
                        sizeF.Width  += sizeF.Width / (float)text.Length;
                        graph.DrawPointLabelStringRel(backPosition: new RectangleF(empty2.X - sizeF.Width / 2f, empty2.Y - sizeF.Height / 2f - relativeSize.Height / 10f, sizeF.Width, sizeF.Height), common: common, text: text, font: point3.Font, brush: new SolidBrush(point3.FontColor), position: empty2, format: stringFormat, angle: point3.FontAngle, backColor: point3.LabelBackColor, borderColor: point3.LabelBorderColor, borderWidth: point3.LabelBorderWidth, borderStyle: point3.LabelBorderStyle, series: item3, point: point3, pointIndex: num11);
                        graph.StopAnimation();
                        graph.Clip = clip;
                    }
                    pointF5 = pointF6;
                    num12   = num13;
                    num11++;
                }
            }
        }
Beispiel #18
0
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            GraphicsPath graphicsPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath) ? new GraphicsPath() : null;

            if (centerPointIndex == int.MaxValue)
            {
                centerPointIndex = GetCenterPointIndex(points);
            }
            DataPoint3D dataPoint3D        = (DataPoint3D)points[pointIndex];
            int         neighborPointIndex = pointIndex;
            DataPoint3D dataPoint3D2       = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, multiSeries ? dataPoint3D : null, ref neighborPointIndex);
            bool        flag = false;

            if (dataPoint3D2.index > dataPoint3D.index)
            {
                DataPoint3D dataPoint3D3 = dataPoint3D2;
                dataPoint3D2 = dataPoint3D;
                dataPoint3D  = dataPoint3D3;
                flag         = true;
            }
            if (matrix.perspective != 0f && centerPointIndex != int.MaxValue)
            {
                neighborPointIndex = pointIndex;
                if (pointIndex != centerPointIndex + 1)
                {
                    dataPoint3D2 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, multiSeries ? dataPoint3D : null, ref neighborPointIndex);
                }
                else if (!area.reverseSeriesOrder)
                {
                    dataPoint3D = ChartGraphics3D.FindPointByIndex(points, dataPoint3D2.index + 1, multiSeries ? dataPoint3D : null, ref neighborPointIndex);
                }
                else
                {
                    dataPoint3D2 = dataPoint3D;
                    dataPoint3D  = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, multiSeries ? dataPoint3D : null, ref neighborPointIndex);
                }
            }
            if (dataPoint3D2 == null || dataPoint3D == null)
            {
                return(graphicsPath);
            }
            DataPoint3D dataPoint3D4 = dataPoint3D;

            if (prevDataPointEx.dataPoint.Empty)
            {
                dataPoint3D4 = prevDataPointEx;
            }
            else if (dataPoint3D2.index > dataPoint3D.index)
            {
                dataPoint3D4 = dataPoint3D2;
            }
            if (!useBorderColor)
            {
                _ = dataPoint3D4.dataPoint.Color;
            }
            else
            {
                _ = dataPoint3D4.dataPoint.BorderColor;
            }
            _ = dataPoint3D4.dataPoint.BorderStyle;
            if (dataPoint3D4.dataPoint.Empty && dataPoint3D4.dataPoint.Color == Color.Empty)
            {
                _ = Color.Gray;
            }
            if (dataPoint3D4.dataPoint.Empty)
            {
                _ = dataPoint3D4.dataPoint.BorderStyle;
            }
            flag = false;
            for (int i = 1; pointIndex + i < points.Count; i++)
            {
                DataPoint3D dataPoint3D5 = (DataPoint3D)points[pointIndex + i];
                if (dataPoint3D5.dataPoint.series.Name == dataPoint3D2.dataPoint.series.Name)
                {
                    if (dataPoint3D5.index == dataPoint3D2.index)
                    {
                        flag = true;
                    }
                    break;
                }
            }
            if (tension != 0f)
            {
                GraphicsPath splineFlattenPath = graph.GetSplineFlattenPath(area, matrix, positionZ, depth, dataPoint3D2, dataPoint3D, points, pointIndex, tension, flatten: true, translateCoordinates: false, 0);
                PointF[]     array             = null;
                flag = (pointIndex < neighborPointIndex);
                if (flag)
                {
                    splineFlattenPath.Reverse();
                }
                array = splineFlattenPath.PathPoints;
                DataPoint3D     dataPoint3D6    = new DataPoint3D();
                DataPoint3D     dataPoint3D7    = new DataPoint3D();
                LineSegmentType lineSegmentType = LineSegmentType.Middle;
                for (int j = 1; j < array.Length; j++)
                {
                    if (!flag)
                    {
                        dataPoint3D6.dataPoint = dataPoint3D2.dataPoint;
                        dataPoint3D6.index     = dataPoint3D2.index;
                        dataPoint3D6.xPosition = array[j - 1].X;
                        dataPoint3D6.yPosition = array[j - 1].Y;
                        dataPoint3D7.dataPoint = dataPoint3D.dataPoint;
                        dataPoint3D7.index     = dataPoint3D.index;
                        dataPoint3D7.xPosition = array[j].X;
                        dataPoint3D7.yPosition = array[j].Y;
                    }
                    else
                    {
                        dataPoint3D7.dataPoint = dataPoint3D2.dataPoint;
                        dataPoint3D7.index     = dataPoint3D2.index;
                        dataPoint3D7.xPosition = array[j - 1].X;
                        dataPoint3D7.yPosition = array[j - 1].Y;
                        dataPoint3D6.dataPoint = dataPoint3D.dataPoint;
                        dataPoint3D6.index     = dataPoint3D.index;
                        dataPoint3D6.xPosition = array[j].X;
                        dataPoint3D6.yPosition = array[j].Y;
                    }
                    lineSegmentType = LineSegmentType.Middle;
                    if (j == 1)
                    {
                        lineSegmentType = ((!flag) ? LineSegmentType.First : LineSegmentType.Last);
                    }
                    else if (j == array.Length - 1)
                    {
                        lineSegmentType = (flag ? LineSegmentType.First : LineSegmentType.Last);
                    }
                    area.IterationCounter = 0;
                    GraphicsPath graphicsPath2 = Draw3DSurface(dataPoint3D6, dataPoint3D7, flag, area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, 0f, operationType, lineSegmentType, topDarkening, bottomDarkening, new PointF(float.NaN, float.NaN), new PointF(float.NaN, float.NaN), clippedSegment, clipOnTop: true, clipOnBottom: true);
                    if (graphicsPath != null && graphicsPath2 != null && graphicsPath2.PointCount > 0)
                    {
                        graphicsPath.AddPath(graphicsPath2, connect: true);
                    }
                }
                return(graphicsPath);
            }
            return(Draw3DSurface(dataPoint3D2, dataPoint3D, flag, area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, tension, operationType, LineSegmentType.Single, topDarkening, bottomDarkening, thirdPointPosition, fourthPointPosition, clippedSegment, clipOnTop: true, clipOnBottom: true));
        }
Beispiel #19
0
        //
        //  This Plot() method has been tweaked so it will color in two different colors
        //  in-between the two plots of Values[3] and Values[4].
        //
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            base.Plot(graphics, bounds, min, max);

            if (Bars == null || ChartControl == null)
            {
                return;
            }

            SolidBrush brush;                                                                           // Set current brush color here.

            SolidBrush brushUP   = new SolidBrush(Color.FromArgb(bandAreaColorOpacity * 20, bandAreaColorUp));
            SolidBrush brushDOWN = new SolidBrush(Color.FromArgb(bandAreaColorOpacity * 20, bandAreaColorDown));

            int           barWidth         = ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);
            SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
            GraphicsPath  path             = new GraphicsPath();

            DataSeries series0 = (DataSeries)Values[0];                 // Color in between these two plots.
            DataSeries series1 = (DataSeries)Values[1];

            brush = brushUP;                                                    // Start with the upwards color.
            int  barcount = 0;                                                  // Start with leftmost bar.
            bool firstbar = true;                                               // Plotting the first bar.

            while (barcount < ChartControl.BarsPainted)                         // Continue until all bars have been painted.
            {
                int count = 0;                                                  // Counter for innner loop.
                for (int seriesCount = 0; seriesCount < 2; seriesCount++)
                {
                    int            lastX  = -1;
                    int            lastY  = -1;
                    DataSeries     series = (DataSeries)Values[seriesCount];
                    Gui.Chart.Plot plot   = Plots[seriesCount];

                    for (count = barcount; count < ChartControl.BarsPainted; count++)
                    {
                        int idx = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + count;
                        if (idx < 0 || idx >= Input.Count || (!ChartControl.ShowBarsRequired && idx < BarsRequired))
                        {
                            continue;
                        }

                        double val = series.Get(idx);                                                           // Get next y-value to be plotted.
                        if (val == 0)                                                                           // If nothing to plot...
                        {
                            continue;                                                                           // ...ignore the enrtry.
                        }
                        int x = (int)(ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2
                                      + (count - ChartControl.BarsPainted + 1) * ChartControl.BarSpace) + 1;

                        int y = (int)((bounds.Y + bounds.Height) - ((val - min) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height);

                        double val0 = series0.Get(idx);
                        double val1 = series1.Get(idx);
                        if (((val0 > val1) && (brush != brushUP)) ||                            // Now going in wrong direction?
                            ((val0 < val1) && (brush != brushDOWN)))
                        {                                                                       // Yes.  Done with this loop.
                            if (lastX >= 0)                                                     // Was there a last point?
                            {                                                                   // Yes.  Connect it to the position half-way to this one.
                                path.AddLine(lastX - plot.Pen.Width / 2, lastY, (x + lastX - plot.Pen.Width) / 2, (lastY + y) / 2);
                                // Plot vertex of cross-over of the lines (1/2 way point).
                            }
                            break;                                                                                              // Done, exit inner loop to change color.
                        }

                        if (firstbar == false)                                                      // Is this the first plotted bar of the chart?
                        {                                                                           // No.  Plot all bars after the first one.
                            if (count == barcount)                                                  // First bar after direction change (and color swap)?
                            {                                                                       // Yes.  Add line segment for cross-over, 1/2 bar back.
                                double valm1 = series.Get(idx - 1);                                 // Get prior y-value to be plotted.
                                lastX = x - ChartControl.BarSpace / 2;                              // Back up 1/2 a bar for x-value.
                                lastY = (y + (int)((bounds.Y + bounds.Height) - ((valm1 - min) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height)) / 2;
                            }

                            path.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y);                 // Connect last point to this one.
                        }
                        firstbar = false;                                                                               // No longer the first bar.
                        lastX    = x;                                                                                   // Save current position for next time, so we can connect the dots.
                        lastY    = y;
                    }
                    path.Reverse();                                                                                     // Go back the other direction.
                }
                graphics.SmoothingMode = SmoothingMode.AntiAlias;
                graphics.FillPath(brush, path);
                path.Reset();                                                           // Eliminate points already colored.

                barcount = count;                                                       // Get ready to process next segment.
                brush    = (brush == brushUP) ? brushDOWN : brushUP;                    // Switch colors for next segment.
            }
            graphics.SmoothingMode = oldSmoothingMode;                                  // Restore smoothing mode before exiting.
        }
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            GraphicsPath graphicsPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath) ? new GraphicsPath() : null;

            if (base.centerPointIndex == 2147483647)
            {
                base.centerPointIndex = base.GetCenterPointIndex(points);
            }
            DataPoint3D dataPoint3D  = (DataPoint3D)points[pointIndex];
            int         num          = pointIndex;
            DataPoint3D dataPoint3D2 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, base.multiSeries ? dataPoint3D : null, ref num);
            bool        flag         = false;

            if (dataPoint3D2.index > dataPoint3D.index)
            {
                DataPoint3D dataPoint3D3 = dataPoint3D2;
                dataPoint3D2 = dataPoint3D;
                dataPoint3D  = dataPoint3D3;
                flag         = true;
            }
            if (matrix.perspective != 0.0 && base.centerPointIndex != 2147483647)
            {
                num = pointIndex;
                if (pointIndex != base.centerPointIndex + 1)
                {
                    dataPoint3D2 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, base.multiSeries ? dataPoint3D : null, ref num);
                }
                else if (!area.reverseSeriesOrder)
                {
                    dataPoint3D = ChartGraphics3D.FindPointByIndex(points, dataPoint3D2.index + 1, base.multiSeries ? dataPoint3D : null, ref num);
                }
                else
                {
                    dataPoint3D2 = dataPoint3D;
                    dataPoint3D  = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, base.multiSeries ? dataPoint3D : null, ref num);
                }
            }
            if (dataPoint3D2 != null && dataPoint3D != null)
            {
                DataPoint3D dataPoint3D4 = dataPoint3D;
                if (prevDataPointEx.dataPoint.Empty)
                {
                    dataPoint3D4 = prevDataPointEx;
                }
                else if (dataPoint3D2.index > dataPoint3D.index)
                {
                    dataPoint3D4 = dataPoint3D2;
                }
                if (!base.useBorderColor)
                {
                    Color color = dataPoint3D4.dataPoint.Color;
                }
                else
                {
                    Color borderColor = dataPoint3D4.dataPoint.BorderColor;
                }
                ChartDashStyle borderStyle = dataPoint3D4.dataPoint.BorderStyle;
                if (dataPoint3D4.dataPoint.Empty && dataPoint3D4.dataPoint.Color == Color.Empty)
                {
                    Color gray = Color.Gray;
                }
                if (dataPoint3D4.dataPoint.Empty)
                {
                    ChartDashStyle borderStyle2 = dataPoint3D4.dataPoint.BorderStyle;
                }
                flag = false;
                for (int i = 1; pointIndex + i < points.Count; i++)
                {
                    DataPoint3D dataPoint3D5 = (DataPoint3D)points[pointIndex + i];
                    if (dataPoint3D5.dataPoint.series.Name == dataPoint3D2.dataPoint.series.Name)
                    {
                        if (dataPoint3D5.index == dataPoint3D2.index)
                        {
                            flag = true;
                        }
                        break;
                    }
                }
                if (tension != 0.0)
                {
                    GraphicsPath splineFlattenPath = graph.GetSplineFlattenPath(area, matrix, positionZ, depth, dataPoint3D2, dataPoint3D, points, pointIndex, tension, true, false, 0);
                    PointF[]     array             = null;
                    flag = (pointIndex < num);
                    if (flag)
                    {
                        splineFlattenPath.Reverse();
                    }
                    array = splineFlattenPath.PathPoints;
                    DataPoint3D     dataPoint3D6    = new DataPoint3D();
                    DataPoint3D     dataPoint3D7    = new DataPoint3D();
                    LineSegmentType lineSegmentType = LineSegmentType.Middle;
                    for (int j = 1; j < array.Length; j++)
                    {
                        if (!flag)
                        {
                            dataPoint3D6.dataPoint = dataPoint3D2.dataPoint;
                            dataPoint3D6.index     = dataPoint3D2.index;
                            dataPoint3D6.xPosition = (double)array[j - 1].X;
                            dataPoint3D6.yPosition = (double)array[j - 1].Y;
                            dataPoint3D7.dataPoint = dataPoint3D.dataPoint;
                            dataPoint3D7.index     = dataPoint3D.index;
                            dataPoint3D7.xPosition = (double)array[j].X;
                            dataPoint3D7.yPosition = (double)array[j].Y;
                        }
                        else
                        {
                            dataPoint3D7.dataPoint = dataPoint3D2.dataPoint;
                            dataPoint3D7.index     = dataPoint3D2.index;
                            dataPoint3D7.xPosition = (double)array[j - 1].X;
                            dataPoint3D7.yPosition = (double)array[j - 1].Y;
                            dataPoint3D6.dataPoint = dataPoint3D.dataPoint;
                            dataPoint3D6.index     = dataPoint3D.index;
                            dataPoint3D6.xPosition = (double)array[j].X;
                            dataPoint3D6.yPosition = (double)array[j].Y;
                        }
                        lineSegmentType = LineSegmentType.Middle;
                        if (j == 1)
                        {
                            lineSegmentType = (LineSegmentType)((!flag) ? 1 : 3);
                        }
                        else if (j == array.Length - 1)
                        {
                            lineSegmentType = (LineSegmentType)(flag ? 1 : 3);
                        }
                        area.IterationCounter = 0;
                        GraphicsPath graphicsPath2 = this.Draw3DSurface(dataPoint3D6, dataPoint3D7, flag, area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, 0f, operationType, lineSegmentType, topDarkening, bottomDarkening, new PointF(float.NaN, float.NaN), new PointF(float.NaN, float.NaN), clippedSegment, true, true);
                        if (graphicsPath != null && graphicsPath2 != null && graphicsPath2.PointCount > 0)
                        {
                            graphicsPath.AddPath(graphicsPath2, true);
                        }
                    }
                    return(graphicsPath);
                }
                return(this.Draw3DSurface(dataPoint3D2, dataPoint3D, flag, area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, tension, operationType, LineSegmentType.Single, topDarkening, bottomDarkening, thirdPointPosition, fourthPointPosition, clippedSegment, true, true));
            }
            return(graphicsPath);
        }
        public static void RenderArcScaleLines(
            this Graphics Graphics, Rectangle ClientRectangle, Point Center,
            Int32 MinorTickOuterRadius, Int32 MinorTickInnerRadius, Int32 MinorTickWidth, Color MinorTickForeColor, Int32 MinorNumOfTicks,
            Int32 IntermediateTickOuterRadius, Int32 IntermediateTickInnerRadius, Int32 IntermediateTickWidth, Color IntermediateTickForeColor,
            Int32 MajorTickOuterRadius, Int32 MajorTickInnerRadius, Int32 MajorTickWidth, Color MajorTickForeColor, Single MajorStepValue,
            Single MinimumValue, Single MaximumValue,
            Int32 ArcStart, Int32 ArcSweep
            )
        {
            using (var graphicsPath = new GraphicsPath()) {
                var renderMajorScale        = true;
                var renderIntermediateScale = true;
                var renderMinorScale        = true;

                Graphics.SetClip(ClientRectangle);
                Graphics.SmoothingMode   = SmoothingMode.AntiAlias;
                Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

                Single countValue = 0;
                Int32  counter1   = 0;
                while (countValue <= (MaximumValue - MinimumValue))
                {
                    graphicsPath.Reset();
                    if (renderMajorScale)
                    {
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MajorTickOuterRadius, Center.Y - MajorTickOuterRadius, 2 * MajorTickOuterRadius, 2 * MajorTickOuterRadius));
                        graphicsPath.Reverse();
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MajorTickInnerRadius, Center.Y - MajorTickInnerRadius, 2 * MajorTickInnerRadius, 2 * MajorTickInnerRadius));
                        graphicsPath.Reverse();
                    }
                    Graphics.SetClip(graphicsPath);

                    using (var pen = new Pen(MajorTickForeColor, MajorTickWidth)) {
                        Graphics.DrawLine(
                            pen,
                            (Single)(Center.X),
                            (Single)(Center.Y),
                            (Single)(Center.X + 2 * MajorTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0)),
                            (Single)(Center.Y + 2 * MajorTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue)) * Math.PI / 180.0))
                            );
                    }


                    graphicsPath.Reset();
                    if (renderMinorScale)
                    {
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickOuterRadius, Center.Y - MinorTickOuterRadius, 2 * MinorTickOuterRadius, 2 * MinorTickOuterRadius));
                        graphicsPath.Reverse();
                        graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickInnerRadius, Center.Y - MinorTickInnerRadius, 2 * MinorTickInnerRadius, 2 * MinorTickInnerRadius));
                        graphicsPath.Reverse();
                    }
                    Graphics.SetClip(graphicsPath);

                    if (countValue < (MaximumValue - MinimumValue))
                    {
                        for (var index = 1; index <= MinorNumOfTicks; index++)
                        {
                            if (((MinorNumOfTicks % 2) == 1) && ((Int32)(MinorNumOfTicks / 2) + 1 == index))
                            {
                                graphicsPath.Reset();
                                if (renderIntermediateScale)
                                {
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - IntermediateTickOuterRadius, Center.Y - IntermediateTickOuterRadius, 2 * IntermediateTickOuterRadius, 2 * IntermediateTickOuterRadius));
                                    graphicsPath.Reverse();
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - IntermediateTickInnerRadius, Center.Y - IntermediateTickInnerRadius, 2 * IntermediateTickInnerRadius, 2 * IntermediateTickInnerRadius));
                                    graphicsPath.Reverse();
                                }
                                Graphics.SetClip(graphicsPath);

                                using (var pen = new Pen(IntermediateTickForeColor, IntermediateTickWidth)) {
                                    Graphics.DrawLine(
                                        pen,
                                        (Single)(Center.X),
                                        (Single)(Center.Y),
                                        (Single)(Center.X + 2 * IntermediateTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0)),
                                        (Single)(Center.Y + 2 * IntermediateTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0))
                                        );
                                }

                                graphicsPath.Reset();
                                if (renderMinorScale)
                                {
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickOuterRadius, Center.Y - MinorTickOuterRadius, 2 * MinorTickOuterRadius, 2 * MinorTickOuterRadius));
                                    graphicsPath.Reverse();
                                    graphicsPath.AddEllipse(new Rectangle(Center.X - MinorTickInnerRadius, Center.Y - MinorTickInnerRadius, 2 * MinorTickInnerRadius, 2 * MinorTickInnerRadius));
                                    graphicsPath.Reverse();
                                }
                                Graphics.SetClip(graphicsPath);
                            }
                            else
                            {
                                using (var pen = new Pen(MinorTickForeColor, MinorTickWidth)) {
                                    Graphics.DrawLine(
                                        pen,
                                        (Single)(Center.X),
                                        (Single)(Center.Y),
                                        (Single)(Center.X + 2 * MinorTickOuterRadius * Math.Cos((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0)),
                                        (Single)(Center.Y + 2 * MinorTickOuterRadius * Math.Sin((ArcStart + countValue * ArcSweep / (MaximumValue - MinimumValue) + index * ArcSweep / (((Single)((MaximumValue - MinimumValue) / MajorStepValue)) * (MinorNumOfTicks + 1))) * Math.PI / 180.0))
                                        );
                                }
                            }
                        }
                    }

                    countValue += MajorStepValue;
                    counter1++;
                }
            }
            Graphics.ResetTransform();
        }
Beispiel #22
0
        public virtual void Enumerate()
        {
            GraphicsPath path = new GraphicsPath();

            path.AddLine(new Point(100, 100), new Point(400, 100));
            path.AddLine(new Point(400, 200), new Point(10, 100));

            path.StartFigure();
            path.AddBezier(10, 10, 50, 250, 100, 5, 200, 280);
            path.StartFigure();
            path.AddRectangle(new Rectangle(10, 20, 300, 400));

            path.StartFigure();
            path.AddLine(new Point(400, 400), new Point(400, 10));

            path.Reverse();

            GraphicsPathIterator iterator = new GraphicsPathIterator(path);

            PointF [] actualPoints = new PointF [14];
            byte []   actualTypes  = new byte [14];
            iterator.Enumerate(ref actualPoints, ref actualTypes);

            PointF [] expectedPoints = new PointF [] { new PointF(400f, 10f),
                                                       new PointF(400f, 400f),
                                                       new PointF(10f, 420f),
                                                       new PointF(310f, 420f),
                                                       new PointF(310f, 20f),
                                                       new PointF(10f, 20f),
                                                       new PointF(200f, 280f),
                                                       new PointF(100f, 5f),
                                                       new PointF(50f, 250f),
                                                       new PointF(10f, 10f),
                                                       new PointF(10f, 100f),
                                                       new PointF(400f, 200f),
                                                       new PointF(400f, 100f),
                                                       new PointF(100f, 100f) };

            for (int i = 0; i < expectedPoints.Length; i++)
            {
                DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
            }

            byte [] expectedTypes = new byte [] { (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)(PathPointType.Line | PathPointType.CloseSubpath),
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Bezier3,
                                                  (byte)PathPointType.Start,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line,
                                                  (byte)PathPointType.Line };

            for (int i = 0; i < expectedTypes.Length; i++)
            {
                Assert.AreEqual(expectedTypes [i], actualTypes [i]);
            }
        }
 public void Reverse()
 {
     Changed();
     gdiPath.Reverse();
 }
Beispiel #24
0
        /// <summary>
        /// Gets graphics path for drawing shadowed part of a planet / Moon.
        /// </summary>
        /// <param name="phase">Phase of celestial object (signed).</param>
        /// <param name="rotation">
        /// Rotation angle in degrees.
        /// Resulting graphics path will be rotated clockwise on this angle around central point of the planet / Moon disk.</param>
        /// <param name="size">Size of a drawn planet / Moon disk</param>
        /// <param name="flattening">Flattening value of a planet globe.</param>
        /// <returns>Graphics path for drawing shadowed part of a planet / Moon.</returns>
        private GraphicsPath GetPhaseShadow(float phase, float size, float flattening = 0)
        {
            float sizeEquat = size;
            float sizePolar = (1 - flattening) * size;

            GraphicsPath gp = new GraphicsPath();

            // растущий серп
            if (phase >= 0 && phase <= 0.5)
            {
                float width  = (0.5f - phase) * sizeEquat * 2;
                float height = sizePolar;
                float x      = -width / 2;
                float y      = -height / 2;

                // terminator arc
                gp.AddArc(x, y, width, height, -90, 180);

                // dark side arc
                gp.AddArc(-sizeEquat / 2, -sizePolar / 2, sizeEquat, sizePolar, 90, 180);
            }

            // растущая горбушка
            if (phase > 0.5 && phase <= 1.0)
            {
                float width  = (phase - 0.5f) * sizeEquat * 2;
                float height = sizePolar;
                float x      = -width / 2;
                float y      = -height / 2;

                // terminator arc
                gp.AddArc(x, y, width, height, 90, 180);
                gp.Reverse();

                // dark side arc
                gp.AddArc(-sizeEquat / 2, -sizePolar / 2, sizeEquat, sizePolar, 90, 180);
            }

            // убывающая горбушка
            if (phase > -1.0 && phase <= -0.5)
            {
                float width  = -(phase + 0.5f) * sizeEquat * 2;
                float height = sizePolar;
                float x      = -width / 2;
                float y      = -height / 2;

                // terminator arc
                gp.AddArc(x, y, width, height, -90, 180);
                gp.Reverse();

                // dark side arc
                gp.AddArc(-sizeEquat / 2, -sizePolar / 2, sizeEquat, sizePolar, -90, 180);
            }

            // убывающий серп
            if (phase > -0.5 && phase <= 0)
            {
                float width  = (phase + 0.5f) * sizeEquat * 2;
                float height = sizePolar;
                float x      = -width / 2;
                float y      = -height / 2;

                // dark side arc
                gp.AddArc(-sizeEquat / 2, -sizePolar / 2, sizeEquat, sizePolar, -90, 180);

                // terminator arc
                gp.AddArc(x, y, width, height, 90, 180);
            }

            gp.CloseAllFigures();

            return(gp);
        }
        //Use the OnPaint overrides sub to paint the control to match how all the properties settings have been set by the user
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        private void PathOnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            TransInPaint(e.Graphics);
            var _with1 = e.Graphics;

            _with1.TextRenderingHint = TextRendering;

            //The StringFormat used to align the Text in the Label
            StringFormat sf = new StringFormat();
            //Use (ta) which is an integer value of the ContentAlignment integer enum to set the
            //Alignment of the Text that will be added to the Drawing2D.GraphicsPath
            int ta = Convert.ToInt32(_TextAlign);

            if (ta < 8)
            {
                sf.LineAlignment = StringAlignment.Near;
            }
            else if (ta < 128)
            {
                sf.LineAlignment = StringAlignment.Center;
                ta = ta / 16;
            }
            else
            {
                sf.LineAlignment = StringAlignment.Far;
                ta = ta / 256;
            }
            if (ta == Convert.ToInt32(ContentAlignment.TopLeft))
            {
                sf.Alignment = StringAlignment.Near;
            }
            else if (ta == Convert.ToInt32(ContentAlignment.TopCenter))
            {
                sf.Alignment = StringAlignment.Center;
            }
            else if (ta == Convert.ToInt32(ContentAlignment.TopRight))
            {
                sf.Alignment = StringAlignment.Far;
            }


            #region RotationCode
            //Getting the width and height of the Text, which we are going to write
            float width  = _with1.MeasureString(Text, this.Font).Width;
            float height = _with1.MeasureString(Text, this.Font).Height;

            //The radius is set to 0.9 of the width or height, b'cos not to
            //hide and part of the Text at any stage
            float radius = 0f;
            if (ClientRectangle.Width < ClientRectangle.Height)
            {
                radius = ClientRectangle.Width * 0.9f / 2;
            }
            else
            {
                radius = ClientRectangle.Height * 0.9f / 2;
            }

            #endregion

            //Fill the background with the BackColor color
            _with1.FillRectangle(_BackgroundBrush, new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height));

            //If the BackgroundImage property has been set to an image then draw the BackgroundImage
            if (this.BackgroundImage != null)
            {
                DrawBackImage(e.Graphics);
            }

            //If the Image property has been set to an image then draw the image on the control
            if (_Image != null)
            {
                _with1.DrawImage(_Image, AlignImage(new Rectangle(0, 0, this.Width - 1, this.Height - 1)));
            }

            //If the Text property has bet assigned any Text then draw the Text on the control
            if (!string.IsNullOrEmpty(this.Text))
            {
                //Set the smothing mode of the _with1 to make things look smother
                //_with1.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias;
                _with1.SmoothingMode = Smoothing;

                //The Drawing2D.GraphicsPath used for drawing and/or filling the Text
                using (GraphicsPath pth = new GraphicsPath())
                {
                    if (Slide)
                    {
                        //For rotation, who about rotation?
                        double angle = (rotationAngle / 180) * Math.PI;
                        _with1.TranslateTransform(
                            (ClientRectangle.Width + (float)(height * Math.Sin(angle)) - (float)(width * Math.Cos(angle))) / 2,
                            (ClientRectangle.Height - (float)(height * Math.Cos(angle)) - (float)(width * Math.Sin(angle))) / 2);
                        _with1.RotateTransform((float)rotationAngle);
                        DrawSlidingText(_with1, new SolidBrush(ForeColor), pth, new StringFormat());
                        _with1.ResetTransform();
                    }
                    else
                    {
                        switch (textOrientation)
                        {
                        case Orientation.Arc:
                        {
                            //Arc angle must be get from the length of the Text.
                            float arcAngle = (2 * width / radius) / Text.Length;
                            if (textDirection == Direction.Clockwise)
                            {
                                for (int i = 0; i < Text.Length; i++)
                                {
                                    pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                  Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                  new Rectangle(
                                                      (int)(radius * (1 - Math.Cos(
                                                                          arcAngle * i +
                                                                          rotationAngle / 180 * Math.PI))),
                                                      (int)(radius * (1 - Math.Sin(
                                                                          arcAngle * i +
                                                                          rotationAngle / 180 * Math.PI))), pathSize,
                                                      pathSize), sf);

                                    if (_ShowTextShadow)
                                    {
                                        switch (ShadowPosition)
                                        {
                                        case ShadowArea.TopLeft:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(arcAngle * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin(arcAngle * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.TopRight:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(arcAngle * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin(arcAngle * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomLeft:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(arcAngle * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin(arcAngle * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomRight:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(arcAngle * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin(arcAngle * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        default:
                                            throw new ArgumentOutOfRangeException();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < Text.Length; i++)
                                {
                                    pth.Reverse();
                                    pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                  Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                  new Rectangle(
                                                      (int)(radius * (1 - Math.Cos(
                                                                          arcAngle * i +
                                                                          rotationAngle / 180 * Math.PI))),
                                                      (int)(radius * (1 + Math.Sin(
                                                                          arcAngle * i +
                                                                          rotationAngle / 180 * Math.PI))), pathSize,
                                                      pathSize), sf);

                                    if (_ShowTextShadow)
                                    {
                                        switch (ShadowPosition)
                                        {
                                        case ShadowArea.TopLeft:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 + Math.Sin(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);

                                            break;

                                        case ShadowArea.TopRight:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 + Math.Sin(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomLeft:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 + Math.Sin(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomRight:


                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 + Math.Sin(
                                                                                  arcAngle * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        default:
                                            throw new ArgumentOutOfRangeException();
                                        }
                                    }

                                    //pth.Reverse();
                                }
                            }
                            break;
                        }

                        case Orientation.Circle:
                        {
                            if (textDirection == Direction.Clockwise)
                            {
                                for (int i = 0; i < Text.Length; i++)
                                {
                                    pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                  Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                  new Rectangle(
                                                      (int)(radius * (1 - Math.Cos(
                                                                          (2 * Math.PI / Text.Length) * i +
                                                                          rotationAngle / 180 * Math.PI))),
                                                      (int)(radius * (1 - Math.Sin(
                                                                          (2 * Math.PI / Text.Length) * i +
                                                                          rotationAngle / 180 * Math.PI))), pathSize,
                                                      pathSize), sf);

                                    if (_ShowTextShadow)
                                    {
                                        switch (ShadowPosition)
                                        {
                                        case ShadowArea.TopLeft:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.TopRight:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomLeft:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomRight:
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Cos((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Sin((2 * Math.PI / Text.Length) * i + rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        default:
                                            throw new ArgumentOutOfRangeException();
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < Text.Length; i++)
                                {
                                    pth.Reverse();
                                    pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                  Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                  new Rectangle(
                                                      (int)(radius * (1 - Math.Sin(
                                                                          (2 * Math.PI / Text.Length) * i +
                                                                          rotationAngle / 180 * Math.PI))),
                                                      (int)(radius * (1 - Math.Cos(
                                                                          (2 * Math.PI / Text.Length) * i +
                                                                          rotationAngle / 180 * Math.PI))), pathSize,
                                                      pathSize), sf);


                                    if (_ShowTextShadow)
                                    {
                                        switch (ShadowPosition)
                                        {
                                        case ShadowArea.TopLeft:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Sin(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.TopRight:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Sin(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomLeft:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Sin(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) - _ShadowDepth,
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        case ShadowArea.BottomRight:

                                            pth.Reverse();
                                            pth.AddString(Text[i].ToString(), this.Font.FontFamily,
                                                          Convert.ToInt32(this.Font.Style),
                                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / CorrectWidth),
                                                          new Rectangle(
                                                              (int)(radius * (1 - Math.Sin(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth,
                                                              (int)(radius * (1 - Math.Cos(
                                                                                  (2 * Math.PI / Text.Length) * i +
                                                                                  rotationAngle / 180 * Math.PI))) + _ShadowDepth, pathSize,
                                                              pathSize), sf);
                                            break;

                                        default:
                                            throw new ArgumentOutOfRangeException();
                                        }
                                    }
                                }
                            }
                            break;
                        }

                        case Orientation.Rotate:
                        {
                            //For rotation, who about rotation?

                            pth.AddString(this.Text, this.Font.FontFamily, Convert.ToInt32(this.Font.Style),
                                          Convert.ToSingle((_with1.DpiY * this.Font.Size) / 72),
                                          new Rectangle(
                                              this.Padding.Left,
                                              this.Padding.Top,
                                              (this.ClientSize.Width - 1) - (this.Padding.Left + this.Padding.Right),
                                              (this.ClientSize.Height - 1) -
                                              (this.Padding.Top + this.Padding.Bottom)), sf);

                            if (_ShowTextShadow)
                            {
                                if (_ShadowPosition == ShadowArea.TopLeft)
                                {
                                    pth.AddString(this.Text, this.Font.FontFamily, Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / 72),
                                                  new Rectangle(
                                                      this.Padding.Left,
                                                      this.Padding.Top,
                                                      (this.ClientSize.Width - 1) - (this.Padding.Left + this.Padding.Right) - _ShadowDepth,
                                                      (this.ClientSize.Height - 1) -
                                                      (this.Padding.Top + this.Padding.Bottom) - _ShadowDepth), sf);
                                }
                                else if (_ShadowPosition == ShadowArea.TopRight)
                                {
                                    pth.AddString(this.Text, this.Font.FontFamily, Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / 72),
                                                  new Rectangle(
                                                      this.Padding.Left,
                                                      this.Padding.Top,
                                                      (this.ClientSize.Width - 1) - (this.Padding.Left + this.Padding.Right) + _ShadowDepth,
                                                      (this.ClientSize.Height - 1) -
                                                      (this.Padding.Top + this.Padding.Bottom) - _ShadowDepth), sf);
                                }
                                else if (_ShadowPosition == ShadowArea.BottomLeft)
                                {
                                    pth.AddString(this.Text, this.Font.FontFamily, Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / 72),
                                                  new Rectangle(
                                                      this.Padding.Left,
                                                      this.Padding.Top,
                                                      (this.ClientSize.Width - 1) - (this.Padding.Left + this.Padding.Right) - _ShadowDepth,
                                                      (this.ClientSize.Height - 1) -
                                                      (this.Padding.Top + this.Padding.Bottom) + _ShadowDepth), sf);
                                }
                                else
                                {
                                    pth.AddString(this.Text, this.Font.FontFamily, Convert.ToInt32(this.Font.Style),
                                                  Convert.ToSingle((_with1.DpiY * this.Font.Size) / 72),
                                                  new Rectangle(
                                                      this.Padding.Left,
                                                      this.Padding.Top,
                                                      (this.ClientSize.Width - 1) - (this.Padding.Left + this.Padding.Right) - _ShadowDepth,
                                                      (this.ClientSize.Height - 1) -
                                                      (this.Padding.Top + this.Padding.Bottom) - _ShadowDepth), sf);
                                }
                            }

                            break;
                        }
                        }

                        //Add the Text to the Drawing2D.GraphicsPath using the StringFormat
                    }


                    //If the TextPatternImage property has been set to an image then fill the center of the Text with the image
                    //else the center will be filled with a soloid color of the ForeColor property.
                    if (_TextPatternImage != null)
                    {
                        //Use the TextPatternImageLayout property to resize and/or position the TextPatternImage
                        Rectangle  br = new Rectangle();
                        RectangleF r  = pth.GetBounds();
                        if (_TextPatternImageLayout == PatternLayout.Normal | _TextPatternImageLayout == PatternLayout.Tile)
                        {
                            br = new Rectangle(Convert.ToInt32(r.X) + 1, Convert.ToInt32(r.Y + 1), _TextPatternImage.Width + 1, _TextPatternImage.Height + 1);
                        }
                        else if (_TextPatternImageLayout == PatternLayout.Center)
                        {
                            int xx = Convert.ToInt32((r.X + 1) + ((r.Width / 2) - (_TextPatternImage.Width / 2)));
                            int yy = Convert.ToInt32((r.Y + 1) + ((r.Height / 2) - (_TextPatternImage.Height / 2)));
                            br = new Rectangle(xx, yy, _TextPatternImage.Width + 1, _TextPatternImage.Height + 1);
                        }
                        else if (_TextPatternImageLayout == PatternLayout.Stretch)
                        {
                            br = new Rectangle(Convert.ToInt32(r.X) + 1, Convert.ToInt32(r.Y + 1), Convert.ToInt32(r.Width) + 1, Convert.ToInt32(r.Height) + 1);
                        }
                        using (Bitmap patBmp = new Bitmap(_TextPatternImage, br.Width, br.Height))
                        {
                            //Use a TextureBrush with the TextPatternImage assigned as the texture image
                            using (TextureBrush tb = new TextureBrush(patBmp))
                            {
                                //If the TextPatternImageLayout property is not set to Tile then set the set the
                                //TextureBrush`s WrapMode to Clamp to stop it from tiling the image.
                                if (!(_TextPatternImageLayout == PatternLayout.Tile))
                                {
                                    tb.WrapMode = WrapMode.Clamp;
                                }
                                tb.TranslateTransform(br.X, br.Y);
                                //Fill the GraphicsPath with the TextureBrush.
                                _with1.FillPath(tb, pth);
                            }
                        }
                    }
                    else
                    {
                        //Fill the GraphicsPath with a soloid color of the ForeColor property.
                        _with1.FillPath(_CenterBrush, pth);
                    }
                    //Draw the GraphicsPath with the OutlineColor.
                    _with1.DrawPath(_OutLinePen, pth);
                }
            }

            //If the BorderStyle property is other than None then call the DrawBorder sub to draw the border
            if (_BorderStyle != BorderType.None)
            {
                DrawLabelBorder(e.Graphics, new Rectangle(2, 2, this.Width - 4, this.Height - 4));
            }
        }
Beispiel #26
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            if (Bars == null || ChartControl == null)
            {
                return;
            }

            if (Color.Transparent == cloudAreaColorUp && Color.Transparent == cloudAreaColorDown || 0 == cloudColorOpacity)
            {
                base.Plot(graphics, bounds, min, max);                          // Call base Plot() method to paint defined Plots.
                return;                                                         // If cloudAreaColor colors are transparent or cloudColorOpacity is 0
                // there is nothing to paint so return to avoid unnecessary calculations.
            }

            SolidBrush brush     = null;                                                                // Set current brush color here.
            SolidBrush brushUP   = new SolidBrush(Color.FromArgb(cloudColorOpacity, cloudAreaColorUp));
            SolidBrush brushDOWN = new SolidBrush(Color.FromArgb(cloudColorOpacity, cloudAreaColorDown));

            int           barWidth         = ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth);
            SmoothingMode oldSmoothingMode = graphics.SmoothingMode;
            GraphicsPath  path             = new GraphicsPath();                        // Create a new path.

            brush = brushUP;                                                            // Start with the upwards color.
            int  barcount = 0;                                                          // Start with leftmost bar.
            bool firstbar = true;                                                       // Plotting the first bar.

            while (barcount < ChartControl.BarsPainted)                                 // Continue until all bars have been painted.
            {
                int count = 0;                                                          // Counter for innner loop.
                for (int seriesCount = 0; seriesCount < 2; seriesCount++)
                {
                    int        lastX  = -1;
                    int        lastY  = -1;
                    DataSeries series = (0 == seriesCount) ? SenkouSpanA : SenkouSpanB;

                    for (count = barcount; count < ChartControl.BarsPainted; count++)
                    {
                        int idx = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + count - periodMedium;
                        if (idx < 0 || idx >= Input.Count || (!ChartControl.ShowBarsRequired && idx < BarsRequired))
                        {
                            continue;
                        }

                        bool senkouSpanAHasValue = SenkouSpanA.IsValidPlot(idx) && SenkouSpanA.Get(idx) > 0;
                        bool senkouSpanBHasValue = SenkouSpanB.IsValidPlot(idx) && SenkouSpanB.Get(idx) > 0;
                        if (!senkouSpanAHasValue || !senkouSpanAHasValue)                       // If we don't have valid value for the series then skip the loop step
                        // as there is nothing to plot. So ignore the entry.
                        {
                            continue;
                        }

                        double val = series.Get(idx);                                                                                   // Get next y-value to be plotted.

                        int x = (int)(ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2
                                      + (count - ChartControl.BarsPainted + 1) * ChartControl.BarSpace) + 1;

                        int y = (int)((bounds.Y + bounds.Height) - ((val - min) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height);

                        double val0 = SenkouSpanA.Get(idx);
                        double val1 = SenkouSpanB.Get(idx);

                        if (((val0 > val1) && (brush != brushUP)) ||                                    // Now going in wrong direction?
                            ((val0 < val1) && (brush != brushDOWN)))
                        {                                                                               // Yes.  Done with this loop.
                            if (lastX >= 0)                                                             // Was there a last point?
                            {                                                                           // Yes.  Connect it to the position half-way to this one.
                                path.AddLine(lastX, lastY, (x + lastX) / 2, (lastY + y) / 2);
                                // Plot vertex of cross-over of the lines (1/2 way point).
                            }
                            break;                                                                                                      // Done, exit inner loop to change color.
                        }

                        if (firstbar == false)                                                              // Is this the first plotted bar of the chart?
                        {                                                                                   // No.  Plot all bars after the first one.
                            if (count == barcount)                                                          // First bar after direction change (and color swap)?
                            {                                                                               // Yes.  Add line segment for cross-over, 1/2 bar back.
                                double valm1 = series.Get(idx - 1);                                         // Get prior y-value to be plotted.
                                lastX = x - ChartControl.BarSpace / 2;                                      // Back up 1/2 a bar for x-value.
                                lastY = (y + (int)((bounds.Y + bounds.Height) - ((valm1 - min) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height)) / 2;
                            }

                            path.AddLine(lastX, lastY, x, y);                                                   // Connect last point to this one.
                        }
                        firstbar = false;                                                                       // No longer the first bar.
                        lastX    = x;                                                                           // Save current position for next time, so we can connect the dots.
                        lastY    = y;
                    }

                    path.Reverse();                                                                                             // Go back the other direction.
                }

                graphics.SmoothingMode = SmoothingMode.AntiAlias;
                graphics.FillPath(brush, path);
                path.Reset();                                                                   // Eliminate points already colored.

                barcount = count;                                                               // Get ready to process next segment.
                brush    = (brush == brushUP) ? brushDOWN : brushUP;                            // Switch colors for next segment.
            }

            graphics.SmoothingMode = oldSmoothingMode;                                                  // Restore smoothing mode before exiting.
            brushUP.Dispose();                                                                          // Dispose of brushes.
            brushDOWN.Dispose();
            path.Dispose();                                                                             // Dispose of path.
            base.Plot(graphics, bounds, min, max);                                                      // Call the base Plot() method to paint defined Plots.
        }