diff --git a/src/Core_30/HandyControlDemo_Core_30/UserControl/Main/NoUserContent.xaml b/src/Core_30/HandyControlDemo_Core_30/UserControl/Main/NoUserContent.xaml index ba1c6ec4..ebc6eaa5 100644 --- a/src/Core_30/HandyControlDemo_Core_30/UserControl/Main/NoUserContent.xaml +++ b/src/Core_30/HandyControlDemo_Core_30/UserControl/Main/NoUserContent.xaml @@ -23,7 +23,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/Net_40/HandyControlDemo_Net_40/UserControl/Main/NoUserContent.xaml b/src/Net_40/HandyControlDemo_Net_40/UserControl/Main/NoUserContent.xaml index d41a04a6..dd935178 100644 --- a/src/Net_40/HandyControlDemo_Net_40/UserControl/Main/NoUserContent.xaml +++ b/src/Net_40/HandyControlDemo_Net_40/UserControl/Main/NoUserContent.xaml @@ -24,7 +24,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -68,7 +68,7 @@ - + diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/UserControl/Main/NoUserContent.xaml b/src/Net_GE45/HandyControlDemo_Net_GE45/UserControl/Main/NoUserContent.xaml index ba1c6ec4..ebc6eaa5 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/UserControl/Main/NoUserContent.xaml +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/UserControl/Main/NoUserContent.xaml @@ -23,7 +23,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml index edd81b73..2b00d656 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/OverView.xaml @@ -156,19 +156,19 @@ - + - - + + - + - + - + @@ -314,7 +314,7 @@ - + @@ -344,7 +344,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/ExpanderDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/ExpanderDemoCtl.xaml index f7e9dfa0..ef62af3e 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/ExpanderDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/ExpanderDemoCtl.xaml @@ -5,17 +5,17 @@ xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" xmlns:hc="https://handyorg.github.io/handycontrol"> - - + + - + - + - + diff --git a/src/Shared/HandyControl_Shared/Controls/Other/ToggleBlock.cs b/src/Shared/HandyControl_Shared/Controls/Other/ToggleBlock.cs new file mode 100644 index 00000000..25876114 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Controls/Other/ToggleBlock.cs @@ -0,0 +1,62 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using HandyControl.Data; + +namespace HandyControl.Controls +{ + /// + /// 切换块 + /// + /// + /// 在不需要命中测试的情况下可代替ToggleButton或CheckBox,以减少内存用量。 + /// + public class ToggleBlock : Control + { + public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register( + "IsChecked", typeof(bool?), typeof(ToggleBlock), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, + FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal)); + + [Category("Appearance")] + [TypeConverter(typeof(NullableBoolConverter))] + [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] + public bool? IsChecked + { + get + { + // Because Nullable unboxing is very slow (uses reflection) first we cast to bool + var value = GetValue(IsCheckedProperty); + // ReSharper disable once RedundantExplicitNullableCreation + return value == null ? new bool?() : new bool?((bool)value); + } + set => SetValue(IsCheckedProperty, value.HasValue ? ValueBoxes.BooleanBox(value.Value) : null); + } + + public static readonly DependencyProperty CheckedContentProperty = DependencyProperty.Register( + "CheckedContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object))); + + public object CheckedContent + { + get => GetValue(CheckedContentProperty); + set => SetValue(CheckedContentProperty, value); + } + + public static readonly DependencyProperty UnCheckedContentProperty = DependencyProperty.Register( + "UnCheckedContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object))); + + public object UnCheckedContent + { + get => GetValue(UnCheckedContentProperty); + set => SetValue(UnCheckedContentProperty, value); + } + + public static readonly DependencyProperty IndeterminateContentProperty = DependencyProperty.Register( + "IndeterminateContent", typeof(object), typeof(ToggleBlock), new PropertyMetadata(default(object))); + + public object IndeterminateContent + { + get => GetValue(IndeterminateContentProperty); + set => SetValue(IndeterminateContentProperty, value); + } + } +} \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index e6c456d2..95447ffc 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -22,6 +22,7 @@ + @@ -371,6 +372,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -771,6 +776,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Shared/HandyControl_Shared/Themes/Basic/Geometries.xaml b/src/Shared/HandyControl_Shared/Themes/Basic/Geometries.xaml index 235a13db..58fe7055 100644 --- a/src/Shared/HandyControl_Shared/Themes/Basic/Geometries.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Basic/Geometries.xaml @@ -21,6 +21,7 @@ M716.6003 213.800623c-138.851102-138.915088-364.020238-138.915088-502.935326 0s-138.915088 364.084225 0 502.935326a355.573996 355.573996 0 0 0 502.935326 0 355.573996 355.573996 0 0 0 0-502.935326z m-580.359212 580.359212a465.183184 465.183184 0 1 1 657.783099 0 465.183184 465.183184 0 0 1-657.783099 0z m868.939152 211.156054a63.474789 63.474789 0 0 1-89.837303 0l-89.773316-89.837303a63.410803 63.410803 0 1 1 89.773316-89.773316l89.837303 89.773316a63.346816 63.346816 0 0 1 0 89.837303z M454.464 143.68l-253.44 253.44c-12.032 12.032-12.032 31.36 0 43.392 11.968 11.968 31.36 11.968 43.328 0l237.376-237.376 237.376 237.376c11.968 11.968 31.36 11.968 43.328 0 12.032-12.032 12.032-31.36 0-43.392l-253.44-253.44C491.264 126.016 478.016 124.032 454.464 143.68zM507.968 947.648l252.48-253.376c11.968-11.968 11.968-31.36 0-43.392-11.968-11.968-31.296-11.968-43.264 0l-236.48 237.376L244.16 650.88c-11.968-11.968-31.296-11.968-43.264 0-11.968 12.032-11.968 31.424 0 43.392l252.48 253.376C465.984 960 491.136 964.48 507.968 947.648z M0,4 L10,4 L10,5 L0,5 z + M 0,2 3,5 8,0 M928 406.4c-100.8-137.6-249.6-224-416-224s-315.2 86.4-416 224c-44.8 60.8-44.8 150.4 0 211.2 102.4 137.6 251.2 224 416 224 166.4 0 315.2-86.4 416-224 46.4-60.8 46.4-150.4 0-211.2zM512 721.6c-115.2 0-209.6-94.4-209.6-209.6 0-115.2 94.4-209.6 209.6-209.6 115.2 0 209.6 94.4 209.6 209.6 1.6 115.2-92.8 209.6-209.6 209.6z m0-360c-83.2 0-150.4 67.2-150.4 150.4s67.2 150.4 150.4 150.4 150.4-67.2 150.4-150.4-67.2-150.4-150.4-150.4z m0 0 M950.4 361.6c8-20.8 0-43.2-19.2-54.4-9.6-4.8-20.8-6.4-32-3.2s-19.2 11.2-24 22.4c-56 132.8-208 228.8-361.6 228.8-155.2 0-307.2-97.6-363.2-232-4.8-11.2-12.8-19.2-24-24-9.6-4.8-20.8-3.2-32 0-20.8 9.6-30.4 35.2-20.8 56 25.6 60.8 67.2 118.4 123.2 164.8l-67.2 70.4c-14.4 16-14.4 40 0 57.6 8 8 17.6 14.4 28.8 14.4s22.4-3.2 30.4-11.2l76.8-81.6c35.2 20.8 73.6 38.4 113.6 49.6l-28.8 83.2c-8 22.4 3.2 46.4 24 54.4 4.8 1.6 9.6 3.2 14.4 3.2 6.4 0 11.2-1.6 17.6-3.2 9.6-4.8 17.6-12.8 22.4-24l33.6-96c41.6 4.8 81.6 3.2 123.2-3.2l32 94.4c3.2 11.2 11.2 19.2 22.4 24 9.6 4.8 20.8 4.8 32 1.6 20.8-8 32-32 24-54.4l-28.8-84.8c30.4-9.6 59.2-22.4 86.4-38.4l62.4 65.6c14.4 16 43.2 16 57.6 0 16-16 16-43.2 0-60.8l-51.2-54.4c56-43.2 100.8-100.8 128-164.8z M1,3 L1,9 L7,9 L7,3 z M3,1 L3,2 L8,2 L8,7 L9,7 L9,1 z M2,0 L10,0 L10,8 L8,8 L8,10 L0,10 L0,2 L2,2 z diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckBoxBaseStyle.xaml index 93b0c69e..b2da6bd3 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckBoxBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckBoxBaseStyle.xaml @@ -4,6 +4,7 @@ + + + \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml index ac89c3a5..bd4bbbf4 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml @@ -69,6 +69,7 @@ + \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/ToggleBlock.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/ToggleBlock.xaml new file mode 100644 index 00000000..a1efe467 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Themes/Styles/ToggleBlock.xaml @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file