Merge branch 'master' into new-branch-name

This commit is contained in:
NaBian 2018-12-06 21:10:23 +08:00 committed by GitHub
commit b9024a51d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 597 additions and 44 deletions

View File

@ -13,5 +13,23 @@ namespace HandyControl.Controls
public static Brush GetBackground(DependencyObject element)
=> (Brush) element.GetValue(BackgroundProperty);
public static readonly DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached(
"Foreground", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
public static void SetForeground(DependencyObject element, Brush value)
=> element.SetValue(ForegroundProperty, value);
public static Brush GetForeground(DependencyObject element)
=> (Brush) element.GetValue(ForegroundProperty);
public static readonly DependencyProperty BorderBrushProperty = DependencyProperty.RegisterAttached(
"BorderBrush", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
public static void SetBorderBrush(DependencyObject element, Brush value)
=> element.SetValue(BorderBrushProperty, value);
public static Brush GetBorderBrush(DependencyObject element)
=> (Brush) element.GetValue(BorderBrushProperty);
}
}

View File

@ -0,0 +1,52 @@
using System.Windows;
using System.Windows.Controls;
using HandyControl.Tools;
namespace HandyControl.Controls
{
public class RadioGroup : ItemsControl
{
protected override DependencyObject GetContainerForItemOverride() => new RadioButton();
protected override bool IsItemItsOwnContainerOverride(object item) => item is RadioButton;
//public static readonly DependencyProperty GroupNameProperty = DependencyProperty.Register(
// "GroupName", typeof(string), typeof(RadioGroup), new PropertyMetadata(default(string)));
//public string GroupName
//{
// get => (string) GetValue(GroupNameProperty);
// set => SetValue(GroupNameProperty, value);
//}
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
"Orientation", typeof(Orientation), typeof(RadioGroup), new PropertyMetadata(default(Orientation)));
public Orientation Orientation
{
get => (Orientation)GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
public static readonly DependencyProperty ItemStyleSelectorProperty = DependencyProperty.Register(
"ItemStyleSelector", typeof(StyleSelector), typeof(RadioGroup), new PropertyMetadata(new RadioGroupItemStyleSelector()));
public StyleSelector ItemStyleSelector
{
get => (StyleSelector)GetValue(ItemStyleSelectorProperty);
set => SetValue(ItemStyleSelectorProperty, value);
}
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
{
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
var count = Items.Count;
for (int i = 0; i < count; i++)
{
var item = (RadioButton)Items[i];
item.Style = ItemStyleSelector?.SelectStyle(item, this);
}
}
}
}

View File

@ -38,5 +38,29 @@
public static readonly string AddTagButtonStyle = nameof(AddTagButtonStyle);
public static readonly string RadioGroupItemDefault = nameof(RadioGroupItemDefault);
public static readonly string RadioGroupItemSingle = nameof(RadioGroupItemSingle);
public static readonly string RadioGroupItemHorizontalFirst = nameof(RadioGroupItemHorizontalFirst);
public static readonly string RadioGroupItemHorizontalLast = nameof(RadioGroupItemHorizontalLast);
public static readonly string RadioGroupItemVerticalFirst = nameof(RadioGroupItemVerticalFirst);
public static readonly string RadioGroupItemVerticalLast = nameof(RadioGroupItemVerticalLast);
public static readonly string TabItemCapsuleDefault = nameof(TabItemCapsuleDefault);
public static readonly string TabItemCapsuleSingle = nameof(TabItemCapsuleSingle);
public static readonly string TabItemCapsuleHorizontalFirst = nameof(TabItemCapsuleHorizontalFirst);
public static readonly string TabItemCapsuleHorizontalLast = nameof(TabItemCapsuleHorizontalLast);
public static readonly string TabItemCapsuleVerticalFirst = nameof(TabItemCapsuleVerticalFirst);
public static readonly string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
}
}

View File

@ -27,7 +27,19 @@ var styleList = new List<string>
"ButtonCustom",
"PaginationButtonStyle",
"CustomWindowStyle",
"AddTagButtonStyle"
"AddTagButtonStyle",
"RadioGroupItemDefault",
"RadioGroupItemSingle",
"RadioGroupItemHorizontalFirst",
"RadioGroupItemHorizontalLast",
"RadioGroupItemVerticalFirst",
"RadioGroupItemVerticalLast",
"TabItemCapsuleDefault",
"TabItemCapsuleSingle",
"TabItemCapsuleHorizontalFirst",
"TabItemCapsuleHorizontalLast",
"TabItemCapsuleVerticalFirst",
"TabItemCapsuleVerticalLast"
};
#>
namespace HandyControl.Data

