Example #1
0
        private void DrawLine(DXMediaBrush brush, double x1, double y1, double x2, double y2, float width, DashStyleHelper dashStyle)
        {
            SharpDX.Direct2D1.StrokeStyleProperties ssProps = new SharpDX.Direct2D1.StrokeStyleProperties();

            if (dashStyle == DashStyleHelper.Dash)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dash;
            }
            if (dashStyle == DashStyleHelper.DashDot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDot;
            }
            if (dashStyle == DashStyleHelper.DashDotDot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDotDot;
            }
            if (dashStyle == DashStyleHelper.Dot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dot;
            }
            if (dashStyle == DashStyleHelper.Solid)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid;
            }

            SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(Core.Globals.D2DFactory, ssProps);

            SharpDX.Vector2 startPoint = new System.Windows.Point(x1, y1).ToVector2();
            SharpDX.Vector2 endPoint   = new System.Windows.Point(x2, y2).ToVector2();

            RenderTarget.DrawLine(startPoint, endPoint, brush.DxBrush, width, strokeStyle);

            strokeStyle.Dispose();
            strokeStyle = null;
        }
Example #2
0
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            if (BarsArray[0] == null || ChartBars == null)
            {
                return;
            }

            ChartPanel panel = chartControl.ChartPanels[chartScale.PanelIndex];
            float      endX  = panel.X + panel.W;

            if (ShowAskLine && ask != double.MinValue)
            {
                float startX = Convert.ToSingle(panel.X + panel.W * (1 - (AskLineLength / 100.0)));
                float y      = chartScale.GetYByValue(ask);

                SharpDX.Direct2D1.StrokeStyleProperties strokeProperties = new SharpDX.Direct2D1.StrokeStyleProperties()
                {
                    DashStyle = AskStroke.DashStyleDX
                };

                using (SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(NinjaTrader.Core.Globals.D2DFactory, strokeProperties))
                {
                    RenderTarget.DrawLine(new SharpDX.Vector2(startX, y), new SharpDX.Vector2(endX, y), askBrush, AskStroke.Width, strokeStyle);
                }
            }

            if (ShowBidLine && bid != double.MinValue)
            {
                float startX = Convert.ToSingle(panel.X + panel.W * (1 - (BidLineLength / 100.0)));
                float y      = chartScale.GetYByValue(bid);

                SharpDX.Direct2D1.StrokeStyleProperties strokeProperties = new SharpDX.Direct2D1.StrokeStyleProperties()
                {
                    DashStyle = BidStroke.DashStyleDX
                };

                using (SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(NinjaTrader.Core.Globals.D2DFactory, strokeProperties))
                {
                    RenderTarget.DrawLine(new SharpDX.Vector2(startX, y), new SharpDX.Vector2(endX, y), bidBrush, BidStroke.Width, strokeStyle);
                }
            }

            if (ShowLastLine && last != double.MinValue)
            {
                float startX = Convert.ToSingle(panel.X + panel.W * (1 - (LastLineLength / 100.0)));
                float y      = chartScale.GetYByValue(last);

                SharpDX.Direct2D1.StrokeStyleProperties strokeProperties = new SharpDX.Direct2D1.StrokeStyleProperties()
                {
                    DashStyle = LastStroke.DashStyleDX
                };

                using (SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(NinjaTrader.Core.Globals.D2DFactory, strokeProperties))
                {
                    RenderTarget.DrawLine(new SharpDX.Vector2(startX, y), new SharpDX.Vector2(endX, y), lastBrush, LastStroke.Width, strokeStyle);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 绘制刻度线
        /// </summary>
        private void drawScale()
        {
            var brush = new SharpDX.Direct2D1.SolidColorBrush(cp._renderTarget, new RawColor4(0, 0, 1, 1));
            var strokeStyleProperties = new SharpDX.Direct2D1.StrokeStyleProperties();

            strokeStyleProperties.DashStyle = SharpDX.Direct2D1.DashStyle.Custom;
            float[] dashes      = { 10, 5 };
            var     strokeStyle = new SharpDX.Direct2D1.StrokeStyle(cp.factory, strokeStyleProperties, dashes);

            foreach (var item in coordianteParamList)
            {
                foreach (var C in item.scalePointList)
                {
                    cp._renderTarget.DrawLine(C.Item1, C.Item2, brush, item.LineWidth);
                    //是否显示虚线
                    if (item.virtualLineVisible == VirtualLineVisible.Visible)
                    {
                        if (item.lineDirection == LineDireciton.Horizontal)
                        {
                            RawVector2 rv = new RawVector2();
                            rv.X = C.Item1.X;
                            rv.Y = C.Item1.Y - VLength;
                            cp._renderTarget.DrawLine(C.Item1, rv, brush, 0.5F, strokeStyle);
                        }
                        else
                        {
                            if (item.lineLocation == LineLocation.Right)
                            {
                                RawVector2 rv = new RawVector2();
                                rv.X = C.Item1.X - HLength - item.Index * LineInterval;
                                rv.Y = C.Item1.Y;
                                cp._renderTarget.DrawLine(C.Item1, rv, brush, 0.5F, strokeStyle);
                            }
                            else
                            {
                                RawVector2 rv = new RawVector2();
                                rv.X = C.Item1.X + HLength;
                                rv.Y = C.Item1.Y;
                                cp._renderTarget.DrawLine(C.Item1, rv, brush, 0.5F, strokeStyle);
                            }
                        }
                    }
                }
            }
        }
        public void DrawLine(System.Drawing.Point p1, System.Drawing.Point p2, System.Drawing.Color LineColor, float LineWidth, System.Drawing.Drawing2D.DashStyle dashStyle)
        {
            SharpDX.Direct2D1.StrokeStyleProperties ssProps = new SharpDX.Direct2D1.StrokeStyleProperties();
            ssProps.StartCap   = SharpDX.Direct2D1.CapStyle.Flat;
            ssProps.EndCap     = SharpDX.Direct2D1.CapStyle.Flat;
            ssProps.DashOffset = 0.1f;
            switch (dashStyle)
            {
            case System.Drawing.Drawing2D.DashStyle.Dash: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dash; break;

            case System.Drawing.Drawing2D.DashStyle.DashDot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDot; break;

            case System.Drawing.Drawing2D.DashStyle.DashDotDot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDotDot; break;

            case System.Drawing.Drawing2D.DashStyle.Dot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dot; break;

            case System.Drawing.Drawing2D.DashStyle.Solid: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid; break;
            }
            SharpDX.Direct2D1.StrokeStyle LineStyle = new SharpDX.Direct2D1.StrokeStyle(D2Drender.Factory, ssProps);
            D2Drender.DrawLine(utils.Point2Raw(p1), utils.Point2Raw(p2), utils.SoildBrush2Raw(LineColor), LineWidth, LineStyle);
        }
Example #5
0
        // Condense Line drawing code
        private void DrawLine(string brushName, double x1, double y1, double x2, double y2, float width, DashStyleHelper dashStyle)
        {
            // Create StrokeStyleProperties
            SharpDX.Direct2D1.StrokeStyleProperties ssProps = new SharpDX.Direct2D1.StrokeStyleProperties();

            // Set StrokeStyleProperties Dashstyle to that of the DashStyleHelper
            if (dashStyle == DashStyleHelper.Dash)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dash;
            }
            if (dashStyle == DashStyleHelper.DashDot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDot;
            }
            if (dashStyle == DashStyleHelper.DashDotDot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDotDot;
            }
            if (dashStyle == DashStyleHelper.Dot)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dot;
            }
            if (dashStyle == DashStyleHelper.Solid)
            {
                ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid;
            }

            // Create StrokeStyle from StrokeStyleProperties
            SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(Core.Globals.D2DFactory, ssProps);

            // Create Vector2 coordinates
            SharpDX.Vector2 startPoint = new System.Windows.Point(x1, y1).ToVector2();
            SharpDX.Vector2 endPoint   = new System.Windows.Point(x2, y2).ToVector2();

            // Draw the line
            RenderTarget.DrawLine(startPoint, endPoint, dxmBrushes[brushName].DxBrush, width, strokeStyle);

            // StrokeStyle is device-independant and does not need to be Disposed after each OnRender() or OnRenderTargetChanged() call, but is for good housekeeping,
            strokeStyle.Dispose();
        }
        public void DrawPathGeometrySink(List <System.Drawing.Point> Points, System.Drawing.Color LineColor, float LineWidth, System.Drawing.Drawing2D.DashStyle dashStyle, bool CloseGeometry = false)
        {
            SharpDX.Direct2D1.PathGeometry pg   = new SharpDX.Direct2D1.PathGeometry(D2Drender.Factory);
            SharpDX.Direct2D1.GeometrySink sink = pg.Open();
            for (int i = 0; i < Points.Count; i++)
            {
                if (i == 0)
                {
                    sink.BeginFigure(utils.Point2Raw(Points[0]), SharpDX.Direct2D1.FigureBegin.Hollow);
                }
                else
                {
                    sink.AddLine(utils.Point2Raw(Points[i]));
                }
            }
            if (Points.Count > 0)
            {
                sink.EndFigure(CloseGeometry?SharpDX.Direct2D1.FigureEnd.Closed:SharpDX.Direct2D1.FigureEnd.Open);
            }
            sink.Close();
            SharpDX.Direct2D1.StrokeStyleProperties ssProps = new SharpDX.Direct2D1.StrokeStyleProperties();
            ssProps.StartCap   = SharpDX.Direct2D1.CapStyle.Flat;
            ssProps.EndCap     = SharpDX.Direct2D1.CapStyle.Flat;
            ssProps.DashOffset = 0.1f;
            switch (dashStyle)
            {
            case System.Drawing.Drawing2D.DashStyle.Dash: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dash; break;

            case System.Drawing.Drawing2D.DashStyle.DashDot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDot; break;

            case System.Drawing.Drawing2D.DashStyle.DashDotDot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDotDot; break;

            case System.Drawing.Drawing2D.DashStyle.Dot: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dot; break;

            case System.Drawing.Drawing2D.DashStyle.Solid: ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid; break;
            }
            SharpDX.Direct2D1.StrokeStyle LineStyle = new SharpDX.Direct2D1.StrokeStyle(D2Drender.Factory, ssProps);
            D2Drender.DrawGeometry(pg, utils.SoildBrush2Raw(LineColor), LineWidth, LineStyle);
        }
        private void DirectXRender(List<UIElement> points)
        {
            if (points.Count <= 0)
                return;

            Line initLine = points[0] as Line;

            Point
                p1 = new Point
                (
                    Math.Min(initLine.X1 - initLine.StrokeThickness / 2, initLine.X2 - initLine.StrokeThickness / 2),
                    Math.Min(initLine.Y1 - initLine.StrokeThickness / 2, initLine.Y2 - initLine.StrokeThickness / 2)
                ),
                p2 = new Point
                (
                    Math.Max(initLine.X1 + initLine.StrokeThickness / 2, initLine.X2 + initLine.StrokeThickness / 2),
                    Math.Max(initLine.Y1 + initLine.StrokeThickness / 2, initLine.Y2 + initLine.StrokeThickness / 2)
                );

            foreach (var child in points)
            {
                var line = child as Line;

                if (line == null)
                    continue;

                if (p1.X > line.X1 - line.StrokeThickness / 2)
                    p1.X = line.X1 - line.StrokeThickness / 2;
                if (p1.X > line.X2 - line.StrokeThickness / 2)
                    p1.X = line.X2 - line.StrokeThickness / 2;

                if (p2.X < line.X1 + line.StrokeThickness / 2)
                    p2.X = line.X1 + line.StrokeThickness / 2;
                if (p2.X < line.X2 + line.StrokeThickness / 2)
                    p2.X = line.X2 + line.StrokeThickness / 2;

                if (p1.Y > line.Y1 - line.StrokeThickness / 2)
                    p1.Y = line.Y1 - line.StrokeThickness / 2;
                if (p1.Y > line.Y2 - line.StrokeThickness / 2)
                    p1.Y = line.Y2 - line.StrokeThickness / 2;

                if (p2.Y < line.Y1 + line.StrokeThickness / 2)
                    p2.Y = line.Y1 + line.StrokeThickness / 2;
                if (p2.Y < line.Y2 + line.StrokeThickness / 2)
                    p2.Y = line.Y2 + line.StrokeThickness / 2;
            }

            var bndRect = new Rect(p1, p2);

            var dxTarget = new SurfaceImageSource
            (
                (int)(bndRect.Width * DisplayProperties.LogicalDpi / 96.0 + 1),
                (int)(bndRect.Height * DisplayProperties.LogicalDpi / 96.0 + 1)
            );

            SharpDX.DXGI.ISurfaceImageSourceNative dxTargetNative = SharpDX.ComObject.As<SharpDX.DXGI.ISurfaceImageSourceNative>(dxTarget);
            dxTargetNative.Device = d3dDevice.QueryInterface<SharpDX.DXGI.Device>();

            /*
             * Draw Logic
             */
            SharpDX.DrawingPoint drawingPoint;
            var surface = dxTargetNative.BeginDraw(new SharpDX.Rectangle(0, 0,
                (int)(bndRect.Width * DisplayProperties.LogicalDpi / 96.0 + 1),
                (int)(bndRect.Height * DisplayProperties.LogicalDpi / 96.0 + 1)),
                out drawingPoint);

            var dxRenderTarget = new SharpDX.Direct2D1.RenderTarget(d2dFactory, surface, new SharpDX.Direct2D1.RenderTargetProperties()
            {
                DpiX = DisplayProperties.LogicalDpi,
                DpiY = DisplayProperties.LogicalDpi,
                PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied),
                Type = SharpDX.Direct2D1.RenderTargetType.Default,
                Usage = SharpDX.Direct2D1.RenderTargetUsage.None
            });

            dxRenderTarget.BeginDraw();
            dxRenderTarget.Clear(SharpDX.Color.Transparent);

            foreach (var child in points)
            {
                var line = child as Line;

                if (line == null)
                    continue;

                Color c = (line.Stroke as SolidColorBrush).Color;
                var brush = new SharpDX.Direct2D1.SolidColorBrush(dxRenderTarget, new SharpDX.Color(c.R, c.G, c.B, c.A));

                var style = new SharpDX.Direct2D1.StrokeStyleProperties();
                style.LineJoin = SharpDX.Direct2D1.LineJoin.Round;
                style.StartCap = SharpDX.Direct2D1.CapStyle.Round;
                style.EndCap = SharpDX.Direct2D1.CapStyle.Round;
                var stroke = new SharpDX.Direct2D1.StrokeStyle(d2dFactory, style);

                dxRenderTarget.DrawLine(
                    new SharpDX.DrawingPointF((float)(line.X1 - bndRect.Left), (float)(line.Y1 - bndRect.Top)),
                    new SharpDX.DrawingPointF((float)(line.X2 - bndRect.Left), (float)(line.Y2 - bndRect.Top)),
                    brush, (float)line.StrokeThickness, stroke);
            }

            dxRenderTarget.EndDraw();
            dxTargetNative.EndDraw();

            var dxImage = new Image();
            dxImage.Source = dxTarget;
            canvas.Children.Add(dxImage);
            Canvas.SetLeft(dxImage, bndRect.X);
            Canvas.SetTop(dxImage, bndRect.Y);
        }
Example #8
0
        internal static SharpDX.Direct2D1.StrokeStyle ToStrokeStyle(this Pen pen, SharpDX.Direct2D1.Factory factory)
        {
            SharpDX.Direct2D1.StrokeStyleProperties properties = new SharpDX.Direct2D1.StrokeStyleProperties
            {
                DashCap = _dashCapMap[pen.DashCap],
                DashOffset = pen.DashOffset,
                DashStyle = _dashStyleMap[pen.DashStyle],
                EndCap = _lineCapMap[pen.EndCap],
                LineJoin = _lineJoinMap[pen.LineJoin],
                MiterLimit = pen.MiterLimit,
                StartCap = _lineCapMap[pen.StartCap],
            };

            if (pen.DashStyle == DashStyle.Custom)
                return new SharpDX.Direct2D1.StrokeStyle(factory, properties, pen.DashPattern);
            return new SharpDX.Direct2D1.StrokeStyle(factory, properties);
        }
Example #9
0
 //public static SharpDX.Direct2D1.StrokeStyle ToStrokeStyle(DUIRenderTarget renderTarget, Pen pen)
 //{
 //    SharpDX.Direct2D1.StrokeStyleProperties strokeStyleProperties = new SharpDX.Direct2D1.StrokeStyleProperties();
 //    strokeStyleProperties.DashCap = (SharpDX.Direct2D1.CapStyle)pen.DashCap;
 //    strokeStyleProperties.DashOffset = pen.DashOffset;
 //    strokeStyleProperties.DashStyle = (SharpDX.Direct2D1.DashStyle)pen.DashStyle;
 //    strokeStyleProperties.EndCap = (SharpDX.Direct2D1.CapStyle)pen.EndCap;
 //    strokeStyleProperties.LineJoin = (SharpDX.Direct2D1.LineJoin)pen.LineJoin;
 //    strokeStyleProperties.MiterLimit = pen.MiterLimit;
 //    strokeStyleProperties.StartCap = (SharpDX.Direct2D1.CapStyle)pen.StartCap;
 //    return new SharpDX.Direct2D1.StrokeStyle(renderTarget.Factory, strokeStyleProperties);
 //}
 public static SharpDX.Direct2D1.StrokeStyle ToStrokeStyle(DUIRenderTarget renderTarget, SharpDX.Direct2D1.StrokeStyleProperties strokeStyleProperties)
 {
     return(new SharpDX.Direct2D1.StrokeStyle(renderTarget.RenderTarget.Factory, strokeStyleProperties));
 }
