当前位置: 首页>>代码示例>>C#>>正文


C# SharpDX.DrawRectangle方法代码示例

本文整理汇总了C#中SharpDX.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# SharpDX.DrawRectangle方法的具体用法?C# SharpDX.DrawRectangle怎么用?C# SharpDX.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpDX的用法示例。


在下文中一共展示了SharpDX.DrawRectangle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        internal static void Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Rectangle rectangle)
        {
            var rect = rectangle.GetBoundingRect(rootElement).ToSharpDX();
            var fill = rectangle.Fill.ToSharpDX(renderTarget, rect);
            var stroke = rectangle.Stroke.ToSharpDX(renderTarget, rect);

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

            if (rectangle.RadiusX > 0 &&
                rectangle.RadiusY > 0)
            {
                var roundedRect = new SharpDX.Direct2D1.RoundedRect();
                roundedRect.Rect = rect;
                roundedRect.RadiusX = (float)rectangle.RadiusX;
                roundedRect.RadiusY = (float)rectangle.RadiusY;

                if (rectangle.StrokeThickness > 0 &&
                    stroke != null)
                {
                    var halfThickness = (float)(rectangle.StrokeThickness * 0.5);
                    roundedRect.Rect = rect.Eroded(halfThickness);

                    if (fill != null)
                    {
                        renderTarget.FillRoundedRectangle(roundedRect, fill);
                    }

                    renderTarget.DrawRoundedRectangle(
                        roundedRect,
                        stroke,
                        (float)rectangle.StrokeThickness,
                        rectangle.GetStrokeStyle(compositionEngine.D2DFactory));
                }
                else
                {
                    renderTarget.FillRoundedRectangle(roundedRect, fill);
                }
            }
            else
            {
                if (rectangle.StrokeThickness > 0 &&
                    stroke != null)
                {
                    var halfThickness = (float)(rectangle.StrokeThickness * 0.5);

                    if (fill != null)
                    {
                        renderTarget.FillRectangle(rect.Eroded(halfThickness), fill);
                    }

                    var strokeRect = rect.Eroded(halfThickness);
                    renderTarget.DrawRectangle(
                        strokeRect,
                        stroke,
                        (float)rectangle.StrokeThickness,
                        rectangle.GetStrokeStyle(compositionEngine.D2DFactory));
                }
                else
                {
                    renderTarget.FillRectangle(rect, fill);
                }
            }
            //renderTarget.PopLayer();
        }
开发者ID:stavrianosy,项目名称:BudgetManagementAssistant,代码行数:67,代码来源:RectangleRenderer.cs

示例2: _drawSelectedTile

        private void _drawSelectedTile(SharpDX.Direct2D1.DeviceContext d2dContext)
        {
            if (_selectedRect != null)
            {
                var strokeStyle_dashed = new SharpDX.Direct2D1.StrokeStyle(d2dContext.Factory, new SharpDX.Direct2D1.StrokeStyleProperties() { DashOffset = (offsetSelectedDash / 5), DashStyle = SharpDX.Direct2D1.DashStyle.Dash });

                ////drown out the shadow of the tile
                //d2dContext.DrawRectangle(
                //    new RectangleF(_selectedRect.Rectangle.X - 2, _selectedRect.Rectangle.Y - 2, _selectedRect.Rectangle.Width + 4, _selectedRect.Rectangle.Height + 4),
                //    new SharpDX.Direct2D1.SolidColorBrush(d2dContext, Color.White),
                //    4
                //    );

                //draw an animated dash around border of tile
                d2dContext.DrawRectangle(
                    new RectangleF(_selectedRect.Rectangle.X - 2, _selectedRect.Rectangle.Y - 2, _selectedRect.Rectangle.Width + 4, _selectedRect.Rectangle.Height + 4),
                    new SharpDX.Direct2D1.SolidColorBrush(d2dContext, Color.Yellow),
                    4,
                    strokeStyle_dashed);

                //_drawTiles(_selectedRect.UniqueId);

                offsetSelectedDash++;

                if (offsetSelectedDash > 100) offsetSelectedDash = 0;
            }
        }
开发者ID:rolandsmeenk,项目名称:ModernApps,代码行数:27,代码来源:DxRenderer.BackgroundComposer.cs

