Exemplo n.º 1
0
        private static void OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            if (rating.settingValuePropertySilently)
            {
                return;
            }

            if (!rating.IsTemplateApplied)
            {
                return;
            }

            double oldValue = (double)args.OldValue;
            double newValue = RadMath.CoerceValue((double)args.NewValue, 0, rating.itemsSource.Count);

            if (newValue != rating.Value)
            {
                rating.SetValuePropertySilently(ValueProperty, newValue);
            }

            if (newValue != oldValue)
            {
                rating.HandleValueChange(oldValue, newValue);
            }
        }
Exemplo n.º 2
0
        private static void OnRatingDisplayPrecisionChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            rating.UpdateDisplayValue();
            rating.UpdateFillRatio();
        }
Exemplo n.º 3
0
        private void Initialize()
        {
            if (this.Owner == null)
            {
                RadRating parent = ElementTreeHelper.FindVisualAncestor <RadRating>(this);
                if (parent == null)
                {
                    throw new InvalidOperationException(InvalidOwnerException);
                }

                this.Owner = parent;
            }
        }
Exemplo n.º 4
0
        private static void OnCommandChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            if (rating.canExecuteChangedHandler != null)
            {
                rating.canExecuteChangedHandler.Unsubscribe();
            }

            System.Windows.Input.ICommand command = args.NewValue as System.Windows.Input.ICommand;
            if (command != null)
            {
                rating.canExecuteChangedHandler = new WeakEventHandler <EventArgs>(command, rating, KnownEvents.CanExecuteChanged);
                rating.UpdateIsReadOnlyFromCommand();
            }
        }
Exemplo n.º 5
0
        private static void OnAutoGeneratedItemsCountChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            if (!rating.IsTemplateApplied)
            {
                return;
            }

            if ((int)args.OldValue == 0 && rating.itemsSource.Count != 0)
            {
                throw new InvalidOperationException(AutoGeneratedItemsCountExceptionMessage);
            }

            rating.isItemsSourceChangedSilently = true;
            rating.itemsSource.Clear();
            int newValue = (int)args.NewValue;

            if (newValue <= 0)
            {
                rating.AutoGeneratedItemsCount = 0;
            }
            else
            {
                rating.GenerateRatingItems();

                double coercedValue = RadMath.CoerceValue(rating.Value, 0, rating.itemsSource.Count);
                if (rating.Value != coercedValue)
                {
                    rating.SetValuePropertySilently(ValueProperty, coercedValue);
                    rating.UpdateDisplayValue();
                    rating.UpdateFillRatio();
                }
            }

            rating.isItemsSourceChangedSilently = false;
            rating.PopulateRatingPanel();
        }
Exemplo n.º 6
0
        private static void OnRatingSelectionModeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            rating.UpdateFillRatio();
        }
Exemplo n.º 7
0
        private static void OnCommandParameterChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            rating.UpdateIsReadOnlyFromCommand();
        }