View File

@ -17,6 +17,10 @@
internal static object DoubleNeg1Box = -1.0;
internal static object Int0Box = 0;
internal static object Int1Box = 1;
internal static object BooleanBox(bool value) => value ? TrueBox : FalseBox;
}
}

View File

@ -62,6 +62,7 @@
<Compile Include="Controls\Other\Carousel.cs" />
<Compile Include="Controls\Other\CirclePanel.cs" />
<Compile Include="Controls\Other\CircleProgressBar.cs" />
<Compile Include="Controls\Other\RadioGroup.cs" />
<Compile Include="Controls\Text\OutlineText.cs" />
<Compile Include="Controls\Other\GifImage.cs" />
<Compile Include="Controls\Input\SearchBar.cs" />
@ -105,7 +106,7 @@
<Compile Include="Data\Gif\GifPropertyItem.cs" />
<Compile Include="Data\Gif\GifPropertyItemInternal.cs" />
<Compile Include="Data\Gif\GPStream.cs" />
<Compile Include="Tools\ColorHelper.cs" />
<Compile Include="Tools\Helper\ColorHelper.cs" />
<Compile Include="Tools\GifImageAnimator.cs" />
<Compile Include="Data\GrowlInfo.cs" />
<Compile Include="Data\Operation\OperationResult!1.cs" />
@ -147,8 +148,8 @@
<Compile Include="Expression\Media\UnitType.cs" />
<Compile Include="Expression\Shapes\Arc.cs" />
<Compile Include="Expression\Shapes\PrimitiveShape.cs" />
<Compile Include="Tools\ExternDllHelper.cs" />
<Compile Include="Tools\SingleOpenHelper.cs" />
<Compile Include="Tools\Helper\ExternDllHelper.cs" />
<Compile Include="Tools\Helper\SingleOpenHelper.cs" />
<Compile Include="Controls\TabControl\TabControl.cs" />
<Compile Include="Controls\TabControl\TabItem.cs" />
<Compile Include="Controls\TabControl\TabPanel.cs" />
@ -212,8 +213,8 @@
<DesignTime>True</DesignTime>
<DependentUpon>Lang.en.resx</DependentUpon>
</Compile>
<Compile Include="Tools\AnimationHelper.cs" />
<Compile Include="Tools\ArithmeticHelper.cs" />
<Compile Include="Tools\Helper\AnimationHelper.cs" />
<Compile Include="Tools\Helper\ArithmeticHelper.cs" />
<Compile Include="Tools\Converter\Boolean2BooleanReConverter.cs" />
<Compile Include="Tools\Converter\Boolean2VisibilityReConverter.cs" />
<Compile Include="Tools\Converter\BooleanArr2VisibilityConverter.cs" />
@ -228,11 +229,13 @@
<Compile Include="Tools\Extension\ColorExtension.cs" />
<Compile Include="Tools\Extension\UIElementExtension.cs" />
<Compile Include="Tools\MouseDragElementBehaviorEx.cs" />
<Compile Include="Tools\StyleSelector\RadioGroupItemStyleSelector.cs" />
<Compile Include="Tools\RegularJudgment.cs" />
<Compile Include="Tools\RegularPatterns.cs" />
<Compile Include="Tools\ResourceHelper.cs" />
<Compile Include="Tools\ValidateHelper.cs" />
<Compile Include="Tools\VisualHelper.cs" />
<Compile Include="Tools\Helper\ResourceHelper.cs" />
<Compile Include="Tools\Helper\ValidateHelper.cs" />
<Compile Include="Tools\Helper\VisualHelper.cs" />
<Compile Include="Tools\StyleSelector\TabItemCapsuleStyleSelector.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="Themes\Basic\Basic.xaml">
@ -295,6 +298,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\RadioGroupBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\SearchBarBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -507,6 +514,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\RadioGroup.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\RichTextBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -620,5 +631,6 @@
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -47,7 +47,7 @@ namespace HandyControl.Properties.Langs {
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]

View File

