Update NumericUpDown.cs
This commit is contained in:
1 parent
efbe02c79f
commit
e109f73ac3
1 file changed
+12
-18
@@ -31,8 +31,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) =>
|
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) =>
|
||||||
{
|
{
|
||||||
if (IsReadOnly)
|
if (IsReadOnly) return;
|
||||||
return;
|
|
||||||
|
|
||||||
Value += Increment;
|
Value += Increment;
|
||||||
_textBox.Text = CurrentText;
|
_textBox.Text = CurrentText;
|
||||||
@@ -40,9 +39,7 @@ namespace HandyControl.Controls
|
|||||||
}));
|
}));
|
||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) =>
|
CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) =>
|
||||||
{
|
{
|
||||||
if (IsReadOnly)
|
if (IsReadOnly) return;
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
Value -= Increment;
|
Value -= Increment;
|
||||||
_textBox.Text = CurrentText;
|
_textBox.Text = CurrentText;
|
||||||
@@ -50,8 +47,7 @@ namespace HandyControl.Controls
|
|||||||
}));
|
}));
|
||||||
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
|
CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
|
||||||
{
|
{
|
||||||
if (IsReadOnly)
|
if (IsReadOnly) return;
|
||||||
return;
|
|
||||||
|
|
||||||
SetCurrentValue(ValueProperty, ValueBoxes.Double0Box);
|
SetCurrentValue(ValueProperty, ValueBoxes.Double0Box);
|
||||||
_textBox.Text = string.Empty;
|
_textBox.Text = string.Empty;
|
||||||
@@ -116,8 +112,7 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (IsReadOnly)
|
if (IsReadOnly) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (e.Key == Key.Up)
|
if (e.Key == Key.Up)
|
||||||
{
|
{
|
||||||
@@ -135,7 +130,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
base.OnMouseWheel(e);
|
base.OnMouseWheel(e);
|
||||||
|
|
||||||
if (_textBox.IsFocused&&IsReadOnly==false)
|
if (_textBox.IsFocused && !IsReadOnly)
|
||||||
{
|
{
|
||||||
Value += e.Delta > 0 ? Increment : -Increment;
|
Value += e.Delta > 0 ? Increment : -Increment;
|
||||||
_textBox.Text = CurrentText;
|
_textBox.Text = CurrentText;
|
||||||
@@ -375,22 +370,21 @@ namespace HandyControl.Controls
|
|||||||
set => SetValue(ShowClearButtonProperty, value);
|
set => SetValue(ShowClearButtonProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标识 IsReadOnly 依赖属性。
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register(
|
||||||
|
"IsReadOnly", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取或设置一个值,该值指示NumericUpDown是否只读。
|
/// 获取或设置一个值,该值指示NumericUpDown是否只读。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsReadOnly
|
public bool IsReadOnly
|
||||||
{
|
{
|
||||||
get => (bool)GetValue(IsReadOnlyProperty);
|
get => (bool) GetValue(IsReadOnlyProperty);
|
||||||
set => SetValue(IsReadOnlyProperty, value);
|
set => SetValue(IsReadOnlyProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 标识 IsReadOnly 依赖属性。
|
|
||||||
/// </summary>
|
|
||||||
public static readonly DependencyProperty IsReadOnlyProperty =
|
|
||||||
DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(NumericUpDown), new PropertyMetadata(default(bool)));
|
|
||||||
|
|
||||||
|
|
||||||
public Func<string, OperationResult<bool>> VerifyFunc { get; set; }
|
public Func<string, OperationResult<bool>> VerifyFunc { get; set; }
|
||||||
|
|
||||||
public virtual bool VerifyData()
|
public virtual bool VerifyData()
|
||||||
|
|||||||
Reference in new issue
Block a user