diff --git a/HandyControl/Controls/Info/InfoControl.cs b/HandyControl/Controls/Info/InfoControl.cs
deleted file mode 100644
index 2b7eace3..00000000
--- a/HandyControl/Controls/Info/InfoControl.cs
+++ /dev/null
@@ -1,374 +0,0 @@
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Input;
-using System.Windows.Media.Animation;
-using HandyControl.Data.Enum;
-using HandyControl.Tools;
-using HandyControl.Tools.Converter;
-using HandyControl.Tools.Extension;
-
-// ReSharper disable once CheckNamespace
-namespace HandyControl.Controls
-{
- internal abstract class InfoControl : UserControl
- {
- private bool _isFocused;
-
- protected TextBlock ErrorTextBlock;
-
- protected TextBox ContentTextBox;
-
- protected StackPanel TitleStackPanel;
-
- ///
- /// 标题
- ///
- public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
- "Title", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
-
- ///
- /// 标题
- ///
- public string Title
- {
- get => (string)GetValue(TitleProperty);
- set => SetValue(TitleProperty, value);
- }
-
- ///
- /// 文本
- ///
- public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
- "Text", typeof(string), typeof(InfoControl), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
-
- ///
- /// 文本
- ///
- public string Text
- {
- get => (string)GetValue(TextProperty);
- set => SetValue(TextProperty, value);
- }
-
- ///
- /// 是否为必填项
- ///
- public static readonly DependencyProperty IsNeedlyProperty = DependencyProperty.Register(
- "IsNeedly", typeof(bool), typeof(InfoControl), new PropertyMetadata(true));
-
- ///
- /// 是否为必填项
- ///
- public bool IsNeedly
- {
- get => (bool)GetValue(IsNeedlyProperty);
- set => SetValue(IsNeedlyProperty, value);
- }
-
- ///
- /// 占位符
- ///
- public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty.Register(
- "PlaceHolder", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
-
- ///
- /// 占位符
- ///
- public string PlaceHolder
- {
- get => (string)GetValue(PlaceHolderProperty);
- set => SetValue(PlaceHolderProperty, value);
- }
-
- ///
- /// 错误信息
- ///
- public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
- "ErrorStr", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
-
- ///
- /// 错误信息
- ///
- public string ErrorStr
- {
- get => (string)GetValue(ErrorStrProperty);
- set => SetValue(ErrorStrProperty, value);
- }
-
- ///
- /// 控件是否包含错误
- ///
- public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
- "IsError", typeof(bool), typeof(InfoControl), new PropertyMetadata(default(bool)));
-
- ///
- /// 控件是否包含错误
- ///
- public bool IsError
- {
- get => (bool)GetValue(IsErrorProperty);
- set => SetValue(IsErrorProperty, value);
- }
-
- ///
- /// 标题宽度
- ///
- public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.RegisterAttached(
- "TitleWidth", typeof(GridLength), typeof(InfoControl),
- new FrameworkPropertyMetadata(GridLength.Auto, FrameworkPropertyMetadataOptions.Inherits));
-
- ///
- /// 设置标题宽度
- ///
- public static void SetTitleWidth(DependencyObject element, GridLength value)
- {
- element.SetValue(TitleWidthProperty, value);
- }
-
- ///
- /// 标题宽度
- ///
- public static GridLength GetTitleWidth(DependencyObject element)
- {
- return (GridLength)element.GetValue(TitleWidthProperty);
- }
-
- ///
- /// 标题宽度
- ///
- public GridLength TitleWidth
- {
- get => (GridLength)GetValue(TitleWidthProperty);
- set => SetValue(TitleWidthProperty, value);
- }
-
- ///
- /// 标题对齐方式
- ///
- public static readonly DependencyProperty TitleAlignmentProperty = DependencyProperty.Register(
- "TitleAlignment", typeof(TitleAlignment), typeof(InfoControl), new PropertyMetadata(TitleAlignment.Left,
- (o, args) =>
- {
- var ctl = (InfoControl)o;
- var v = (TitleAlignment)args.NewValue;
- if (v == TitleAlignment.Left)
- {
- Grid.SetColumn(ctl.TitleStackPanel, 0);
- Grid.SetRow(ctl.TitleStackPanel, 1);
- ctl.HorizontalAlignment = HorizontalAlignment.Right;
- ctl.Height = ctl.MaxHeight;
- }
- else
- {
- Grid.SetColumn(ctl.TitleStackPanel, 1);
- Grid.SetRow(ctl.TitleStackPanel, 0);
- ctl.TitleStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
- ctl.TitleStackPanel.Margin = new Thickness(4, 0, 0, 4);
- ctl.Height += 18;
- }
- }));
-
- ///
- /// 标题对齐方式
- ///
- public TitleAlignment TitleAlignment
- {
- get => (TitleAlignment)GetValue(TitleAlignmentProperty);
- set => SetValue(TitleAlignmentProperty, value);
- }
-
- ///
- /// 文本的水平对齐方式
- ///
- public static readonly DependencyProperty HorizontalTextAlignmentProperty = DependencyProperty.Register(
- "HorizontalTextAlignment", typeof(HorizontalAlignment), typeof(InfoControl), new PropertyMetadata(HorizontalAlignment.Left));
-
- ///
- /// 文本的水平对齐方式
- ///
- public HorizontalAlignment HorizontalTextAlignment
- {
- get => (HorizontalAlignment)GetValue(HorizontalTextAlignmentProperty);
- set => SetValue(HorizontalTextAlignmentProperty, value);
- }
-
- ///
- /// 是否显示清除按钮
- ///
- public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
- "ShowClearButton", typeof(bool), typeof(InfoControl), new PropertyMetadata(true, (o, args) =>
- {
- var ctl = (InfoControl)o;
- var v = (bool)args.NewValue;
- if (!(ctl.FindName("ButtonClear") is Button button)) return;
- BindingOperations.ClearBinding(button, VisibilityProperty);
- button.IsEnabled = v;
- if (v)
- {
- button.SetBinding(VisibilityProperty, new Binding("Text")
- {
- Source = ctl,
- Converter = new String2VisibilityConverter()
- });
- }
- else
- {
- button.Collapse();
- }
- }));
-
- ///
- /// 是否显示清除按钮
- ///
- public bool ShowClearButton
- {
- get => (bool)GetValue(ShowClearButtonProperty);
- set => SetValue(ShowClearButtonProperty, value);
- }
-
- ///
- /// 是否显示小圆角
- ///
- public static readonly DependencyProperty ShowSmallCornerRadiusProperty = DependencyProperty.Register(
- "ShowSmallCornerRadius", typeof(bool), typeof(InfoControl), new PropertyMetadata(default(bool), (o, args) =>
- {
- var ctl = (InfoControl)o;
- var v = (bool)args.NewValue;
- ctl.CornerRadius = v ? new CornerRadius(2, 2, 2, 2) : new CornerRadius(4, 4, 4, 4);
- }));
-
- ///
- /// 是否显示小圆角
- ///
- public bool ShowSmallCornerRadius
- {
- get => (bool)GetValue(ShowSmallCornerRadiusProperty);
- set => SetValue(ShowSmallCornerRadiusProperty, value);
- }
-
- ///
- /// 圆角
- ///
- protected static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
- "CornerRadius", typeof(CornerRadius), typeof(InfoControl), new PropertyMetadata(new CornerRadius(4, 4, 4, 4)));
-
- ///
- /// 圆角
- ///
- protected CornerRadius CornerRadius
- {
- get => (CornerRadius)GetValue(CornerRadiusProperty);
- set => SetValue(CornerRadiusProperty, value);
- }
-
- ///
- /// 文本内边距
- ///
- public static readonly DependencyProperty TextPaddingProperty = DependencyProperty.Register(
- "TextPadding", typeof(Thickness), typeof(InfoControl), new PropertyMetadata(new Thickness(6, 0, 0, 0)));
-
- ///
- /// 文本内边距
- ///
- public Thickness TextPadding
- {
- get => (Thickness)GetValue(TextPaddingProperty);
- set => SetValue(TextPaddingProperty, value);
- }
-
- ///
- /// 更新状态
- ///
- public virtual void Update()
- {
- if (!IsError)
- {
- if (!_isFocused)
- {
- (TryFindResource("Storyboard2") as Storyboard)?.Begin();
- }
- else
- {
- (TryFindResource("Storyboard3") as Storyboard)?.Begin();
- }
- ErrorTextBlock.BeginAnimation(MarginProperty, AnimationHelper.CreateAnimation(new Thickness(4, 0, 0, 1)));
- return;
- }
- (TryFindResource("Storyboard4") as Storyboard)?.Begin();
- ErrorTextBlock.BeginAnimation(MarginProperty, AnimationHelper.CreateAnimation(new Thickness(4, 0, 0, -ErrorTextBlock.ActualHeight - 2)));
- }
-
- protected virtual void InputBox_OnLostFocus(object sender, RoutedEventArgs e)
- {
- _isFocused = false;
- CheckInfo();
- }
-
- protected virtual void InputBox_OnGotFocus(object sender, RoutedEventArgs e)
- {
- _isFocused = true;
- if (!IsError)
- {
- (TryFindResource("Storyboard3") as Storyboard)?.Begin();
- }
- }
-
- protected virtual void InputBox_OnMouseEnter(object sender, MouseEventArgs e)
- {
- if (!IsError && !ContentTextBox.IsFocused)
- {
- (TryFindResource("Storyboard1") as Storyboard)?.Begin();
- }
- }
-
- protected virtual void InputBox_OnMouseLeave(object sender, MouseEventArgs e)
- {
- if (!IsError && !ContentTextBox.IsFocused)
- {
- (TryFindResource("Storyboard2") as Storyboard)?.Begin();
- }
- }
-
- protected virtual void InputBox_OnTextChanged(object sender, TextChangedEventArgs e) => CheckInfo();
-
- protected virtual void ButtonClear_OnClick(object sender, RoutedEventArgs e) => Text = string.Empty;
-
- ///
- /// 文本类型
- ///
- public TextType TextType { get; set; }
-
- ///
- /// 正则字符串(当文本类型为Common时,此属性才生效)
- ///
- public string RegularStr { get; set; }
-
- ///
- /// 用于监测数据的正确性
- ///
- ///
- public virtual bool CheckInfo()
- {
- bool result;
- if (TextType == TextType.Common)
- {
- if (string.IsNullOrEmpty(RegularStr))
- {
- result = !IsNeedly || !string.IsNullOrEmpty(Text);
- }
- else
- {
- result = Text.IsKindOf(RegularStr);
- }
- }
- else
- {
- result = Text.IsKindOf(TextType);
- }
- IsError = !result;
- Update();
- return result;
- }
- }
-}
\ No newline at end of file
diff --git a/HandyControl/Controls/Info/InfoNumericUpDown.xaml b/HandyControl/Controls/Info/InfoNumericUpDown.xaml
deleted file mode 100644
index 65c786c3..00000000
--- a/HandyControl/Controls/Info/InfoNumericUpDown.xaml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/HandyControl/Controls/Info/InfoNumericUpDown.xaml.cs b/HandyControl/Controls/Info/InfoNumericUpDown.xaml.cs
deleted file mode 100644
index de4606f6..00000000
--- a/HandyControl/Controls/Info/InfoNumericUpDown.xaml.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-using System;
-using System.Windows;
-using System.Windows.Input;
-using System.Windows.Media.Animation;
-using HandyControl.Data;
-using HandyControl.Tools;
-
-// ReSharper disable once CheckNamespace
-namespace HandyControl.Controls
-{
- ///
- /// InfoNumericUpDown.xaml 的交互逻辑
- ///
- internal partial class InfoNumericUpDown
- {
- public InfoNumericUpDown()
- {
- InitializeComponent();
-
- ErrorTextBlock = TextBlockError;
- ContentTextBox = MyTextBox;
- TitleStackPanel = StackPanelTitle;
-
- (TryFindResource("Storyboard2") as Storyboard)?.Begin();
-
- Loaded += (s, e) =>
- {
- StackPanelTitle.Focusable = true;
- StackPanelTitle.Focus();
- StackPanelTitle.Focusable = false;
- };
- }
-
- ///
- /// 最大值
- ///
- public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
- "Maximum", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(100.0, (o, args) =>
- {
- o.CoerceValue(MinimumProperty);
- o.CoerceValue(ValueProperty);
- }, (o, value) =>
- {
- var info = (InfoNumericUpDown)o;
- var max = (double)value;
- if (max < info.Minimum) max = info.Minimum;
- return max;
- }), ValidateHelper.IsInRangeOfDouble);
-
- ///
- /// 最大值
- ///
- public double Maximum
- {
- get => (double)GetValue(MaximumProperty);
- set => SetValue(MaximumProperty, value);
- }
-
- ///
- /// 最小值
- ///
- public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
- "Minimum", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(0.0, (o, args) =>
- {
- o.CoerceValue(MaximumProperty);
- o.CoerceValue(ValueProperty);
- }, (o, value) =>
- {
- var info = (InfoNumericUpDown)o;
- var min = (double)value;
- if (min > info.Maximum) min = info.Maximum;
- return min;
- }), ValidateHelper.IsInRangeOfDouble);
-
- ///
- /// 最小值
- ///
- public double Minimum
- {
- get => (double)GetValue(MinimumProperty);
- set => SetValue(MinimumProperty, value);
- }
-
- ///
- /// 当前值
- ///
- public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
- "Value", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(1.0, (o, args) =>
- {
- o.CoerceValue(MinimumProperty);
- o.CoerceValue(MaximumProperty);
- var ctl = (InfoNumericUpDown)o;
- ctl.RaiseEvent(new FunctionEventArgs(ValueChangedEvent, ctl)
- {
- Info = (double)args.NewValue
- });
- }, (o, value) =>
- {
- var info = (InfoNumericUpDown)o;
- var current = (double)value;
-
- if (current < info.Minimum) current = info.Minimum;
- if (current > info.Maximum) current = info.Maximum;
-
- return current;
- }), ValidateHelper.IsInRangeOfDouble);
-
- ///
- /// 当前值
- ///
- public double Value
- {
- get => (double)GetValue(ValueProperty);
- set => SetValue(ValueProperty, value);
- }
-
- ///
- /// 最小改变值
- ///
- public static readonly DependencyProperty SmallChangeProperty = DependencyProperty.Register(
- "SmallChange", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(1.0), ValidateHelper.IsInRangeOfDouble);
-
- ///
- /// 最小改变值
- ///
- public double SmallChange
- {
- get => (double)GetValue(SmallChangeProperty);
- set => SetValue(SmallChangeProperty, value);
- }
-
- ///
- /// 是否显示上下调整按钮
- ///
- public static readonly DependencyProperty ShowUpDownButtonProperty = DependencyProperty.Register(
- "ShowUpDownButton", typeof(bool), typeof(InfoNumericUpDown), new PropertyMetadata(true));
-
- ///
- /// 是否显示上下调整按钮
- ///
- public bool ShowUpDownButton
- {
- get => (bool)GetValue(ShowUpDownButtonProperty);
- set => SetValue(ShowUpDownButtonProperty, value);
- }
-
- ///
- /// 值改变事件
- ///
- public static readonly RoutedEvent ValueChangedEvent =
- EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
- typeof(EventHandler>), typeof(InfoNumericUpDown));
-
- ///
- /// 值改变事件
- ///
- public event EventHandler> ValueChanged
- {
- add => AddHandler(ValueChangedEvent, value);
- remove => RemoveHandler(ValueChangedEvent, value);
- }
-
- private void ButtonUp_OnClick(object sender, RoutedEventArgs e) => Value += SmallChange;
-
- private void ButtonDown_OnClick(object sender, RoutedEventArgs e) => Value -= SmallChange;
-
- private void MyTextBox_OnMouseWheel(object sender, MouseWheelEventArgs e)
- {
- if (e.Delta > 0)
- {
- Value += SmallChange;
- }
- else
- {
- Value -= SmallChange;
- }
- MyTextBox.Select(MyTextBox.Text.Length, 0);
- e.Handled = true;
- }
- }
-}
\ No newline at end of file
diff --git a/HandyControl/Controls/Info/InfoTextBox.xaml b/HandyControl/Controls/Info/InfoTextBox.xaml
deleted file mode 100644
index 364e462a..00000000
--- a/HandyControl/Controls/Info/InfoTextBox.xaml
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/HandyControl/Controls/Info/InfoTextBox.xaml.cs b/HandyControl/Controls/Info/InfoTextBox.xaml.cs
deleted file mode 100644
index c633d476..00000000
--- a/HandyControl/Controls/Info/InfoTextBox.xaml.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.Windows;
-using System.Windows.Media.Animation;
-
-// ReSharper disable once CheckNamespace
-namespace HandyControl.Controls
-{
- ///
- /// InfoTextBox.xaml 的交互逻辑
- ///
- internal partial class InfoTextBox
- {
- ///
- /// 可输入的最大字符数
- ///
- public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.Register(
- "MaxLength", typeof(int), typeof(InfoTextBox), new PropertyMetadata(default(int)));
-
- ///
- /// 可输入的最大字符数
- ///
- public int MaxLength
- {
- get => (int)GetValue(MaxLengthProperty);
- set => SetValue(MaxLengthProperty, value);
- }
-
- public InfoTextBox()
- {
- InitializeComponent();
-
- ErrorTextBlock = TextBlockError;
- ContentTextBox = MyTextBox;
- TitleStackPanel = StackPanelTitle;
-
- (TryFindResource("Storyboard2") as Storyboard)?.Begin();
-
- Loaded += (s, e) =>
- {
- StackPanelTitle.Focusable = true;
- StackPanelTitle.Focus();
- StackPanelTitle.Focusable = false;
- };
- }
- }
-}
\ No newline at end of file
diff --git a/HandyControl/Controls/NumericUpDown.cs b/HandyControl/Controls/NumericUpDown.cs
new file mode 100644
index 00000000..90dde33d
--- /dev/null
+++ b/HandyControl/Controls/NumericUpDown.cs
@@ -0,0 +1,257 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using HandyControl.Data;
+using HandyControl.Interactivity;
+
+namespace HandyControl.Controls
+{
+ ///
+ /// 数值选择控件
+ ///
+ [TemplatePart(Name = ElementTextBox, Type = typeof(TextBox))]
+ public class NumericUpDown : Control
+ {
+ #region Constants
+
+ private const string ElementTextBox = "PART_TextBox";
+
+ #endregion Constants
+
+ #region Data
+
+ private TextBox _textBox;
+
+ #endregion Data
+
+ public NumericUpDown()
+ {
+ CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Value += Increment));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Value -= Increment));
+ }
+
+ protected override void OnGotFocus(RoutedEventArgs e)
+ {
+ base.OnGotFocus(e);
+
+ if (_textBox != null)
+ {
+ _textBox?.Focus();
+ _textBox.Select(_textBox.Text.Length, 0);
+ }
+ }
+
+ public override void OnApplyTemplate()
+ {
+ if (_textBox != null)
+ {
+ _textBox.PreviewTextInput -= TextBoxValue_TextInput;
+ }
+
+ base.OnApplyTemplate();
+
+ _textBox = GetTemplateChild(ElementTextBox) as TextBox;
+
+ if (_textBox != null)
+ {
+ _textBox.PreviewTextInput += TextBoxValue_TextInput;
+ _textBox.Text = Value.ToString($"#0.{new string('0', DecimalPlaces)}");
+ }
+ }
+
+ private void TextBoxValue_TextInput(object sender, TextCompositionEventArgs e)
+ {
+ if (double.TryParse(_textBox.Text, out var value))
+ {
+ Value = value;
+ }
+
+ if (_textBox != null)
+ {
+ _textBox.Text = Value.ToString($"#0.{new string('0', DecimalPlaces)}");
+ _textBox.Select(_textBox.Text.Length, 0);
+ }
+ }
+
+ protected override void OnMouseWheel(MouseWheelEventArgs e)
+ {
+ base.OnMouseWheel(e);
+
+ if (_textBox.IsFocused)
+ {
+ Value += e.Delta > 0 ? Increment : -Increment;
+ e.Handled = true;
+ }
+ }
+
+ protected virtual void OnValueChanged(FunctionEventArgs e) => RaiseEvent(e);
+
+ ///
+ /// 值改变事件
+ ///
+ public static readonly RoutedEvent ValueChangedEvent =
+ EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
+ typeof(EventHandler>), typeof(NumericUpDown));
+
+ ///
+ /// 值改变事件
+ ///
+ public event EventHandler> ValueChanged
+ {
+ add => AddHandler(ValueChangedEvent, value);
+ remove => RemoveHandler(ValueChangedEvent, value);
+ }
+
+ ///
+ /// 当前值
+ ///
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
+ "Value", typeof(double), typeof(NumericUpDown), new PropertyMetadata(default(double), OnValueChanged, CoerceValue), IsValidDoubleValue);
+
+ private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctl = (NumericUpDown) d;
+ var v = (double) e.NewValue;
+ if (ctl._textBox != null)
+ {
+ ctl._textBox.Text = v.ToString($"#0.{new string('0', ctl.DecimalPlaces)}");
+ ctl._textBox.Select(ctl._textBox.Text.Length, 0);
+ }
+ ctl.OnValueChanged(new FunctionEventArgs(ValueChangedEvent, ctl)
+ {
+ Info = v
+ });
+ }
+
+ private static object CoerceValue(DependencyObject d, object basevalue)
+ {
+ var ctl = (NumericUpDown)d;
+ var minimum = ctl.Minimum;
+ var num = (double)basevalue;
+ if (num < minimum)
+ {
+ ctl.Value = minimum;
+ return minimum;
+ }
+ var maximum = ctl.Maximum;
+ if (num > maximum)
+ {
+ ctl.Value = maximum;
+ }
+ return num > maximum ? maximum : basevalue;
+ }
+
+ ///
+ /// 当前值
+ ///
+ public double Value
+ {
+ get => (double) GetValue(ValueProperty);
+ set => SetValue(ValueProperty, value);
+ }
+
+ ///
+ /// 最大值
+ ///
+ public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
+ "Maximum", typeof(double), typeof(NumericUpDown), new PropertyMetadata(100.0, OnMaximumChanged, CoerceMaximum), IsValidDoubleValue);
+
+ private static void OnMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctl = (NumericUpDown)d;
+ ctl.CoerceValue(MinimumProperty);
+ ctl.CoerceValue(ValueProperty);
+ }
+
+ private static object CoerceMaximum(DependencyObject d, object basevalue)
+ {
+ var minimum = ((NumericUpDown)d).Minimum;
+ return (double)basevalue < minimum ? minimum : basevalue;
+ }
+
+ ///
+ /// 最大值
+ ///
+ public double Maximum
+ {
+ get => (double) GetValue(MaximumProperty);
+ set => SetValue(MaximumProperty, value);
+ }
+
+ ///
+ /// 最小值
+ ///
+ public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
+ "Minimum", typeof(double), typeof(NumericUpDown), new PropertyMetadata(default(double), OnMinimumChanged, CoerceMinimum), IsValidDoubleValue);
+
+ private static void OnMinimumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctl = (NumericUpDown)d;
+ ctl.CoerceValue(MaximumProperty);
+ ctl.CoerceValue(ValueProperty);
+ }
+
+ private static object CoerceMinimum(DependencyObject d, object basevalue)
+ {
+ var maximum = ((NumericUpDown)d).Maximum;
+ return (double)basevalue > maximum ? maximum : basevalue;
+ }
+
+ ///
+ /// 最小值
+ ///
+ public double Minimum
+ {
+ get => (double) GetValue(MinimumProperty);
+ set => SetValue(MinimumProperty, value);
+ }
+
+ private static bool IsValidDoubleValue(object value)
+ {
+ var d = (double)value;
+ if (!double.IsNaN(d))
+ return !double.IsInfinity(d);
+ return false;
+ }
+
+ ///
+ /// 指示每单击一下按钮时增加或减少的数量
+ ///
+ public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register(
+ "Increment", typeof(double), typeof(NumericUpDown), new PropertyMetadata(1.0));
+
+ ///
+ /// 指示每单击一下按钮时增加或减少的数量
+ ///
+ public double Increment
+ {
+ get => (double) GetValue(IncrementProperty);
+ set => SetValue(IncrementProperty, value);
+ }
+
+ ///
+ /// 指示要显示的小数位数
+ ///
+ public static readonly DependencyProperty DecimalPlacesProperty = DependencyProperty.Register(
+ "DecimalPlaces", typeof(int), typeof(NumericUpDown), new PropertyMetadata(default(int)));
+
+ ///
+ /// 指示要显示的小数位数
+ ///
+ public int DecimalPlaces
+ {
+ get => (int) GetValue(DecimalPlacesProperty);
+ 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Controls/Picker/ColorPicker.xaml b/HandyControl/Controls/Picker/ColorPicker.xaml
index b6d8951f..3ca152cb 100644
--- a/HandyControl/Controls/Picker/ColorPicker.xaml
+++ b/HandyControl/Controls/Picker/ColorPicker.xaml
@@ -22,7 +22,20 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -58,21 +71,21 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/HandyControl/Controls/Picker/ColorPicker.xaml.cs b/HandyControl/Controls/Picker/ColorPicker.xaml.cs
index bdb86adb..396c48dd 100644
--- a/HandyControl/Controls/Picker/ColorPicker.xaml.cs
+++ b/HandyControl/Controls/Picker/ColorPicker.xaml.cs
@@ -8,6 +8,7 @@ using System.Windows.Media;
using HandyControl.Data;
using HandyControl.Tools.Extension;
+// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
///
@@ -510,10 +511,10 @@ namespace HandyControl.Controls
private void ButtonSwitch_OnClick(object sender, RoutedEventArgs e) => ColorType++;
- private void InfoNumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs e)
+ private void NumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs e)
{
if (!_isLoaded || !IsNeedUpdateInfo) return;
- if (e.OriginalSource is InfoNumericUpDown ctl && ctl.Tag is string tag)
+ if (e.OriginalSource is NumericUpDown ctl && ctl.Tag is string tag)
{
var color = SelectedBrush.Color;
IsNeedUpdateInfo = false;
diff --git a/HandyControl/Controls/TimeBar/TimeBar.cs b/HandyControl/Controls/TimeBar/TimeBar.cs
index 6541c40b..83ba1e63 100644
--- a/HandyControl/Controls/TimeBar/TimeBar.cs
+++ b/HandyControl/Controls/TimeBar/TimeBar.cs
@@ -31,8 +31,7 @@ namespace HandyControl.Controls
private const string ElementCanvasSpe = "PART_CanvasSpe";
#endregion Constants
-
-
+
#region Data
private Border _borderTop;
diff --git a/HandyControl/Controls/Window/ImageBrowser.xaml.cs b/HandyControl/Controls/Window/ImageBrowser.cs
similarity index 73%
rename from HandyControl/Controls/Window/ImageBrowser.xaml.cs
rename to HandyControl/Controls/Window/ImageBrowser.cs
index 54b3ece3..e9d7ea85 100644
--- a/HandyControl/Controls/Window/ImageBrowser.xaml.cs
+++ b/HandyControl/Controls/Window/ImageBrowser.cs
@@ -2,10 +2,13 @@
using System.Diagnostics;
using System.IO;
using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
+using HandyControl.Interactivity;
using HandyControl.Tools;
using Microsoft.Win32;
@@ -15,40 +18,87 @@ namespace HandyControl.Controls
///
/// 图片浏览器
///
- public partial class ImageBrowser
+ [TemplatePart(Name = ElementGridTop, Type = typeof(Grid))]
+ [TemplatePart(Name = ElementGridMain, Type = typeof(Grid))]
+ [TemplatePart(Name = ElementCanvasSmallImg, Type = typeof(Canvas))]
+ [TemplatePart(Name = ElementBorderMove, Type = typeof(Border))]
+ [TemplatePart(Name = ElementBorderBottom, Type = typeof(Border))]
+ [TemplatePart(Name = ElementImageMain, Type = typeof(Image))]
+ public class ImageBrowser : WindowBorderless
{
+ #region Constants
+
+ private const string ElementGridTop = "PART_GridTop";
+
+ private const string ElementGridMain = "PART_GridMain";
+
+ private const string ElementCanvasSmallImg = "PART_CanvasSmallImg";
+
+ private const string ElementBorderMove = "PART_BorderMove";
+
+ private const string ElementBorderBottom = "PART_BorderBottom";
+
+ private const string ElementImageMain = "PART_ImageMain";
+
///
/// 缩放比间隔
///
private const double ScaleInternal = 0.2;
+ #endregion Constants
+
+ #region Data
+
+ private Grid _gridTop;
+
+ private Grid _canvasMain;
+
+ private Canvas _canvasSmallImg;
+
+ private Border _borderMove;
+
+ private Border _borderBottom;
+
+ private Image _imageMain;
+
+ #endregion Data
+
static ImageBrowser()
{
IsFullScreenProperty.AddOwner(typeof(ImageBrowser), new PropertyMetadata(default(bool)));
}
- private static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ImageContentProperty = DependencyProperty.Register(
+ "ImageContent", typeof(object), typeof(ImageBrowser), new PropertyMetadata(default(object)));
+
+ internal object ImageContent
+ {
+ get => GetValue(ImageContentProperty);
+ set => SetValue(ImageContentProperty, value);
+ }
+
+ internal static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource", typeof(BitmapFrame), typeof(ImageBrowser), new PropertyMetadata(default(BitmapFrame)));
- private static readonly DependencyProperty ImageMarginProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ImageMarginProperty = DependencyProperty.Register(
"ImageMargin", typeof(Thickness), typeof(ImageBrowser), new PropertyMetadata(default(Thickness)));
- private static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
"ImageWidth", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
- private static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
"ImageHeight", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
public static readonly DependencyProperty ImageScaleProperty = DependencyProperty.Register(
"ImageScale", typeof(double), typeof(ImageBrowser), new PropertyMetadata(1.0, OnImageScaleChanged));
- private static readonly DependencyProperty ScaleStrProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ScaleStrProperty = DependencyProperty.Register(
"ScaleStr", typeof(string), typeof(ImageBrowser), new PropertyMetadata("100%"));
- private static readonly DependencyProperty ImageRotateProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ImageRotateProperty = DependencyProperty.Register(
"ImageRotate", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
- private static readonly DependencyProperty ShowSmallImgProperty = DependencyProperty.Register(
+ internal static readonly DependencyProperty ShowSmallImgProperty = DependencyProperty.Register(
"ShowSmallImg", typeof(bool), typeof(ImageBrowser), new PropertyMetadata(false));
///
@@ -182,15 +232,22 @@ namespace HandyControl.Controls
///
private bool _isOblique;
- public ImageBrowser() => InitializeComponent();
-
- ///
- /// 带一个图片路径的构造函数
- ///
- ///
- public ImageBrowser(string path) : this(new Uri(path))
+ public ImageBrowser()
{
+ Loaded += ImageBrowser_OnLoaded;
+ CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Save, ButtonSave_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Open, ButtonWindowsOpen_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Restore, ButtonActual_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Reduce, ButtonReduce_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Enlarge, ButtonEnlarge_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.RotateLeft, ButtonRotateLeft_OnClick));
+ CommandBindings.Add(new CommandBinding(ControlCommands.RotateRight, ButtonRotateRight_OnClick));
+
+ WindowStartupLocation = WindowStartupLocation.CenterScreen;
+ WindowStyle = WindowStyle.None;
+ AllowsTransparency = true;
}
///
@@ -215,25 +272,82 @@ namespace HandyControl.Controls
}
}
- private BitmapFrame ImageSource
+ ///
+ /// 带一个图片路径的构造函数
+ ///
+ ///
+ public ImageBrowser(string path) : this(new Uri(path))
+ {
+
+ }
+
+ public override void OnApplyTemplate()
+ {
+ if (_imageMain != null)
+ {
+ _imageMain.MouseLeftButtonDown -= ImageMain_OnMouseLeftButtonDown;
+ }
+
+ if (_gridTop != null)
+ {
+ _gridTop.MouseLeftButtonDown -= GridTop_OnMouseLeftButtonDown;
+ }
+
+ if (_canvasSmallImg != null)
+ {
+ _canvasSmallImg.MouseLeftButtonDown -= CanvasSmallImg_OnMouseLeftButtonDown;
+ _canvasSmallImg.MouseLeftButtonUp -= CanvasSmallImg_OnMouseLeftButtonUp;
+ _canvasSmallImg.MouseMove -= CanvasSmallImg_OnMouseMove;
+ _canvasSmallImg.MouseLeave -= CanvasSmallImg_OnMouseLeave;
+ }
+
+ base.OnApplyTemplate();
+
+ _gridTop = GetTemplateChild(ElementGridTop) as Grid;
+ _canvasMain = GetTemplateChild(ElementGridMain) as Grid;
+ _canvasSmallImg = GetTemplateChild(ElementCanvasSmallImg) as Canvas;
+ _borderMove = GetTemplateChild(ElementBorderMove) as Border;
+ _imageMain = GetTemplateChild(ElementImageMain) as Image;
+ _borderBottom = GetTemplateChild(ElementBorderBottom) as Border;
+
+ if (_imageMain != null)
+ {
+ _imageMain.MouseLeftButtonDown += ImageMain_OnMouseLeftButtonDown;
+ }
+
+ if (_gridTop != null)
+ {
+ _gridTop.MouseLeftButtonDown += GridTop_OnMouseLeftButtonDown;
+ }
+
+ if (_canvasSmallImg != null)
+ {
+ _canvasSmallImg.MouseLeftButtonDown += CanvasSmallImg_OnMouseLeftButtonDown;
+ _canvasSmallImg.MouseLeftButtonUp += CanvasSmallImg_OnMouseLeftButtonUp;
+ _canvasSmallImg.MouseMove += CanvasSmallImg_OnMouseMove;
+ _canvasSmallImg.MouseLeave += CanvasSmallImg_OnMouseLeave;
+ }
+ }
+
+ internal BitmapFrame ImageSource
{
get => (BitmapFrame)GetValue(ImageSourceProperty);
set => SetValue(ImageSourceProperty, value);
}
- private Thickness ImageMargin
+ internal Thickness ImageMargin
{
get => (Thickness)GetValue(ImageMarginProperty);
set => SetValue(ImageMarginProperty, value);
}
- private double ImageWidth
+ internal double ImageWidth
{
get => (double)GetValue(ImageWidthProperty);
set => SetValue(ImageWidthProperty, value);
}
- private double ImageHeight
+ internal double ImageHeight
{
get => (double)GetValue(ImageHeightProperty);
set => SetValue(ImageHeightProperty, value);
@@ -245,19 +359,19 @@ namespace HandyControl.Controls
set => SetValue(ImageScaleProperty, value);
}
- private string ScaleStr
+ internal string ScaleStr
{
get => (string)GetValue(ScaleStrProperty);
set => SetValue(ScaleStrProperty, value);
}
- private double ImageRotate
+ internal double ImageRotate
{
get => (double)GetValue(ImageRotateProperty);
set => SetValue(ImageRotateProperty, value);
}
- private bool ShowSmallImg
+ internal bool ShowSmallImg
{
get => (bool)GetValue(ShowSmallImgProperty);
set => SetValue(ShowSmallImgProperty, value);
@@ -282,7 +396,7 @@ namespace HandyControl.Controls
set
{
if (_showCloseButton == value) return;
- GridTop.BeginAnimation(OpacityProperty,
+ _gridTop.BeginAnimation(OpacityProperty,
value ? AnimationHelper.CreateAnimation(1, 100) : AnimationHelper.CreateAnimation(0, 400));
_showCloseButton = value;
}
@@ -297,7 +411,7 @@ namespace HandyControl.Controls
set
{
if (_showBorderBottom == value) return;
- BorderBottom.BeginAnimation(OpacityProperty,
+ _borderBottom?.BeginAnimation(OpacityProperty,
value ? AnimationHelper.CreateAnimation(1, 100) : AnimationHelper.CreateAnimation(0, 400));
_showBorderBottom = value;
}
@@ -359,7 +473,7 @@ namespace HandyControl.Controls
}
ImageMargin = new Thickness((ActualWidth - ImageWidth) / 2, (ActualHeight - ImageHeight) / 2, 0, 0);
- _imgActualScale = ImageScale;
+ _imgActualScale = 1;
_imgActualMargin = ImageMargin;
}
@@ -420,20 +534,16 @@ namespace HandyControl.Controls
}
}
- private void ButtonScreenChange_OnClick(object sender, RoutedEventArgs e) => WindowState = IsFullScreen ? WindowState.Maximized : WindowState.Normal;
+ //private void ButtonScreenChange_OnClick(object sender, RoutedEventArgs e) => WindowState = IsFullScreen ? WindowState.Maximized : WindowState.Normal;
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
- private void CanvasBack_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ private void GridTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- try
+ if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
- catch
- {
- // ignored
- }
}
protected override void OnMouseMove(MouseEventArgs e)
@@ -480,7 +590,7 @@ namespace HandyControl.Controls
}
else
{
- var right = Math.Abs(BorderMove.Width - CanvasSmallImg.ActualWidth + BorderMove.Margin.Left);
+ var right = Math.Abs(_borderMove.Width - _canvasSmallImg.ActualWidth + _borderMove.Margin.Left);
if (right < 0.001)
{
marginX = ActualWidth - ImageWidth;
@@ -497,7 +607,7 @@ namespace HandyControl.Controls
}
else
{
- var top = Math.Abs(BorderMove.Height - CanvasSmallImg.ActualHeight + BorderMove.Margin.Top);
+ var top = Math.Abs(_borderMove.Height - _canvasSmallImg.ActualHeight + _borderMove.Margin.Top);
if (top < 0.001)
{
marginY = ActualHeight - ImageHeight;
@@ -513,9 +623,8 @@ namespace HandyControl.Controls
{
base.OnMouseDoubleClick(e);
- if (e.GetPosition(GridTop).Y > GridTop.ActualHeight) return;
+ if (e.GetPosition(_gridTop).Y > _gridTop.ActualHeight) return;
IsFullScreen = !IsFullScreen;
- ButtonScreenChange_OnClick(null, null);
}
private void ImageBrowser_OnLoaded(object sender, RoutedEventArgs e)
@@ -532,7 +641,7 @@ namespace HandyControl.Controls
DragMove();
return;
}
- _imgMouseDownPoint = Mouse.GetPosition(CanvasMain);
+ _imgMouseDownPoint = Mouse.GetPosition(_canvasMain);
_imgMouseDownMargin = ImageMargin;
_imgIsMouseLeftButtonDown = true;
e.Handled = true;
@@ -553,7 +662,7 @@ namespace HandyControl.Controls
{
if (!_borderSmallIsLoaded)
{
- CanvasSmallImg.Background = new VisualBrush(ImageMain);
+ _canvasSmallImg.Background = new VisualBrush(_imageMain);
InitBorderSmall();
_borderSmallIsLoaded = true;
}
@@ -571,16 +680,16 @@ namespace HandyControl.Controls
///
private void InitBorderSmall()
{
- var scaleWindow = CanvasSmallImg.MaxWidth / CanvasSmallImg.MaxHeight;
+ var scaleWindow = _canvasSmallImg.MaxWidth / _canvasSmallImg.MaxHeight;
if (_imgWidHeiScale > scaleWindow)
{
- CanvasSmallImg.Width = CanvasSmallImg.MaxWidth;
- CanvasSmallImg.Height = CanvasSmallImg.Width / _imgWidHeiScale;
+ _canvasSmallImg.Width = _canvasSmallImg.MaxWidth;
+ _canvasSmallImg.Height = _canvasSmallImg.Width / _imgWidHeiScale;
}
else
{
- CanvasSmallImg.Width = CanvasSmallImg.MaxHeight * _imgWidHeiScale;
- CanvasSmallImg.Height = CanvasSmallImg.MaxHeight;
+ _canvasSmallImg.Width = _canvasSmallImg.MaxHeight * _imgWidHeiScale;
+ _canvasSmallImg.Height = _canvasSmallImg.MaxHeight;
}
}
@@ -594,21 +703,21 @@ namespace HandyControl.Controls
var widthMin = Math.Min(ImageWidth, ActualWidth);
var heightMin = Math.Min(ImageHeight, ActualHeight);
- BorderMove.Width = widthMin / ImageWidth * CanvasSmallImg.Width;
- BorderMove.Height = heightMin / ImageHeight * CanvasSmallImg.Height;
+ _borderMove.Width = widthMin / ImageWidth * _canvasSmallImg.Width;
+ _borderMove.Height = heightMin / ImageHeight * _canvasSmallImg.Height;
- var marginX = -ImageMargin.Left / ImageWidth * CanvasSmallImg.Width;
- var marginY = -ImageMargin.Top / ImageHeight * CanvasSmallImg.Height;
+ var marginX = -ImageMargin.Left / ImageWidth * _canvasSmallImg.Width;
+ var marginY = -ImageMargin.Top / ImageHeight * _canvasSmallImg.Height;
- var marginXMax = CanvasSmallImg.Width - BorderMove.Width;
- var marginYMax = CanvasSmallImg.Height - BorderMove.Height;
+ var marginXMax = _canvasSmallImg.Width - _borderMove.Width;
+ var marginYMax = _canvasSmallImg.Height - _borderMove.Height;
marginX = Math.Max(0, marginX);
marginX = Math.Min(marginXMax, marginX);
marginY = Math.Max(0, marginY);
marginY = Math.Min(marginYMax, marginY);
- BorderMove.Margin = new Thickness(marginX, marginY, 0, 0);
+ _borderMove.Margin = new Thickness(marginX, marginY, 0, 0);
}
///
@@ -627,7 +736,7 @@ namespace HandyControl.Controls
ImageScale = tempScale;
- var posCanvas = Mouse.GetPosition(CanvasMain);
+ var posCanvas = Mouse.GetPosition(_canvasMain);
var posImg = new Point(posCanvas.X - _imgActualMargin.Left, posCanvas.Y - _imgActualMargin.Top);
var marginX = .5 * _scaleInternalWidth;
@@ -665,15 +774,15 @@ namespace HandyControl.Controls
var subX = ImageWidth - ActualWidth;
var subY = ImageHeight - ActualHeight;
- var right = Math.Abs(BorderMove.Width - CanvasSmallImg.ActualWidth + BorderMove.Margin.Left);
- var top = Math.Abs(BorderMove.Height - CanvasSmallImg.ActualHeight + BorderMove.Margin.Top);
+ var right = Math.Abs(_borderMove.Width - _canvasSmallImg.ActualWidth + _borderMove.Margin.Left);
+ var top = Math.Abs(_borderMove.Height - _canvasSmallImg.ActualHeight + _borderMove.Margin.Top);
if (Math.Abs(ImageMargin.Left) < 0.001 || right < 0.001)
{
- marginActualX = _imgActualMargin.Left + BorderMove.Margin.Left / (CanvasSmallImg.ActualWidth - BorderMove.Width) * _scaleInternalWidth;
+ marginActualX = _imgActualMargin.Left + _borderMove.Margin.Left / (_canvasSmallImg.ActualWidth - _borderMove.Width) * _scaleInternalWidth;
}
if (Math.Abs(ImageMargin.Top) < 0.001 || top < 0.001)
{
- marginActualY = _imgActualMargin.Top + BorderMove.Margin.Top / (CanvasSmallImg.ActualHeight - BorderMove.Height) * _scaleInternalHeight;
+ marginActualY = _imgActualMargin.Top + _borderMove.Margin.Top / (_canvasSmallImg.ActualHeight - _borderMove.Height) * _scaleInternalHeight;
}
if (subX < 0.001)
{
@@ -716,7 +825,7 @@ namespace HandyControl.Controls
///
private void MoveImg()
{
- _imgCurrentPoint = Mouse.GetPosition(CanvasMain);
+ _imgCurrentPoint = Mouse.GetPosition(_canvasMain);
ShowCloseButton = _imgCurrentPoint.Y < 200;
ShowBorderBottom = _imgCurrentPoint.Y > ActualHeight - 200;
@@ -769,7 +878,7 @@ namespace HandyControl.Controls
{
if (_imgSmallIsMouseLeftButtonDown)
{
- _imgSmallCurrentPoint = Mouse.GetPosition(CanvasSmallImg);
+ _imgSmallCurrentPoint = Mouse.GetPosition(_canvasSmallImg);
var subX = _imgSmallCurrentPoint.X - _imgSmallMouseDownPoint.X;
var subY = _imgSmallCurrentPoint.Y - _imgSmallMouseDownPoint.Y;
@@ -779,9 +888,9 @@ namespace HandyControl.Controls
{
marginX = 0;
}
- else if (marginX + BorderMove.Width >= CanvasSmallImg.ActualWidth)
+ else if (marginX + _borderMove.Width >= _canvasSmallImg.ActualWidth)
{
- marginX = CanvasSmallImg.ActualWidth - BorderMove.Width;
+ marginX = _canvasSmallImg.ActualWidth - _borderMove.Width;
}
var marginY = _imgSmallMouseDownMargin.Top + subY;
@@ -789,22 +898,22 @@ namespace HandyControl.Controls
{
marginY = 0;
}
- else if (marginY + BorderMove.Height >= CanvasSmallImg.ActualHeight)
+ else if (marginY + _borderMove.Height >= _canvasSmallImg.ActualHeight)
{
- marginY = CanvasSmallImg.ActualHeight - BorderMove.Height;
+ marginY = _canvasSmallImg.ActualHeight - _borderMove.Height;
}
- BorderMove.Margin = new Thickness(marginX, marginY, 0, 0);
+ _borderMove.Margin = new Thickness(marginX, marginY, 0, 0);
var marginActualX = (ActualWidth - ImageWidth) / 2;
var marginActualY = (ActualHeight - ImageHeight) / 2;
if (_canMoveX)
{
- marginActualX = -marginX / CanvasSmallImg.ActualWidth * ImageWidth;
+ marginActualX = -marginX / _canvasSmallImg.ActualWidth * ImageWidth;
}
if (_canMoveY)
{
- marginActualY = -marginY / CanvasSmallImg.ActualHeight * ImageHeight;
+ marginActualY = -marginY / _canvasSmallImg.ActualHeight * ImageHeight;
}
ImageMargin = new Thickness(marginActualX, marginActualY, 0, 0);
@@ -814,8 +923,8 @@ namespace HandyControl.Controls
private void CanvasSmallImg_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
- _imgSmallMouseDownPoint = Mouse.GetPosition(CanvasSmallImg);
- _imgSmallMouseDownMargin = BorderMove.Margin;
+ _imgSmallMouseDownPoint = Mouse.GetPosition(_canvasSmallImg);
+ _imgSmallMouseDownMargin = _borderMove.Margin;
_imgSmallIsMouseLeftButtonDown = true;
e.Handled = true;
}
diff --git a/HandyControl/Controls/Window/ImageBrowser.xaml b/HandyControl/Controls/Window/ImageBrowser.xaml
deleted file mode 100644
index b0e0ab84..00000000
--- a/HandyControl/Controls/Window/ImageBrowser.xaml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj
index 8e2d91c0..07607d04 100644
--- a/HandyControl/HandyControl.csproj
+++ b/HandyControl/HandyControl.csproj
@@ -47,6 +47,7 @@
+
ColorPicker.xaml
@@ -54,13 +55,6 @@
-
-
- InfoNumericUpDown.xaml
-
-
- InfoTextBox.xaml
-
@@ -74,9 +68,7 @@
-
- ImageBrowser.xaml
-
+
@@ -153,26 +145,11 @@
-
-
-
Designer
MSBuild:Compile
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
@@ -213,6 +190,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -337,6 +318,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/HandyControl/Interactivity/ControlCommands.cs b/HandyControl/Interactivity/ControlCommands.cs
index 2bb1b1cc..50c70f73 100644
--- a/HandyControl/Interactivity/ControlCommands.cs
+++ b/HandyControl/Interactivity/ControlCommands.cs
@@ -3,10 +3,45 @@
namespace HandyControl.Interactivity
{
///
- /// 控件库使用的所有命令
+ /// 控件库使用的所有命令(为了统一,不使用wpf自带的命令)
///
public static class ControlCommands
{
+ ///
+ /// 右转
+ ///
+ public static RoutedCommand RotateRight { get; } = new RoutedCommand("RotateRight", typeof(ControlCommands));
+
+ ///
+ /// 左转
+ ///
+ public static RoutedCommand RotateLeft { get; } = new RoutedCommand("RotateLeft", typeof(ControlCommands));
+
+ ///
+ /// 小
+ ///
+ public static RoutedCommand Reduce { get; } = new RoutedCommand("Reduce", typeof(ControlCommands));
+
+ ///
+ /// 大
+ ///
+ public static RoutedCommand Enlarge { get; } = new RoutedCommand("Enlarge", typeof(ControlCommands));
+
+ ///
+ /// 还原
+ ///
+ public static RoutedCommand Restore { get; } = new RoutedCommand("Restore", typeof(ControlCommands));
+
+ ///
+ /// 打开
+ ///
+ public static RoutedCommand Open { get; } = new RoutedCommand("Open", typeof(ControlCommands));
+
+ ///
+ /// 保存
+ ///
+ public static RoutedCommand Save { get; } = new RoutedCommand("Save", typeof(ControlCommands));
+
///
/// 选中
///
diff --git a/HandyControl/Properties/AssemblyInfo.cs b/HandyControl/Properties/AssemblyInfo.cs
index 59ab3326..8399a9fa 100644
--- a/HandyControl/Properties/AssemblyInfo.cs
+++ b/HandyControl/Properties/AssemblyInfo.cs
@@ -10,5 +10,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.3.2.2")]
-[assembly: AssemblyFileVersion("1.3.2.2")]
+[assembly: AssemblyVersion("1.3.3")]
+[assembly: AssemblyFileVersion("1.3.3")]
diff --git a/HandyControl/Resources/colorPickerBack.png b/HandyControl/Resources/colorPickerBack.png
deleted file mode 100644
index 770865e9..00000000
Binary files a/HandyControl/Resources/colorPickerBack.png and /dev/null differ
diff --git a/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
index d4eb6ca9..ac84f132 100644
--- a/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
@@ -512,7 +512,6 @@
-
diff --git a/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml b/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
index 48ef45a7..be2295c7 100644
--- a/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
@@ -34,7 +34,6 @@
-
diff --git a/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml b/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
new file mode 100644
index 00000000..42a61e02
--- /dev/null
+++ b/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
index bc102f40..7e9841f8 100644
--- a/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
@@ -13,7 +13,6 @@
-
diff --git a/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
index e7d40ae3..492c7634 100644
--- a/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
@@ -36,7 +36,6 @@
-
diff --git a/HandyControl/Themes/Styles/Base/TimePickerBaseStyle.xaml b/HandyControl/Themes/Styles/Base/TimePickerBaseStyle.xaml
index 0249997e..d98952de 100644
--- a/HandyControl/Themes/Styles/Base/TimePickerBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/TimePickerBaseStyle.xaml
@@ -12,7 +12,6 @@
-
diff --git a/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
index 33e3c5d8..01f0498b 100644
--- a/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
@@ -14,9 +14,6 @@
-
diff --git a/HandyControl/Themes/Styles/Border.xaml b/HandyControl/Themes/Styles/Border.xaml
index 174be80e..cb6ea280 100644
--- a/HandyControl/Themes/Styles/Border.xaml
+++ b/HandyControl/Themes/Styles/Border.xaml
@@ -9,13 +9,13 @@
-
-
+
+
\ No newline at end of file
diff --git a/HandyControlDemo/Data/MessageToken.cs b/HandyControlDemo/Data/MessageToken.cs
index 6be64883..185d6790 100644
--- a/HandyControlDemo/Data/MessageToken.cs
+++ b/HandyControlDemo/Data/MessageToken.cs
@@ -28,6 +28,8 @@
public static readonly string CirclePanelDemoCtl = nameof(CirclePanelDemoCtl);
+ public static readonly string NumericUpDownDemoCtl = nameof(NumericUpDownDemoCtl);
+
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
diff --git a/HandyControlDemo/Data/MessageToken.tt b/HandyControlDemo/Data/MessageToken.tt
index cc7d34cd..d7a2467e 100644
--- a/HandyControlDemo/Data/MessageToken.tt
+++ b/HandyControlDemo/Data/MessageToken.tt
@@ -16,7 +16,8 @@ var controlList = new List
"StepBarDemoCtl",
"ClockDemoCtl",
"TimePickerDemoCtl",
- "CirclePanelDemoCtl"
+ "CirclePanelDemoCtl",
+ "NumericUpDownDemoCtl"
};
var styleList = new List
{
diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj
index 8f28510d..8095c7b9 100644
--- a/HandyControlDemo/HandyControlDemo.csproj
+++ b/HandyControlDemo/HandyControlDemo.csproj
@@ -106,6 +106,9 @@
LoadingDemoCtl.xaml
+
+ NumericUpDownDemoCtl.xaml
+
StepBarDemoCtl.xaml
@@ -248,6 +251,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/HandyControlDemo/Properties/AssemblyInfo.cs b/HandyControlDemo/Properties/AssemblyInfo.cs
index 1e33adb5..db61bf36 100644
--- a/HandyControlDemo/Properties/AssemblyInfo.cs
+++ b/HandyControlDemo/Properties/AssemblyInfo.cs
@@ -12,5 +12,5 @@ using System.Windows;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
-[assembly: AssemblyVersion("1.3.2.2")]
-[assembly: AssemblyFileVersion("1.3.2.2")]
+[assembly: AssemblyVersion("1.3.3")]
+[assembly: AssemblyFileVersion("1.3.3")]
diff --git a/HandyControlDemo/Properties/Langs/Lang.Designer.cs b/HandyControlDemo/Properties/Langs/Lang.Designer.cs
index 91f27645..a106e2e9 100644
--- a/HandyControlDemo/Properties/Langs/Lang.Designer.cs
+++ b/HandyControlDemo/Properties/Langs/Lang.Designer.cs
@@ -330,6 +330,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 数值选择控件 的本地化字符串。
+ ///
+ public static string NumericUpDown {
+ get {
+ return ResourceManager.GetString("NumericUpDown", resourceCulture);
+ }
+ }
+
///
/// 查找类似 点击打开图片浏览器 的本地化字符串。
///
diff --git a/HandyControlDemo/Properties/Langs/Lang.en.resx b/HandyControlDemo/Properties/Langs/Lang.en.resx
index 741cf0ce..456eadb3 100644
--- a/HandyControlDemo/Properties/Langs/Lang.en.resx
+++ b/HandyControlDemo/Properties/Langs/Lang.en.resx
@@ -282,4 +282,7 @@
ComboBox
+
+ NumericUpDown
+
\ No newline at end of file
diff --git a/HandyControlDemo/Properties/Langs/Lang.resx b/HandyControlDemo/Properties/Langs/Lang.resx
index b5a6042d..4956b5ff 100644
--- a/HandyControlDemo/Properties/Langs/Lang.resx
+++ b/HandyControlDemo/Properties/Langs/Lang.resx
@@ -262,4 +262,7 @@
组合框
+
+ 数值选择控件
+
\ No newline at end of file
diff --git a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml
new file mode 100644
index 00000000..1e48e96e
--- /dev/null
+++ b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
new file mode 100644
index 00000000..e09320bb
--- /dev/null
+++ b/HandyControlDemo/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
@@ -0,0 +1,11 @@
+// ReSharper disable once CheckNamespace
+namespace HandyControlDemo.UserControl
+{
+ public partial class NumericUpDownDemoCtl
+ {
+ public NumericUpDownDemoCtl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
index f2ef5904..cc126180 100644
--- a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
+++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
@@ -25,11 +25,12 @@
-
+
+
@@ -47,40 +48,4 @@
-
\ No newline at end of file