Example #10
0
        private void DirectXRender(List <UIElement> points)
        {
            if (points.Count <= 0)
            {
                return;
            }

            Line initLine = points[0] as Line;

            Point
                p1 = new Point
                     (
                Math.Min(initLine.X1 - initLine.StrokeThickness / 2, initLine.X2 - initLine.StrokeThickness / 2),
                Math.Min(initLine.Y1 - initLine.StrokeThickness / 2, initLine.Y2 - initLine.StrokeThickness / 2)
                     ),
                p2 = new Point
                     (
                Math.Max(initLine.X1 + initLine.StrokeThickness / 2, initLine.X2 + initLine.StrokeThickness / 2),
                Math.Max(initLine.Y1 + initLine.StrokeThickness / 2, initLine.Y2 + initLine.StrokeThickness / 2)
                     );

            foreach (var child in points)
            {
                var line = child as Line;

                if (line == null)
                {
                    continue;
                }

                if (p1.X > line.X1 - line.StrokeThickness / 2)
                {
                    p1.X = line.X1 - line.StrokeThickness / 2;
                }
                if (p1.X > line.X2 - line.StrokeThickness / 2)
                {
                    p1.X = line.X2 - line.StrokeThickness / 2;
                }

                if (p2.X < line.X1 + line.StrokeThickness / 2)
                {
                    p2.X = line.X1 + line.StrokeThickness / 2;
                }
                if (p2.X < line.X2 + line.StrokeThickness / 2)
                {
                    p2.X = line.X2 + line.StrokeThickness / 2;
                }

                if (p1.Y > line.Y1 - line.StrokeThickness / 2)
                {
                    p1.Y = line.Y1 - line.StrokeThickness / 2;
                }
                if (p1.Y > line.Y2 - line.StrokeThickness / 2)
                {
                    p1.Y = line.Y2 - line.StrokeThickness / 2;
                }

                if (p2.Y < line.Y1 + line.StrokeThickness / 2)
                {
                    p2.Y = line.Y1 + line.StrokeThickness / 2;
                }
                if (p2.Y < line.Y2 + line.StrokeThickness / 2)
                {
                    p2.Y = line.Y2 + line.StrokeThickness / 2;
                }
            }

            var bndRect = new Rect(p1, p2);

            var dxTarget = new SurfaceImageSource
                           (
                (int)(bndRect.Width * DisplayProperties.LogicalDpi / 96.0 + 1),
                (int)(bndRect.Height * DisplayProperties.LogicalDpi / 96.0 + 1)
                           );

            SharpDX.DXGI.ISurfaceImageSourceNative dxTargetNative = SharpDX.ComObject.As <SharpDX.DXGI.ISurfaceImageSourceNative>(dxTarget);
            dxTargetNative.Device = d3dDevice.QueryInterface <SharpDX.DXGI.Device>();

            /*
             * Draw Logic
             */
            SharpDX.DrawingPoint drawingPoint;
            var surface = dxTargetNative.BeginDraw(new SharpDX.Rectangle(0, 0,
                                                                         (int)(bndRect.Width * DisplayProperties.LogicalDpi / 96.0 + 1),
                                                                         (int)(bndRect.Height * DisplayProperties.LogicalDpi / 96.0 + 1)),
                                                   out drawingPoint);

            var dxRenderTarget = new SharpDX.Direct2D1.RenderTarget(d2dFactory, surface, new SharpDX.Direct2D1.RenderTargetProperties()
            {
                DpiX        = DisplayProperties.LogicalDpi,
                DpiY        = DisplayProperties.LogicalDpi,
                PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied),
                Type        = SharpDX.Direct2D1.RenderTargetType.Default,
                Usage       = SharpDX.Direct2D1.RenderTargetUsage.None
            });

            dxRenderTarget.BeginDraw();
            dxRenderTarget.Clear(SharpDX.Color.Transparent);

            foreach (var child in points)
            {
                var line = child as Line;

                if (line == null)
                {
                    continue;
                }

                Color c     = (line.Stroke as SolidColorBrush).Color;
                var   brush = new SharpDX.Direct2D1.SolidColorBrush(dxRenderTarget, new SharpDX.Color(c.R, c.G, c.B, c.A));

                var style = new SharpDX.Direct2D1.StrokeStyleProperties();
                style.LineJoin = SharpDX.Direct2D1.LineJoin.Round;
                style.StartCap = SharpDX.Direct2D1.CapStyle.Round;
                style.EndCap   = SharpDX.Direct2D1.CapStyle.Round;
                var stroke = new SharpDX.Direct2D1.StrokeStyle(d2dFactory, style);

                dxRenderTarget.DrawLine(
                    new SharpDX.DrawingPointF((float)(line.X1 - bndRect.Left), (float)(line.Y1 - bndRect.Top)),
                    new SharpDX.DrawingPointF((float)(line.X2 - bndRect.Left), (float)(line.Y2 - bndRect.Top)),
                    brush, (float)line.StrokeThickness, stroke);
            }

            dxRenderTarget.EndDraw();
            dxTargetNative.EndDraw();

            var dxImage = new Image();

            dxImage.Source = dxTarget;
            canvas.Children.Add(dxImage);
            Canvas.SetLeft(dxImage, bndRect.X);
            Canvas.SetTop(dxImage, bndRect.Y);
        }