Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing && !_disposed)
            {
                _drawable?.Dispose();
                _disposed = true;
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _drawable?.Dispose();
                    _drawable = null;

                    _defaultDrawable?.Dispose();
                    _defaultDrawable = null;
                }

                _disposed = true;
            }
        }
        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.BorderDashPatternProperty.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.ShadowProperty.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));
            }
        }