Skip to content

Commit

Permalink
chore(style): add GroupBox small style.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Oct 6, 2022
1 parent 5e364ff commit 8b52df3
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 85 deletions.
37 changes: 25 additions & 12 deletions src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@
<ControlTemplate x:Key="GroupBoxBaseTopTemplate" TargetType="GroupBox">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="30" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Border MinHeight="30" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,6">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="10,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border MinHeight="{Binding Path=(hc:TitleElement.MinHeight), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,0,6">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<Border Grid.Row="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
Expand All @@ -512,11 +512,11 @@
<ControlTemplate x:Key="GroupBoxBaseLeftTemplate" TargetType="GroupBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border MinWidth="30" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="False" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,6,0">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,10" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RenderTransformOrigin="0.5,0.5">
<Border MinWidth="{Binding Path=(hc:TitleElement.MinWidth), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="False" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Margin="0,0,6,0">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RenderTransformOrigin="0.5,0.5">
<ContentPresenter.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
Expand All @@ -532,28 +532,28 @@
<ControlTemplate x:Key="GroupBoxTabTopTemplate" TargetType="GroupBox">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="30" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,0,1,1'}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<Border Grid.Row="0" MinHeight="30" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,1,0'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,1,0,0'}">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="10,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border Grid.Row="0" MinHeight="{Binding Path=(hc:TitleElement.MinHeight), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,1,0'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,1,0,0'}">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="GroupBoxTabLeftTemplate" TargetType="GroupBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border Grid.Column="1" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,1,1,0'}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<Border Grid.Column="0" MinWidth="30" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,0,1'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,0,0,1'}">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,10" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<Border Grid.Column="0" MinWidth="{Binding Path=(hc:TitleElement.MinWidth), RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource ThicknessSplitConverter},ConverterParameter='1,1,0,1'}" BorderBrush="{TemplateBinding BorderBrush}" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,0,0,1'}">
<ContentPresenter TextElement.Foreground="{TemplateBinding Foreground}" Margin="{Binding Path=(hc:TitleElement.Padding), RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<ContentPresenter.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
Expand Down Expand Up @@ -2443,6 +2443,9 @@
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource SecondaryRegionBrush}" />
<Setter Property="hc:TitleElement.TitlePlacement" Value="Top" />
<Setter Property="hc:TitleElement.Padding" Value="4 0" />
<Setter Property="hc:TitleElement.MinHeight" Value="{StaticResource DefaultControlHeight}" />
<Setter Property="hc:TitleElement.MinWidth" Value="{StaticResource DefaultControlHeight}" />
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
Expand All @@ -2452,6 +2455,7 @@
<Style.Triggers>
<Trigger Property="hc:TitleElement.TitlePlacement" Value="Left">
<Setter Property="Template" Value="{StaticResource GroupBoxBaseLeftTemplate}" />
<Setter Property="hc:TitleElement.Padding" Value="0 4" />
</Trigger>
</Style.Triggers>
</Style>
Expand Down Expand Up @@ -2503,6 +2507,7 @@
<Style.Triggers>
<Trigger Property="hc:TitleElement.TitlePlacement" Value="Left">
<Setter Property="Template" Value="{StaticResource GroupBoxTabLeftTemplate}" />
<Setter Property="hc:TitleElement.Padding" Value="0 4" />
</Trigger>
</Style.Triggers>
</Style>
Expand Down Expand Up @@ -4359,8 +4364,16 @@
</Setter>
</Style>
<Style BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox" />
<Style x:Key="GroupBox.Small" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
<Setter Property="hc:TitleElement.MinHeight" Value="20" />
<Setter Property="hc:TitleElement.MinWidth" Value="20" />
</Style>
<Style x:Key="GroupBoxOriginal" BasedOn="{StaticResource GroupBoxOriginalBaseStyle}" TargetType="GroupBox" />
<Style x:Key="GroupBoxTab" BasedOn="{StaticResource GroupBoxTabBaseStyle}" TargetType="GroupBox" />
<Style x:Key="GroupBoxTab.Small" BasedOn="{StaticResource GroupBoxTab}" TargetType="GroupBox">
<Setter Property="hc:TitleElement.MinHeight" Value="20" />
<Setter Property="hc:TitleElement.MinWidth" Value="20" />
</Style>
<Style BasedOn="{StaticResource ButtonGroupBaseStyle}" TargetType="hc:ButtonGroup" />
<Style x:Key="ButtonGroupSolid" BasedOn="{StaticResource ButtonGroupBaseStyle}" TargetType="hc:ButtonGroup">
<Setter Property="hc:VisualElement.HighlightBorderBrush" Value="{DynamicResource TitleBrush}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</GroupBox>
<GroupBox Height="200" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Padding="10" Style="{StaticResource GroupBox.Small}">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</GroupBox>
<GroupBox Height="200" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Padding="10" Style="{StaticResource GroupBox.Small}" hc:TitleElement.TitlePlacement="Left">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</GroupBox>
<GroupBox Height="200" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Padding="10" Style="{StaticResource GroupBoxTab}">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
Expand All @@ -28,6 +38,16 @@
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</GroupBox>
<GroupBox Height="200" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Padding="10" Style="{StaticResource GroupBoxTab.Small}">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</GroupBox>
<GroupBox Height="200" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Padding="10" Style="{StaticResource GroupBoxTab.Small}" hc:TitleElement.TitlePlacement="Left">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock Text="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</GroupBox>
<hc:UniformSpacingPanel Orientation="Vertical" Spacing="16">
<GroupBox VerticalAlignment="Bottom" Header="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Style="{StaticResource GroupBoxOriginal}" HorizontalContentAlignment="Left">
<TextBox/>
Expand Down
21 changes: 21 additions & 0 deletions src/Shared/HandyControl_Shared/Controls/Attach/TitleElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,25 @@ public static void SetMarginOnTheLeft(DependencyObject element, Thickness value)

public static Thickness GetMarginOnTheLeft(DependencyObject element)
=> (Thickness) element.GetValue(MarginOnTheLeftProperty);

public static readonly DependencyProperty PaddingProperty = DependencyProperty.RegisterAttached(
"Padding", typeof(Thickness), typeof(TitleElement), new FrameworkPropertyMetadata(default(Thickness), FrameworkPropertyMetadataOptions.Inherits));

public static void SetPadding(DependencyObject element, Thickness value) => element.SetValue(PaddingProperty, value);

public static Thickness GetPadding(DependencyObject element) => (Thickness) element.GetValue(PaddingProperty);

public static readonly DependencyProperty MinHeightProperty =
DependencyProperty.RegisterAttached("MinHeight", typeof(double), typeof(TitleElement), new PropertyMetadata(ValueBoxes.Double0Box));

public static double GetMinHeight(DependencyObject obj) => (double) obj.GetValue(MinHeightProperty);

public static void SetMinHeight(DependencyObject obj, double value) => obj.SetValue(MinHeightProperty, value);

public static readonly DependencyProperty MinWidthProperty =
DependencyProperty.RegisterAttached("MinWidth", typeof(double), typeof(TitleElement), new PropertyMetadata(ValueBoxes.Double0Box));

public static double GetMinWidth(DependencyObject obj) => (double) obj.GetValue(MinWidthProperty);

public static void SetMinWidth(DependencyObject obj, double value) => obj.SetValue(MinWidthProperty, value);
}

0 comments on commit 8b52df3

Please sign in to comment.