コード例 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <TFormsView> e)
        {
            if (e.OldElement != null)
            {
                var oldController = (ISKCanvasViewController)e.OldElement;

                // unsubscribe from events
                oldController.SurfaceInvalidated -= OnSurfaceInvalidated;
                oldController.GetCanvasSize      -= OnGetCanvasSize;
            }

            if (e.NewElement != null)
            {
                var newController = (ISKCanvasViewController)e.NewElement;

                // create the native view
                if (Control == null)
                {
                    var view = CreateNativeControl();
                    view.PaintSurface += OnPaintSurface;
                    SetNativeControl(view);
                }

                // set the initial values
                touchHandler.SetEnabled(Control, e.NewElement.EnableTouchEvents);
#if !__GTK__
                // TODO: implement this if it is actually supported
                Control.IgnorePixelScaling = e.NewElement.IgnorePixelScaling;
#endif

                // subscribe to events from the user
                newController.SurfaceInvalidated += OnSurfaceInvalidated;
                newController.GetCanvasSize      += OnGetCanvasSize;

                // paint for the first time
                OnSurfaceInvalidated(newController, EventArgs.Empty);
            }

            base.OnElementChanged(e);
        }
コード例 #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <TFormsView> e)
        {
            if (e.OldElement != null)
            {
                var oldController = (ISKGLViewController)e.OldElement;

                // unsubscribe from events
                oldController.SurfaceInvalidated -= OnSurfaceInvalidated;
                oldController.GetCanvasSize      -= OnGetCanvasSize;
                oldController.GetGRContext       -= OnGetGRContext;
            }

            if (e.NewElement != null)
            {
                var newController = (ISKGLViewController)e.NewElement;

                // create the native view
                if (Control == null)
                {
                    var view = CreateNativeControl();
                    view.PaintSurface += OnPaintSurface;
                    SetNativeControl(view);
                }

                touchHandler.SetEnabled(Control, e.NewElement.EnableTouchEvents);

                // subscribe to events from the user
                newController.SurfaceInvalidated += OnSurfaceInvalidated;
                newController.GetCanvasSize      += OnGetCanvasSize;
                newController.GetGRContext       += OnGetGRContext;

                // start the rendering
                SetupRenderLoop(false);
            }

            base.OnElementChanged(e);
        }