Ejemplo n.º 1
0
        private static object CoerceValue(DependencyObject element, object value)
        {
            int             newValue = (int)value;
            UseLevelSpinner control  = (UseLevelSpinner)element;

            newValue = Math.Min(MaximumLevel, Math.Max(MinimumLevel, newValue));
            return(newValue);
        }
Ejemplo n.º 2
0
        private static void OnDecreaseCommand(object sender, ExecutedRoutedEventArgs e)
        {
            UseLevelSpinner control = sender as UseLevelSpinner;

            if (control != null)
            {
                control.OnDecrease();
            }
        }
Ejemplo n.º 3
0
        private static void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UseLevelSpinner control = (UseLevelSpinner)sender;

            // When someone click on a part in the NumericUpDown and it's not focusable
            // NumericUpDown needs to take the focus in order to process keyboard correctly
            if (!control.IsKeyboardFocusWithin)
            {
                e.Handled = control.Focus() || e.Handled;
            }
        }
Ejemplo n.º 4
0
        private static void OnIsReadOnlyChanged(DependencyObject element, DependencyPropertyChangedEventArgs args)
        {
            UseLevelSpinner control = element as UseLevelSpinner;

            bool readOnly = (bool)args.NewValue;

            if (readOnly != control._textBox.IsReadOnly)
            {
                control._textBox.IsReadOnly = readOnly;
            }
        }
Ejemplo n.º 5
0
        private static void OnLevelChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            UseLevelSpinner control = (UseLevelSpinner)obj;

            int oldValue = (int)args.OldValue;
            int newValue = (int)args.NewValue;

            RoutedPropertyChangedEventArgs <int> e = new RoutedPropertyChangedEventArgs <int>(
                oldValue, newValue, LevelChangedEvent);

            control.OnLevelChanged(e);
            control.UpdateText();
        }
Ejemplo n.º 6
0
        private static void OnKeepListStructureChanged(DependencyObject element, DependencyPropertyChangedEventArgs args)
        {
            UseLevelSpinner control = element as UseLevelSpinner;

            control.UpdateText();
        }