Ejemplo 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);
 }
Ejemplo n.º 2
0
        protected static void OnDecreaseCommand(Object sender, ExecutedRoutedEventArgs e)
        {
            SpinnerControl control = sender as SpinnerControl;

            if (control != null)
            {
                control.OnDecrease();
            }
        }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }