Merge pull request #20 from ghost1372/new-branch-name

add new control ImageRadioButton
This commit is contained in:
NaBian authored and GitHub committed 2018-12-08 15:17:32 +08:00
commit 9a76cea5ba
18 files changed
+123 -36

No files matched your search

@@ -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));
@@ -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));
@@ -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));
+1 -2
View File
@@ -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));
+23 -9
View File
@@ -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);
}
}
@@ -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)));
+1 -2
View File
@@ -1,10 +1,9 @@
using System.Windows;
using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
public class InfoElement : DependencyObject
public class InfoElement
{
/// <summary>
/// 标题
@@ -1,7 +1,6 @@
using System.Windows;
using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
public class PasswordBoxMonitor
@@ -1,7 +1,6 @@
using System.Windows;
using HandyControl.Data;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
public class StatusSwitchElement
+1 -2
View File
@@ -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));
+1 -1
View File
@@ -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));
@@ -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);
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
namespace HandyControl.Data
{
/// <summary>
/// 装箱后的布尔值(用于提高效率)
/// 装箱后的值类型(用于提高效率)
/// </summary>
internal static class ValueBoxes
{
+1
View File
@@ -45,6 +45,7 @@
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controls\Attach\VisualElement.cs" />
<Compile Include="Controls\Other\AnimationPath.cs" />
<Compile Include="Controls\Attach\BackgroundSwitchElement.cs" />
<Compile Include="Controls\Attach\BorderElement.cs" />
@@ -94,6 +94,60 @@
</Setter>
</Style>
<Style x:Key="RadioButtonIconBaseStyle" TargetType="RadioButton">
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="controls:BorderElement.CornerRadius" Value="0"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="controls:VisualElement.HighlightBrush" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="controls:IconElement.Width" Value="16"/>
<Setter Property="controls:IconElement.Height" Value="16"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<Border Name="BorderHighlight" BorderThickness="3,0,0,0" BorderBrush="Transparent">
<StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
<Path x:Name="PathMain" Height="{Binding Path=(controls:IconElement.Height),RelativeSource={RelativeSource TemplatedParent}}" Width="{Binding Path=(controls:IconElement.Width),RelativeSource={RelativeSource TemplatedParent}}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconElement.Geometry}"/>
<ContentPresenter x:Name="ContentPresenterMain" VerticalAlignment="Center" Margin="6,0,0,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</StackPanel>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Content" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="controls:IconElement.Geometry" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="PathMain"/>
<Setter Property="Margin" Value="0" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" Value="{Binding Path=(controls:VisualElement.HighlightBrush),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderHighlight"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value=".9"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Opacity" Value=".6"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="RadioGroupItemBaseStyle" TargetType="RadioButton">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
-1
View File
@@ -1,5 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
+3 -4
View File
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls">
@@ -9,7 +9,7 @@
<Style BasedOn="{StaticResource RadioButtonBaseStyle}" TargetType="RadioButton"/>
<Style x:Key="RadioButtonCustom" BasedOn="{StaticResource ToggleButtonCustom}" TargetType="RadioButton"/>
<Style x:Key="RadioButtonIcon" BasedOn="{StaticResource RadioButtonIconBaseStyle}" TargetType="RadioButton"/>
<Style x:Key="RadioGroupItemDefault" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton"/>
@@ -34,5 +34,4 @@
<Style x:Key="RadioGroupItemVerticalLast" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="0,0,4,4"/>
</Style>
</ResourceDictionary>
</ResourceDictionary>
@@ -1,17 +1,26 @@
<UserControl x:Class="HandyControlDemo.UserControl.RadioButtonDemoCtl"
<UserControl x:Class="HandyControlDemo.UserControl.RadioButtonDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl>
<StackPanel Margin="32" HorizontalAlignment="Center" VerticalAlignment="Center">
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsChecked="True" IsEnabled="False"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsEnabled="False"/>
<controls:RadioGroup Margin="0,16,0,0">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<StackPanel>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsChecked="True" IsEnabled="False"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="0,16,0,0" Content="{x:Static langs:Lang.RadioButton}" IsEnabled="False"/>
</StackPanel>
<UniformGrid Margin="22,0,0,0" Rows="2" Columns="2">
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" controls:IconElement.Geometry="{StaticResource CalendarGeometry}" Style="{StaticResource RadioButtonIcon}" Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="10,0,0,0" Background="{DynamicResource SecondaryRegionBrush}" Style="{StaticResource RadioButtonIcon}" Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Margin="10,0,0,0" BorderThickness="1" controls:IconElement.Geometry="{StaticResource CalendarGeometry}" Style="{StaticResource RadioButtonIcon}" Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Margin="10,0,0,0" BorderThickness="1" Style="{StaticResource RadioButtonIcon}" Content="{x:Static langs:Lang.RadioButton}"/>
</UniformGrid>
</StackPanel>
<controls:RadioGroup Margin="0,32,0,0">
<RadioButton Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton IsEnabled="False" Content="{x:Static langs:Lang.RadioButton}"/>