From 042c6bd4e48cf4369630a034b46673e617eaf6cd Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Mon, 12 Nov 2018 19:22:37 +0800
Subject: [PATCH] Optimized performance
---
HandyControl/Controls/AnimationPath.cs | 3 ++-
HandyControl/Controls/Attach/EdgeElement.cs | 2 +-
HandyControl/Controls/Attach/InfoElement.cs | 2 +-
.../Controls/Attach/PasswordBoxMonitor.cs | 3 ++-
.../Controls/Attach/StatusSwitchElement.cs | 2 +-
HandyControl/Controls/Carousel.cs | 6 ++---
HandyControl/Controls/CirclePanel.cs | 5 +++--
HandyControl/Controls/CircleProgressBar.cs | 8 +++----
HandyControl/Controls/Clock/Clock.cs | 2 +-
HandyControl/Controls/Growl.cs | 4 ++--
HandyControl/Controls/ImageViewer.cs | 16 +++++++-------
HandyControl/Controls/Input/NumericUpDown.cs | 8 +++----
HandyControl/Controls/Input/TextBox.cs | 4 ++--
HandyControl/Controls/Input/TimePicker.cs | 8 +++----
HandyControl/Controls/Loading/LoadingBase.cs | 4 ++--
HandyControl/Controls/ScrollViewer.cs | 6 ++---
HandyControl/Controls/Slider/PreviewSlider.cs | 2 +-
.../Controls/TabControl/TabControl.cs | 8 +++----
HandyControl/Controls/TabControl/TabPanel.cs | 2 +-
HandyControl/Controls/TimeBar/TimeBar.cs | 2 +-
.../Controls/TransitioningContentControl.cs | 3 ++-
HandyControl/Controls/Window/ImageBrowser.cs | 2 +-
HandyControl/Controls/Window/PopupWindow.cs | 6 ++---
.../Controls/Window/WindowBorderless.cs | 6 ++---
HandyControl/Data/BooleanBoxes.cs | 13 -----------
HandyControl/Data/GrowlInfo.cs | 1 -
HandyControl/Data/ValueBoxes.cs | 22 +++++++++++++++++++
HandyControl/HandyControl.csproj | 2 +-
HandyControl/Interactivity/EventToCommand.cs | 5 +++--
.../ExtendedVisualStateManager.cs | 5 +++--
.../Interactivity/FluidMoveBehavior.cs | 4 ++--
.../Interactivity/FluidMoveBehaviorBase.cs | 2 +-
.../Interactivity/MouseDragElementBehavior.cs | 7 +++---
.../Tools/MouseDragElementBehaviorEx.cs | 3 ++-
34 files changed, 97 insertions(+), 81 deletions(-)
delete mode 100644 HandyControl/Data/BooleanBoxes.cs
create mode 100644 HandyControl/Data/ValueBoxes.cs
diff --git a/HandyControl/Controls/AnimationPath.cs b/HandyControl/Controls/AnimationPath.cs
index ce23dbbc..ff126038 100644
--- a/HandyControl/Controls/AnimationPath.cs
+++ b/HandyControl/Controls/AnimationPath.cs
@@ -4,6 +4,7 @@ using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
+using HandyControl.Data;
namespace HandyControl.Controls
{
@@ -46,7 +47,7 @@ namespace HandyControl.Controls
/// 路径长度
///
public static readonly DependencyProperty PathLengthProperty = DependencyProperty.Register(
- "PathLength", typeof(double), typeof(AnimationPath), new FrameworkPropertyMetadata(default(double),
+ "PathLength", typeof(double), typeof(AnimationPath), new FrameworkPropertyMetadata(ValueBoxes.Double0Box,
OnPropertiesChanged));
///
diff --git a/HandyControl/Controls/Attach/EdgeElement.cs b/HandyControl/Controls/Attach/EdgeElement.cs
index d674641b..60c2a552 100644
--- a/HandyControl/Controls/Attach/EdgeElement.cs
+++ b/HandyControl/Controls/Attach/EdgeElement.cs
@@ -35,7 +35,7 @@ namespace HandyControl.Controls
public static object GetBottomContent(DependencyObject element) => element.GetValue(BottomContentProperty);
public static readonly DependencyProperty ShowEdgeContentProperty = DependencyProperty.RegisterAttached(
- "ShowEdgeContent", typeof(bool), typeof(EdgeElement), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowEdgeContent", typeof(bool), typeof(EdgeElement), new PropertyMetadata(ValueBoxes.FalseBox));
public static void SetShowEdgeContent(DependencyObject element, bool value) => element.SetValue(ShowEdgeContentProperty, value);
diff --git a/HandyControl/Controls/Attach/InfoElement.cs b/HandyControl/Controls/Attach/InfoElement.cs
index f256fe2e..088aa1f3 100644
--- a/HandyControl/Controls/Attach/InfoElement.cs
+++ b/HandyControl/Controls/Attach/InfoElement.cs
@@ -30,7 +30,7 @@ namespace HandyControl.Controls
/// 是否必填
///
public static readonly DependencyProperty NecessaryProperty = DependencyProperty.RegisterAttached(
- "Necessary", typeof(bool), typeof(InfoElement), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.Inherits));
+ "Necessary", typeof(bool), typeof(InfoElement), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.Inherits));
public static void SetNecessary(DependencyObject element, bool value) => element.SetValue(NecessaryProperty, value);
diff --git a/HandyControl/Controls/Attach/PasswordBoxMonitor.cs b/HandyControl/Controls/Attach/PasswordBoxMonitor.cs
index e1d3d6e4..9c469155 100644
--- a/HandyControl/Controls/Attach/PasswordBoxMonitor.cs
+++ b/HandyControl/Controls/Attach/PasswordBoxMonitor.cs
@@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
+using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
@@ -20,7 +21,7 @@ namespace HandyControl.Controls
/// 是否监测
///
public static readonly DependencyProperty IsMonitoringProperty = DependencyProperty.RegisterAttached(
- "IsMonitoring", typeof(bool), typeof(PasswordBoxMonitor), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.Inherits, OnIsMonitoringChanged));
+ "IsMonitoring", typeof(bool), typeof(PasswordBoxMonitor), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.Inherits, OnIsMonitoringChanged));
private static void OnIsMonitoringChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
diff --git a/HandyControl/Controls/Attach/StatusSwitchElement.cs b/HandyControl/Controls/Attach/StatusSwitchElement.cs
index ab822d2d..b1e8e74a 100644
--- a/HandyControl/Controls/Attach/StatusSwitchElement.cs
+++ b/HandyControl/Controls/Attach/StatusSwitchElement.cs
@@ -20,7 +20,7 @@ namespace HandyControl.Controls
/// 是否隐藏元素
///
public static readonly DependencyProperty HiddenElementProperty = DependencyProperty.RegisterAttached(
- "HiddenElement", typeof(bool), typeof(StatusSwitchElement), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "HiddenElement", typeof(bool), typeof(StatusSwitchElement), new PropertyMetadata(ValueBoxes.FalseBox));
public static void SetHiddenElement(DependencyObject element, bool value) => element.SetValue(HiddenElementProperty, value);
diff --git a/HandyControl/Controls/Carousel.cs b/HandyControl/Controls/Carousel.cs
index 3d2e7226..6fc3ed06 100644
--- a/HandyControl/Controls/Carousel.cs
+++ b/HandyControl/Controls/Carousel.cs
@@ -80,7 +80,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty AutoRunProperty = DependencyProperty.Register(
- "AutoRun", typeof(bool), typeof(Carousel), new PropertyMetadata(BooleanBoxes.FalseBox, (o, args) =>
+ "AutoRun", typeof(bool), typeof(Carousel), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) =>
{
var ctl = (Carousel)o;
ctl.TimerSwitch((bool)args.NewValue);
@@ -90,7 +90,7 @@ namespace HandyControl.Controls
"Interval", typeof(TimeSpan), typeof(Carousel), new PropertyMetadata(TimeSpan.FromSeconds(2)));
public static readonly DependencyProperty ExtendWidthProperty = DependencyProperty.Register(
- "ExtendWidth", typeof(double), typeof(Carousel), new PropertyMetadata(default(double)));
+ "ExtendWidth", typeof(double), typeof(Carousel), new PropertyMetadata(ValueBoxes.Double0Box));
public double ExtendWidth
{
@@ -99,7 +99,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty IsCenterProperty = DependencyProperty.Register(
- "IsCenter", typeof(bool), typeof(Carousel), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsCenter", typeof(bool), typeof(Carousel), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsCenter
{
diff --git a/HandyControl/Controls/CirclePanel.cs b/HandyControl/Controls/CirclePanel.cs
index c90fb7ae..1eebdf43 100644
--- a/HandyControl/Controls/CirclePanel.cs
+++ b/HandyControl/Controls/CirclePanel.cs
@@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
+using HandyControl.Data;
namespace HandyControl.Controls
{
@@ -17,7 +18,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty KeepVerticalProperty = DependencyProperty.Register(
- "KeepVertical", typeof(bool), typeof(CirclePanel), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.AffectsMeasure));
+ "KeepVertical", typeof(bool), typeof(CirclePanel), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.AffectsMeasure));
public bool KeepVertical
{
@@ -26,7 +27,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty OffsetAngleProperty = DependencyProperty.Register(
- "OffsetAngle", typeof(double), typeof(CirclePanel), new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsMeasure));
+ "OffsetAngle", typeof(double), typeof(CirclePanel), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsMeasure));
public double OffsetAngle
{
diff --git a/HandyControl/Controls/CircleProgressBar.cs b/HandyControl/Controls/CircleProgressBar.cs
index 261f8b56..9da8314b 100644
--- a/HandyControl/Controls/CircleProgressBar.cs
+++ b/HandyControl/Controls/CircleProgressBar.cs
@@ -11,18 +11,18 @@ namespace HandyControl.Controls
private const string IndicatorTemplateName = "PART_Indicator";
public static readonly DependencyProperty ArcThicknessProperty = DependencyProperty.Register(
- "ArcThickness", typeof(double), typeof(CircleProgressBar), new PropertyMetadata(default(double)));
+ "ArcThickness", typeof(double), typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.Double0Box));
public static readonly DependencyProperty ShowTextProperty = DependencyProperty.Register(
- "ShowText", typeof(bool), typeof(CircleProgressBar), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "ShowText", typeof(bool), typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.TrueBox));
private Arc _indicator;
static CircleProgressBar()
{
FocusableProperty.OverrideMetadata(typeof(CircleProgressBar),
- new FrameworkPropertyMetadata(BooleanBoxes.FalseBox));
- MaximumProperty.OverrideMetadata(typeof(CircleProgressBar), new FrameworkPropertyMetadata(100.0));
+ new FrameworkPropertyMetadata(ValueBoxes.FalseBox));
+ MaximumProperty.OverrideMetadata(typeof(CircleProgressBar), new PropertyMetadata(ValueBoxes.Double100Box));
}
public bool ShowText
diff --git a/HandyControl/Controls/Clock/Clock.cs b/HandyControl/Controls/Clock/Clock.cs
index 9a474966..647c5d79 100644
--- a/HandyControl/Controls/Clock/Clock.cs
+++ b/HandyControl/Controls/Clock/Clock.cs
@@ -152,7 +152,7 @@ namespace HandyControl.Controls
}
internal static readonly DependencyProperty ShowConfirmButtonProperty = DependencyProperty.Register(
- "ShowConfirmButton", typeof(bool), typeof(Clock), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowConfirmButton", typeof(bool), typeof(Clock), new PropertyMetadata(ValueBoxes.FalseBox));
internal bool ShowConfirmButton
{
diff --git a/HandyControl/Controls/Growl.cs b/HandyControl/Controls/Growl.cs
index 51be50ce..b5002547 100644
--- a/HandyControl/Controls/Growl.cs
+++ b/HandyControl/Controls/Growl.cs
@@ -103,7 +103,7 @@ namespace HandyControl.Controls
"ConfirmStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
public static readonly DependencyProperty ShowDateTimeProperty = DependencyProperty.Register(
- "ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "ShowDateTime", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.TrueBox));
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
"Message", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
@@ -121,7 +121,7 @@ namespace HandyControl.Controls
"Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType)));
public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached(
- "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(BooleanBoxes.FalseBox, (o, args) =>
+ "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) =>
{
if (o is Panel panel)
{
diff --git a/HandyControl/Controls/ImageViewer.cs b/HandyControl/Controls/ImageViewer.cs
index 5561d63f..7b6c237c 100644
--- a/HandyControl/Controls/ImageViewer.cs
+++ b/HandyControl/Controls/ImageViewer.cs
@@ -213,7 +213,7 @@ namespace HandyControl.Controls
#region Properties
public static readonly DependencyProperty ShowImgMapProperty = DependencyProperty.Register(
- "ShowImgMap", typeof(bool), typeof(ImageViewer), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowImgMap", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource", typeof(BitmapFrame), typeof(ImageViewer), new PropertyMetadata(default(BitmapFrame)));
@@ -228,13 +228,13 @@ namespace HandyControl.Controls
/// 是否显示全屏按钮
///
internal static readonly DependencyProperty ShowFullScreenButtonProperty = DependencyProperty.Register(
- "ShowFullScreenButton", typeof(bool), typeof(ImageViewer), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowFullScreenButton", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 关闭按钮是否显示中
///
internal static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.Register(
- "ShowCloseButton", typeof(bool), typeof(ImageViewer), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowCloseButton", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
internal static readonly DependencyProperty ImageContentProperty = DependencyProperty.Register(
"ImageContent", typeof(object), typeof(ImageViewer), new PropertyMetadata(default(object)));
@@ -243,22 +243,22 @@ namespace HandyControl.Controls
"ImageMargin", typeof(Thickness), typeof(ImageViewer), new PropertyMetadata(default(Thickness)));
internal static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
- "ImageWidth", typeof(double), typeof(ImageViewer), new PropertyMetadata(default(double)));
+ "ImageWidth", typeof(double), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.Double0Box));
internal static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
- "ImageHeight", typeof(double), typeof(ImageViewer), new PropertyMetadata(default(double)));
+ "ImageHeight", typeof(double), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.Double0Box));
internal static readonly DependencyProperty ImageScaleProperty = DependencyProperty.Register(
- "ImageScale", typeof(double), typeof(ImageViewer), new PropertyMetadata(1.0, OnImageScaleChanged));
+ "ImageScale", typeof(double), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.Double1Box, OnImageScaleChanged));
internal static readonly DependencyProperty ScaleStrProperty = DependencyProperty.Register(
"ScaleStr", typeof(string), typeof(ImageViewer), new PropertyMetadata("100%"));
internal static readonly DependencyProperty ImageRotateProperty = DependencyProperty.Register(
- "ImageRotate", typeof(double), typeof(ImageViewer), new PropertyMetadata(default(double)));
+ "ImageRotate", typeof(double), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.Double0Box));
internal static readonly DependencyProperty ShowSmallImgInternalProperty = DependencyProperty.Register(
- "ShowSmallImgInternal", typeof(bool), typeof(ImageViewer), new PropertyMetadata(false));
+ "ShowSmallImgInternal", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowImgMap
{
diff --git a/HandyControl/Controls/Input/NumericUpDown.cs b/HandyControl/Controls/Input/NumericUpDown.cs
index c76d411d..78b902e0 100644
--- a/HandyControl/Controls/Input/NumericUpDown.cs
+++ b/HandyControl/Controls/Input/NumericUpDown.cs
@@ -271,7 +271,7 @@ namespace HandyControl.Controls
/// 指示每单击一下按钮时增加或减少的数量
///
public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register(
- "Increment", typeof(double), typeof(NumericUpDown), new PropertyMetadata(1.0));
+ "Increment", typeof(double), typeof(NumericUpDown), new PropertyMetadata(ValueBoxes.Double1Box));
///
/// 指示每单击一下按钮时增加或减少的数量
@@ -301,7 +301,7 @@ namespace HandyControl.Controls
/// 是否显示上下调值按钮
///
internal static readonly DependencyProperty ShowUpDownButtonProperty = DependencyProperty.Register(
- "ShowUpDownButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "ShowUpDownButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(ValueBoxes.TrueBox));
///
/// 是否显示上下调值按钮
@@ -316,7 +316,7 @@ namespace HandyControl.Controls
/// 数据是否错误
///
public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
- "IsError", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsError", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsError
{
@@ -352,7 +352,7 @@ namespace HandyControl.Controls
/// 是否显示清除按钮
///
public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
- "ShowClearButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowClearButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowClearButton
{
diff --git a/HandyControl/Controls/Input/TextBox.cs b/HandyControl/Controls/Input/TextBox.cs
index aa7b32ab..815e6ade 100644
--- a/HandyControl/Controls/Input/TextBox.cs
+++ b/HandyControl/Controls/Input/TextBox.cs
@@ -32,7 +32,7 @@ namespace HandyControl.Controls
/// 数据是否错误
///
public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
- "IsError", typeof(bool), typeof(TextBox), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsError", typeof(bool), typeof(TextBox), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsError
{
@@ -68,7 +68,7 @@ namespace HandyControl.Controls
/// 是否显示清除按钮
///
public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
- "ShowClearButton", typeof(bool), typeof(TextBox), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowClearButton", typeof(bool), typeof(TextBox), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowClearButton
{
diff --git a/HandyControl/Controls/Input/TimePicker.cs b/HandyControl/Controls/Input/TimePicker.cs
index ab5be77f..47669f96 100644
--- a/HandyControl/Controls/Input/TimePicker.cs
+++ b/HandyControl/Controls/Input/TimePicker.cs
@@ -471,7 +471,7 @@ namespace HandyControl.Controls
{
if (!IsDropDownOpen)
{
- SetCurrentValue(IsDropDownOpenProperty, BooleanBoxes.TrueBox);
+ SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.TrueBox);
}
_clock?.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
@@ -483,7 +483,7 @@ namespace HandyControl.Controls
{
if (IsDropDownOpen)
{
- SetCurrentValue(IsDropDownOpenProperty, BooleanBoxes.FalseBox);
+ SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.FalseBox);
}
if (_clock.IsKeyboardFocusWithin)
@@ -500,7 +500,7 @@ namespace HandyControl.Controls
{
if (IsDropDownOpen)
{
- SetCurrentValue(IsDropDownOpenProperty, BooleanBoxes.FalseBox);
+ SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.FalseBox);
}
else
{
@@ -511,7 +511,7 @@ namespace HandyControl.Controls
else
{
SetSelectedTime();
- SetCurrentValue(IsDropDownOpenProperty, BooleanBoxes.TrueBox);
+ SetCurrentValue(IsDropDownOpenProperty, ValueBoxes.TrueBox);
}
}
}
diff --git a/HandyControl/Controls/Loading/LoadingBase.cs b/HandyControl/Controls/Loading/LoadingBase.cs
index 20f38e07..9c8d0455 100644
--- a/HandyControl/Controls/Loading/LoadingBase.cs
+++ b/HandyControl/Controls/Loading/LoadingBase.cs
@@ -14,7 +14,7 @@ namespace HandyControl.Controls
protected Storyboard Storyboard;
public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register(
- "IsRunning", typeof(bool), typeof(LoadingBase), new PropertyMetadata(BooleanBoxes.TrueBox, (o, args) =>
+ "IsRunning", typeof(bool), typeof(LoadingBase), new PropertyMetadata(ValueBoxes.TrueBox, (o, args) =>
{
var ctl = (LoadingBase) o;
var v = (bool) args.NewValue;
@@ -48,7 +48,7 @@ namespace HandyControl.Controls
public static readonly DependencyProperty DotBorderThicknessProperty = DependencyProperty.Register(
"DotBorderThickness", typeof(double), typeof(LoadingBase),
- new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsRender));
+ new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DotDiameterProperty = DependencyProperty.Register(
"DotDiameter", typeof(double), typeof(LoadingBase),
diff --git a/HandyControl/Controls/ScrollViewer.cs b/HandyControl/Controls/ScrollViewer.cs
index 779cc80e..b024d360 100644
--- a/HandyControl/Controls/ScrollViewer.cs
+++ b/HandyControl/Controls/ScrollViewer.cs
@@ -36,7 +36,7 @@ namespace HandyControl.Controls
/// 是否响应鼠标滚轮操作
///
public static readonly DependencyProperty CanMouseWheelProperty = DependencyProperty.Register(
- "CanMouseWheel", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "CanMouseWheel", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(ValueBoxes.TrueBox));
///
/// 是否响应鼠标滚轮操作
@@ -120,7 +120,7 @@ namespace HandyControl.Controls
/// 是否支持惯性
///
public static readonly DependencyProperty IsEnableInertiaProperty = DependencyProperty.RegisterAttached(
- "IsEnableInertia", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsEnableInertia", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(ValueBoxes.FalseBox));
public static void SetIsEnableInertia(DependencyObject element, bool value)
{
@@ -145,7 +145,7 @@ namespace HandyControl.Controls
/// 控件是否可以穿透点击
///
public static readonly DependencyProperty IsPenetratingProperty = DependencyProperty.RegisterAttached(
- "IsPenetrating", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsPenetrating", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 控件是否可以穿透点击
diff --git a/HandyControl/Controls/Slider/PreviewSlider.cs b/HandyControl/Controls/Slider/PreviewSlider.cs
index f4cdf158..fd27b38e 100644
--- a/HandyControl/Controls/Slider/PreviewSlider.cs
+++ b/HandyControl/Controls/Slider/PreviewSlider.cs
@@ -39,7 +39,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty PreviewPositionProperty = DependencyProperty.Register(
- "PreviewPosition", typeof(double), typeof(PreviewSlider), new PropertyMetadata(default(double)));
+ "PreviewPosition", typeof(double), typeof(PreviewSlider), new PropertyMetadata(ValueBoxes.Double0Box));
public double PreviewPosition
{
diff --git a/HandyControl/Controls/TabControl/TabControl.cs b/HandyControl/Controls/TabControl/TabControl.cs
index 39bf124e..97a12f73 100644
--- a/HandyControl/Controls/TabControl/TabControl.cs
+++ b/HandyControl/Controls/TabControl/TabControl.cs
@@ -30,7 +30,7 @@ namespace HandyControl.Controls
/// 是否启用动画
///
public static readonly DependencyProperty IsEnableAnimationProperty = DependencyProperty.Register(
- "IsEnableAnimation", typeof(bool), typeof(TabControl), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsEnableAnimation", typeof(bool), typeof(TabControl), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 是否启用动画
@@ -45,7 +45,7 @@ namespace HandyControl.Controls
/// 是否可以拖动
///
public static readonly DependencyProperty IsDraggableProperty = DependencyProperty.Register(
- "IsDraggable", typeof(bool), typeof(TabControl), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsDraggable", typeof(bool), typeof(TabControl), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 是否可以拖动
@@ -60,7 +60,7 @@ namespace HandyControl.Controls
/// 是否显示关闭按钮
///
public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.Register(
- "ShowCloseButton", typeof(bool), typeof(TabControl), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowCloseButton", typeof(bool), typeof(TabControl), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 是否显示关闭按钮
@@ -75,7 +75,7 @@ namespace HandyControl.Controls
/// 是否将标签填充
///
public static readonly DependencyProperty IsEnableTabFillProperty = DependencyProperty.Register(
- "IsEnableTabFill", typeof(bool), typeof(TabControl), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsEnableTabFill", typeof(bool), typeof(TabControl), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 是否将标签填充
diff --git a/HandyControl/Controls/TabControl/TabPanel.cs b/HandyControl/Controls/TabControl/TabPanel.cs
index 214353b1..f90c7bf1 100644
--- a/HandyControl/Controls/TabControl/TabPanel.cs
+++ b/HandyControl/Controls/TabControl/TabPanel.cs
@@ -42,7 +42,7 @@ namespace HandyControl.Controls
/// 是否将标签填充
///
public static readonly DependencyProperty IsEnableTabFillProperty = DependencyProperty.Register(
- "IsEnableTabFill", typeof(bool), typeof(TabPanel), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "IsEnableTabFill", typeof(bool), typeof(TabPanel), new PropertyMetadata(ValueBoxes.FalseBox));
///
/// 是否将标签填充
diff --git a/HandyControl/Controls/TimeBar/TimeBar.cs b/HandyControl/Controls/TimeBar/TimeBar.cs
index 84dff82b..c7ec532a 100644
--- a/HandyControl/Controls/TimeBar/TimeBar.cs
+++ b/HandyControl/Controls/TimeBar/TimeBar.cs
@@ -48,7 +48,7 @@ namespace HandyControl.Controls
/// 是否显示刻度字符串
///
public static readonly DependencyProperty ShowSpeStrProperty = DependencyProperty.Register(
- "ShowSpeStr", typeof(bool), typeof(TimeBar), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowSpeStr", typeof(bool), typeof(TimeBar), new PropertyMetadata(ValueBoxes.FalseBox));
public static readonly DependencyProperty TimeFormatProperty = DependencyProperty.Register(
"TimeFormat", typeof(string), typeof(TimeBar), new PropertyMetadata("yyyy-MM-dd HH:mm:ss"));
diff --git a/HandyControl/Controls/TransitioningContentControl.cs b/HandyControl/Controls/TransitioningContentControl.cs
index 4712eb7a..574a0525 100644
--- a/HandyControl/Controls/TransitioningContentControl.cs
+++ b/HandyControl/Controls/TransitioningContentControl.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
+using HandyControl.Data;
using HandyControl.Tools;
namespace HandyControl.Controls
@@ -247,7 +248,7 @@ namespace HandyControl.Controls
"RestartTransitionOnContentChange",
typeof(bool),
typeof(TransitioningContentControl),
- new PropertyMetadata(false, OnRestartTransitionOnContentChangePropertyChanged));
+ new PropertyMetadata(ValueBoxes.FalseBox, OnRestartTransitionOnContentChangePropertyChanged));
private static void OnRestartTransitionOnContentChangePropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
diff --git a/HandyControl/Controls/Window/ImageBrowser.cs b/HandyControl/Controls/Window/ImageBrowser.cs
index c8e7e0cc..e74d9922 100644
--- a/HandyControl/Controls/Window/ImageBrowser.cs
+++ b/HandyControl/Controls/Window/ImageBrowser.cs
@@ -34,7 +34,7 @@ namespace HandyControl.Controls
static ImageBrowser()
{
- IsFullScreenProperty.AddOwner(typeof(ImageBrowser), new PropertyMetadata(BooleanBoxes.FalseBox));
+ IsFullScreenProperty.AddOwner(typeof(ImageBrowser), new PropertyMetadata(ValueBoxes.FalseBox));
}
public ImageBrowser()
diff --git a/HandyControl/Controls/Window/PopupWindow.cs b/HandyControl/Controls/Window/PopupWindow.cs
index aa497740..833b75fe 100644
--- a/HandyControl/Controls/Window/PopupWindow.cs
+++ b/HandyControl/Controls/Window/PopupWindow.cs
@@ -105,7 +105,7 @@ namespace HandyControl.Controls
public FrameworkElement PopupElement { get; set; }
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
- "ShowTitle", typeof(bool), typeof(PopupWindow), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "ShowTitle", typeof(bool), typeof(PopupWindow), new PropertyMetadata(ValueBoxes.TrueBox));
public bool ShowTitle
{
@@ -114,7 +114,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty ShowCancelProperty = DependencyProperty.Register(
- "ShowCancel", typeof(bool), typeof(PopupWindow), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowCancel", typeof(bool), typeof(PopupWindow), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowCancel
{
@@ -123,7 +123,7 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty ShowBorderProperty = DependencyProperty.Register(
- "ShowBorder", typeof(bool), typeof(PopupWindow), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowBorder", typeof(bool), typeof(PopupWindow), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowBorder
{
diff --git a/HandyControl/Controls/Window/WindowBorderless.cs b/HandyControl/Controls/Window/WindowBorderless.cs
index 94db0f95..3b427c3d 100644
--- a/HandyControl/Controls/Window/WindowBorderless.cs
+++ b/HandyControl/Controls/Window/WindowBorderless.cs
@@ -60,13 +60,13 @@ namespace HandyControl.Controls
new PropertyMetadata(28.0));
public static readonly DependencyProperty ShowNonClientAreaProperty = DependencyProperty.Register(
- "ShowNonClientArea", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(BooleanBoxes.TrueBox));
+ "ShowNonClientArea", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(ValueBoxes.TrueBox));
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
- "ShowTitle", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(BooleanBoxes.FalseBox));
+ "ShowTitle", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(ValueBoxes.FalseBox));
public static readonly DependencyProperty IsFullScreenProperty = DependencyProperty.Register(
- "IsFullScreen", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(BooleanBoxes.FalseBox,
+ "IsFullScreen", typeof(bool), typeof(WindowBorderless), new PropertyMetadata(ValueBoxes.FalseBox,
(o, args) =>
{
var ctl = (WindowBorderless)o;
diff --git a/HandyControl/Data/BooleanBoxes.cs b/HandyControl/Data/BooleanBoxes.cs
deleted file mode 100644
index 8681b16e..00000000
--- a/HandyControl/Data/BooleanBoxes.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace HandyControl.Data
-{
- ///
- /// 装箱后的布尔值(用于提高效率)
- ///
- internal static class BooleanBoxes
- {
- internal static object TrueBox = true;
- internal static object FalseBox = false;
-
- internal static object Box(bool value) => value ? TrueBox : FalseBox;
- }
-}
\ No newline at end of file
diff --git a/HandyControl/Data/GrowlInfo.cs b/HandyControl/Data/GrowlInfo.cs
index 68fc52e5..9c952a8a 100644
--- a/HandyControl/Data/GrowlInfo.cs
+++ b/HandyControl/Data/GrowlInfo.cs
@@ -1,5 +1,4 @@
using System;
-using HandyControl.Data;
namespace HandyControl.Data
{
diff --git a/HandyControl/Data/ValueBoxes.cs b/HandyControl/Data/ValueBoxes.cs
new file mode 100644
index 00000000..dbf21d59
--- /dev/null
+++ b/HandyControl/Data/ValueBoxes.cs
@@ -0,0 +1,22 @@
+namespace HandyControl.Data
+{
+ ///
+ /// 装箱后的布尔值(用于提高效率)
+ ///
+ internal static class ValueBoxes
+ {
+ internal static object TrueBox = true;
+
+ internal static object FalseBox = false;
+
+ internal static object Double0Box = .0;
+
+ internal static object Double1Box = 1.0;
+
+ internal static object Double100Box = 100.0;
+
+ internal static object DoubleNeg1Box = -1.0;
+
+ internal static object BooleanBox(bool value) => value ? TrueBox : FalseBox;
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj
index 551cfac4..772869a8 100644
--- a/HandyControl/HandyControl.csproj
+++ b/HandyControl/HandyControl.csproj
@@ -126,7 +126,7 @@
-
+
diff --git a/HandyControl/Interactivity/EventToCommand.cs b/HandyControl/Interactivity/EventToCommand.cs
index 9f8c403d..de449aa5 100644
--- a/HandyControl/Interactivity/EventToCommand.cs
+++ b/HandyControl/Interactivity/EventToCommand.cs
@@ -25,6 +25,7 @@
using System;
using System.Windows;
using System.Windows.Input;
+using HandyControl.Data;
namespace HandyControl.Interactivity
{
@@ -49,7 +50,7 @@ namespace HandyControl.Interactivity
new PropertyMetadata(null, (s, e) => OnCommandChanged(s as EventToCommand, e)));
public static readonly DependencyProperty MustToggleIsEnabledProperty = DependencyProperty.Register(
- nameof(MustToggleIsEnabled), typeof(bool), typeof(EventToCommand), new PropertyMetadata(false,
+ nameof(MustToggleIsEnabled), typeof(bool), typeof(EventToCommand), new PropertyMetadata(ValueBoxes.FalseBox,
(s, e) =>
{
var eventToCommand = s as EventToCommand;
@@ -64,7 +65,7 @@ namespace HandyControl.Interactivity
public static readonly DependencyProperty AlwaysInvokeCommandProperty =
DependencyProperty.Register(nameof(AlwaysInvokeCommand), typeof(bool), typeof(EventToCommand),
- new PropertyMetadata(false));
+ new PropertyMetadata(ValueBoxes.FalseBox));
private object _commandParameterValue;
diff --git a/HandyControl/Interactivity/ExtendedVisualStateManager.cs b/HandyControl/Interactivity/ExtendedVisualStateManager.cs
index e4608be1..da7abd08 100644
--- a/HandyControl/Interactivity/ExtendedVisualStateManager.cs
+++ b/HandyControl/Interactivity/ExtendedVisualStateManager.cs
@@ -8,6 +8,7 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
+using HandyControl.Data;
namespace HandyControl.Interactivity
{
@@ -30,7 +31,7 @@ namespace HandyControl.Interactivity
internal static readonly DependencyProperty DidCacheBackgroundProperty =
DependencyProperty.RegisterAttached("DidCacheBackground", typeof(bool), typeof(ExtendedVisualStateManager),
- new PropertyMetadata(false));
+ new PropertyMetadata(ValueBoxes.FalseBox));
private static readonly List LayoutProperties;
@@ -59,7 +60,7 @@ namespace HandyControl.Interactivity
public static readonly DependencyProperty UseFluidLayoutProperty =
DependencyProperty.RegisterAttached("UseFluidLayout", typeof(bool), typeof(ExtendedVisualStateManager),
- new PropertyMetadata(false));
+ new PropertyMetadata(ValueBoxes.FalseBox));
private bool _changingState;
diff --git a/HandyControl/Interactivity/FluidMoveBehavior.cs b/HandyControl/Interactivity/FluidMoveBehavior.cs
index be3190e4..40da23b0 100644
--- a/HandyControl/Interactivity/FluidMoveBehavior.cs
+++ b/HandyControl/Interactivity/FluidMoveBehavior.cs
@@ -29,11 +29,11 @@ namespace HandyControl.Interactivity
public static readonly DependencyProperty FloatAboveProperty =
DependencyProperty.Register("FloatAbove", typeof(bool), typeof(FluidMoveBehavior),
- new PropertyMetadata(BooleanBoxes.TrueBox));
+ new PropertyMetadata(ValueBoxes.TrueBox));
private static readonly DependencyProperty HasTransformWrapperProperty =
DependencyProperty.RegisterAttached("HasTransformWrapper", typeof(bool),
- typeof(FluidMoveBehavior), new PropertyMetadata(false));
+ typeof(FluidMoveBehavior), new PropertyMetadata(ValueBoxes.FalseBox));
private static readonly DependencyProperty InitialIdentityTagProperty =
DependencyProperty.RegisterAttached("InitialIdentityTag", typeof(object),
diff --git a/HandyControl/Interactivity/FluidMoveBehaviorBase.cs b/HandyControl/Interactivity/FluidMoveBehaviorBase.cs
index 01d0373b..cf21a814 100644
--- a/HandyControl/Interactivity/FluidMoveBehaviorBase.cs
+++ b/HandyControl/Interactivity/FluidMoveBehaviorBase.cs
@@ -19,7 +19,7 @@ namespace HandyControl.Interactivity
new PropertyMetadata(null));
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register("IsActive",
- typeof(bool), typeof(FluidMoveBehaviorBase), new PropertyMetadata(BooleanBoxes.TrueBox));
+ typeof(bool), typeof(FluidMoveBehaviorBase), new PropertyMetadata(ValueBoxes.TrueBox));
private static DateTime LastPurgeTick = DateTime.MinValue;
diff --git a/HandyControl/Interactivity/MouseDragElementBehavior.cs b/HandyControl/Interactivity/MouseDragElementBehavior.cs
index 27167d5f..9245eaf6 100644
--- a/HandyControl/Interactivity/MouseDragElementBehavior.cs
+++ b/HandyControl/Interactivity/MouseDragElementBehavior.cs
@@ -1,6 +1,7 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
+using HandyControl.Data;
namespace HandyControl.Interactivity
{
@@ -8,13 +9,13 @@ namespace HandyControl.Interactivity
{
public static readonly DependencyProperty ConstrainToParentBoundsProperty =
DependencyProperty.Register("ConstrainToParentBounds", typeof(bool), typeof(MouseDragElementBehavior),
- new PropertyMetadata(false, OnConstrainToParentBoundsChanged));
+ new PropertyMetadata(ValueBoxes.FalseBox, OnConstrainToParentBoundsChanged));
public static readonly DependencyProperty XProperty = DependencyProperty.Register("X", typeof(double),
- typeof(MouseDragElementBehavior), new PropertyMetadata(1.0 / 0.0, OnXChanged));
+ typeof(MouseDragElementBehavior), new PropertyMetadata(double.PositiveInfinity, OnXChanged));
public static readonly DependencyProperty YProperty = DependencyProperty.Register("Y", typeof(double),
- typeof(MouseDragElementBehavior), new PropertyMetadata(1.0 / 0.0, OnYChanged));
+ typeof(MouseDragElementBehavior), new PropertyMetadata(double.PositiveInfinity, OnYChanged));
// Fields
private Transform _cachedRenderTransform;
diff --git a/HandyControl/Tools/MouseDragElementBehaviorEx.cs b/HandyControl/Tools/MouseDragElementBehaviorEx.cs
index b0757a00..a598f167 100644
--- a/HandyControl/Tools/MouseDragElementBehaviorEx.cs
+++ b/HandyControl/Tools/MouseDragElementBehaviorEx.cs
@@ -1,6 +1,7 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
+using HandyControl.Data;
using HandyControl.Interactivity;
namespace HandyControl.Tools
@@ -18,7 +19,7 @@ namespace HandyControl.Tools
public static readonly DependencyProperty ConstrainToParentBoundsProperty =
DependencyProperty.Register(nameof(ConstrainToParentBounds), typeof(bool),
- typeof(MouseDragElementBehaviorEx), new PropertyMetadata(false, OnConstrainToParentBoundsChanged));
+ typeof(MouseDragElementBehaviorEx), new PropertyMetadata(ValueBoxes.FalseBox, OnConstrainToParentBoundsChanged));
private Transform _cachedRenderTransform;
private Point _relativePosition;