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


C# CanvasDrawingSession.DrawTextLayout方法代码示例

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


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

示例1: DrawTextOverWhiteRectangle

        private static void DrawTextOverWhiteRectangle(CanvasDrawingSession ds, Vector2 paddedTopLeft, CanvasTextLayout textLayout)
        {
            var bounds = textLayout.LayoutBounds;

            var rect = new Rect(bounds.Left + paddedTopLeft.X, bounds.Top + paddedTopLeft.Y, bounds.Width, bounds.Height);

            ds.FillRectangle(rect, Colors.White);
            ds.DrawTextLayout(textLayout, paddedTopLeft, Colors.Black);
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:9,代码来源:PrintingExample.xaml.cs

示例2: drawText

 public void drawText(CanvasDrawingSession ds, Color color)
 {
     ds.DrawTextLayout(textLayout, (float)location.X, (float)location.Y, color);
 }
开发者ID:michael-spinelli,项目名称:Renderer2525C-W10-UWP,代码行数:4,代码来源:TextInfo.cs

示例3: DoEffect

        private void DoEffect(CanvasDrawingSession ds, Size size, float amount)
        {
            size.Width = size.Width - ExpandAmount;
            size.Height = size.Height - ExpandAmount;

            var offset = (float)(ExpandAmount / 2);           

            using (var textLayout = CreateTextLayout(ds, size))
            using (var textCommandList = new CanvasCommandList(ds))
            {
                using (var textDs = textCommandList.CreateDrawingSession())
                {                     
                    textDs.DrawTextLayout(textLayout, 0, 0, GlowColor);
                }

                glowEffectGraph.Setup(textCommandList, amount);
                ds.DrawImage(glowEffectGraph.Output, offset, offset);

                ds.DrawTextLayout(textLayout, offset, offset, TextColor);
            }
        }
开发者ID:clarkezone,项目名称:Win2D,代码行数:21,代码来源:GlowTextCustomControl.cs

示例4: Draw

            public void Draw(CanvasDrawingSession ds, int frameCounter, float width, float height)
            {
                ++frameCounter;
                float opacity = (float)(Math.Sin(frameCounter * 0.05) + 1) / 2;

                DoTest(opacity, ignoreSource, premultipliedTarget[0]);
                DoTest(opacity, ignoreSource, ignoreTarget[0]);
                DoTest(opacity, premultipliedSource, premultipliedTarget[1]);
                DoTest(opacity, premultipliedSource, ignoreTarget[1]);

                float halfWidth = width / 2;
                var premultipliedToIgnoreLabel = MakeLabel(ds, "Draw Premultiplied to Ignore", halfWidth);
                var premultipliedToPremultipliedLabel = MakeLabel(ds, "Draw Premultiplied to Premultiplied", halfWidth);
                var ignoreToIgnoreLabel = MakeLabel(ds, "Draw Ignore to Ignore", halfWidth);
                var ignoreToPremultipliedLabel = MakeLabel(ds, "Draw Ignore to Premultiplied", halfWidth);

                var totalHeight = 64 * 8.0f;

                float middle = width / 2;

                float imageX = middle + 10;
                float textRight = middle - 10;

                float y = (height / 2) - (totalHeight / 2);
                float ydiff = 64.0f * 2.0f;

                ds.DrawImage(premultipliedTarget[0], imageX, y);
                ds.DrawTextLayout(premultipliedToPremultipliedLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(ignoreTarget[0], imageX, y);
                ds.DrawTextLayout(premultipliedToIgnoreLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(premultipliedTarget[1], imageX, y);
                ds.DrawTextLayout(ignoreToPremultipliedLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(ignoreTarget[1], imageX, y);
                ds.DrawTextLayout(ignoreToIgnoreLabel, 0, y, Colors.White);
                y += ydiff;
            }
开发者ID:fengweijp,项目名称:Win2D,代码行数:42,代码来源:DrawImageEmulations.xaml.cs

示例5: DrawTextWithBackground

        private void DrawTextWithBackground(CanvasDrawingSession ds, CanvasTextLayout layout, double x, double y)
        {
            var backgroundRect = layout.LayoutBounds;
            backgroundRect.X += x;
            backgroundRect.Y += y;

            backgroundRect.X -= 20;
            backgroundRect.Y -= 20;
            backgroundRect.Width += 40;
            backgroundRect.Height += 40;

            ds.FillRectangle(backgroundRect, Colors.White);
            ds.DrawTextLayout(layout, (float)x, (float)y, Colors.Black);
        }
开发者ID:RainbowGardens,项目名称:Win2D,代码行数:14,代码来源:VirtualImageSourceExample.xaml.cs


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