@ -1,5 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Basic/Sizes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="RadioButtonBaseStyle" TargetType="RadioButton">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
@ -88,4 +94,49 @@
</Setter>
</Style>
<Style x:Key="RadioGroupItemBaseStyle" TargetType="RadioButton">
<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="1"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="controls:BorderElement.CornerRadius" Value="0"/>
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="Margin" Value="-1,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border x:Name="BorderRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter x:Name="contentPresenter" TextElement.Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter Property="BorderBrush" Value="{Binding Path=(controls:TitleElement.BorderBrush),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
<Setter Property="Background" Value="{Binding Path=(controls:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
<Setter Property="TextElement.Foreground" Value="{Binding Path=(controls:TitleElement.Foreground),RelativeSource={RelativeSource TemplatedParent}}" TargetName="contentPresenter"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Panel.ZIndex" Value="{x:Static system:Int32.MaxValue}"/>
</Trigger>
<DataTrigger Binding="{Binding Orientation,RelativeSource={RelativeSource FindAncestor, AncestorType=controls:RadioGroup}}" Value="Vertical">
<Setter Property="Margin" Value="0,-1,0,0"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@ -0,0 +1,26 @@
<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"
xmlns:tools="clr-namespace:HandyControl.Tools">
<ItemsPanelTemplate x:Key="RadioGroupHorizontalItemsPanelTemplate">
<UniformGrid FocusVisualStyle="{x:Null}" Rows="1"/>
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="RadioGroupVerticalItemsPanelTemplate">
<UniformGrid FocusVisualStyle="{x:Null}" Columns="1"/>
</ItemsPanelTemplate>
<Style x:Key="RadioGroupBaseStyle" TargetType="controls:RadioGroup">
<Setter Property="ItemsPanel" Value="{StaticResource RadioGroupHorizontalItemsPanelTemplate}"/>
<Setter Property="controls:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="controls:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="ItemsPanel" Value="{StaticResource RadioGroupVerticalItemsPanelTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@ -1,5 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Basic/Sizes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="TabItemStyle" TargetType="TabItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
@ -70,4 +76,41 @@
</Setter>
</Style>
<Style x:Key="TabItemCapsuleBaseStyle" TargetType="TabItem">
<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="1"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="controls:BorderElement.CornerRadius" Value="0"/>
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="Padding" Value="10,0"/>
<Setter Property="Margin" Value="-1,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border x:Name="BorderRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter x:Name="contentPresenter" ContentSource="Header" TextElement.Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="Center" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="BorderBrush" Value="{Binding Path=(controls:TitleElement.BorderBrush),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
<Setter Property="Background" Value="{Binding Path=(controls:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
<Setter Property="TextElement.Foreground" Value="{Binding Path=(controls:TitleElement.Foreground),RelativeSource={RelativeSource TemplatedParent}}" TargetName="contentPresenter"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="{x:Static system:Int32.MaxValue}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

View File

@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<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>
<ResourceDictionary Source="Base/RadioButtonBaseStyle.xaml"/>
@ -71,4 +71,28 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RadioGroupItemDefault" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton"/>
<Style x:Key="RadioGroupItemHorizontalFirst" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="4,0,0,4"/>
<Setter Property="Margin" Value="0"/>
</Style>
<Style x:Key="RadioGroupItemHorizontalLast" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="0,4,4,0"/>
</Style>
<Style x:Key="RadioGroupItemSingle" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
</Style>
<Style x:Key="RadioGroupItemVerticalFirst" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="4,4,0,0"/>
<Setter Property="Margin" Value="0"/>
</Style>
<Style x:Key="RadioGroupItemVerticalLast" BasedOn="{StaticResource RadioGroupItemBaseStyle}" TargetType="RadioButton">
<Setter Property="controls:BorderElement.CornerRadius" Value="0,0,4,4"/>
</Style>
</ResourceDictionary>

View File

@ -0,0 +1,17 @@
<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>
<ResourceDictionary Source="Base/RadioGroupBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource RadioGroupBaseStyle}" TargetType="controls:RadioGroup"/>
<Style x:Key="RadioGroupSolid" BasedOn="{StaticResource RadioGroupBaseStyle}" TargetType="controls:RadioGroup">
<Setter Property="controls:TitleElement.BorderBrush" Value="{DynamicResource TitleBrush}"/>
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
<Setter Property="controls:TitleElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
</Style>
</ResourceDictionary>

View File

@ -46,6 +46,7 @@
<ResourceDictionary Source="ToolBar.xaml"/>
<ResourceDictionary Source="SearchBar.xaml"/>
<ResourceDictionary Source="Tag.xaml"/>
<ResourceDictionary Source="RadioGroup.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

View File

