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] 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 @@ +