Exemple #1
0
        protected override void DrawLine(ChartGraphics graph, CommonElements common, DataPoint point, Series series, PointF[] points, int pointIndex, float tension)
        {
            if (pointIndex <= 0)
            {
                return;
            }
            if (this.series != null)
            {
                if (this.series.Name != series.Name)
                {
                    FillLastSeriesGradient(graph);
                    this.series = series;
                }
            }
            else
            {
                this.series = series;
            }
            PointF pointF  = points[pointIndex - 1];
            PointF pointF2 = points[pointIndex];

            pointF.X  = (float)Math.Round(pointF.X);
            pointF.Y  = (float)Math.Round(pointF.Y);
            pointF2.X = (float)Math.Round(pointF2.X);
            pointF2.Y = (float)Math.Round(pointF2.Y);
            if (axisPos == PointF.Empty)
            {
                axisPos.X = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos.Y = (float)vAxis.GetPosition(vAxis.Crossing);
                axisPos   = graph.GetAbsolutePoint(axisPos);
                axisPos.X = (float)Math.Round(axisPos.X);
                axisPos.Y = (float)Math.Round(axisPos.Y);
            }
            Color          color       = point.Color;
            Color          borderColor = point.BorderColor;
            int            borderWidth = point.BorderWidth;
            ChartDashStyle borderStyle = point.BorderStyle;
            Brush          brush       = null;

            if (point.BackHatchStyle != 0)
            {
                brush = graph.GetHatchBrush(point.BackHatchStyle, color, point.BackGradientEndColor);
            }
            else if (point.BackGradientType == GradientType.None)
            {
                brush = ((point.BackImage.Length <= 0 || point.BackImageMode == ChartImageWrapMode.Unscaled || point.BackImageMode == ChartImageWrapMode.Scaled) ? new SolidBrush(color) : graph.GetTextureBrush(point.BackImage, point.BackImageTransparentColor, point.BackImageMode, point.Color));
            }
            else
            {
                gradientFill = true;
                this.series  = point.series;
            }
            GraphicsPath graphicsPath = new GraphicsPath();

            graphicsPath.AddLine(pointF.X, axisPos.Y, pointF.X, pointF.Y);
            if (lineTension == 0f)
            {
                graphicsPath.AddLine(points[pointIndex - 1], points[pointIndex]);
            }
            else
            {
                graphicsPath.AddCurve(points, pointIndex - 1, 1, lineTension);
            }
            graphicsPath.AddLine(pointF2.X, pointF2.Y, pointF2.X, axisPos.Y);
            if (series.ShadowColor != Color.Empty && series.ShadowOffset != 0)
            {
                graph.shadowDrawingMode = true;
                if (color != Color.Empty && color != Color.Transparent)
                {
                    Region        region  = new Region(graphicsPath);
                    Brush         brush2  = new SolidBrush((series.ShadowColor.A != byte.MaxValue) ? series.ShadowColor : Color.FromArgb((int)color.A / 2, series.ShadowColor));
                    GraphicsState gstate  = graph.Save();
                    Region        region2 = null;
                    Region        region3 = null;
                    if (!graph.IsClipEmpty && !graph.Clip.IsInfinite(graph.Graphics))
                    {
                        region3 = graph.Clip.Clone();
                        region2 = graph.Clip;
                        region2.Translate(series.ShadowOffset, series.ShadowOffset);
                        graph.Clip = region2;
                    }
                    graph.TranslateTransform(series.ShadowOffset, series.ShadowOffset);
                    if (graph.SmoothingMode != SmoothingMode.None)
                    {
                        Pen pen = new Pen(brush2, 1f);
                        if (lineTension == 0f)
                        {
                            graph.DrawLine(pen, points[pointIndex - 1], points[pointIndex]);
                        }
                        else
                        {
                            graph.DrawCurve(pen, points, pointIndex - 1, 1, lineTension);
                        }
                    }
                    graph.FillRegion(brush2, region);
                    graph.Restore(gstate);
                    if (region2 != null && region3 != null)
                    {
                        graph.Clip = region3;
                    }
                }
                graph.shadowDrawingMode = false;
            }
            if (!gradientFill)
            {
                SmoothingMode smoothingMode = graph.SmoothingMode;
                graph.SmoothingMode = SmoothingMode.None;
                graph.FillPath(brush, graphicsPath);
                graph.SmoothingMode = smoothingMode;
                if (graph.SmoothingMode != SmoothingMode.None)
                {
                    graph.StartHotRegion(point);
                    Pen pen2 = new Pen(brush, 1f);
                    if (lineTension == 0f)
                    {
                        if (points[pointIndex - 1].X != points[pointIndex].X && points[pointIndex - 1].Y != points[pointIndex].Y)
                        {
                            graph.DrawLine(pen2, points[pointIndex - 1], points[pointIndex]);
                        }
                    }
                    else
                    {
                        graph.DrawCurve(pen2, points, pointIndex - 1, 1, lineTension);
                    }
                    graph.EndHotRegion();
                }
            }
            if (areaPath == null)
            {
                areaPath = new GraphicsPath();
                areaPath.AddLine(pointF.X, axisPos.Y, pointF.X, pointF.Y);
            }
            if (lineTension == 0f)
            {
                areaPath.AddLine(points[pointIndex - 1], points[pointIndex]);
            }
            else
            {
                areaPath.AddCurve(points, pointIndex - 1, 1, lineTension);
            }
            if (borderWidth > 0 && borderColor != Color.Empty)
            {
                Pen pen3 = new Pen((borderColor != Color.Empty) ? borderColor : color, borderWidth);
                pen3.DashStyle = graph.GetPenStyle(borderStyle);
                pen3.StartCap  = LineCap.Round;
                pen3.EndCap    = LineCap.Round;
                if (lineTension == 0f)
                {
                    graph.DrawLine(pen3, points[pointIndex - 1], points[pointIndex]);
                }
                else
                {
                    graph.DrawCurve(pen3, points, pointIndex - 1, 1, lineTension);
                }
            }
            if (!common.ProcessModeRegions)
            {
                return;
            }
            GraphicsPath graphicsPath2 = new GraphicsPath();

            graphicsPath2.AddLine(pointF.X, axisPos.Y, pointF.X, pointF.Y);
            if (lineTension == 0f)
            {
                graphicsPath2.AddLine(points[pointIndex - 1], points[pointIndex]);
            }
            else
            {
                graphicsPath2.AddCurve(points, pointIndex - 1, 1, lineTension);
                graphicsPath2.Flatten();
            }
            graphicsPath2.AddLine(pointF2.X, pointF2.Y, pointF2.X, axisPos.Y);
            graphicsPath2.AddLine(pointF2.X, axisPos.Y, pointF.X, axisPos.Y);
            PointF empty = PointF.Empty;

            float[]  array      = new float[graphicsPath2.PointCount * 2];
            PointF[] pathPoints = graphicsPath2.PathPoints;
            for (int i = 0; i < graphicsPath2.PointCount; i++)
            {
                empty            = graph.GetRelativePoint(pathPoints[i]);
                array[2 * i]     = empty.X;
                array[2 * i + 1] = empty.Y;
            }
            common.HotRegionsList.AddHotRegion(graph, graphicsPath2, relativePath: false, array, point, series.Name, pointIndex);
            if (borderWidth <= 1 || borderStyle == ChartDashStyle.NotSet || !(borderColor != Color.Empty))
            {
                return;
            }
            try
            {
                graphicsPath2 = new GraphicsPath();
                if (lineTension == 0f)
                {
                    graphicsPath2.AddLine(points[pointIndex - 1], points[pointIndex]);
                }
                else
                {
                    graphicsPath2.AddCurve(points, pointIndex - 1, 1, lineTension);
                    graphicsPath2.Flatten();
                }
                ChartGraphics.Widen(graphicsPath2, new Pen(color, borderWidth + 2));
            }
            catch (Exception)
            {
            }
            empty = PointF.Empty;
            array = new float[graphicsPath2.PointCount * 2];
            PointF[] pathPoints2 = graphicsPath2.PathPoints;
            for (int j = 0; j < pathPoints2.Length; j++)
            {
                empty            = graph.GetRelativePoint(pathPoints2[j]);
                array[2 * j]     = empty.X;
                array[2 * j + 1] = empty.Y;
            }
            common.HotRegionsList.AddHotRegion(graph, graphicsPath2, relativePath: false, array, point, series.Name, pointIndex);
        }
