コード例 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <DrawingView> e)
        {
            base.OnElementChanged(e);
            if (Control == null && Element != null)
            {
                canvasView = new SKCanvasView(Forms.Forms.NativeParent)
                {
                    BackgroundColor = Element.BackgroundColor.ToNative()
                };
                canvasView.Show();
                Element.Points.CollectionChanged += OnPointsCollectionChanged;
                SetNativeControl(canvasView);
            }

            if (e.OldElement != null)
            {
                canvasView !.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseDown, MouseDown);
                canvasView.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseUp, MouseUp);
                canvasView.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseMove, MouseMove);
                canvasView.PaintSurface -= OnPaintSurface;
            }

            if (e.NewElement != null)
            {
                canvasView !.PaintSurface += OnPaintSurface;
                canvasView.EvasCanvas.AddEventAction(EvasObjectCallbackType.MouseDown, MouseDown);
                canvasView.EvasCanvas.AddEventAction(EvasObjectCallbackType.MouseUp, MouseUp);
                canvasView.EvasCanvas.AddEventAction(EvasObjectCallbackType.MouseMove, MouseMove);
            }
        }
コード例 #2
0
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == DrawingView.PointsProperty.PropertyName)
     {
         canvasView !.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseUp, MouseUp);
         LoadPoints();
         canvasView.EvasCanvas.AddEventAction(EvasObjectCallbackType.MouseUp, MouseUp);
     }
 }
コード例 #3
0
        protected override void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (Element != null)
            {
                Element.Points.CollectionChanged -= OnPointsCollectionChanged;
                canvasView !.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseDown, MouseDown);
                canvasView.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseUp, MouseUp);
                canvasView.EvasCanvas.DeleteEventAction(EvasObjectCallbackType.MouseMove, MouseMove);
                canvasView.PaintSurface -= OnPaintSurface;
            }

            base.Dispose(disposing);
        }