コード例 #1
0
ファイル: SkiaControl.cs プロジェクト: AndreAbrantes/Comet
        protected virtual void DrawText(TextBlock tb, SKCanvas canvas, VerticalAlignment verticalAlignment)
        {
            tb.MaxWidth  = VirtualView.Frame.Width;
            tb.MaxHeight = VirtualView.Frame.Height;
            tb.Layout();
            var y = verticalAlignment switch
            {
                VerticalAlignment.Bottom => VirtualView.Frame.Height - tb.MeasuredHeight,
                VerticalAlignment.Center => (VirtualView.Frame.Height - tb.MeasuredHeight) / 2,
                _ => 0
            };

            tb.Paint(canvas, new SKPoint(0, y));
        }
コード例 #2
0
ファイル: SkiaControl.cs プロジェクト: AndreAbrantes/Comet
        protected virtual void DrawText(string text, SKCanvas canvas, FontAttributes data, Color color, TextAlignment alignment, LineBreakMode lineBreakMode, VerticalAlignment verticalAlignment)
        {
            var tb = new TextBlock();

            tb.AddText(text, data.ToStyle(color));
            tb.MaxWidth  = VirtualView.Frame.Width;
            tb.MaxHeight = VirtualView.Frame.Height;
            tb.MaxLines  = null;
            tb.Alignment = alignment.ToTextAlignment();
            tb.Layout();

            var y = verticalAlignment switch
            {
                VerticalAlignment.Bottom => VirtualView.Frame.Height - tb.MeasuredHeight,
                VerticalAlignment.Center => (VirtualView.Frame.Height - tb.MeasuredHeight) / 2,
                _ => 0
            };

            tb.Paint(canvas, new SKPoint(0, y));
        }