diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs index 0b813db4..eeb2c0a0 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Controls; using System.Windows; +using System.Globalization; namespace Microsoft.Windows.Controls.Primitives { @@ -8,6 +9,17 @@ namespace Microsoft.Windows.Controls.Primitives { #region Properties + #region CultureInfo + + public static readonly DependencyProperty CultureInfoProperty = DependencyProperty.Register("CultureInfo", typeof(CultureInfo), typeof(InputBase), new UIPropertyMetadata(CultureInfo.CurrentCulture)); + public CultureInfo CultureInfo + { + get { return (CultureInfo)GetValue(CultureInfoProperty); } + set { SetValue(CultureInfoProperty, value); } + } + + #endregion //CultureInfo + #region IsEditable public static readonly DependencyProperty IsEditableProperty = DependencyProperty.Register("IsEditable", typeof(bool), typeof(InputBase), new PropertyMetadata(true)); diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs index c1bfc015..30f86d0b 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs @@ -3,6 +3,7 @@ using System.Windows.Controls; using Microsoft.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows; +using System.Windows.Data; namespace Microsoft.Windows.Controls.Primitives { @@ -187,6 +188,13 @@ namespace Microsoft.Windows.Controls.Primitives #endregion //Methods } + + + + + + + /// /// This is going to be the new UpDownBase class. In order to reliably support the different numeric data types, I need to create a specific control for each data type. /// So instead of copying and pasting I am going to try to create a generic base class that has most of the logic in it. This will make the NumericUpDown control obsolete @@ -216,8 +224,8 @@ namespace Microsoft.Windows.Controls.Primitives #region Properties + protected Spinner Spinner { get; private set; } protected TextBox TextBox { get; private set; } - internal Spinner Spinner { get; private set; } #region AllowSpin @@ -260,7 +268,7 @@ namespace Microsoft.Windows.Controls.Primitives } protected virtual T OnCoerceValue(T value) - { + { return value; } @@ -273,7 +281,7 @@ namespace Microsoft.Windows.Controls.Primitives protected virtual void OnValueChanged(T oldValue, T newValue) { - SyncTextAndValueProperties(NumericUpDown.ValueProperty, newValue); + SyncTextAndValueProperties(NumericUpDown.ValueProperty, string.Empty); RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue); args.RoutedEvent = NumericUpDown.ValueChangedEvent; @@ -292,6 +300,14 @@ namespace Microsoft.Windows.Controls.Primitives #region Base Class Overrides + protected override void OnAccessKey(AccessKeyEventArgs e) + { + if (TextBox != null) + TextBox.Focus(); + + base.OnAccessKey(e); + } + public override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -313,14 +329,14 @@ namespace Microsoft.Windows.Controls.Primitives { case Key.Up: { - if (AllowSpin) + if (AllowSpin && IsEditable) DoIncrement(); e.Handled = true; break; } case Key.Down: { - if (AllowSpin) + if (AllowSpin && IsEditable) DoDecrement(); e.Handled = true; break; @@ -328,7 +344,10 @@ namespace Microsoft.Windows.Controls.Primitives case Key.Enter: { if (IsEditable) - SyncTextAndValueProperties(UpDownBase.TextProperty, TextBox.Text); + { + var binding = BindingOperations.GetBindingExpression(TextBox, System.Windows.Controls.TextBox.TextProperty); + binding.UpdateSource(); + } break; } } @@ -338,7 +357,7 @@ namespace Microsoft.Windows.Controls.Primitives { base.OnMouseWheel(e); - if (!e.Handled && AllowSpin) + if (!e.Handled && AllowSpin && IsEditable) { if (e.Delta < 0) { @@ -416,7 +435,7 @@ namespace Microsoft.Windows.Controls.Primitives } } - private void SyncTextAndValueProperties(DependencyProperty p, object newValue) + private void SyncTextAndValueProperties(DependencyProperty p, string text) { //prevents recursive syncing properties if (_isSyncingTextAndValueProperties) @@ -427,11 +446,10 @@ namespace Microsoft.Windows.Controls.Primitives //this only occures when the user typed in the value if (InputBase.TextProperty == p) { - string text = newValue == null ? String.Empty : newValue.ToString(); - SetValue(UpDownBase.ValueProperty, ConvertTextToValue(text)); + Value = ConvertTextToValue(text); } - SetValue(InputBase.TextProperty, ConvertValueToText(newValue)); + Text = ConvertValueToText(); _isSyncingTextAndValueProperties = false; } @@ -450,7 +468,7 @@ namespace Microsoft.Windows.Controls.Primitives protected abstract T ConvertTextToValue(string text); - protected abstract string ConvertValueToText(object value); + protected abstract string ConvertValueToText(); #endregion //Abstract diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs new file mode 100644 index 00000000..0ccd7854 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs @@ -0,0 +1,235 @@ +using System; +using Microsoft.Windows.Controls.Primitives; +using System.Windows; +using System.Windows.Input; + +namespace Microsoft.Windows.Controls +{ + public class DecimalUpDown : UpDownBase + { + #region Properties + + #region DefaultValue + + //can possibly be in base class + public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("DefaultValue", typeof(decimal), typeof(DecimalUpDown), new UIPropertyMetadata(default(decimal))); + public decimal DefaultValue + { + get { return (decimal)GetValue(DefaultValueProperty); } + set { SetValue(DefaultValueProperty, value); } + } + + #endregion //DefaultValue + + #region FormatString + + public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(DecimalUpDown), new UIPropertyMetadata(String.Empty)); + public string FormatString + { + get { return (string)GetValue(FormatStringProperty); } + set { SetValue(FormatStringProperty, value); } + } + + #endregion //FormatString + + #region Increment + + public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(decimal), typeof(DecimalUpDown), new PropertyMetadata(1m)); + public decimal Increment + { + get { return (decimal)GetValue(IncrementProperty); } + set { SetValue(IncrementProperty, value); } + } + + #endregion + + #region Maximum + + public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(decimal), typeof(DecimalUpDown), new UIPropertyMetadata(decimal.MaxValue, OnMaximumChanged)); + public decimal Maximum + { + get { return (decimal)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + + private static void OnMaximumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + DecimalUpDown decimalUpDown = o as DecimalUpDown; + if (decimalUpDown != null) + decimalUpDown.OnMaximumChanged((decimal)e.OldValue, (decimal)e.NewValue); + } + + protected virtual void OnMaximumChanged(decimal oldValue, decimal newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Maximum + + #region Minimum + + public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(decimal), typeof(DecimalUpDown), new UIPropertyMetadata(decimal.MinValue, OnMinimumChanged)); + public decimal Minimum + { + get { return (decimal)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + + private static void OnMinimumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + DecimalUpDown decimalUpDown = o as DecimalUpDown; + if (decimalUpDown != null) + decimalUpDown.OnMinimumChanged((decimal)e.OldValue, (decimal)e.NewValue); + } + + protected virtual void OnMinimumChanged(decimal oldValue, decimal newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Minimum + + #region SelectAllOnGotFocus + + public static readonly DependencyProperty SelectAllOnGotFocusProperty = DependencyProperty.Register("SelectAllOnGotFocus", typeof(bool), typeof(DecimalUpDown), new PropertyMetadata(false)); + public bool SelectAllOnGotFocus + { + get { return (bool)GetValue(SelectAllOnGotFocusProperty); } + set { SetValue(SelectAllOnGotFocusProperty, value); } + } + + #endregion //SelectAllOnGotFocus + + #endregion //Properties + + #region Constructors + + static DecimalUpDown() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(typeof(DecimalUpDown))); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (SelectAllOnGotFocus) + { + //in order to select all the text we must handle both the keybord (tabbing) and mouse (clicking) events + TextBox.GotKeyboardFocus += OnTextBoxGotKeyBoardFocus; + TextBox.PreviewMouseLeftButtonDown += OnTextBoxPreviewMouseLeftButtonDown; + } + + //SetValidSpinDirection(); + } + + protected override decimal? OnCoerceValue(decimal? value) + { + if (value == null) return value; + + decimal val = value.Value; + + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + + protected override void OnIncrement() + { + if (Value.HasValue) + Value += Increment; + else + Value = DefaultValue; + } + + protected override void OnDecrement() + { + if (Value.HasValue) + Value -= Increment; + else + Value = DefaultValue; + } + + protected override decimal? ConvertTextToValue(string text) + { + decimal? result = null; + + if (String.IsNullOrEmpty(text)) + return result; + + try + { + result = Decimal.Parse(text, System.Globalization.NumberStyles.Any, CultureInfo); + } + catch + { + Text = ConvertValueToText(); + return Value; + } + + return result; + } + + protected override string ConvertValueToText() + { + if (Value == null) + return string.Empty; + + return Value.Value.ToString(FormatString, CultureInfo); + } + + protected override void OnValueChanged(decimal? oldValue, decimal? newValue) + { + //SetValidSpinDirection(); + base.OnValueChanged(oldValue, newValue); + } + + #endregion //Base Class Overrides + + #region Event Handlers + + private void OnTextBoxGotKeyBoardFocus(object sender, RoutedEventArgs e) + { + TextBox.SelectAll(); + } + + void OnTextBoxPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!TextBox.IsKeyboardFocused) + { + e.Handled = true; + TextBox.Focus(); + } + } + + #endregion //Event Handlers + + #region Methods + + /// + /// Sets the valid spin direction based on current value, minimum and maximum. + /// + //private void SetValidSpinDirection() + //{ + // ValidSpinDirections validDirections = ValidSpinDirections.None; + + // if (Value < Maximum) + // validDirections = validDirections | ValidSpinDirections.Increase; + + // if (Value > Minimum) + // validDirections = validDirections | ValidSpinDirections.Decrease; + + // if (Spinner != null) + // Spinner.ValidSpinDirection = validDirections; + //} + + #endregion //Methods + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs new file mode 100644 index 00000000..8248de80 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs @@ -0,0 +1,235 @@ +using System; +using Microsoft.Windows.Controls.Primitives; +using System.Windows; +using System.Windows.Input; + +namespace Microsoft.Windows.Controls +{ + public class DoubleUpDown : UpDownBase + { + #region Properties + + #region DefaultValue + + //can possibly be in base class + public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("DefaultValue", typeof(double), typeof(DoubleUpDown), new UIPropertyMetadata(default(double))); + public double DefaultValue + { + get { return (double)GetValue(DefaultValueProperty); } + set { SetValue(DefaultValueProperty, value); } + } + + #endregion //DefaultValue + + #region FormatString + + public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(DoubleUpDown), new UIPropertyMetadata(String.Empty)); + public string FormatString + { + get { return (string)GetValue(FormatStringProperty); } + set { SetValue(FormatStringProperty, value); } + } + + #endregion //FormatString + + #region Increment + + public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(double), typeof(DoubleUpDown), new PropertyMetadata(1d)); + public double Increment + { + get { return (double)GetValue(IncrementProperty); } + set { SetValue(IncrementProperty, value); } + } + + #endregion + + #region Maximum + + public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(DoubleUpDown), new UIPropertyMetadata(double.MaxValue, OnMaximumChanged)); + public double Maximum + { + get { return (double)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + + private static void OnMaximumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + DoubleUpDown doubleUpDown = o as DoubleUpDown; + if (doubleUpDown != null) + doubleUpDown.OnMaximumChanged((double)e.OldValue, (double)e.NewValue); + } + + protected virtual void OnMaximumChanged(double oldValue, double newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Maximum + + #region Minimum + + public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(DoubleUpDown), new UIPropertyMetadata(double.MinValue, OnMinimumChanged)); + public double Minimum + { + get { return (double)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + + private static void OnMinimumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + DoubleUpDown doubleUpDown = o as DoubleUpDown; + if (doubleUpDown != null) + doubleUpDown.OnMinimumChanged((double)e.OldValue, (double)e.NewValue); + } + + protected virtual void OnMinimumChanged(double oldValue, double newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Minimum + + #region SelectAllOnGotFocus + + public static readonly DependencyProperty SelectAllOnGotFocusProperty = DependencyProperty.Register("SelectAllOnGotFocus", typeof(bool), typeof(DoubleUpDown), new PropertyMetadata(false)); + public bool SelectAllOnGotFocus + { + get { return (bool)GetValue(SelectAllOnGotFocusProperty); } + set { SetValue(SelectAllOnGotFocusProperty, value); } + } + + #endregion //SelectAllOnGotFocus + + #endregion //Properties + + #region Constructors + + static DoubleUpDown() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(typeof(DoubleUpDown))); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (SelectAllOnGotFocus) + { + //in order to select all the text we must handle both the keybord (tabbing) and mouse (clicking) events + TextBox.GotKeyboardFocus += OnTextBoxGotKeyBoardFocus; + TextBox.PreviewMouseLeftButtonDown += OnTextBoxPreviewMouseLeftButtonDown; + } + + //SetValidSpinDirection(); + } + + protected override double? OnCoerceValue(double? value) + { + if (value == null) return value; + + double val = value.Value; + + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + + protected override void OnIncrement() + { + if (Value.HasValue) + Value += Increment; + else + Value = DefaultValue; + } + + protected override void OnDecrement() + { + if (Value.HasValue) + Value -= Increment; + else + Value = DefaultValue; + } + + protected override double? ConvertTextToValue(string text) + { + double? result = null; + + if (String.IsNullOrEmpty(text)) + return result; + + try + { + result = Double.Parse(text, System.Globalization.NumberStyles.Any, CultureInfo); + } + catch + { + Text = ConvertValueToText(); + return Value; + } + + return result; + } + + protected override string ConvertValueToText() + { + if (Value == null) + return string.Empty; + + return Value.Value.ToString(FormatString, CultureInfo); + } + + protected override void OnValueChanged(double? oldValue, double? newValue) + { + //SetValidSpinDirection(); + base.OnValueChanged(oldValue, newValue); + } + + #endregion //Base Class Overrides + + #region Event Handlers + + private void OnTextBoxGotKeyBoardFocus(object sender, RoutedEventArgs e) + { + TextBox.SelectAll(); + } + + void OnTextBoxPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!TextBox.IsKeyboardFocused) + { + e.Handled = true; + TextBox.Focus(); + } + } + + #endregion //Event Handlers + + #region Methods + + /// + /// Sets the valid spin direction based on current value, minimum and maximum. + /// + //private void SetValidSpinDirection() + //{ + // ValidSpinDirections validDirections = ValidSpinDirections.None; + + // if (Value < Maximum) + // validDirections = validDirections | ValidSpinDirections.Increase; + + // if (Value > Minimum) + // validDirections = validDirections | ValidSpinDirections.Decrease; + + // if (Spinner != null) + // Spinner.ValidSpinDirection = validDirections; + //} + + #endregion //Methods + } +} diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs index fb128094..00af6d7f 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs @@ -1,16 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Microsoft.Windows.Controls.Primitives; namespace Microsoft.Windows.Controls @@ -31,6 +21,17 @@ namespace Microsoft.Windows.Controls #endregion //DefaultValue + #region FormatString + + public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(IntegerUpDown), new UIPropertyMetadata(String.Empty)); + public string FormatString + { + get { return (string)GetValue(FormatStringProperty); } + set { SetValue(FormatStringProperty, value); } + } + + #endregion //FormatString + #region Increment public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(int), typeof(IntegerUpDown), new PropertyMetadata(1)); @@ -42,6 +43,63 @@ namespace Microsoft.Windows.Controls #endregion + #region Maximum + + public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(int), typeof(IntegerUpDown), new UIPropertyMetadata(int.MaxValue, OnMaximumChanged)); + public int Maximum + { + get { return (int)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + + private static void OnMaximumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + IntegerUpDown integerUpDown = o as IntegerUpDown; + if (integerUpDown != null) + integerUpDown.OnMaximumChanged((int)e.OldValue, (int)e.NewValue); + } + + protected virtual void OnMaximumChanged(int oldValue, int newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Maximum + + #region Minimum + + public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(int), typeof(IntegerUpDown), new UIPropertyMetadata(int.MinValue, OnMinimumChanged)); + public int Minimum + { + get { return (int)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + + private static void OnMinimumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + IntegerUpDown integerUpDown = o as IntegerUpDown; + if (integerUpDown != null) + integerUpDown.OnMinimumChanged((int)e.OldValue, (int)e.NewValue); + } + + protected virtual void OnMinimumChanged(int oldValue, int newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Minimum + + #region SelectAllOnGotFocus + + public static readonly DependencyProperty SelectAllOnGotFocusProperty = DependencyProperty.Register("SelectAllOnGotFocus", typeof(bool), typeof(IntegerUpDown), new PropertyMetadata(false)); + public bool SelectAllOnGotFocus + { + get { return (bool)GetValue(SelectAllOnGotFocusProperty); } + set { SetValue(SelectAllOnGotFocusProperty, value); } + } + + #endregion //SelectAllOnGotFocus + #endregion //Properties #region Constructors @@ -55,6 +113,34 @@ namespace Microsoft.Windows.Controls #region Base Class Overrides + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (SelectAllOnGotFocus) + { + //in order to select all the text we must handle both the keybord (tabbing) and mouse (clicking) events + TextBox.GotKeyboardFocus += OnTextBoxGotKeyBoardFocus; + TextBox.PreviewMouseLeftButtonDown += OnTextBoxPreviewMouseLeftButtonDown; + } + + //SetValidSpinDirection(); + } + + protected override int? OnCoerceValue(int? value) + { + if (value == null) return value; + + int val = value.Value; + + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + protected override void OnIncrement() { if (Value.HasValue) @@ -80,25 +166,70 @@ namespace Microsoft.Windows.Controls try { - result = Int16.Parse(text, System.Globalization.NumberStyles.Any); + result = Int32.Parse(text, System.Globalization.NumberStyles.Any, CultureInfo); } catch { - Text = ConvertValueToText(Value); + Text = ConvertValueToText(); return Value; } return result; } - protected override string ConvertValueToText(object value) + protected override string ConvertValueToText() { - if (value == null) + if (Value == null) return string.Empty; - return value.ToString(); + return Value.Value.ToString(FormatString, CultureInfo); + } + + protected override void OnValueChanged(int? oldValue, int? newValue) + { + //SetValidSpinDirection(); + base.OnValueChanged(oldValue, newValue); } #endregion //Base Class Overrides + + #region Event Handlers + + private void OnTextBoxGotKeyBoardFocus(object sender, RoutedEventArgs e) + { + TextBox.SelectAll(); + } + + void OnTextBoxPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!TextBox.IsKeyboardFocused) + { + e.Handled = true; + TextBox.Focus(); + } + } + + #endregion //Event Handlers + + #region Methods + + /// + /// Sets the valid spin direction based on current value, minimum and maximum. + /// + //private void SetValidSpinDirection() + //{ + // ValidSpinDirections validDirections = ValidSpinDirections.None; + + // if (Value < Maximum) + // validDirections = validDirections | ValidSpinDirections.Increase; + + // if (Value > Minimum) + // validDirections = validDirections | ValidSpinDirections.Decrease; + + // if (Spinner != null) + // Spinner.ValidSpinDirection = validDirections; + //} + + #endregion //Methods } } diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs index aaa90eb4..764278d3 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs @@ -6,6 +6,7 @@ using Microsoft.Windows.Controls.Primitives; namespace Microsoft.Windows.Controls { + [Obsolete("This control has been replaced with numeric data type specific controls; DecimalUpDown, DoubleUpDown, IntegerUpDown")] public class NumericUpDown : UpDownBase { #region Members diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml index 5c8ef8ef..df83f938 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml @@ -10,6 +10,82 @@ + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj index d4dc7703..f23c01aa 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -177,6 +177,8 @@ + +