Пример #1
0
        override protected void DrawPath(SeriesBase series, System.Drawing.Pen pen)
        {
            if (series is LineSeries || series is HiLoSeries || series is HiLoOpenCloseSeries)
            {
                var             points          = new PointCollection();
                var             lowPoints       = new PointCollection();
                var             pointCount      = 0;
                PartsCollection partsCollection = new PartsCollection();
                if (series is LineSeries)
                {
                    LineSeries lineSeries = series as LineSeries;
                    points          = lineSeries.LinePoints;
                    pointCount      = lineSeries.LinePoints.Count;
                    partsCollection = lineSeries.Parts;
                }
                else if (series is HiLoSeries)
                {
                    HiLoSeries lineSeries = series as HiLoSeries;
                    points          = lineSeries.HighPoints;
                    lowPoints       = lineSeries.LowPoints;
                    pointCount      = lineSeries.HighPoints.Count;
                    partsCollection = lineSeries.Parts;
                }
                else if (series is HiLoOpenCloseSeries)
                {
                    HiLoOpenCloseSeries lineSeries = series as HiLoOpenCloseSeries;
                    points          = lineSeries.HighPoints;
                    lowPoints       = lineSeries.LowPoints;
                    pointCount      = lineSeries.HighPoints.Count;
                    partsCollection = lineSeries.Parts;
                }
                if (RenderingMode == RenderingMode.Default)
                {
                    for (int i = 0; i < partsCollection.Count; i++)
                    {
                        UIElement renderElement = partsCollection[i].CreatePart();
                        if (renderElement != null && !PartsCanvas.Children.Contains(renderElement))
                        {
                            PartsCanvas.Children.Add(renderElement);
                        }
                    }
                }
                else
                {
                    if (series is LineSeries)
                    {
                        for (int i = 0; i < pointCount - 1; i++)
                        {
                            switch (RenderingMode)
                            {
                            case RenderingMode.GDIRendering:
                                GDIGraphics.DrawLine(pen, points[i].AsDrawingPointF(), points[i + 1].AsDrawingPointF());

                                break;

                            case RenderingMode.Default:
                                break;

                            case RenderingMode.WritableBitmap:
                                this.WritableBitmap.Lock();
                                WritableBitmapGraphics.DrawLine(pen, points[i].AsDrawingPointF(), points[i + 1].AsDrawingPointF());
                                this.WritableBitmap.Unlock();
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < pointCount; i++)
                        {
                            switch (RenderingMode)
                            {
                            case RenderingMode.GDIRendering:
                                GDIGraphics.DrawLine(pen, points[i].AsDrawingPointF(), lowPoints[i].AsDrawingPointF());

                                break;

                            case RenderingMode.Default:
                                break;

                            case RenderingMode.WritableBitmap:
                                this.WritableBitmap.Lock();
                                WritableBitmapGraphics.DrawLine(pen, points[i].AsDrawingPointF(), lowPoints[i].AsDrawingPointF());
                                this.WritableBitmap.Unlock();
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    this.Collection.InvalidateBitmap();
                }
            }
        }
Пример #2
0
        override protected void DrawPath(SeriesBase series, System.Drawing.Pen pen)
        {
            if (series is ScatterSeries || series is BubbleSeries)
            {
                var             points          = new PointCollection();
                var             sizes           = new List <double>();
                var             pointCount      = 0;
                float           size            = 0;
                var             brush           = new SolidColorBrush(Colors.Blue).AsDrawingBrush();
                PartsCollection partsCollection = new PartsCollection();
                if (series is ScatterSeries)
                {
                    ScatterSeries scatterSeries = series as ScatterSeries;
                    points          = scatterSeries.ScatterPoints;
                    pointCount      = scatterSeries.ScatterPoints.Count;
                    size            = (float)scatterSeries.ScatterSize;
                    brush           = (this.Series as ScatterSeries).Fill.AsDrawingBrush();
                    partsCollection = scatterSeries.Parts;
                }
                else if (series is BubbleSeries)
                {
                    BubbleSeries scatterSeries = series as BubbleSeries;
                    points     = scatterSeries.BubblePoints;
                    pointCount = scatterSeries.BubblePoints.Count;
                    //size = (float)scatterSeries.;
                    sizes           = scatterSeries.SizeValues;
                    brush           = (this.Series as FillSeriesBase).Fill.AsDrawingBrush();
                    partsCollection = scatterSeries.Parts;
                }

                if (RenderingMode == RenderingMode.Default)
                {
                    for (int i = 0; i < partsCollection.Count; i++)
                    {
                        Ellipse element = (Ellipse)partsCollection[i].CreatePart();
                        if (element != null && !PartsCanvas.Children.Contains(element))
                        {
                            PartsCanvas.Children.Add(element);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < pointCount; i++)
                    {
                        if (series is ScatterSeries)
                        {
                            switch (RenderingMode)
                            {
                            case RenderingMode.GDIRendering:
                                GDIGraphics.DrawEllipse(pen, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                GDIGraphics.FillEllipse(brush, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                break;

                            case RenderingMode.Default:
                                break;

                            case RenderingMode.WritableBitmap:
                                this.WritableBitmap.Lock();
                                WritableBitmapGraphics.DrawEllipse(pen, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                WritableBitmapGraphics.FillEllipse(brush, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                this.WritableBitmap.Unlock();
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            size = (int)sizes[i];
                            switch (RenderingMode)
                            {
                            case RenderingMode.GDIRendering:
                                GDIGraphics.DrawEllipse(pen, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                GDIGraphics.FillEllipse(brush, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                break;

                            case RenderingMode.Default:
                                break;

                            case RenderingMode.WritableBitmap:
                                this.WritableBitmap.Lock();
                                WritableBitmapGraphics.DrawEllipse(pen, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                WritableBitmapGraphics.FillEllipse(brush, points[i].AsDrawingPointF().X - size / 2, points[i].AsDrawingPointF().Y - size / 2, size, size);
                                this.WritableBitmap.Unlock();
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    this.Collection.InvalidateBitmap();
                }
            }
        }