From 88656774bf31a20dd6439055517b783ec3930d79 Mon Sep 17 00:00:00 2001 From: heartacker Date: Wed, 20 Jul 2022 09:48:29 +0800 Subject: [PATCH] make it false by default --- .../Base/InputBaseUpDown.xaml.cs | 478 +++++++++--------- 1 file changed, 239 insertions(+), 239 deletions(-) diff --git a/source/NumericUpDownLib/Base/InputBaseUpDown.xaml.cs b/source/NumericUpDownLib/Base/InputBaseUpDown.xaml.cs index eb23bd4..da30b42 100644 --- a/source/NumericUpDownLib/Base/InputBaseUpDown.xaml.cs +++ b/source/NumericUpDownLib/Base/InputBaseUpDown.xaml.cs @@ -1,242 +1,242 @@ namespace NumericUpDownLib.Base { - using System.Globalization; - using System.Windows; - using System.Windows.Controls; - using System.Windows.Input; - - /// - /// This class serves as a target for styling the class - /// since styling directly on is not supported in XAML. - /// - public abstract class InputBaseUpDown : Control - { - #region fields - /// - /// Determines whether the textbox portion of the control is editable - /// (requires additional check of bounds) or not. - /// - public static readonly DependencyProperty IsReadOnlyProperty = - DependencyProperty.Register("IsReadOnly", - typeof(bool), typeof(InputBaseUpDown), new PropertyMetadata(true)); - - /// - /// Determines the allowed style of a number entered and displayed in the textbox. - /// - public static readonly DependencyProperty NumberStyleProperty = - DependencyProperty.Register("NumberStyle", typeof(NumberStyles), - typeof(InputBaseUpDown), new PropertyMetadata(NumberStyles.Any)); - - /// - /// Backing store of dependency property. - /// - public static readonly DependencyProperty IsEnableValidatingIndicatorProperty = - DependencyProperty.Register("IsEnableValidatingIndicator", typeof(bool), typeof(InputBaseUpDown), new PropertyMetadata(true)); - - /// - /// Backing store of dependency property. - /// - public static readonly DependencyProperty EditingVisibilityProperty = - DependencyProperty.Register("EditingVisibility", typeof(Visibility), typeof(InputBaseUpDown), new PropertyMetadata(Visibility.Hidden)); - - /// - /// Backing store of dependency property. - /// - public static readonly DependencyProperty EditingColorBrushProperty = - DependencyProperty.Register("EditingColorBrush", typeof(System.Windows.Media.SolidColorBrush), - typeof(InputBaseUpDown), new PropertyMetadata(new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green))); - - - /// - /// identify that the inputing data is valid or not., - /// - /// - protected System.Windows.Media.SolidColorBrush EditingColorBrush - { - get { return (System.Windows.Media.SolidColorBrush)GetValue(EditingColorBrushProperty); } - set { SetValue(EditingColorBrushProperty, value); } - } - - /// - /// identify that the editing Visibility - /// - /// - protected Visibility EditingVisibility - { - get { return (Visibility)GetValue(EditingVisibilityProperty); } - set { SetValue(EditingVisibilityProperty, value); } - } - - /// - /// identify that the is enable the red/green tip while editing - /// - /// - public bool IsEnableValidatingIndicator - { - get { return (bool)GetValue(IsEnableValidatingIndicatorProperty); } - set { SetValue(IsEnableValidatingIndicatorProperty, value); } - } - - private static RoutedCommand _IncreaseCommand; - private static RoutedCommand _DecreaseCommand; - #endregion fields - - /// - /// Class constructor - /// - public InputBaseUpDown() - { - InitializeCommands(); - } - - #region properties - /// - /// Expose the increase value command via property. - /// - public static RoutedCommand IncreaseCommand - { - get - { - return _IncreaseCommand; - } - } - - /// - /// Expose the decrease value command via property. - /// - public static RoutedCommand DecreaseCommand - { - get - { - return _DecreaseCommand; - } - } - - /// - /// Determines whether the textbox portion of the control is editable - /// (requires additional check of bounds) or not. - /// - public bool IsReadOnly - { - get { return (bool)GetValue(IsReadOnlyProperty); } - set { SetValue(IsReadOnlyProperty, value); } - } - - /// - /// Gets/sets the allowed style of a number entered and displayed in the textbox. - /// - public NumberStyles NumberStyle - { - get { return (NumberStyles)GetValue(NumberStyleProperty); } - set { SetValue(NumberStyleProperty, value); } - } - - #endregion properties - - #region methods - #region Commands - /// - /// Increase the displayed integer value - /// - protected abstract void OnIncrease(); - - /// - /// Determines whether the increase command is available or not. - /// - protected abstract bool CanIncreaseCommand(); - - /// - /// Decrease the displayed integer value - /// - protected abstract void OnDecrease(); - - /// - /// Determines whether the decrease command is available or not. - /// - protected abstract bool CanDecreaseCommand(); - - /// - /// Initialize up down/button commands and key gestures for up/down cursor keys - /// - private void InitializeCommands() - { - InputBaseUpDown._IncreaseCommand = new RoutedCommand("IncreaseCommand", typeof(InputBaseUpDown)); - CommandManager.RegisterClassCommandBinding(typeof(InputBaseUpDown), - new CommandBinding(_IncreaseCommand, OnIncreaseCommand, OnCanIncreaseCommand)); - - CommandManager.RegisterClassInputBinding(typeof(InputBaseUpDown), - new InputBinding(_IncreaseCommand, new KeyGesture(Key.Up))); - - InputBaseUpDown._DecreaseCommand = new RoutedCommand("DecreaseCommand", typeof(InputBaseUpDown)); - - CommandManager.RegisterClassCommandBinding(typeof(InputBaseUpDown), - new CommandBinding(_DecreaseCommand, OnDecreaseCommand, OnCanDecreaseCommand)); - } - - /// - /// Determine whether the IncreaseCommand can be executed or not and return the result - /// in the property of the given - /// . - /// - /// - /// - private static void OnCanIncreaseCommand(object sender, CanExecuteRoutedEventArgs e) - { - var control = sender as InputBaseUpDown; - if (control != null) - { - e.CanExecute = control.CanIncreaseCommand(); - e.Handled = true; - } - } - - /// - /// Execute the increase value command - /// - /// - /// - private static void OnIncreaseCommand(object sender, ExecutedRoutedEventArgs e) - { - var control = sender as InputBaseUpDown; - if (control != null) - { - control.OnIncrease(); - e.Handled = true; - } - } - - /// - /// Execute the decrease value command - /// - /// - /// - private static void OnDecreaseCommand(object sender, ExecutedRoutedEventArgs e) - { - var control = sender as InputBaseUpDown; - if (control != null) - { - control.OnDecrease(); - e.Handled = true; - } - } - - /// - /// Determine whether the DecreaseCommand can be executed or not and return the result - /// in the property of the given - /// . - /// - /// - /// - private static void OnCanDecreaseCommand(object sender, CanExecuteRoutedEventArgs e) - { - var control = sender as InputBaseUpDown; - if (control != null) - { - e.CanExecute = control.CanDecreaseCommand(); - e.Handled = true; - } - } - #endregion - #endregion methods - } + using System.Globalization; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Input; + + /// + /// This class serves as a target for styling the class + /// since styling directly on is not supported in XAML. + /// + public abstract class InputBaseUpDown : Control + { + #region fields + /// + /// Determines whether the textbox portion of the control is editable + /// (requires additional check of bounds) or not. + /// + public static readonly DependencyProperty IsReadOnlyProperty = + DependencyProperty.Register("IsReadOnly", + typeof(bool), typeof(InputBaseUpDown), new PropertyMetadata(true)); + + /// + /// Determines the allowed style of a number entered and displayed in the textbox. + /// + public static readonly DependencyProperty NumberStyleProperty = + DependencyProperty.Register("NumberStyle", typeof(NumberStyles), + typeof(InputBaseUpDown), new PropertyMetadata(NumberStyles.Any)); + + /// + /// Backing store of dependency property. + /// + public static readonly DependencyProperty IsEnableValidatingIndicatorProperty = + DependencyProperty.Register("IsEnableValidatingIndicator", typeof(bool), typeof(InputBaseUpDown), new PropertyMetadata(false)); + + /// + /// Backing store of dependency property. + /// + public static readonly DependencyProperty EditingVisibilityProperty = + DependencyProperty.Register("EditingVisibility", typeof(Visibility), typeof(InputBaseUpDown), new PropertyMetadata(Visibility.Hidden)); + + /// + /// Backing store of dependency property. + /// + public static readonly DependencyProperty EditingColorBrushProperty = + DependencyProperty.Register("EditingColorBrush", typeof(System.Windows.Media.SolidColorBrush), + typeof(InputBaseUpDown), new PropertyMetadata(new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green))); + + + /// + /// identify that the inputing data is valid or not., + /// + /// + protected System.Windows.Media.SolidColorBrush EditingColorBrush + { + get { return (System.Windows.Media.SolidColorBrush)GetValue(EditingColorBrushProperty); } + set { SetValue(EditingColorBrushProperty, value); } + } + + /// + /// identify that the editing Visibility + /// + /// + protected Visibility EditingVisibility + { + get { return (Visibility)GetValue(EditingVisibilityProperty); } + set { SetValue(EditingVisibilityProperty, value); } + } + + /// + /// identify that the is enable the red/green tip while editing + /// + /// + public bool IsEnableValidatingIndicator + { + get { return (bool)GetValue(IsEnableValidatingIndicatorProperty); } + set { SetValue(IsEnableValidatingIndicatorProperty, value); } + } + + private static RoutedCommand _IncreaseCommand; + private static RoutedCommand _DecreaseCommand; + #endregion fields + + /// + /// Class constructor + /// + public InputBaseUpDown() + { + InitializeCommands(); + } + + #region properties + /// + /// Expose the increase value command via property. + /// + public static RoutedCommand IncreaseCommand + { + get + { + return _IncreaseCommand; + } + } + + /// + /// Expose the decrease value command via property. + /// + public static RoutedCommand DecreaseCommand + { + get + { + return _DecreaseCommand; + } + } + + /// + /// Determines whether the textbox portion of the control is editable + /// (requires additional check of bounds) or not. + /// + public bool IsReadOnly + { + get { return (bool)GetValue(IsReadOnlyProperty); } + set { SetValue(IsReadOnlyProperty, value); } + } + + /// + /// Gets/sets the allowed style of a number entered and displayed in the textbox. + /// + public NumberStyles NumberStyle + { + get { return (NumberStyles)GetValue(NumberStyleProperty); } + set { SetValue(NumberStyleProperty, value); } + } + + #endregion properties + + #region methods + #region Commands + /// + /// Increase the displayed integer value + /// + protected abstract void OnIncrease(); + + /// + /// Determines whether the increase command is available or not. + /// + protected abstract bool CanIncreaseCommand(); + + /// + /// Decrease the displayed integer value + /// + protected abstract void OnDecrease(); + + /// + /// Determines whether the decrease command is available or not. + /// + protected abstract bool CanDecreaseCommand(); + + /// + /// Initialize up down/button commands and key gestures for up/down cursor keys + /// + private void InitializeCommands() + { + InputBaseUpDown._IncreaseCommand = new RoutedCommand("IncreaseCommand", typeof(InputBaseUpDown)); + CommandManager.RegisterClassCommandBinding(typeof(InputBaseUpDown), + new CommandBinding(_IncreaseCommand, OnIncreaseCommand, OnCanIncreaseCommand)); + + CommandManager.RegisterClassInputBinding(typeof(InputBaseUpDown), + new InputBinding(_IncreaseCommand, new KeyGesture(Key.Up))); + + InputBaseUpDown._DecreaseCommand = new RoutedCommand("DecreaseCommand", typeof(InputBaseUpDown)); + + CommandManager.RegisterClassCommandBinding(typeof(InputBaseUpDown), + new CommandBinding(_DecreaseCommand, OnDecreaseCommand, OnCanDecreaseCommand)); + } + + /// + /// Determine whether the IncreaseCommand can be executed or not and return the result + /// in the property of the given + /// . + /// + /// + /// + private static void OnCanIncreaseCommand(object sender, CanExecuteRoutedEventArgs e) + { + var control = sender as InputBaseUpDown; + if (control != null) + { + e.CanExecute = control.CanIncreaseCommand(); + e.Handled = true; + } + } + + /// + /// Execute the increase value command + /// + /// + /// + private static void OnIncreaseCommand(object sender, ExecutedRoutedEventArgs e) + { + var control = sender as InputBaseUpDown; + if (control != null) + { + control.OnIncrease(); + e.Handled = true; + } + } + + /// + /// Execute the decrease value command + /// + /// + /// + private static void OnDecreaseCommand(object sender, ExecutedRoutedEventArgs e) + { + var control = sender as InputBaseUpDown; + if (control != null) + { + control.OnDecrease(); + e.Handled = true; + } + } + + /// + /// Determine whether the DecreaseCommand can be executed or not and return the result + /// in the property of the given + /// . + /// + /// + /// + private static void OnCanDecreaseCommand(object sender, CanExecuteRoutedEventArgs e) + { + var control = sender as InputBaseUpDown; + if (control != null) + { + e.CanExecute = control.CanDecreaseCommand(); + e.Handled = true; + } + } + #endregion + #endregion methods + } }