Exemplo n.º 1
0
 protected override void DrawPath(SeriesBase series, Brush brush, double strokeThickness)
 {
     if (series is LineSeries || series is HiLoSeries)
     {
         PartsCollection partsCollection = new PartsCollection();
         if (series is LineSeries)
         {
             LineSeries lineSeries = series as LineSeries;
             partsCollection = lineSeries.Parts;
         }
         else if (series is HiLoSeries)
         {
             HiLoSeries lineSeries = series as HiLoSeries;
             partsCollection = lineSeries.Parts;
         }
         if (RenderingMode == RenderingMode.Default)
         {
             for (int i = 0; i < partsCollection.Count; i++)
             {
                 UIElement element = partsCollection[i].CreatePart();
                 if (element != null)
                 {
                     PartsCanvas.Children.Add(element);
                 }
             }
         }
     }
 }
Exemplo n.º 2
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();
                }
            }
        }