예제 #1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing && !_disposed)
            {
                _drawable?.Dispose();
                _disposed = true;
            }
        }
예제 #2
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var pancake = Element as PancakeView;

            Validate(pancake);

            base.OnElementPropertyChanged(sender, e);
            if (e.PropertyName == PancakeView.BorderColorProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderThicknessProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderIsDashedProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderDrawingStyleProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderGradientAngleProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderGradientEndColorProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderGradientStartColorProperty.PropertyName ||
                e.PropertyName == PancakeView.BorderGradientStopsProperty.PropertyName)
            {
                Invalidate();
            }
            else if (e.PropertyName == PancakeView.SidesProperty.PropertyName ||
                     e.PropertyName == PancakeView.OffsetAngleProperty.PropertyName ||
                     e.PropertyName == PancakeView.HasShadowProperty.PropertyName ||
                     e.PropertyName == PancakeView.ElevationProperty.PropertyName)
            {
                SetupShadow(pancake);
            }
            else if (e.PropertyName == PancakeView.CornerRadiusProperty.PropertyName)
            {
                Invalidate();
                SetupShadow(pancake);
            }
            else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
            {
                _drawable.Dispose();
                this.SetBackground(_drawable = new PancakeDrawable(pancake, Context.ToPixels));
            }
        }