From def100f84264dc7c21156a60e87bd307c33a7903 Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Tue, 4 Dec 2018 14:57:02 +0330 Subject: [PATCH 1/6] add new control ImageRadioButton (new list style for radio button) --- .../Controls/Input/ImageRadioButton.cs | 57 +++ HandyControl/HandyControl.csproj | 1 + HandyControl/Themes/Styles/Expander.xaml | 350 ++++++++++++++++++ HandyControl/Themes/Styles/RadioButton.xaml | 61 +++ .../Styles/RadioButtonDemoCtl.xaml | 30 +- 5 files changed, 494 insertions(+), 5 deletions(-) create mode 100644 HandyControl/Controls/Input/ImageRadioButton.cs diff --git a/HandyControl/Controls/Input/ImageRadioButton.cs b/HandyControl/Controls/Input/ImageRadioButton.cs new file mode 100644 index 00000000..616fa3ce --- /dev/null +++ b/HandyControl/Controls/Input/ImageRadioButton.cs @@ -0,0 +1,57 @@ +using HandyControl.Data; +using HandyControl.Tools; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace HandyControl.Controls +{ + public class ImageRadioButton : RadioButton + { + public ImageRadioButton() + { + SetSideBrush(this, ResourceHelper.GetResource(ResourceToken.PrimaryBrush)); + } + public Geometry Image + { + get { return (Geometry)GetValue(ImageProperty); } + set { SetValue(ImageProperty, value); } + } + + public static readonly DependencyProperty ImageProperty = + DependencyProperty.Register("Image", typeof(Geometry), typeof(ImageRadioButton)); + + + + public double ImageWidth + { + get { return (double)GetValue(ImageWidthProperty); } + set { SetValue(ImageWidthProperty, value); } + } + + public static readonly DependencyProperty ImageWidthProperty = + DependencyProperty.Register("ImageWidth", typeof(double), typeof(ImageRadioButton), new PropertyMetadata(15.0)); + + public double ImageHeight + { + get { return (double)GetValue(ImageHeightProperty); } + set { SetValue(ImageHeightProperty, value); } + } + + public static readonly DependencyProperty ImageHeightProperty = + DependencyProperty.Register("ImageHeight", typeof(double), typeof(ImageRadioButton), new PropertyMetadata(15.0)); + + public static readonly DependencyProperty SideBrushProperty = DependencyProperty.RegisterAttached( + "SideBrush", typeof(Brush), typeof(ImageRadioButton), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.Inherits)); + + public static void SetSideBrush(DependencyObject element, Brush value) => element.SetValue(SideBrushProperty, value); + + public static Brush GetSideBrush(DependencyObject element) => (Brush)element.GetValue(SideBrushProperty); + + } +} diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 78a8655f..a0f6d12f 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -45,6 +45,7 @@ v4.6.2 + diff --git a/HandyControl/Themes/Styles/Expander.xaml b/HandyControl/Themes/Styles/Expander.xaml index d25f1a09..e02c0427 100644 --- a/HandyControl/Themes/Styles/Expander.xaml +++ b/HandyControl/Themes/Styles/Expander.xaml @@ -52,4 +52,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/RadioButton.xaml b/HandyControl/Themes/Styles/RadioButton.xaml index 20051738..e4f3dd77 100644 --- a/HandyControl/Themes/Styles/RadioButton.xaml +++ b/HandyControl/Themes/Styles/RadioButton.xaml @@ -1,4 +1,5 @@  @@ -10,4 +11,64 @@ \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml index 011e72f3..b36fdfe1 100644 --- a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml @@ -6,11 +6,31 @@ Background="{DynamicResource RegionBrush}" Width="400"> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + From 0fd452ca2fdf767dbc5acf54ee50b74e5b645cd2 Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Tue, 4 Dec 2018 15:13:55 +0330 Subject: [PATCH 2/6] fixed Demo --- HandyControl/Themes/Styles/Expander.xaml | 295 +++++++++++++++++- .../Styles/RadioButtonDemoCtl.xaml | 63 +++- 2 files changed, 345 insertions(+), 13 deletions(-) diff --git a/HandyControl/Themes/Styles/Expander.xaml b/HandyControl/Themes/Styles/Expander.xaml index e02c0427..17b30f60 100644 --- a/HandyControl/Themes/Styles/Expander.xaml +++ b/HandyControl/Themes/Styles/Expander.xaml @@ -401,5 +401,298 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml index b36fdfe1..9b88c9b4 100644 --- a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml @@ -17,18 +17,57 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + From 6e5898bb85dac600ab07eaba951dbf21b05066cc Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Thu, 6 Dec 2018 20:24:03 +0330 Subject: [PATCH 3/6] image property removed --- HandyControl/Controls/Input/ImageRadioButton.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/HandyControl/Controls/Input/ImageRadioButton.cs b/HandyControl/Controls/Input/ImageRadioButton.cs index 616fa3ce..e74228a7 100644 --- a/HandyControl/Controls/Input/ImageRadioButton.cs +++ b/HandyControl/Controls/Input/ImageRadioButton.cs @@ -17,16 +17,6 @@ namespace HandyControl.Controls { SetSideBrush(this, ResourceHelper.GetResource(ResourceToken.PrimaryBrush)); } - public Geometry Image - { - get { return (Geometry)GetValue(ImageProperty); } - set { SetValue(ImageProperty, value); } - } - - public static readonly DependencyProperty ImageProperty = - DependencyProperty.Register("Image", typeof(Geometry), typeof(ImageRadioButton)); - - public double ImageWidth { From 4805b70c141bec9be973b661e0cb8c8493bb70f4 Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Thu, 6 Dec 2018 20:25:37 +0330 Subject: [PATCH 4/6] replaced iconElement with image property --- HandyControl/Themes/Styles/RadioButton.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HandyControl/Themes/Styles/RadioButton.xaml b/HandyControl/Themes/Styles/RadioButton.xaml index 3424f948..cc27d30b 100644 --- a/HandyControl/Themes/Styles/RadioButton.xaml +++ b/HandyControl/Themes/Styles/RadioButton.xaml @@ -35,7 +35,7 @@ Width="{TemplateBinding ImageWidth}" Height="{TemplateBinding ImageHeight}" Margin="15,0,0,0" - Data="{TemplateBinding Image}" + Data="{TemplateBinding controls:IconElement.Geometry}" Fill="{TemplateBinding Foreground}" Stretch="Fill" /> @@ -59,7 +59,7 @@ - + @@ -95,4 +95,4 @@ - \ No newline at end of file + From d3267e85d52b122371a1a0cce254eeb51d8d1fa4 Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Thu, 6 Dec 2018 20:27:09 +0330 Subject: [PATCH 5/6] replaced iconElement with image Property --- .../UserControl/Styles/RadioButtonDemoCtl.xaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml index cc5bc57f..077e780e 100644 --- a/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Styles/RadioButtonDemoCtl.xaml @@ -27,24 +27,24 @@ Content="Radio Button1" GroupName="Menu" SideBrush="{DynamicResource DangerBrush}" - Image="{DynamicResource WindowsGeometry}" + controls:IconElement.Geometry="{DynamicResource WindowsGeometry}" IsChecked="True" /> @@ -57,12 +57,12 @@ From a581a0bd73b62f89f1a625ac8c1d88d5ba2f5e42 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 8 Dec 2018 15:15:32 +0800 Subject: [PATCH 6/6] Modified the radiobutton style in the #20 --- .../Attach/BackgroundSwitchElement.cs | 2 +- HandyControl/Controls/Attach/BorderElement.cs | 2 +- .../Controls/Attach/DataGridAttach.cs | 2 +- HandyControl/Controls/Attach/EdgeElement.cs | 3 +- HandyControl/Controls/Attach/IconElement.cs | 32 +- .../Controls/Attach/IconSwitchElement.cs | 3 +- HandyControl/Controls/Attach/InfoElement.cs | 3 +- .../Controls/Attach/PasswordBoxMonitor.cs | 1 - .../Controls/Attach/StatusSwitchElement.cs | 1 - HandyControl/Controls/Attach/TipElement.cs | 3 +- HandyControl/Controls/Attach/TitleElement.cs | 2 +- HandyControl/Controls/Attach/VisualElement.cs | 17 + .../Controls/Input/ImageRadioButton.cs | 47 -- HandyControl/Data/ValueBoxes.cs | 2 +- HandyControl/HandyControl.csproj | 2 +- .../Styles/Base/RadioButtonBaseStyle.xaml | 54 ++ HandyControl/Themes/Styles/Expander.xaml | 644 ------------------ HandyControl/Themes/Styles/RadioButton.xaml | 63 +- .../Styles/RadioButtonDemoCtl.xaml | 96 +-- 19 files changed, 141 insertions(+), 838 deletions(-) create mode 100644 HandyControl/Controls/Attach/VisualElement.cs delete mode 100644 HandyControl/Controls/Input/ImageRadioButton.cs diff --git a/HandyControl/Controls/Attach/BackgroundSwitchElement.cs b/HandyControl/Controls/Attach/BackgroundSwitchElement.cs index c690435b..c305f080 100644 --- a/HandyControl/Controls/Attach/BackgroundSwitchElement.cs +++ b/HandyControl/Controls/Attach/BackgroundSwitchElement.cs @@ -3,7 +3,7 @@ using System.Windows.Media; namespace HandyControl.Controls { - public class BackgroundSwitchElement : DependencyObject + public class BackgroundSwitchElement { public static readonly DependencyProperty MouseHoverBackgroundProperty = DependencyProperty.RegisterAttached( "MouseHoverBackground", typeof(Brush), typeof(BackgroundSwitchElement), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.Inherits)); diff --git a/HandyControl/Controls/Attach/BorderElement.cs b/HandyControl/Controls/Attach/BorderElement.cs index 451095e1..05db296b 100644 --- a/HandyControl/Controls/Attach/BorderElement.cs +++ b/HandyControl/Controls/Attach/BorderElement.cs @@ -2,7 +2,7 @@ namespace HandyControl.Controls { - public class BorderElement : DependencyObject + public class BorderElement { public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.RegisterAttached( "CornerRadius", typeof(CornerRadius), typeof(BorderElement), new FrameworkPropertyMetadata(default(CornerRadius), FrameworkPropertyMetadataOptions.Inherits)); diff --git a/HandyControl/Controls/Attach/DataGridAttach.cs b/HandyControl/Controls/Attach/DataGridAttach.cs index 68416965..7d49181f 100644 --- a/HandyControl/Controls/Attach/DataGridAttach.cs +++ b/HandyControl/Controls/Attach/DataGridAttach.cs @@ -6,7 +6,7 @@ using HandyControl.Data; namespace HandyControl.Controls { - public class DataGridAttach : DependencyObject + public class DataGridAttach { public static readonly DependencyProperty TextColumnStyleProperty = DependencyProperty.RegisterAttached( "TextColumnStyle", typeof(Style), typeof(DataGridAttach), new PropertyMetadata(default(Style), OnTextColumnStyleChanged)); diff --git a/HandyControl/Controls/Attach/EdgeElement.cs b/HandyControl/Controls/Attach/EdgeElement.cs index 60c2a552..7103947c 100644 --- a/HandyControl/Controls/Attach/EdgeElement.cs +++ b/HandyControl/Controls/Attach/EdgeElement.cs @@ -1,10 +1,9 @@ using System.Windows; using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { - public class EdgeElement : DependencyObject + public class EdgeElement { public static readonly DependencyProperty LeftContentProperty = DependencyProperty.RegisterAttached( "LeftContent", typeof(object), typeof(EdgeElement), new PropertyMetadata(default(object), OnEdgeContentChanged)); diff --git a/HandyControl/Controls/Attach/IconElement.cs b/HandyControl/Controls/Attach/IconElement.cs index 003da5da..9a39bbc1 100644 --- a/HandyControl/Controls/Attach/IconElement.cs +++ b/HandyControl/Controls/Attach/IconElement.cs @@ -1,22 +1,36 @@ using System.Windows; using System.Windows.Media; +using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { - public class IconElement : DependencyObject + public class IconElement { public static readonly DependencyProperty GeometryProperty = DependencyProperty.RegisterAttached( "Geometry", typeof(Geometry), typeof(IconElement), new PropertyMetadata(default(Geometry))); public static void SetGeometry(DependencyObject element, Geometry value) - { - element.SetValue(GeometryProperty, value); - } + => element.SetValue(GeometryProperty, value); - public static Geometry GetGeometry(DependencyObject element) - { - return (Geometry)element.GetValue(GeometryProperty); - } + public static Geometry GetGeometry(DependencyObject element) + => (Geometry) element.GetValue(GeometryProperty); + + public static readonly DependencyProperty WidthProperty = DependencyProperty.RegisterAttached( + "Width", typeof(double), typeof(IconElement), new PropertyMetadata(ValueBoxes.Double0Box)); + + public static void SetWidth(DependencyObject element, double value) + => element.SetValue(WidthProperty, value); + + public static double GetWidth(DependencyObject element) + => (double) element.GetValue(WidthProperty); + + public static readonly DependencyProperty HeightProperty = DependencyProperty.RegisterAttached( + "Height", typeof(double), typeof(IconElement), new PropertyMetadata(ValueBoxes.Double0Box)); + + public static void SetHeight(DependencyObject element, double value) + => element.SetValue(HeightProperty, value); + + public static double GetHeight(DependencyObject element) + => (double) element.GetValue(HeightProperty); } } \ No newline at end of file diff --git a/HandyControl/Controls/Attach/IconSwitchElement.cs b/HandyControl/Controls/Attach/IconSwitchElement.cs index 0b6f8a9a..8bdcfb2d 100644 --- a/HandyControl/Controls/Attach/IconSwitchElement.cs +++ b/HandyControl/Controls/Attach/IconSwitchElement.cs @@ -1,10 +1,9 @@ using System.Windows; using System.Windows.Media; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { - public class IconSwitchElement : DependencyObject + public class IconSwitchElement { public static readonly DependencyProperty GeometryProperty = DependencyProperty.RegisterAttached( "Geometry", typeof(Geometry), typeof(IconSwitchElement), new PropertyMetadata(default(Geometry))); diff --git a/HandyControl/Controls/Attach/InfoElement.cs b/HandyControl/Controls/Attach/InfoElement.cs index 96556197..73777651 100644 --- a/HandyControl/Controls/Attach/InfoElement.cs +++ b/HandyControl/Controls/Attach/InfoElement.cs @@ -1,10 +1,9 @@ using System.Windows; using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { - public class InfoElement : DependencyObject + public class InfoElement { /// /// 标题 diff --git a/HandyControl/Controls/Attach/PasswordBoxMonitor.cs b/HandyControl/Controls/Attach/PasswordBoxMonitor.cs index 0e78d619..450613f2 100644 --- a/HandyControl/Controls/Attach/PasswordBoxMonitor.cs +++ b/HandyControl/Controls/Attach/PasswordBoxMonitor.cs @@ -1,7 +1,6 @@ using System.Windows; using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { public class PasswordBoxMonitor diff --git a/HandyControl/Controls/Attach/StatusSwitchElement.cs b/HandyControl/Controls/Attach/StatusSwitchElement.cs index b1e8e74a..350c82d9 100644 --- a/HandyControl/Controls/Attach/StatusSwitchElement.cs +++ b/HandyControl/Controls/Attach/StatusSwitchElement.cs @@ -1,7 +1,6 @@ using System.Windows; using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { public class StatusSwitchElement diff --git a/HandyControl/Controls/Attach/TipElement.cs b/HandyControl/Controls/Attach/TipElement.cs index ca3f9caa..5fa5481f 100644 --- a/HandyControl/Controls/Attach/TipElement.cs +++ b/HandyControl/Controls/Attach/TipElement.cs @@ -1,10 +1,9 @@ using System.Windows; using HandyControl.Data; -// ReSharper disable once CheckNamespace namespace HandyControl.Controls { - public class TipElement : DependencyObject + public class TipElement { public static readonly DependencyProperty VisibilityProperty = DependencyProperty.RegisterAttached( "Visibility", typeof(Visibility), typeof(TipElement), new PropertyMetadata(Visibility.Collapsed)); diff --git a/HandyControl/Controls/Attach/TitleElement.cs b/HandyControl/Controls/Attach/TitleElement.cs index 5fab90ea..14415c6f 100644 --- a/HandyControl/Controls/Attach/TitleElement.cs +++ b/HandyControl/Controls/Attach/TitleElement.cs @@ -3,7 +3,7 @@ using System.Windows.Media; namespace HandyControl.Controls { - public class TitleElement : DependencyObject + public class TitleElement { public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached( "Background", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits)); diff --git a/HandyControl/Controls/Attach/VisualElement.cs b/HandyControl/Controls/Attach/VisualElement.cs new file mode 100644 index 00000000..511922bc --- /dev/null +++ b/HandyControl/Controls/Attach/VisualElement.cs @@ -0,0 +1,17 @@ +using System.Windows; +using System.Windows.Media; + +namespace HandyControl.Controls +{ + public class VisualElement + { + public static readonly DependencyProperty HighlightBrushProperty = DependencyProperty.RegisterAttached( + "HighlightBrush", typeof(Brush), typeof(VisualElement), new PropertyMetadata(default(Brush))); + + public static void SetHighlightBrush(DependencyObject element, Brush value) + => element.SetValue(HighlightBrushProperty, value); + + public static Brush GetHighlightBrush(DependencyObject element) + => (Brush) element.GetValue(HighlightBrushProperty); + } +} \ No newline at end of file diff --git a/HandyControl/Controls/Input/ImageRadioButton.cs b/HandyControl/Controls/Input/ImageRadioButton.cs deleted file mode 100644 index e74228a7..00000000 --- a/HandyControl/Controls/Input/ImageRadioButton.cs +++ /dev/null @@ -1,47 +0,0 @@ -using HandyControl.Data; -using HandyControl.Tools; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; - -namespace HandyControl.Controls -{ - public class ImageRadioButton : RadioButton - { - public ImageRadioButton() - { - SetSideBrush(this, ResourceHelper.GetResource(ResourceToken.PrimaryBrush)); - } - - public double ImageWidth - { - get { return (double)GetValue(ImageWidthProperty); } - set { SetValue(ImageWidthProperty, value); } - } - - public static readonly DependencyProperty ImageWidthProperty = - DependencyProperty.Register("ImageWidth", typeof(double), typeof(ImageRadioButton), new PropertyMetadata(15.0)); - - public double ImageHeight - { - get { return (double)GetValue(ImageHeightProperty); } - set { SetValue(ImageHeightProperty, value); } - } - - public static readonly DependencyProperty ImageHeightProperty = - DependencyProperty.Register("ImageHeight", typeof(double), typeof(ImageRadioButton), new PropertyMetadata(15.0)); - - public static readonly DependencyProperty SideBrushProperty = DependencyProperty.RegisterAttached( - "SideBrush", typeof(Brush), typeof(ImageRadioButton), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.Inherits)); - - public static void SetSideBrush(DependencyObject element, Brush value) => element.SetValue(SideBrushProperty, value); - - public static Brush GetSideBrush(DependencyObject element) => (Brush)element.GetValue(SideBrushProperty); - - } -} diff --git a/HandyControl/Data/ValueBoxes.cs b/HandyControl/Data/ValueBoxes.cs index b1d1aef2..ece11652 100644 --- a/HandyControl/Data/ValueBoxes.cs +++ b/HandyControl/Data/ValueBoxes.cs @@ -1,7 +1,7 @@ namespace HandyControl.Data { /// - /// 装箱后的布尔值(用于提高效率) + /// 装箱后的值类型(用于提高效率) /// internal static class ValueBoxes { diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 16760bb7..60c9cd5a 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -45,7 +45,7 @@ v4.6.2 - + diff --git a/HandyControl/Themes/Styles/Base/RadioButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/RadioButtonBaseStyle.xaml index d1b7764e..771c7a1a 100644 --- a/HandyControl/Themes/Styles/Base/RadioButtonBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/RadioButtonBaseStyle.xaml @@ -94,6 +94,60 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/HandyControl/Themes/Styles/RadioButton.xaml b/HandyControl/Themes/Styles/RadioButton.xaml index cc27d30b..34f08e2f 100644 --- a/HandyControl/Themes/Styles/RadioButton.xaml +++ b/HandyControl/Themes/Styles/RadioButton.xaml @@ -9,68 +9,7 @@ +