diff --git a/HandyControl/Controls/Attach/InfoElement.cs b/HandyControl/Controls/Attach/InfoElement.cs
index 6a4cf320..f256fe2e 100644
--- a/HandyControl/Controls/Attach/InfoElement.cs
+++ b/HandyControl/Controls/Attach/InfoElement.cs
@@ -1,5 +1,5 @@
using System.Windows;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
diff --git a/HandyControl/Controls/Attach/TipElement.cs b/HandyControl/Controls/Attach/TipElement.cs
index 7da236d6..ca3f9caa 100644
--- a/HandyControl/Controls/Attach/TipElement.cs
+++ b/HandyControl/Controls/Attach/TipElement.cs
@@ -1,5 +1,5 @@
using System.Windows;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
diff --git a/HandyControl/Controls/Growl.cs b/HandyControl/Controls/Growl.cs
index a9e911e1..3f1a5cc6 100644
--- a/HandyControl/Controls/Growl.cs
+++ b/HandyControl/Controls/Growl.cs
@@ -7,7 +7,6 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using HandyControl.Data;
-using HandyControl.Data.Enum;
using HandyControl.Interactivity;
using HandyControl.Tools;
using HandyControl.Tools.Extension;
diff --git a/HandyControl/Controls/IDataInput.cs b/HandyControl/Controls/IDataInput.cs
new file mode 100644
index 00000000..66f39b04
--- /dev/null
+++ b/HandyControl/Controls/IDataInput.cs
@@ -0,0 +1,23 @@
+using System;
+using HandyControl.Data;
+
+namespace HandyControl.Controls
+{
+ ///
+ /// 表示可以成为一个数据输入控件
+ ///
+ public interface IDataInput
+ {
+ bool VerifyData();
+
+ Func> VerifyFunc { get; set; }
+
+ bool IsError { get; set; }
+
+ string ErrorStr { get; set; }
+
+ TextType TextType { get; set; }
+
+ bool ShowClearButton { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Controls/Input/TextBox.cs b/HandyControl/Controls/Input/TextBox.cs
new file mode 100644
index 00000000..96fd0046
--- /dev/null
+++ b/HandyControl/Controls/Input/TextBox.cs
@@ -0,0 +1,8 @@
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Controls
+{
+ public class TextBox : System.Windows.Controls.TextBox
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Controls/NumericUpDown.cs b/HandyControl/Controls/NumericUpDown.cs
index 03b0d475..6fe737a1 100644
--- a/HandyControl/Controls/NumericUpDown.cs
+++ b/HandyControl/Controls/NumericUpDown.cs
@@ -11,7 +11,7 @@ namespace HandyControl.Controls
/// 数值选择控件
///
[TemplatePart(Name = ElementTextBox, Type = typeof(TextBox))]
- public class NumericUpDown : Control
+ public class NumericUpDown : Control, IDataInput
{
#region Constants
@@ -27,8 +27,23 @@ namespace HandyControl.Controls
public NumericUpDown()
{
- CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Value += Increment));
- CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Value -= Increment));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) =>
+ {
+ Value += Increment;
+ _textBox.Text = CurrentText;
+ _textBox.Select(_textBox.Text.Length, 0);
+ }));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) =>
+ {
+ Value -= Increment;
+ _textBox.Text = CurrentText;
+ _textBox.Select(_textBox.Text.Length, 0);
+ }));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
+ {
+ ClearValue(ValueProperty);
+ _textBox.Text = string.Empty;
+ }));
}
protected override void OnGotFocus(RoutedEventArgs e)
@@ -48,6 +63,7 @@ namespace HandyControl.Controls
{
_textBox.TextChanged -= TextBox_TextChanged;
_textBox.PreviewKeyDown -= TextBox_PreviewKeyDown;
+ _textBox.LostFocus -= TextBox_LostFocus;
}
base.OnApplyTemplate();
@@ -58,34 +74,38 @@ namespace HandyControl.Controls
{
_textBox.TextChanged += TextBox_TextChanged;
_textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
+ _textBox.LostFocus += TextBox_LostFocus;
_textBox.Text = CurrentText;
}
}
+ private void TextBox_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (IsError) return;
+ _textBox.Text = CurrentText;
+ }
+
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Up)
{
Value += Increment;
+ _textBox.Text = CurrentText;
}
else if (e.Key == Key.Down)
{
Value -= Increment;
+ _textBox.Text = CurrentText;
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
- if (string.IsNullOrEmpty(_textBox.Text)) return;
+ if (!VerifyData()) return;
if (double.TryParse(_textBox.Text, out var value))
{
Value = value;
}
-
- if (_textBox != null)
- {
- _textBox.Text = CurrentText;
- }
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
@@ -95,6 +115,8 @@ namespace HandyControl.Controls
if (_textBox.IsFocused)
{
Value += e.Delta > 0 ? Increment : -Increment;
+ _textBox.Text = CurrentText;
+ _textBox.Select(_textBox.Text.Length, 0);
e.Handled = true;
}
}
@@ -132,13 +154,6 @@ namespace HandyControl.Controls
var ctl = (NumericUpDown) d;
var v = (double) e.NewValue;
- if (ctl._textBox != null)
- {
- ctl._textBox.Text = ctl.DecimalPlaces.HasValue
- ? v.ToString($"#0.{new string('0', ctl.DecimalPlaces.Value)}")
- : v.ToString("#0");
- }
-
ctl.OnValueChanged(new FunctionEventArgs(ValueChangedEvent, ctl)
{
Info = v
@@ -273,13 +288,131 @@ namespace HandyControl.Controls
set => SetValue(DecimalPlacesProperty, value);
}
+ ///
+ /// 是否显示上下调值按钮
+ ///
internal static readonly DependencyProperty ShowUpDownButtonProperty = DependencyProperty.Register(
"ShowUpDownButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(true));
+ ///
+ /// 是否显示上下调值按钮
+ ///
internal bool ShowUpDownButton
{
get => (bool) GetValue(ShowUpDownButtonProperty);
set => SetValue(ShowUpDownButtonProperty, value);
}
+
+ ///
+ /// 数据是否错误
+ ///
+ public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
+ "IsError", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(default(bool)));
+
+ ///
+ /// 数据是否错误
+ ///
+ public bool IsError
+ {
+ get => (bool) GetValue(IsErrorProperty);
+ set => SetValue(IsErrorProperty, value);
+ }
+
+ ///
+ /// 错误提示
+ ///
+ public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
+ "ErrorStr", typeof(string), typeof(NumericUpDown), new PropertyMetadata(default(string)));
+
+ ///
+ /// 错误提示
+ ///
+ public string ErrorStr
+ {
+ get => (string) GetValue(ErrorStrProperty);
+ set => SetValue(ErrorStrProperty, value);
+ }
+
+ ///
+ /// 文本类型
+ ///
+ public static readonly DependencyProperty TextTypeProperty = DependencyProperty.Register(
+ "TextType", typeof(TextType), typeof(NumericUpDown), new PropertyMetadata(default(TextType)));
+
+ ///
+ /// 文本类型
+ ///
+ public TextType TextType
+ {
+ get => (TextType) GetValue(TextTypeProperty);
+ set => SetValue(TextTypeProperty, value);
+ }
+
+ ///
+ /// 是否显示清除按钮
+ ///
+ public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
+ "ShowClearButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(default(bool)));
+
+ ///
+ /// 是否显示清除按钮
+ ///
+ public bool ShowClearButton
+ {
+ get => (bool) GetValue(ShowClearButtonProperty);
+ set => SetValue(ShowClearButtonProperty, value);
+ }
+
+ ///
+ /// 数据验证委托
+ ///
+ public Func> VerifyFunc { get; set; }
+
+ ///
+ /// 验证数据
+ ///
+ ///
+ public virtual bool VerifyData()
+ {
+ OperationResult result;
+
+ if (VerifyFunc != null)
+ {
+ result = VerifyFunc.Invoke(_textBox.Text);
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(_textBox.Text))
+ {
+ if (double.TryParse(_textBox.Text, out var value))
+ {
+ if (value < Minimum || value > Maximum)
+ {
+ result = OperationResult.Failed(Properties.Langs.Lang.OutOfRange);
+ }
+ else
+ {
+ result = OperationResult.Success();
+ }
+ }
+ else
+ {
+ result = OperationResult.Failed(Properties.Langs.Lang.FormatError);
+ }
+ }
+ else if (InfoElement.GetNecessary(this))
+ {
+ result = OperationResult.Failed(Properties.Langs.Lang.IsNecessary);
+ }
+ else
+ {
+ result = OperationResult.Success();
+ }
+ }
+
+ IsError = !result.Data;
+ ErrorStr = result.Message;
+ return result.Data;
+ }
}
}
\ No newline at end of file
diff --git a/HandyControl/Data/Enum/InfoType.cs b/HandyControl/Data/Enum/InfoType.cs
index 47b9747d..e71b29dd 100644
--- a/HandyControl/Data/Enum/InfoType.cs
+++ b/HandyControl/Data/Enum/InfoType.cs
@@ -1,4 +1,5 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
public enum InfoType
{
diff --git a/HandyControl/Data/Enum/IpType.cs b/HandyControl/Data/Enum/IpType.cs
index 1551d04c..bbf4af19 100644
--- a/HandyControl/Data/Enum/IpType.cs
+++ b/HandyControl/Data/Enum/IpType.cs
@@ -1,4 +1,5 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
///
/// IP类型枚举
diff --git a/HandyControl/Data/Enum/ResultType.cs b/HandyControl/Data/Enum/ResultType.cs
new file mode 100644
index 00000000..1b75f89a
--- /dev/null
+++ b/HandyControl/Data/Enum/ResultType.cs
@@ -0,0 +1,24 @@
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
+{
+ ///
+ /// 表示一个操作的返回结果类型
+ ///
+ public enum ResultType
+ {
+ ///
+ /// 成功
+ ///
+ Success,
+
+ ///
+ /// 失败
+ ///
+ Failed,
+
+ ///
+ /// 无数据
+ ///
+ None
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Data/Enum/SkinType.cs b/HandyControl/Data/Enum/SkinType.cs
index 5fb63e6f..dc182f24 100644
--- a/HandyControl/Data/Enum/SkinType.cs
+++ b/HandyControl/Data/Enum/SkinType.cs
@@ -1,4 +1,5 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
public enum SkinType
{
diff --git a/HandyControl/Data/Enum/TextType.cs b/HandyControl/Data/Enum/TextType.cs
index 867e5d3e..b73bc771 100644
--- a/HandyControl/Data/Enum/TextType.cs
+++ b/HandyControl/Data/Enum/TextType.cs
@@ -1,11 +1,12 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
///
/// 文本类型枚举
///
public enum TextType
{
- Common = 0,
+ Common,
Phone,
Mail,
Url,
diff --git a/HandyControl/Data/Enum/TipPlacement.cs b/HandyControl/Data/Enum/TipPlacement.cs
index 53aeb715..f459e9ce 100644
--- a/HandyControl/Data/Enum/TipPlacement.cs
+++ b/HandyControl/Data/Enum/TipPlacement.cs
@@ -1,4 +1,5 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
public enum TipPlacement
{
diff --git a/HandyControl/Data/Enum/TitleAlignment.cs b/HandyControl/Data/Enum/TitleAlignment.cs
index af88faab..d17f8f1c 100644
--- a/HandyControl/Data/Enum/TitleAlignment.cs
+++ b/HandyControl/Data/Enum/TitleAlignment.cs
@@ -1,4 +1,5 @@
-namespace HandyControl.Data.Enum
+// ReSharper disable once CheckNamespace
+namespace HandyControl.Data
{
///
/// 标题对齐方式
diff --git a/HandyControl/Data/GrowlInfo.cs b/HandyControl/Data/GrowlInfo.cs
index 11716b36..68fc52e5 100644
--- a/HandyControl/Data/GrowlInfo.cs
+++ b/HandyControl/Data/GrowlInfo.cs
@@ -1,5 +1,5 @@
using System;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
namespace HandyControl.Data
{
diff --git a/HandyControl/Data/OperationResult!1.cs b/HandyControl/Data/OperationResult!1.cs
new file mode 100644
index 00000000..40a4d9cc
--- /dev/null
+++ b/HandyControl/Data/OperationResult!1.cs
@@ -0,0 +1,23 @@
+namespace HandyControl.Data
+{
+ ///
+ /// 表示一个操作的返回结果信息
+ ///
+ public class OperationResult : OperationResult
+ {
+ ///
+ /// 操作结果
+ ///
+ public ResultType ResultType { get; set; }
+
+ ///
+ /// 返回数据
+ ///
+ public T Data { get; set; }
+
+ ///
+ /// 操作消息(包含错误原因等数据)
+ ///
+ public string Message { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Data/OperationResult.cs b/HandyControl/Data/OperationResult.cs
new file mode 100644
index 00000000..05fbe781
--- /dev/null
+++ b/HandyControl/Data/OperationResult.cs
@@ -0,0 +1,25 @@
+namespace HandyControl.Data
+{
+ public class OperationResult
+ {
+ public static OperationResult Failed(string message = "")
+ {
+ return new OperationResult
+ {
+ ResultType = ResultType.Failed,
+ Message = message,
+ Data = false
+ };
+ }
+
+ public static OperationResult Success(string message = "")
+ {
+ return new OperationResult
+ {
+ ResultType = ResultType.Success,
+ Message = message,
+ Data = true
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Expression/Media/DrawingPropertyMetadata.cs b/HandyControl/Expression/Media/DrawingPropertyMetadata.cs
index f3fb8776..941811e1 100644
--- a/HandyControl/Expression/Media/DrawingPropertyMetadata.cs
+++ b/HandyControl/Expression/Media/DrawingPropertyMetadata.cs
@@ -5,7 +5,9 @@ namespace HandyControl.Expression.Media
{
internal class DrawingPropertyMetadata : FrameworkPropertyMetadata
{
+#pragma warning disable 414
private DrawingPropertyMetadataOptions options;
+#pragma warning restore 414
private PropertyChangedCallback propertyChangedCallback;
@@ -14,8 +16,7 @@ namespace HandyControl.Expression.Media
static DrawingPropertyMetadata()
{
DrawingPropertyChanged += delegate (object sender, DrawingPropertyChangedEventArgs args) {
- IShape shape = sender as IShape;
- if ((shape != null) && args.Metadata.AffectsRender)
+ if ((sender is IShape shape) && args.Metadata.AffectsRender)
{
InvalidateGeometryReasons reasons = InvalidateGeometryReasons.PropertyChanged;
if (args.IsAnimated)
@@ -54,7 +55,7 @@ namespace HandyControl.Expression.Media
options = options,
propertyChangedCallback = propertyChangedCallback
};
- return new PropertyChangedCallback(metadata.InternalCallback);
+ return metadata.InternalCallback;
}
private void InternalCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
@@ -68,10 +69,8 @@ namespace HandyControl.Expression.Media
};
DrawingPropertyChanged(sender, args);
}
- if (this.propertyChangedCallback != null)
- {
- this.propertyChangedCallback(sender, e);
- }
+
+ propertyChangedCallback?.Invoke(sender, e);
}
}
}
\ No newline at end of file
diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj
index 38f500c3..98311e31 100644
--- a/HandyControl/HandyControl.csproj
+++ b/HandyControl/HandyControl.csproj
@@ -51,6 +51,8 @@
+
+
@@ -64,9 +66,12 @@
+
+
+
True
True
diff --git a/HandyControl/Interactivity/ControlCommands.cs b/HandyControl/Interactivity/ControlCommands.cs
index 5b68b0c0..2f57807a 100644
--- a/HandyControl/Interactivity/ControlCommands.cs
+++ b/HandyControl/Interactivity/ControlCommands.cs
@@ -7,119 +7,124 @@ namespace HandyControl.Interactivity
///
public static class ControlCommands
{
+ ///
+ /// 清除
+ ///
+ public static RoutedCommand Clear { get; } = new RoutedCommand(nameof(Clear), typeof(ControlCommands));
+
///
/// 切换
///
- public static RoutedCommand Switch { get; } = new RoutedCommand("Switch", typeof(ControlCommands));
+ public static RoutedCommand Switch { get; } = new RoutedCommand(nameof(Switch), typeof(ControlCommands));
///
/// 右转
///
- public static RoutedCommand RotateRight { get; } = new RoutedCommand("RotateRight", typeof(ControlCommands));
+ public static RoutedCommand RotateRight { get; } = new RoutedCommand(nameof(RotateRight), typeof(ControlCommands));
///
/// 左转
///
- public static RoutedCommand RotateLeft { get; } = new RoutedCommand("RotateLeft", typeof(ControlCommands));
+ public static RoutedCommand RotateLeft { get; } = new RoutedCommand(nameof(RotateLeft), typeof(ControlCommands));
///
/// 小
///
- public static RoutedCommand Reduce { get; } = new RoutedCommand("Reduce", typeof(ControlCommands));
+ public static RoutedCommand Reduce { get; } = new RoutedCommand(nameof(Reduce), typeof(ControlCommands));
///
/// 大
///
- public static RoutedCommand Enlarge { get; } = new RoutedCommand("Enlarge", typeof(ControlCommands));
+ public static RoutedCommand Enlarge { get; } = new RoutedCommand(nameof(Enlarge), typeof(ControlCommands));
///
/// 还原
///
- public static RoutedCommand Restore { get; } = new RoutedCommand("Restore", typeof(ControlCommands));
+ public static RoutedCommand Restore { get; } = new RoutedCommand(nameof(Restore), typeof(ControlCommands));
///
/// 打开
///
- public static RoutedCommand Open { get; } = new RoutedCommand("Open", typeof(ControlCommands));
+ public static RoutedCommand Open { get; } = new RoutedCommand(nameof(Open), typeof(ControlCommands));
///
/// 保存
///
- public static RoutedCommand Save { get; } = new RoutedCommand("Save", typeof(ControlCommands));
+ public static RoutedCommand Save { get; } = new RoutedCommand(nameof(Save), typeof(ControlCommands));
///
/// 选中
///
- public static RoutedCommand Selected { get; } = new RoutedCommand("Selected", typeof(ControlCommands));
+ public static RoutedCommand Selected { get; } = new RoutedCommand(nameof(Selected), typeof(ControlCommands));
///
/// 关闭
///
- public static RoutedCommand Close { get; } = new RoutedCommand("Close", typeof(ControlCommands));
+ public static RoutedCommand Close { get; } = new RoutedCommand(nameof(Close), typeof(ControlCommands));
///
/// 取消
///
- public static RoutedCommand Cancel { get; } = new RoutedCommand("Cancel", typeof(ControlCommands));
+ public static RoutedCommand Cancel { get; } = new RoutedCommand(nameof(Cancel), typeof(ControlCommands));
///
/// 确定
///
- public static RoutedCommand Confirm { get; } = new RoutedCommand("Confirm", typeof(ControlCommands));
+ public static RoutedCommand Confirm { get; } = new RoutedCommand(nameof(Confirm), typeof(ControlCommands));
///
/// 关闭所有
///
- public static RoutedCommand CloseAll { get; } = new RoutedCommand("CloseAll", typeof(ControlCommands));
+ public static RoutedCommand CloseAll { get; } = new RoutedCommand(nameof(CloseAll), typeof(ControlCommands));
///
/// 关闭其他
///
- public static RoutedCommand CloseOther { get; } = new RoutedCommand("CloseOther", typeof(ControlCommands));
+ public static RoutedCommand CloseOther { get; } = new RoutedCommand(nameof(CloseOther), typeof(ControlCommands));
///
/// 上一个
///
- public static RoutedCommand Prev { get; } = new RoutedCommand("Prev", typeof(ControlCommands));
+ public static RoutedCommand Prev { get; } = new RoutedCommand(nameof(Prev), typeof(ControlCommands));
///
/// 下一个
///
- public static RoutedCommand Next { get; } = new RoutedCommand("Next", typeof(ControlCommands));
+ public static RoutedCommand Next { get; } = new RoutedCommand(nameof(Next), typeof(ControlCommands));
///
/// 上午
///
- public static RoutedCommand Am { get; } = new RoutedCommand("Am", typeof(ControlCommands));
+ public static RoutedCommand Am { get; } = new RoutedCommand(nameof(Am), typeof(ControlCommands));
///
/// 下午
///
- public static RoutedCommand Pm { get; } = new RoutedCommand("Pm", typeof(ControlCommands));
+ public static RoutedCommand Pm { get; } = new RoutedCommand(nameof(Pm), typeof(ControlCommands));
///
/// 确认
///
- public static RoutedCommand Sure { get; } = new RoutedCommand("Sure", typeof(ControlCommands));
+ public static RoutedCommand Sure { get; } = new RoutedCommand(nameof(Sure), typeof(ControlCommands));
///
/// 小时改变
///
- public static RoutedCommand HourChange { get; } = new RoutedCommand("HourChange", typeof(ControlCommands));
+ public static RoutedCommand HourChange { get; } = new RoutedCommand(nameof(HourChange), typeof(ControlCommands));
///
/// 分钟改变
///
- public static RoutedCommand MinuteChange { get; } = new RoutedCommand("MinuteChange", typeof(ControlCommands));
+ public static RoutedCommand MinuteChange { get; } = new RoutedCommand(nameof(MinuteChange), typeof(ControlCommands));
///
/// 秒改变
///
- public static RoutedCommand SecondChange { get; } = new RoutedCommand("SecondChange", typeof(ControlCommands));
+ public static RoutedCommand SecondChange { get; } = new RoutedCommand(nameof(SecondChange), typeof(ControlCommands));
///
/// 鼠标移动
///
- public static RoutedCommand MouseMove { get; } = new RoutedCommand("MouseMove", typeof(ControlCommands));
+ public static RoutedCommand MouseMove { get; } = new RoutedCommand(nameof(MouseMove), typeof(ControlCommands));
}
}
\ No newline at end of file
diff --git a/HandyControl/Properties/Langs/Lang.Designer.cs b/HandyControl/Properties/Langs/Lang.Designer.cs
index e92c76d4..9b13e3fc 100644
--- a/HandyControl/Properties/Langs/Lang.Designer.cs
+++ b/HandyControl/Properties/Langs/Lang.Designer.cs
@@ -47,7 +47,7 @@ namespace HandyControl.Properties.Langs {
}
///
- /// 使用此强类型资源类,为所有资源查找
+ /// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
@@ -141,6 +141,15 @@ namespace HandyControl.Properties.Langs {
}
}
+ ///
+ /// 查找类似 格式错误 的本地化字符串。
+ ///
+ public static string FormatError {
+ get {
+ return ResourceManager.GetString("FormatError", resourceCulture);
+ }
+ }
+
///
/// 查找类似 间隔10分钟 的本地化字符串。
///
@@ -204,6 +213,24 @@ namespace HandyControl.Properties.Langs {
}
}
+ ///
+ /// 查找类似 不能为空 的本地化字符串。
+ ///
+ public static string IsNecessary {
+ get {
+ return ResourceManager.GetString("IsNecessary", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 不在范围内 的本地化字符串。
+ ///
+ public static string OutOfRange {
+ get {
+ return ResourceManager.GetString("OutOfRange", resourceCulture);
+ }
+ }
+
///
/// 查找类似 下午 的本地化字符串。
///
diff --git a/HandyControl/Properties/Langs/Lang.en.resx b/HandyControl/Properties/Langs/Lang.en.resx
index c0119e2f..b6ba11e5 100644
--- a/HandyControl/Properties/Langs/Lang.en.resx
+++ b/HandyControl/Properties/Langs/Lang.en.resx
@@ -186,4 +186,13 @@
Prompt
+
+ cannot be empty
+
+
+ out of range
+
+
+ format error
+
\ No newline at end of file
diff --git a/HandyControl/Properties/Langs/Lang.resx b/HandyControl/Properties/Langs/Lang.resx
index 1a5a3aa0..7c115a14 100644
--- a/HandyControl/Properties/Langs/Lang.resx
+++ b/HandyControl/Properties/Langs/Lang.resx
@@ -166,4 +166,13 @@
提示
+
+ 不能为空
+
+
+ 不在范围内
+
+
+ 格式错误
+
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/NumericUpDown.xaml b/HandyControl/Themes/Styles/NumericUpDown.xaml
index d562f20b..65294048 100644
--- a/HandyControl/Themes/Styles/NumericUpDown.xaml
+++ b/HandyControl/Themes/Styles/NumericUpDown.xaml
@@ -93,4 +93,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/TextBox.xaml b/HandyControl/Themes/Styles/TextBox.xaml
index 4e1ade6f..13ddbdd4 100644
--- a/HandyControl/Themes/Styles/TextBox.xaml
+++ b/HandyControl/Themes/Styles/TextBox.xaml
@@ -79,4 +79,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HandyControl/Tools/RegularJudgment.cs b/HandyControl/Tools/RegularJudgment.cs
index 59ddbe38..725e11b3 100644
--- a/HandyControl/Tools/RegularJudgment.cs
+++ b/HandyControl/Tools/RegularJudgment.cs
@@ -1,6 +1,6 @@
using System;
using System.Text.RegularExpressions;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
namespace HandyControl.Tools
{
diff --git a/HandyControl/Tools/ResourceHelper.cs b/HandyControl/Tools/ResourceHelper.cs
index 794d4181..057a7c27 100644
--- a/HandyControl/Tools/ResourceHelper.cs
+++ b/HandyControl/Tools/ResourceHelper.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
namespace HandyControl.Tools
{
diff --git a/HandyControlDemo/App.xaml.cs b/HandyControlDemo/App.xaml.cs
index 9e9ebb21..47f358c0 100644
--- a/HandyControlDemo/App.xaml.cs
+++ b/HandyControlDemo/App.xaml.cs
@@ -2,7 +2,7 @@
using System.Globalization;
using System.Threading;
using System.Windows;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
using HandyControl.Tools;
using HandyControlDemo.Data;
diff --git a/HandyControlDemo/Data/AppConfig.cs b/HandyControlDemo/Data/AppConfig.cs
index f6843693..6e3412aa 100644
--- a/HandyControlDemo/Data/AppConfig.cs
+++ b/HandyControlDemo/Data/AppConfig.cs
@@ -1,5 +1,5 @@
using System;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
namespace HandyControlDemo.Data
{
diff --git a/HandyControlDemo/Properties/Langs/Lang.Designer.cs b/HandyControlDemo/Properties/Langs/Lang.Designer.cs
index a238925e..fec18810 100644
--- a/HandyControlDemo/Properties/Langs/Lang.Designer.cs
+++ b/HandyControlDemo/Properties/Langs/Lang.Designer.cs
@@ -47,7 +47,7 @@ namespace HandyControlDemo.Properties.Langs {
}
///
- /// 使用此强类型资源类,为所有资源查找
+ /// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
@@ -456,6 +456,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 不是手机号码 的本地化字符串。
+ ///
+ public static string IsNotPhone {
+ get {
+ return ResourceManager.GetString("IsNotPhone", resourceCulture);
+ }
+ }
+
///
/// 查找类似 列表框 的本地化字符串。
///
diff --git a/HandyControlDemo/Properties/Langs/Lang.en.resx b/HandyControlDemo/Properties/Langs/Lang.en.resx
index 95d80786..50b779ca 100644
--- a/HandyControlDemo/Properties/Langs/Lang.en.resx
+++ b/HandyControlDemo/Properties/Langs/Lang.en.resx
@@ -390,4 +390,7 @@
CircleProgressBar
+
+ It's not a phone number
+
\ No newline at end of file
diff --git a/HandyControlDemo/Properties/Langs/Lang.resx b/HandyControlDemo/Properties/Langs/Lang.resx
index caffe899..ed6b2efe 100644
--- a/HandyControlDemo/Properties/Langs/Lang.resx
+++ b/HandyControlDemo/Properties/Langs/Lang.resx
@@ -370,4 +370,7 @@
圆形进度条
+
+ 不是手机号码
+
\ No newline at end of file
diff --git a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml
index 7a50561e..181773f5 100644
--- a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml
+++ b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml
@@ -5,15 +5,25 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="{DynamicResource RegionBrush}">
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
index e09320bb..5005c44b 100644
--- a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
+++ b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
@@ -1,4 +1,6 @@
-// ReSharper disable once CheckNamespace
+using HandyControl.Data;
+
+// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class NumericUpDownDemoCtl
@@ -6,6 +8,12 @@ namespace HandyControlDemo.UserControl
public NumericUpDownDemoCtl()
{
InitializeComponent();
+
+ NumericUpDownCustomVerify.VerifyFunc = str => double.TryParse(str, out var v)
+ ? v % 2 < 1e-06
+ ? OperationResult.Failed(Properties.Langs.Lang.Error)
+ : OperationResult.Success()
+ : OperationResult.Failed(Properties.Langs.Lang.Error);
}
}
}
diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
index 4e4295e8..0639799c 100644
--- a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
+++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
@@ -45,7 +45,7 @@
-
+
@@ -124,7 +124,7 @@
-
+
@@ -134,7 +134,7 @@
-
+
diff --git a/HandyControlDemo/UserControl/Main/NoUserContent.xaml b/HandyControlDemo/UserControl/Main/NoUserContent.xaml
index 46790fad..18717935 100644
--- a/HandyControlDemo/UserControl/Main/NoUserContent.xaml
+++ b/HandyControlDemo/UserControl/Main/NoUserContent.xaml
@@ -5,7 +5,7 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Height="28"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
- xmlns:enum="clr-namespace:HandyControl.Data.Enum;assembly=HandyControl">
+ xmlns:enum="clr-namespace:HandyControl.Data;assembly=HandyControl">
diff --git a/HandyControlDemo/UserControl/Main/NoUserContent.xaml.cs b/HandyControlDemo/UserControl/Main/NoUserContent.xaml.cs
index 7ad310da..ba87a1bb 100644
--- a/HandyControlDemo/UserControl/Main/NoUserContent.xaml.cs
+++ b/HandyControlDemo/UserControl/Main/NoUserContent.xaml.cs
@@ -5,7 +5,7 @@ using System.Windows;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Messaging;
using HandyControl.Controls;
-using HandyControl.Data.Enum;
+using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.Tools;