示例3: _drawDesktopOutline

        private void _drawDesktopOutline( SharpDX.Direct2D1.DeviceContext d2dContext)
        {
            
 

            //BORDER
            d2dContext.Transform = Matrix.Translation(_globalTranslation) * Matrix.Scaling(_globalScale);
            d2dContext.DrawRectangle(
                _layoutDeviceScreenSize,
                _generalLightGrayColor,
                3
                );

            //WIDTH
            d2dContext.Transform =  Matrix.Translation(_globalTranslation) * Matrix.Scaling(_globalScale);
            d2dContext.FillRectangle(
                new RectangleF(0, -30, 100, 30),
                _generalLightGrayColor
                );
            d2dContext.Transform = Matrix.Translation(10, 0, 0) * Matrix.Translation(_globalTranslation) * Matrix.Scaling(_globalScale);
            d2dContext.DrawText(_layoutDetail.Width.ToString(), _generalTextFormat, new RectangleF(0, -30, 100, 30), _generalLightWhiteColor);

            ////HEIGHT
            double angleRadians = 90 * Math.PI / 180; //90 degrees
            d2dContext.Transform = Matrix.RotationZ((float)angleRadians)  * Matrix.Identity * Matrix.Translation(_globalTranslation) * Matrix.Scaling(_globalScale);
            d2dContext.FillRectangle(
                new RectangleF(0, 0, 100, 30),
                _generalLightGrayColor
            );
            d2dContext.Transform = Matrix.RotationZ((float)angleRadians) * Matrix.Translation(0, 10, 0) *  Matrix.Translation(_globalTranslation) * Matrix.Scaling(_globalScale);
            d2dContext.DrawText(_layoutDetail.Height.ToString(), _generalTextFormat, new RectangleF(0, 0, 100, 30), _generalLightWhiteColor);

            
        }
开发者ID:rolandsmeenk,项目名称:ModernApps,代码行数:34,代码来源:DxRenderer.BackgroundComposer.cs

示例4: Render

        internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Rectangle rectangle)
        {
            var rect = rectangle.GetBoundingRect(rootElement).ToSharpDX();
            var fill = await rectangle.Fill.ToSharpDX(renderTarget, rect);
            var stroke = await rectangle.Stroke.ToSharpDX(renderTarget, rect);

            try
            {
                var layer = rectangle.CreateAndPushLayerIfNecessary(renderTarget, rootElement);

                if (rectangle.RadiusX > 0 &&
                    rectangle.RadiusY > 0)
                {
                    var roundedRect = new SharpDX.Direct2D1.RoundedRectangle();
                    roundedRect.Rect = rect;
                    roundedRect.RadiusX = (float)rectangle.RadiusX;
                    roundedRect.RadiusY = (float)rectangle.RadiusY;

                    if (rectangle.StrokeThickness > 0 &&
                        stroke != null)
                    {
                        var halfThickness = (float)(rectangle.StrokeThickness * 0.5);
                        roundedRect.Rect = rect.Eroded(halfThickness);

                        if (fill != null)
                        {
                            renderTarget.FillRoundedRectangle(roundedRect, fill);
                        }

                        renderTarget.DrawRoundedRectangle(
                            roundedRect,
                            stroke,
                            (float)rectangle.StrokeThickness,
                            rectangle.GetStrokeStyle(compositionEngine.D2DFactory));
                    }
                    else
                    {
                        renderTarget.FillRoundedRectangle(roundedRect, fill);
                    }
                }
                else
                {
                    if (rectangle.StrokeThickness > 0 &&
                        stroke != null)
                    {
                        var halfThickness = (float)(rectangle.StrokeThickness * 0.5);

                        if (fill != null)
                        {
                            renderTarget.FillRectangle(rect.Eroded(halfThickness), fill);
                        }

                        var strokeRect = rect.Eroded(halfThickness);
                        renderTarget.DrawRectangle(
                            strokeRect,
                            stroke,
                            (float)rectangle.StrokeThickness,
                            rectangle.GetStrokeStyle(compositionEngine.D2DFactory));
                    }
                    else
                    {
                        renderTarget.FillRectangle(rect, fill);
                    }
                }

                if (layer != null)
                {
                    renderTarget.PopLayer();
                    layer.Dispose();
                }
            }
            finally
            {
                if (fill != null)
                    fill.Dispose();
                if (stroke != null)
                    stroke.Dispose();
            }
        }
开发者ID:siatwangmin,项目名称:WinRTXamlToolkit,代码行数:79,代码来源:RectangleRenderer.cs


注:本文中的SharpDX.DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。