@ -2,7 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:tools="clr-namespace:HandyControl.Tools">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Basic/Paths.xaml"/>
@ -145,4 +146,65 @@
</Setter>
</Style>
<Style x:Key="TabItemCapsuleDefault" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem"/>
<Style x:Key="TabItemCapsuleHorizontalFirst" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem">
<Setter Property="controls:BorderElement.CornerRadius" Value="4,0,0,4"/>
<Setter Property="Margin" Value="0"/>
</Style>
<Style x:Key="TabItemCapsuleHorizontalLast" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem">
<Setter Property="controls:BorderElement.CornerRadius" Value="0,4,4,0"/>
</Style>
<Style x:Key="TabItemCapsuleSingle" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem">
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
</Style>
<Style x:Key="TabItemCapsuleVerticalFirst" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem">
<Setter Property="controls:BorderElement.CornerRadius" Value="4,4,0,0"/>
<Setter Property="Margin" Value="0"/>
</Style>
<Style x:Key="TabItemCapsuleVerticalLast" BasedOn="{StaticResource TabItemCapsuleBaseStyle}" TargetType="TabItem">
<Setter Property="controls:BorderElement.CornerRadius" Value="0,0,4,4"/>
</Style>
<Style x:Key="TabControlCapsule" TargetType="TabControl">
<Setter Property="controls:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="controls:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}"/>
<Setter Property="ItemContainerStyleSelector">
<Setter.Value>
<tools:TabItemCapsuleStyleSelector/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabControl">
<Grid x:Name="templateRoot" Background="{DynamicResource RegionBrush}" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<UniformGrid Rows="1" HorizontalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabControlCapsuleSolid" BasedOn="{StaticResource TabControlCapsule}" TargetType="TabControl">
<Setter Property="controls:TitleElement.BorderBrush" Value="{DynamicResource TitleBrush}"/>
<Setter Property="controls:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
<Setter Property="controls:TitleElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
</Style>
</ResourceDictionary>

View File

@ -0,0 +1,37 @@
using System.Windows;
using System.Windows.Controls;
using HandyControl.Controls;
using HandyControl.Data;
namespace HandyControl.Tools
{
public class RadioGroupItemStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
if (container is RadioGroup radioGroup && item is UIElement radioButton)
{
var count = radioGroup.Items.Count;
if (count == 1)
{
return ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemSingle);
}
var index = radioGroup.Items.IndexOf(radioButton);
return radioGroup.Orientation == Orientation.Horizontal
? index == 0
? ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemHorizontalFirst)
: ResourceHelper.GetResource<Style>(index == count - 1
? ResourceToken.RadioGroupItemHorizontalLast
: ResourceToken.RadioGroupItemDefault)
: index == 0
? ResourceHelper.GetResource<Style>(ResourceToken.RadioGroupItemVerticalFirst)
: ResourceHelper.GetResource<Style>(index == count - 1
? ResourceToken.RadioGroupItemVerticalLast
: ResourceToken.RadioGroupItemDefault);
}
return null;
}
}
}

View File

@ -0,0 +1,30 @@
using System.Windows;
using System.Windows.Controls;
using HandyControl.Data;
namespace HandyControl.Tools
{
public class TabItemCapsuleStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
if (item is TabItem tabItem && tabItem.Parent is TabControl tabControl)
{
var count = tabControl.Items.Count;
if (count == 1)
{
return ResourceHelper.GetResource<Style>(ResourceToken.TabItemCapsuleSingle);
}
var index = tabControl.Items.IndexOf(tabItem);
return index == 0
? ResourceHelper.GetResource<Style>(ResourceToken.TabItemCapsuleHorizontalFirst)
: ResourceHelper.GetResource<Style>(index == count - 1
? ResourceToken.TabItemCapsuleHorizontalLast
: ResourceToken.TabItemCapsuleDefault);
}
return null;
}
}
}

View File

