private void MyGraphCanvasGrid_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            h_grid = (float)myGraphCanvasGrid.CanvasSize.Height;
            w_grid = (float)myGraphCanvasGrid.CanvasSize.Width;

            DrawGrid(canvas);
        }
        private void MyGraphCanvas_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            h_data = (float)myGraphCanvas.CanvasSize.Height;
            w_data = (float)myGraphCanvas.CanvasSize.Width;

            // graphics frame duration = Every 15 ms the data is updated and this data point takes 4 pixels.  So width / 4 = number of datapoints * 15 ms = duration of 1 frame
            GraphicsFrameDuration = ((w_data - 2 * GraphXOffset) / PixelPerDataPoint) * DataRefreshRate;
            DrawGraph(canvas);
        }
示例#3
0
 protected virtual void OnPaintSurface(SKPaintSurfaceEventArgs e)
 {
     // invoke the event
     PaintSurface?.Invoke(this, e);
 }
示例#4
0
        private void SkCtrl_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e)
        {
            //var info = e.Info;
            //var sf = e.Surface;
            //var canvas = sf.Canvas;
            //canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, DefPaint);
            //DefPaint.Style = SKPaintStyle.Fill;
            //DefPaint.Color = SKColors.Blue;
            //canvas.DrawCircle(info.Width / 2, info.Height / 2, 100, DefPaint);
            SKImageInfo info    = e.Info;
            SKSurface   surface = e.Surface;
            SKCanvas    canvas  = surface.Canvas;

            canvas.Clear();
            //canvas.Clear(SystemColors.ControlText.ToSKColor());
            float maxRadius = 0.75f * Math.Min(info.Width, info.Height) / 2;
            float minRadius = 0.25f * maxRadius;

            float xRadius = minRadius * CurrentScale + maxRadius * (1 - CurrentScale);
            float yRadius = maxRadius * CurrentScale + minRadius * (1 - CurrentScale);

            //using (SKPaint paint = new SKPaint())
            //{
            //DefPaint.Style = SKPaintStyle.Stroke;
            //DefPaint.Color = SKColors.Blue;
            //DefPaint.StrokeWidth = 50;
            //DefPaint.IsAntialias = true;
            canvas.DrawOval(info.Width / 2, info.Height / 2, xRadius, yRadius, DefPaint);

            //DefPaint.Style = SKPaintStyle.Fill;
            //DefPaint.Color = SKColors.SkyBlue;
            canvas.DrawOval(info.Width / 2, info.Height / 2, xRadius, yRadius, DefPaint);
            //}
            //var ii = new SKImageInfo(640, 480,SKColorType.Bgra8888);
            //using (var sf = SKSurface.Create(ii))
            //{
            //    SKCanvas c = sf.Canvas;
            //    c.Clear(SKColors.White);
            //    c.DrawSurface(surface, new SKPoint(0, 0));
            //}
            var txt      = "Hello World";
            var txtWidth = DefPaint.MeasureText(txt);

            DefPaint.TextSize = 0.9f * info.Width * DefPaint.TextSize / txtWidth;
            var textBounds = new SKRect();

            DefPaint.MeasureText(txt, ref textBounds);
            float xText = info.Width / 2 - textBounds.MidX;
            float yText = info.Height / 2 - textBounds.MidY;

            // And draw the text
            canvas.DrawText(txt, xText, yText, DefPaint);
            using (DefPaint.ImageFilter = SKImageFilter.CreateBlur(5, 5))
            {
                if (webBitmap != null)
                {
                    canvas.DrawBitmap(webBitmap, new SKRect
                    {
                        Left   = 50,
                        Top    = 50,
                        Right  = 250,
                        Bottom = 160
                    }, DefPaint);
                    //canvas.DrawBitmap(webBitmap, 0, 0);
                }
                if (resourceBitmap != null)
                {
                    DefPaint.Color = DefPaint.Color.WithAlpha(100);
                    canvas.DrawBitmap(resourceBitmap, new SKRect
                    {
                        Left   = 50,
                        Top    = 180,
                        Right  = 250,
                        Bottom = 360
                    }, DefPaint);
                    DefPaint.Color = DefPaint.Color.WithAlpha(255);
                }
            }
            DefPaint.ImageFilter = null;
            //canvas.Clear(SKColors.Transparent);
            //canvas.DrawColor(SKColors.Transparent);
            //DefPaint.Color = DefPaint.Color.WithAlpha(0);
            //DefPaint.Style = SKPaintStyle.Stroke;
            //canvas.DrawRect(info.Rect, DefPaint);
            //DefPaint.Color = DefPaint.Color.WithAlpha(240);
        }