Exemple #2
0
        protected override void DrawLine(ChartGraphics graph, CommonElements common, DataPoint point, Series series, PointF[] points, int pointIndex, float tension)
        {
            if (point.YValues.Length < 2)
            {
                throw new InvalidOperationException(SR.ExceptionChartTypeRequiresYValues(Name, "2"));
            }
            if (pointIndex <= 0 || yValueIndex == 1)
            {
                return;
            }
            if (this.series != null)
            {
                if (this.series.Name != series.Name)
                {
                    FillLastSeriesGradient(graph);
                    this.series = series;
                    lowPoints   = null;
                    areaBottomPath.Reset();
                }
            }
            else
            {
                this.series = series;
            }
            if (lowPoints == null)
            {
                yValueIndex = 1;
                lowPoints   = GetPointsPosition(graph, series, indexedBasedX);
                yValueIndex = 0;
            }
            PointF pointF  = points[pointIndex - 1];
            PointF pointF2 = points[pointIndex];
            PointF pointF3 = lowPoints[pointIndex - 1];
            PointF pointF4 = lowPoints[pointIndex];
            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) ? new SolidBrush(point.Color) : graph.GetTextureBrush(point.BackImage, point.BackImageTransparentColor, point.BackImageMode, point.Color));
            }
            else
            {
                gradientFill = true;
                this.series  = point.series;
            }
            GraphicsPath graphicsPath = new GraphicsPath();

            graphicsPath.AddLine(pointF.X, pointF3.Y, pointF.X, pointF.Y);
            if (lineTension == 0f)
            {
                graphicsPath.AddLine(points[pointIndex - 1], points[pointIndex]);
            }
            else
            {
                graphicsPath.AddCurve(points, pointIndex - 1, 1, lineTension);
            }
            graphicsPath.AddLine(pointF2.X, pointF2.Y, pointF2.X, pointF4.Y);
            if (graph.ActiveRenderingType == RenderingType.Svg)
            {
                GraphicsPath graphicsPath2 = new GraphicsPath();
                if (lineTension == 0f)
                {
                    graphicsPath.AddLine(lowPoints[pointIndex - 1], lowPoints[pointIndex]);
                }
                else
                {
                    graphicsPath2.AddCurve(lowPoints, pointIndex - 1, 1, lineTension);
                    graphicsPath2.Flatten();
                    PointF[] pathPoints = graphicsPath2.PathPoints;
                    PointF[] array      = new PointF[pathPoints.Length];
                    int      num        = pathPoints.Length - 1;
                    PointF[] array2     = pathPoints;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        PointF pointF5 = array[num] = array2[i];
                        num--;
                    }
                    if (array.Length == 2)
                    {
                        array = new PointF[3]
                        {
                            array[0],
                            array[1],
                            array[1]
                        };
                    }
                    graphicsPath.AddPolygon(array);
                }
            }
            else if (lineTension == 0f)
            {
                graphicsPath.AddLine(lowPoints[pointIndex - 1], lowPoints[pointIndex]);
            }
            else
            {
                graphicsPath.AddCurve(lowPoints, pointIndex - 1, 1, lineTension);
            }
            if (!clipRegionSet)
            {
                double num2 = indexedSeries ? ((double)(pointIndex + 1)) : series.Points[pointIndex].XValue;
                double num3 = indexedSeries ? ((double)pointIndex) : series.Points[pointIndex - 1].XValue;
                if (num3 < hAxisMin || num3 > hAxisMax || num2 > hAxisMax || num2 < hAxisMin || series.Points[pointIndex - 1].YValues[1] < vAxisMin || series.Points[pointIndex - 1].YValues[1] > vAxisMax || series.Points[pointIndex].YValues[1] < vAxisMin || series.Points[pointIndex].YValues[1] > vAxisMax)
                {
                    graph.SetClip(area.PlotAreaPosition.ToRectangleF());
                    clipRegionSet = true;
                }
            }
            if (series.ShadowColor != Color.Empty && series.ShadowOffset != 0 && point.Color != Color.Empty && point.Color != Color.Transparent)
            {
                Matrix matrix = graph.Transform.Clone();
                matrix.Translate(series.ShadowOffset, series.ShadowOffset);
                Matrix transform = graph.Transform;
                graph.Transform = matrix;
                Region region  = new Region(graphicsPath);
                Brush  brush2  = new SolidBrush((series.ShadowColor.A != byte.MaxValue) ? series.ShadowColor : Color.FromArgb((int)point.Color.A / 2, series.ShadowColor));
                Region region2 = null;
                if (!graph.IsClipEmpty && !graph.Clip.IsInfinite(graph.Graphics))
                {
                    region2 = graph.Clip;
                    region2.Translate(series.ShadowOffset + 1, series.ShadowOffset + 1);
                    graph.Clip = region2;
                }
                graph.FillRegion(brush2, region);
                Pen pen = new Pen(brush2, 1f);
                if (pointIndex == 0)
                {
                    graph.DrawLine(pen, pointF.X, pointF3.Y, pointF.X, pointF.Y);
                }
                if (pointIndex == series.Points.Count - 1)
                {
                    graph.DrawLine(pen, pointF2.X, pointF2.Y, pointF2.X, pointF4.Y);
                }
                graph.Transform         = transform;
                graph.shadowDrawingMode = true;
                drawShadowOnly          = true;
                base.DrawLine(graph, common, point, series, points, pointIndex, tension);
                yValueIndex = 1;
                base.DrawLine(graph, common, point, series, lowPoints, pointIndex, tension);
                yValueIndex             = 0;
                drawShadowOnly          = false;
                graph.shadowDrawingMode = false;
                if (region2 != null)
                {
                    region2 = graph.Clip;
                    region2.Translate(-(series.ShadowOffset + 1), -(series.ShadowOffset + 1));
                    graph.Clip = region2;
                }
            }
            if (!gradientFill)
            {
                SmoothingMode smoothingMode = graph.SmoothingMode;
                graph.SmoothingMode = SmoothingMode.None;
                graphicsPath.CloseAllFigures();
                graph.FillPath(brush, graphicsPath);
                graph.SmoothingMode = smoothingMode;
                if (graph.SmoothingMode != SmoothingMode.None)
                {
                    Pen pen2 = new Pen(brush, 1f);
                    if (brush is HatchBrush)
                    {
                        pen2.Color = ((HatchBrush)brush).ForegroundColor;
                    }
                    if (pointIndex == 0)
                    {
                        graph.DrawLine(pen2, pointF.X, pointF3.Y, pointF.X, pointF.Y);
                    }
                    if (pointIndex == series.Points.Count - 1)
                    {
                        graph.DrawLine(pen2, pointF2.X, pointF2.Y, pointF2.X, pointF4.Y);
                    }
                    if (lineTension == 0f)
                    {
                        graph.DrawLine(pen2, points[pointIndex - 1], points[pointIndex]);
                    }
                    else
                    {
                        graph.DrawCurve(pen2, points, pointIndex - 1, 1, lineTension);
                    }
                    if (lineTension == 0f)
                    {
                        graph.DrawLine(pen2, lowPoints[pointIndex - 1], lowPoints[pointIndex]);
                    }
                    else
                    {
                        graph.DrawCurve(pen2, lowPoints, pointIndex - 1, 1, lineTension);
                    }
                }
            }
            if (areaPath == null)
            {
                areaPath = new GraphicsPath();
                areaPath.AddLine(pointF.X, pointF3.Y, pointF.X, pointF.Y);
            }
            if (lineTension == 0f)
            {
                areaPath.AddLine(points[pointIndex - 1], points[pointIndex]);
            }
            else
            {
                areaPath.AddCurve(points, pointIndex - 1, 1, lineTension);
            }
            if (lineTension == 0f)
            {
                areaBottomPath.AddLine(lowPoints[pointIndex - 1], lowPoints[pointIndex]);
            }
            else
            {
                areaBottomPath.AddCurve(lowPoints, pointIndex - 1, 1, lineTension);
            }
            if ((point.BorderWidth > 0 && point.BorderStyle != 0 && point.BorderColor != Color.Empty) || brush is SolidBrush)
            {
                useBorderColor = true;
                disableShadow  = true;
                base.DrawLine(graph, common, point, series, points, pointIndex, tension);
                yValueIndex = 1;
                base.DrawLine(graph, common, point, series, lowPoints, pointIndex, tension);
                yValueIndex    = 0;
                useBorderColor = false;
                disableShadow  = false;
            }
            if (common.ProcessModeRegions)
            {
                graphicsPath.AddLine(pointF.X, pointF3.Y, pointF.X, pointF.Y);
                if (lineTension == 0f)
                {
                    graphicsPath.AddLine(points[pointIndex - 1], points[pointIndex]);
                }
                else
                {
                    graphicsPath.AddCurve(points, pointIndex - 1, 1, lineTension);
                }
                graphicsPath.AddLine(pointF2.X, pointF2.Y, pointF2.X, pointF4.Y);
                if (lineTension == 0f)
                {
                    graphicsPath.AddLine(lowPoints[pointIndex - 1], lowPoints[pointIndex]);
                }
                else
                {
                    graphicsPath.AddCurve(lowPoints, pointIndex - 1, 1, lineTension);
                }
                GraphicsPath graphicsPath3 = new GraphicsPath();
                graphicsPath3.AddLine(pointF.X, pointF3.Y, pointF.X, pointF.Y);
                if (lineTension == 0f)
                {
                    graphicsPath3.AddLine(points[pointIndex - 1], points[pointIndex]);
                }
                else
                {
                    graphicsPath3.AddCurve(points, pointIndex - 1, 1, lineTension);
                    graphicsPath3.Flatten();
                }
                graphicsPath3.AddLine(pointF2.X, pointF2.Y, pointF2.X, pointF4.Y);
                if (lineTension == 0f)
                {
                    graphicsPath3.AddLine(lowPoints[pointIndex - 1], lowPoints[pointIndex]);
                }
                else
                {
                    graphicsPath3.AddCurve(lowPoints, pointIndex - 1, 1, lineTension);
                    graphicsPath3.Flatten();
                }
                PointF   empty       = PointF.Empty;
                float[]  array3      = new float[graphicsPath3.PointCount * 2];
                PointF[] pathPoints2 = graphicsPath3.PathPoints;
                for (int j = 0; j < graphicsPath3.PointCount; j++)
                {
                    empty             = graph.GetRelativePoint(pathPoints2[j]);
                    array3[2 * j]     = empty.X;
                    array3[2 * j + 1] = empty.Y;
                }
                common.HotRegionsList.AddHotRegion(graph, graphicsPath3, relativePath: false, array3, point, series.Name, pointIndex);
            }
        }