@ -6,92 +6,176 @@
Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl>
<ScrollViewer>
<StackPanel>
<TabControl Margin="32" Width="800" Height="300">
<UniformGrid Rows="2" Columns="2" Margin="16">
<TabControl Margin="16" Width="400" Height="200">
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}1">
<Border Background="{DynamicResource PrimaryBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}2">
<Border Background="{DynamicResource SuccessBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}3">
<Border Background="{DynamicResource InfoBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}4">
<Border Background="{DynamicResource WarningBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}5">
<Border Background="{DynamicResource DangerBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
</TextBlock>
</Border>
</TabItem>
</TabControl>
<TabControl Margin="32,0,32,32" Width="800" Height="300" Style="{StaticResource TabControlInLine}">
<TabControl Margin="16" Width="400" Height="200" Style="{StaticResource TabControlInLine}">
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}1">
<Border Background="{DynamicResource PrimaryBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}2">
<Border Background="{DynamicResource SuccessBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}3">
<Border Background="{DynamicResource InfoBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}4">
<Border Background="{DynamicResource WarningBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
</TextBlock>
</Border>
</TabItem>
<TabItem IsSelected="True" Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}5">
<Border Background="{DynamicResource DangerBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
</TextBlock>
</Border>
</TabItem>
</TabControl>
</StackPanel>
<TabControl Margin="16" Width="400" Height="200" Style="{StaticResource TabControlCapsule}">
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}1">
<Border Background="{DynamicResource PrimaryBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
</TextBlock>
</Border>
</TabItem>
<TabItem IsSelected="True" Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}2">
<Border Background="{DynamicResource SuccessBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}3">
<Border Background="{DynamicResource InfoBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}4">
<Border Background="{DynamicResource WarningBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}5">
<Border Background="{DynamicResource DangerBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
</TextBlock>
</Border>
</TabItem>
</TabControl>
<TabControl Margin="16" Width="400" Height="200" Style="{StaticResource TabControlCapsuleSolid}">
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}1">
<Border Background="{DynamicResource PrimaryBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="1"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}2">
<Border Background="{DynamicResource SuccessBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="2"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}3">
<Border Background="{DynamicResource InfoBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="3"/>
</TextBlock>
</Border>
</TabItem>
<TabItem IsSelected="True" Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}4">
<Border Background="{DynamicResource WarningBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="4"/>
</TextBlock>
</Border>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Title}" HeaderStringFormat="{}{0}5">
<Border Background="{DynamicResource DangerBrush}">
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}">
<Run Text="{x:Static langs:Lang.Text}"/>
<Run Text="5"/>
</TextBlock>
</Border>
</TabItem>
</TabControl>
</UniformGrid>
</ScrollViewer>
</controls:TransitioningContentControl>
</UserControl>

View File

@ -1,10 +1,10 @@
<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"
Background="{DynamicResource RegionBrush}"
Width="400">
xmlns:system="clr-namespace:System;assembly=mscorlib"
Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl>
<StackPanel Width="400">
<GroupBox Background="Transparent" Margin="10" Header="Base Style">
@ -69,7 +69,7 @@
</Expander>
</StackPanel>
</StackPanel>
</GroupBox>
</GroupBox>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>

View File

@ -28,6 +28,34 @@
## History publication
### ButtonStyle
![ButtonStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Button.png)
### ToggleButtonStyle
![ToggleButtonStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ToggleButton.png)
### RadioButtonStyle
![RadioButtonStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/RadioButton.png)
### CheckBoxStyle
![CheckBoxStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CheckBox.png)
### ListBoxStyle
![ListBoxStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ListBox.png)
### TreeViewStyle
![TreeViewStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/TreeView.png)
### ListViewStyle
![ListViewStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ListView.png)
### DataGrid
![DataGrid](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/DataGrid.png)
@ -86,10 +114,22 @@
![TabControl](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/TabControl.gif)
### TabControlStyle
![TabControlStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/TabControl.png)
### StepBar
![StepBar](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/StepBar.png)
### GifImage
![GifImage](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/GifImage.gif)
### ContextMenu
![ContextMenu](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ContextMenu.png)
### Calendar
![Calendar](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Calendar.jpg)
@ -98,10 +138,18 @@
![Clock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Clock.jpg)
### CalendarWithClock
![CalendarWithClock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CalendarWithClock.png)
### TextBlock
![TextBlock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/TextBlock.jpg)
### RichTextBoxStyle
![RichTextBoxStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/RichTextBox.png)
### TextBox
![TextBox](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/TextBox.jpg)
@ -126,6 +174,10 @@
![CirclePanel](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CirclePanel.jpg)
### BorderStyle
![BorderStyle](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Border.png)
# Usage
Step 1Add a reference to HandyControl or search for HandyControl on the nuget;
@ -142,6 +194,10 @@ Step 2Add code in App.xaml as follows:
```
Step 3enjoy coding
# Switching configuration
![Switching configuration](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/SwitchConfig.png)
# Discussion
![DataGrid](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/qq-group.jpg)

BIN
Resources/Border.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
Resources/Button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
Resources/CheckBox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
Resources/ContextMenu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
Resources/GifImage.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
Resources/ListBox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
Resources/ListView.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
Resources/RadioButton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
Resources/RichTextBox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
Resources/SwitchConfig.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
Resources/TabControl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
Resources/ToggleButton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
Resources/TreeView.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB