internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Ellipse ellipse)
        {
            var rect = ellipse.GetBoundingRect(rootElement).ToSharpDX();

            var d2dEllipse = new D2D.Ellipse(
                new Vector2(
                    (float)((rect.Left + rect.Right) * 0.5),
                    (float)((rect.Top + rect.Bottom) * 0.5)),
                (float)(0.5 * rect.Width),
                (float)(0.5 * rect.Height));
            var fill = await ellipse.Fill.ToSharpDX(renderTarget, rect);

            var layer = ellipse.CreateAndPushLayerIfNecessary(renderTarget, rootElement);

            var stroke = await ellipse.Stroke.ToSharpDX(renderTarget, rect);

            if (ellipse.StrokeThickness > 0 &&
                stroke != null)
            {
                var halfStrokeThickness = (float)(ellipse.StrokeThickness * 0.5);
                d2dEllipse.RadiusX -= halfStrokeThickness;
                d2dEllipse.RadiusY -= halfStrokeThickness;

                if (fill != null)
                {
                    renderTarget.FillEllipse(d2dEllipse, fill);
                }

                renderTarget.DrawEllipse(
                    d2dEllipse,
                    stroke,
                    (float)ellipse.StrokeThickness,
                    ellipse.GetStrokeStyle(compositionEngine.D2DFactory));
            }
            else if (fill != null)
            {
                renderTarget.FillEllipse(d2dEllipse, fill);
            }

            if (layer != null)
            {
                renderTarget.PopLayer();
                layer.Dispose();
            }
        }
        internal static void Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Ellipse ellipse)
        {
            var rect = ellipse.GetBoundingRect(rootElement).ToSharpDX();

            var d2dEllipse = new D2D.Ellipse(
                new DrawingPointF(
                    (float)((rect.Left + rect.Right) * 0.5),
                    (float)((rect.Top + rect.Bottom) * 0.5)),
                (float)(0.5 * rect.Width),
                (float)(0.5 * rect.Height));
            var fill = ellipse.Fill.ToSharpDX(renderTarget, rect);

            //var layer = new Layer(renderTarget);
            //var layerParameters = new LayerParameters();
            //layerParameters.ContentBounds = rect;
            //renderTarget.PushLayer(ref layerParameters, layer);

            var stroke = ellipse.Stroke.ToSharpDX(renderTarget, rect);

            if (ellipse.StrokeThickness > 0 &&
                stroke != null)
            {
                var halfStrokeThickness = (float)(ellipse.StrokeThickness * 0.5);
                d2dEllipse.RadiusX -= halfStrokeThickness;
                d2dEllipse.RadiusY -= halfStrokeThickness;

                if (fill != null)
                {
                    renderTarget.FillEllipse(d2dEllipse, fill);
                }

                renderTarget.DrawEllipse(
                    d2dEllipse,
                    stroke,
                    (float)ellipse.StrokeThickness,
                    ellipse.GetStrokeStyle(compositionEngine.D2DFactory));
            }
            else if (fill != null)
            {
                renderTarget.FillEllipse(d2dEllipse, fill);
            }

            //renderTarget.PopLayer();
        }
示例#3
0
 internal void Draw(SharpDX.Direct2D1.RenderTarget d2dRenderTarget)
 {
     if (Color != null)
         GameForm.solidColorBrush.Color = Color;
     d2dRenderTarget.FillEllipse(el, GameForm.solidColorBrush);
 }