コード例 #1
0
        private void canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            sharedResources = TextDirectionControl.GetSharedResources(sender);

            var ds = args.DrawingSession;

            Rect rect = new Rect(0, 0, sender.ActualWidth, sender.ActualHeight);

            if (ThumbnailGenerator.IsDrawingThumbnail)
            {
                rect.Width = sender.ActualWidth / 2;
            }
            else
            {
                ds.DrawText("Win2D DrawText", rect, drawingColor,
                            new CanvasTextFormat()
                {
                    FontSize            = 14,
                    HorizontalAlignment = CanvasHorizontalAlignment.Center,
                    VerticalAlignment   = CanvasVerticalAlignment.Top
                });

                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Left, CanvasVerticalAlignment.Top);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Right, CanvasVerticalAlignment.Top);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Left, CanvasVerticalAlignment.Bottom);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Right, CanvasVerticalAlignment.Bottom);
            }

            var arrow = sharedResources.GetArrow(CurrentDirection);

            var arrowBounds = arrow.ComputeStrokeBounds(4);

            var destSize   = new Size(sender.ActualWidth / 2, sender.ActualHeight / 2);
            var destBounds = new Rect(new Point(sender.ActualWidth / 2 - destSize.Width / 2, sender.ActualHeight / 2 - destSize.Height / 2), destSize);

            arrow = arrow.Transform(TextDirectionControl.CalculateTransform(arrowBounds, destBounds));

            ds.DrawGeometry(arrow, drawingColor, 4, TextDirectionControl.ArrowStrokeStyle);
        }
コード例 #2
0
        private void canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            sharedResources = TextDirectionControl.GetSharedResources(sender);

            var ds = args.DrawingSession;

            Rect rect = new Rect(0,0, sender.ActualWidth, sender.ActualHeight);

            if (ThumbnailGenerator.IsDrawingThumbnail)
            {
                rect.Width = sender.ActualWidth / 2;
            }
            else
            {
                ds.DrawText("Win2D DrawText", rect, drawingColor,
                    new CanvasTextFormat()
                    {
                        FontSize = 14,
                        HorizontalAlignment = CanvasHorizontalAlignment.Center,
                        VerticalAlignment = CanvasVerticalAlignment.Top
                    });

                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Left, CanvasVerticalAlignment.Top);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Right, CanvasVerticalAlignment.Top);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Left, CanvasVerticalAlignment.Bottom);
                DrawAlignedText(ds, rect, CanvasHorizontalAlignment.Right, CanvasVerticalAlignment.Bottom);
            }

            var arrow = sharedResources.GetArrow(CurrentDirection);

            var arrowBounds = arrow.ComputeStrokeBounds(4);

            var destSize = new Size(sender.ActualWidth / 2, sender.ActualHeight / 2);
            var destBounds = new Rect(new Point(sender.ActualWidth / 2 - destSize.Width / 2, sender.ActualHeight / 2 - destSize.Height / 2), destSize);
            arrow = arrow.Transform(TextDirectionControl.CalculateTransform(arrowBounds, destBounds));

            ds.DrawGeometry(arrow, drawingColor, 4, TextDirectionControl.ArrowStrokeStyle);
        }