Interaction logic for SpinnerControl.xaml
Inheritance: System.Windows.Controls.UserControl
Esempio n. 1
0
 private static decimal LimitValueByBounds(decimal newValue, SpinnerControl control)
 {
     newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue));
     //  then ensure the number of decimal places is correct.
     newValue = Decimal.Round(newValue, control.DecimalPlaces);
     return(newValue);
 }
Esempio n. 2
0
        protected static void OnDecreaseCommand(Object sender, ExecutedRoutedEventArgs e)
        {
            SpinnerControl control = sender as SpinnerControl;

            if (control != null)
            {
                control.OnDecrease();
            }
        }
Esempio n. 3
0
        private static object CoerceValue(DependencyObject obj, object value)
        {
            decimal        newValue = (decimal)value;
            SpinnerControl control  = obj as SpinnerControl;

            if (control != null)
            {
                //  ensure that the value stays within the bounds of the minimum and
                //  maximum values that we define.
                newValue = LimitValueByBounds(newValue, control);
            }

            return(newValue);
        }
Esempio n. 4
0
        /// <summary>
        /// If the value changes, update the text box that displays the Value
        /// property to the consumer.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="args"></param>
        private static void OnValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SpinnerControl control = obj as SpinnerControl;

            if (control != null)
            {
                var newValue = (decimal)args.NewValue;
                var oldValue = (decimal)args.OldValue;

                control.UpdateFormattedValue(newValue);

                RoutedPropertyChangedEventArgs <decimal> e =
                    new RoutedPropertyChangedEventArgs <decimal>(oldValue, newValue, ValueChangedEvent);

                control.OnValueChanged(e);
            }
        }
 private static decimal LimitValueByBounds(decimal newValue, SpinnerControl control)
 {
     newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue));
     //  then ensure the number of decimal places is correct.
     newValue = Decimal.Round(newValue, control.DecimalPlaces);
     return newValue;
 }