Esempio n. 1
0
        private SharpDX.Direct2D1.PathGeometry CreatePathGeometry(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, double pixelAdjust)
        {
            List <SharpDX.Vector2> vectors = new List <SharpDX.Vector2>();
            Vector pixelAdjustVec          = new Vector(pixelAdjust, pixelAdjust);

            for (int i = 0; i < ChartAnchors.Count; i++)
            {
                Point p = ChartAnchors[i].GetPoint(chartControl, chartPanel, chartScale);
                vectors.Add((p + pixelAdjustVec).ToVector2());

                if (i + 1 < ChartAnchors.Count)
                {
                    Point p2 = ChartAnchors[i + 1].GetPoint(chartControl, chartPanel, chartScale);
                    vectors.Add((p2 + pixelAdjustVec).ToVector2());
                }
            }

            SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
            SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open();

            geometrySink.BeginFigure(vectors[0], SharpDX.Direct2D1.FigureBegin.Filled);
            geometrySink.AddLines(vectors.ToArray());
            geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
            geometrySink.Close();             // calls dispose for you

            return(pathGeometry);
        }