Exemple #1
0
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == IsPressedProperty && change.GetNewValue <bool>() == false)
            {
                StopTimer();
            }
        }
Exemple #2
0
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == PositionProperty)
            {
                UpdatePseudoClasses(change.GetNewValue <NotificationPosition>());
            }
        }
Exemple #3
0
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == WindowManagerAddShadowHintProperty && _popup != null)
            {
                _popup.WindowManagerAddShadowHint = change.GetNewValue <bool>();
            }
        }
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == ButtonSpinnerLocationProperty)
            {
                UpdatePseudoClasses(change.GetNewValue <Location>());
            }
        }
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == BoundsProperty)
            {
                var isMobile = change.GetNewValue <Rect>().Width < 1200;
                this.Find <DockPanel>("FirstPanel") !.Classes.Set("mobile", isMobile);
                this.Find <DockPanel>("SecondPanel") !.Classes.Set("mobile", isMobile);
            }
        }
        /// <inheritdoc/>
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            if (change.Property == HsvColorProperty)
            {
                OnColorChanged(new ColorChangedEventArgs(
                                   change.GetOldValue <HsvColor>().ToRgb(),
                                   change.GetNewValue <HsvColor>().ToRgb()));
            }

            base.OnPropertyChanged(change);
        }
Exemple #7
0
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == IsVisibleProperty)
            {
                DesiredSize = default;

                // All changes to visibility cause the parent element to be notified.
                this.GetVisualParent <ILayoutable>()?.ChildDesiredSizeChanged(this);

                // We only invalidate outselves when visibility is changed to true.
                if (change.GetNewValue <bool>())
                {
                    InvalidateMeasure();
                }
            }
        }
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            base.OnPropertyChanged(change);

            if (change.Property == AutoScrollToSelectedItemProperty)
            {
                AutoScrollToSelectedItemIfNecessary();
            }
            if (change.Property == ItemsProperty && _updateState is null && _selection is object)
            {
                var newValue = change.GetNewValue <IEnumerable>();
                _selection.Source = newValue;

                if (newValue is null)
                {
                    _selection.Clear();
                }
            }
Exemple #9
0
        /// <inheritdoc/>
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            if (ignorePropertyChanged)
            {
                base.OnPropertyChanged(change);
                return;
            }

            // Always keep the two color properties in sync
            if (change.Property == ColorProperty)
            {
                ignorePropertyChanged = true;

                HsvColor = Color.ToHsv();
                SetColorToHexTextBox();

                OnColorChanged(new ColorChangedEventArgs(
                                   change.GetOldValue <Color>(),
                                   change.GetNewValue <Color>()));

                ignorePropertyChanged = false;
            }
            else if (change.Property == HsvColorProperty)
            {
                ignorePropertyChanged = true;

                Color = HsvColor.ToRgb();
                SetColorToHexTextBox();

                OnColorChanged(new ColorChangedEventArgs(
                                   change.GetOldValue <HsvColor>().ToRgb(),
                                   change.GetNewValue <HsvColor>().ToRgb()));

                ignorePropertyChanged = false;
            }
            else if (change.Property == PaletteProperty)
            {
                IColorPalette?palette = Palette;

                // Any custom palette change must be automatically synced with the
                // bound properties controlling the palette grid
                if (palette != null)
                {
                    PaletteColumnCount = palette.ColorCount;

                    List <Color> newPaletteColors = new List <Color>();
                    for (int shadeIndex = 0; shadeIndex < palette.ShadeCount; shadeIndex++)
                    {
                        for (int colorIndex = 0; colorIndex < palette.ColorCount; colorIndex++)
                        {
                            newPaletteColors.Add(palette.GetColor(colorIndex, shadeIndex));
                        }
                    }

                    PaletteColors = newPaletteColors;
                }
            }
            else if (change.Property == IsAlphaEnabledProperty)
            {
                // Manually coerce the HsvColor value
                // (Color will be coerced automatically if HsvColor changes)
                HsvColor = OnCoerceHsvColor(HsvColor);
            }
            else if (change.Property == IsColorComponentsVisibleProperty ||
                     change.Property == IsColorPaletteVisibleProperty ||
                     change.Property == IsColorSpectrumVisibleProperty)
            {
                // When the property changed notification is received here the visibility
                // of individual tab items has not yet been updated through the bindings.
                // Therefore, the validation is delayed until after bindings update.
                Dispatcher.UIThread.Post(() =>
                {
                    ValidateSelection();
                }, DispatcherPriority.Background);
            }
            else if (change.Property == SelectedIndexProperty)
            {
                // Again, it is necessary to wait for the SelectedIndex value to
                // be applied to the TabControl through binding before validation occurs.
                Dispatcher.UIThread.Post(() =>
                {
                    ValidateSelection();
                }, DispatcherPriority.Background);
            }

            base.OnPropertyChanged(change);
        }
Exemple #10
0
        /// <inheritdoc/>
        protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
        {
            if (ignorePropertyChanged)
            {
                base.OnPropertyChanged(change);
                return;
            }

            // Always keep the two color properties in sync
            if (change.Property == ColorProperty)
            {
                ignorePropertyChanged = true;

                HsvColor = Color.ToHsv();

                SetColorToSliderValues();
                UpdateBackground();
                UpdatePseudoClasses();

                OnColorChanged(new ColorChangedEventArgs(
                                   change.GetOldValue <Color>(),
                                   change.GetNewValue <Color>()));

                ignorePropertyChanged = false;
            }
            else if (change.Property == ColorModelProperty)
            {
                ignorePropertyChanged = true;

                SetColorToSliderValues();
                UpdateBackground();
                UpdatePseudoClasses();

                ignorePropertyChanged = false;
            }
            else if (change.Property == HsvColorProperty)
            {
                ignorePropertyChanged = true;

                Color = HsvColor.ToRgb();

                SetColorToSliderValues();
                UpdateBackground();
                UpdatePseudoClasses();

                OnColorChanged(new ColorChangedEventArgs(
                                   change.GetOldValue <HsvColor>().ToRgb(),
                                   change.GetNewValue <HsvColor>().ToRgb()));

                ignorePropertyChanged = false;
            }
            else if (change.Property == IsRoundingEnabledProperty)
            {
                SetColorToSliderValues();
            }
            else if (change.Property == BoundsProperty)
            {
                UpdateBackground();
            }
            else if (change.Property == ValueProperty ||
                     change.Property == MinimumProperty ||
                     change.Property == MaximumProperty)
            {
                ignorePropertyChanged = true;

                Color oldColor = Color;
                (var color, var hsvColor) = GetColorFromSliderValues();

                if (ColorModel == ColorModel.Hsva)
                {
                    HsvColor = hsvColor;
                    Color    = hsvColor.ToRgb();
                }
                else
                {
                    Color    = color;
                    HsvColor = color.ToHsv();
                }

                UpdatePseudoClasses();
                OnColorChanged(new ColorChangedEventArgs(oldColor, Color));

                ignorePropertyChanged = false;
            }

            base.OnPropertyChanged(change);
        }