protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing && !_disposed) { _drawable?.Dispose(); _disposed = true; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { var pancake = Element as CanvasView; Validate(pancake); base.OnElementPropertyChanged(sender, e); if (e.PropertyName == CanvasView.BorderColorProperty.PropertyName || e.PropertyName == CanvasView.BorderThicknessProperty.PropertyName || e.PropertyName == CanvasView.BorderIsDashedProperty.PropertyName || e.PropertyName == CanvasView.BorderDrawingStyleProperty.PropertyName || e.PropertyName == CanvasView.BorderGradientAngleProperty.PropertyName || e.PropertyName == CanvasView.BorderGradientEndColorProperty.PropertyName || e.PropertyName == CanvasView.BorderGradientStartColorProperty.PropertyName || e.PropertyName == CanvasView.BorderGradientStopsProperty.PropertyName) { Invalidate(); } else if (e.PropertyName == CanvasView.SidesProperty.PropertyName || e.PropertyName == CanvasView.OffsetAngleProperty.PropertyName || e.PropertyName == CanvasView.HasShadowProperty.PropertyName || e.PropertyName == CanvasView.ElevationProperty.PropertyName) { SetupShadow(pancake); } else if (e.PropertyName == CanvasView.CornerRadiusProperty.PropertyName) { Invalidate(); SetupShadow(pancake); } else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) { _drawable.Dispose(); this.SetBackground(_drawable = new CanvasDrawable(pancake, Context.ToPixels)); } }