From c9fdcd1114b43d0a8f0a34df4df192fe5338b833 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 23 Aug 2018 19:49:08 +0800 Subject: [PATCH] add Expander --- .../Controls/{ => Attach}/IconElement.cs | 2 +- .../Controls/Attach/IconSwitchElement.cs | 35 ++++ .../Controls/Attach/StatusSwitchElement.cs | 15 ++ HandyControl/HandyControl.csproj | 20 +- .../Styles/Base/ToggleButtonBaseStyle.xaml | 49 +++++ .../Base/ToggleButtonSwitchBaseStyle.xaml | 184 ++++++++++++++++++ HandyControl/Themes/Styles/Expander.xaml | 85 ++++++++ HandyControl/Themes/Styles/Style.xaml | 2 +- HandyControl/Themes/Styles/ToggleButton.xaml | 149 ++++++++++++++ HandyControlDemo/MainWindow.xaml | 26 +++ README.md | 6 +- Resources/Expander.gif | Bin 0 -> 11107 bytes 12 files changed, 569 insertions(+), 4 deletions(-) rename HandyControl/Controls/{ => Attach}/IconElement.cs (96%) create mode 100644 HandyControl/Controls/Attach/IconSwitchElement.cs create mode 100644 HandyControl/Controls/Attach/StatusSwitchElement.cs create mode 100644 HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml create mode 100644 HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml create mode 100644 HandyControl/Themes/Styles/Expander.xaml create mode 100644 HandyControl/Themes/Styles/ToggleButton.xaml create mode 100644 Resources/Expander.gif diff --git a/HandyControl/Controls/IconElement.cs b/HandyControl/Controls/Attach/IconElement.cs similarity index 96% rename from HandyControl/Controls/IconElement.cs rename to HandyControl/Controls/Attach/IconElement.cs index 3cc778b5..62f69c5d 100644 --- a/HandyControl/Controls/IconElement.cs +++ b/HandyControl/Controls/Attach/IconElement.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Media; +// ReSharper disable once CheckNamespace namespace HandyControl.Controls { public class IconElement : DependencyObject @@ -31,5 +32,4 @@ namespace HandyControl.Controls return (double)element.GetValue(AngleProperty); } } - } \ No newline at end of file diff --git a/HandyControl/Controls/Attach/IconSwitchElement.cs b/HandyControl/Controls/Attach/IconSwitchElement.cs new file mode 100644 index 00000000..0b6f8a9a --- /dev/null +++ b/HandyControl/Controls/Attach/IconSwitchElement.cs @@ -0,0 +1,35 @@ +using System.Windows; +using System.Windows.Media; + +// ReSharper disable once CheckNamespace +namespace HandyControl.Controls +{ + public class IconSwitchElement : DependencyObject + { + public static readonly DependencyProperty GeometryProperty = DependencyProperty.RegisterAttached( + "Geometry", typeof(Geometry), typeof(IconSwitchElement), new PropertyMetadata(default(Geometry))); + + public static void SetGeometry(DependencyObject element, Geometry value) + { + element.SetValue(GeometryProperty, value); + } + + public static Geometry GetGeometry(DependencyObject element) + { + return (Geometry)element.GetValue(GeometryProperty); + } + + public static readonly DependencyProperty GeometrySelectedProperty = DependencyProperty.RegisterAttached( + "GeometrySelected", typeof(Geometry), typeof(IconSwitchElement), new PropertyMetadata(default(Geometry))); + + public static void SetGeometrySelected(DependencyObject element, Geometry value) + { + element.SetValue(GeometrySelectedProperty, value); + } + + public static Geometry GetGeometrySelected(DependencyObject element) + { + return (Geometry)element.GetValue(GeometrySelectedProperty); + } + } +} \ No newline at end of file diff --git a/HandyControl/Controls/Attach/StatusSwitchElement.cs b/HandyControl/Controls/Attach/StatusSwitchElement.cs new file mode 100644 index 00000000..6c52ab80 --- /dev/null +++ b/HandyControl/Controls/Attach/StatusSwitchElement.cs @@ -0,0 +1,15 @@ +using System.Windows; + +// ReSharper disable once CheckNamespace +namespace HandyControl.Controls +{ + public class StatusSwitchElement + { + public static readonly DependencyProperty CheckedElementProperty = DependencyProperty.RegisterAttached( + "CheckedElement", typeof(object), typeof(StatusSwitchElement), new PropertyMetadata(default(object))); + + public static void SetCheckedElement(DependencyObject element, object value) => element.SetValue(CheckedElementProperty, value); + + public static object GetCheckedElement(DependencyObject element) => element.GetValue(CheckedElementProperty); + } +} \ No newline at end of file diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 4cde2006..c4ad4433 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -31,13 +31,15 @@ 4 + + Carousel.xaml ColorPicker.xaml - + InfoNumericUpDown.xaml @@ -200,6 +202,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -208,6 +218,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -244,6 +258,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml new file mode 100644 index 00000000..1930b0cd --- /dev/null +++ b/HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml @@ -0,0 +1,49 @@ + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml new file mode 100644 index 00000000..ad96b31f --- /dev/null +++ b/HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml @@ -0,0 +1,184 @@ + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Expander.xaml b/HandyControl/Themes/Styles/Expander.xaml new file mode 100644 index 00000000..2c6f3625 --- /dev/null +++ b/HandyControl/Themes/Styles/Expander.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Style.xaml b/HandyControl/Themes/Styles/Style.xaml index a5596eca..d51e6a04 100644 --- a/HandyControl/Themes/Styles/Style.xaml +++ b/HandyControl/Themes/Styles/Style.xaml @@ -26,7 +26,7 @@ - + diff --git a/HandyControl/Themes/Styles/ToggleButton.xaml b/HandyControl/Themes/Styles/ToggleButton.xaml new file mode 100644 index 00000000..db9849cf --- /dev/null +++ b/HandyControl/Themes/Styles/ToggleButton.xaml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/MainWindow.xaml b/HandyControlDemo/MainWindow.xaml index 290bd2ce..ab14c10e 100644 --- a/HandyControlDemo/MainWindow.xaml +++ b/HandyControlDemo/MainWindow.xaml @@ -620,6 +620,32 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + + +