예제 #1
0
 private void RefreshGraphicsWithTryCatch()
 {
     try
     {
         // Bothe Invalidate and _canvas.Invalidate are necessary in different scenarios.
         Invalidate();
         _canvas?.Invalidate();
     }
     catch (ObjectDisposedException e)
     {
         // See issue: https://github.com/Mapsui/Mapsui/issues/433
         // What seems to be happening. The Activity is Disposed. Appently it's children get Disposed
         // explicitly by something in Xamarin. During this Dispose the MessageCenter, which is itself
         // not disposed gets another notification to call RefreshGraphics.
         Logger.Log(LogLevel.Warning, "This can happen when the parent Activity is disposing.", e);
     }
 }
예제 #2
0
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };

            view.UpdateBackgroundColor(Color.FromHex("#618833"));

            var canvas = new SKCanvasView()
            {
                SizeWidth  = 300,
                SizeHeight = 300,
            };

            view.Add(new Label
            {
                Text = "ImageView"
            });
            view.Add(canvas);

            var glSurface = new SKGLSurfaceView()
            {
                SizeWidth  = 300,
                SizeHeight = 300,
            };

            view.Add(new Label
            {
                Text = "GL Surface View"
            });
            view.Add(glSurface);

            canvas.PaintSurface    += OnPaintSurface;
            glSurface.PaintSurface += OnPaintSurface;


            var left = new Button
            {
                Text = "<-"
            };

            view.Add(left);
            left.Clicked += (s, e) =>
            {
                startX -= 10;
                canvas.Invalidate();
                glSurface.Invalidate();
            };

            var right = new Button
            {
                Text = "->"
            };

            view.Add(right);
            right.Clicked += (s, e) =>
            {
                startX += 10;
                canvas.Invalidate();
                glSurface.Invalidate();
            };

            var add = new Button
            {
                Text = "+"
            };

            view.Add(add);
            add.Clicked += (s, e) =>
            {
                canvas.SizeWidth    += 30;
                glSurface.SizeWidth += 30;
            };

            return(view);
        }