예제 #1
0
        private UIElement Rendering(byte[] resourceStream, string title)
        {
            var control = new SKXamlCanvas();
            var bmp     = SKBitmap.Decode(resourceStream);
            var width   = bmp.Info.Width;
            var height  = bmp.Info.Height;

            control.Width         = width;
            control.Height        = height;
            control.PaintSurface += (s, e) =>
            {
                var canvas = e.Surface.Canvas;
                canvas.DrawBitmap(bmp, 0, 0);

                var textPos = new SKPoint(width / 2f, height / 2f);
                using (var paint = new SKPaint())
                {
                    paint.TextSize    = 45f;
                    paint.IsAntialias = true;
                    paint.TextAlign   = SKTextAlign.Center;

                    paint.Color = SKColors.Cyan;
                    canvas.DrawText(title, textPos, paint);

                    paint.Color       = SKColors.Crimson;
                    paint.IsStroke    = true;
                    paint.StrokeWidth = 2f;
                    canvas.DrawText(title, textPos, paint);
                }
            };
            return(control);
        }
예제 #2
0
        public MainPage()
        {
            skiaView = new SKXamlCanvas();
            skiaView.PaintSurface += OnPaintSurface;

            Content = skiaView;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MotionCanvas"/> class.
        /// </summary>
        public MotionCanvas()
        {
            InitializeComponent();
            Loaded += OnLoaded;
            Unloaded += OnUnloaded;

            var canvas = (SKXamlCanvas)FindName("canvas");
            _skiaElement = canvas;
            _skiaElement.PaintSurface += OnPaintSurface;
        }
예제 #4
0
 public static void UpdateIgnorePixelScaling(this SKXamlCanvas nativeView, ISKCanvasView canvasView) =>
 nativeView.IgnorePixelScaling = canvasView?.IgnorePixelScaling ?? false;
예제 #5
0
 void Build()
 {
     Content = new SKXamlCanvas
     {
     }
 }