Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/CalendarStyle.xaml

371 lines
21 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-08-20 12:10:13 +08:00
xmlns:assists="clr-namespace:NeumUI.Assists"
2025-07-31 20:12:01 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-07-31 20:12:24 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Assets/CommonGeometry.xaml" />
<ResourceDictionary Source="FlattenButton.xaml" />
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<!-- 年月按钮 -->
<Style TargetType="{x:Type CalendarButton}" x:Key="CalendarButtonDefault">
2025-08-12 23:08:54 +08:00
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="MinWidth" Value="48" />
<Setter Property="MinHeight" Value="42" />
<Setter Property="FontSize" Value="12" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CalendarButton}">
<Grid>
2025-07-31 20:12:01 +08:00
<Rectangle
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
2025-07-31 20:12:01 +08:00
Margin="2"
RadiusX="4"
RadiusY="4"
StrokeThickness="{TemplateBinding BorderThickness}"
Visibility="Hidden"
x:Name="SelectionMark" />
<Border
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
CornerRadius="4"
Margin="2"
Visibility="Hidden"
x:Name="SelectedBorder" />
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-08-12 23:08:54 +08:00
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
2025-07-31 20:12:01 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="NormalText" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasSelectedDays" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="Visibility" TargetName="SelectedBorder" Value="Visible" />
2025-08-12 23:08:54 +08:00
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextOnAccentPrimaryBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="Visibility" TargetName="SelectionMark" Value="Visible" />
2025-08-12 23:08:54 +08:00
<Setter Property="Background" TargetName="SelectedBorder" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsInactive" Value="True">
2025-08-12 23:08:54 +08:00
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextSecondaryBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<!-- 日期按钮 -->
<Style TargetType="{x:Type CalendarDayButton}" x:Key="CalendarDayButtonDefault">
2025-07-11 09:20:23 +08:00
<Setter Property="MinWidth" Value="28" />
<Setter Property="MinHeight" Value="26" />
<Setter Property="FontSize" Value="12" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CalendarDayButton}">
<Grid>
2025-07-31 20:12:01 +08:00
<!-- 选中背景 -->
<Rectangle
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
Visibility="Hidden"
x:Name="SelectedBackground" />
<!-- 鼠标划过背景 -->
<Rectangle
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundHoverBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
Visibility="Hidden"
x:Name="HighlightBackground" />
<!-- 今日背景 -->
<Rectangle
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
2025-08-12 23:08:54 +08:00
Stroke="{DynamicResource PrimaryVariantBrush}"
2025-07-31 20:12:01 +08:00
StrokeThickness="0"
Visibility="Hidden"
x:Name="TodayBackground" />
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="5,1,5,1"
2025-08-12 23:08:54 +08:00
TextElement.Foreground="{DynamicResource TextPrimaryBrush}"
2025-07-31 20:12:01 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="NormalText" />
<!-- 叉 -->
<Path
Data="M0,10 L10,0"
Margin="4"
Opacity="0"
RenderTransformOrigin="0.5,0.5"
Stretch="Uniform"
2025-08-12 23:08:54 +08:00
Stroke="{DynamicResource ErrorBrush}"
2025-07-31 20:12:01 +08:00
StrokeThickness="2"
x:Name="Blackout" />
2025-07-11 09:20:23 +08:00
<VisualStateManager.VisualStateGroups>
2025-07-31 20:12:01 +08:00
<!-- 激活状态 -->
2025-07-11 09:20:23 +08:00
<VisualStateGroup x:Name="ActiveStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Active" />
<VisualState x:Name="Inactive">
<Storyboard>
2025-07-31 20:12:01 +08:00
<ColorAnimation
Duration="0"
Storyboard.TargetName="NormalText"
Storyboard.TargetProperty="(TextElement.Foreground) .(SolidColorBrush.Color)"
2025-08-12 23:08:54 +08:00
To="{DynamicResource TextSecondaryColor}" />
2025-07-11 09:20:23 +08:00
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="Visibility" TargetName="HighlightBackground" Value="Visible" />
2025-08-12 23:08:54 +08:00
<Setter Property="Fill" TargetName="TodayBackground" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="StrokeThickness" TargetName="TodayBackground" Value="1" />
<Setter Property="Visibility" TargetName="SelectedBackground" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsToday" Value="True">
2025-08-12 23:08:54 +08:00
<Setter Property="TextElement.Foreground" TargetName="NormalText" Value="{DynamicResource TextOnAccentPrimaryBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Visibility" TargetName="TodayBackground" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsBlackedOut" Value="True">
2025-07-31 20:12:01 +08:00
<Setter Property="Visibility" TargetName="Blackout" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsEnabled" Value="False">
2025-07-31 20:12:01 +08:00
<!-- TODO:设置禁用效果 -->
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<Style TargetType="{x:Type CalendarItem}" x:Key="CalendarItemDefault">
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CalendarItem}">
<ControlTemplate.Resources>
2025-07-31 20:12:01 +08:00
<!-- 星期标题 -->
2025-07-11 09:20:23 +08:00
<DataTemplate x:Key="{x:Static CalendarItem.DayTitleTemplateResourceKey}">
2025-07-31 20:12:01 +08:00
<TextBlock
FontFamily="Verdana"
FontSize="12"
FontWeight="Bold"
2025-08-12 23:08:54 +08:00
Foreground="{DynamicResource AdditionalBlueBrush}"
2025-07-31 20:12:01 +08:00
HorizontalAlignment="Center"
Margin="0,6,0,6"
Text="{Binding}"
VerticalAlignment="Center" />
2025-07-11 09:20:23 +08:00
</DataTemplate>
</ControlTemplate.Resources>
<Grid x:Name="PART_Root">
2025-07-31 20:12:01 +08:00
<Border
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8"
2025-07-31 20:12:24 +08:00
Effect="{DynamicResource PopupShadow}"
2025-07-31 20:12:01 +08:00
Margin="4">
2025-07-11 09:20:23 +08:00
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="32" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
2025-07-31 20:12:01 +08:00
<!-- 上方背景 -->
<Border
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
CornerRadius="6,6,0,0"
Grid.ColumnSpan="3"
Margin="2" />
<!-- 向左按钮 -->
<Button
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
Focusable="False"
Grid.Column="0"
Grid.Row="0"
Margin="3"
Padding="8"
2025-07-31 20:12:24 +08:00
Style="{StaticResource FlattenButton}"
2025-07-31 20:12:01 +08:00
x:Name="PART_PreviousButton">
<Path
Data="{StaticResource LeftArrow}"
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource TextOnAccentPrimaryBrush}"
2025-07-31 20:12:01 +08:00
Height="8"
Stretch="Uniform"
Width="8" />
2025-07-11 09:20:23 +08:00
</Button>
2025-07-31 20:12:01 +08:00
<!-- 中间按钮 -->
<Button
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
Focusable="False"
FontSize="12"
FontWeight="Bold"
2025-08-12 23:08:54 +08:00
Foreground="{DynamicResource TextOnAccentPrimaryBrush}"
2025-07-31 20:12:01 +08:00
Grid.Column="1"
Grid.Row="0"
HorizontalAlignment="Stretch"
Margin="0,3"
2025-07-31 20:12:24 +08:00
Style="{StaticResource FlattenButton}"
2025-08-12 23:08:54 +08:00
assists:ShadingAssist.DisabledForeground="{DynamicResource TextOnAccentDisabledBrush}"
2025-07-31 20:12:01 +08:00
x:Name="PART_HeaderButton" />
<!-- 右侧按钮 -->
<Button
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
Focusable="False"
Grid.Column="2"
Grid.Row="0"
Margin="3"
Padding="8"
2025-07-31 20:12:24 +08:00
Style="{StaticResource FlattenButton}"
2025-07-31 20:12:01 +08:00
x:Name="PART_NextButton">
<Path
Data="{StaticResource RightArrow}"
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource TextOnAccentPrimaryBrush}"
2025-07-31 20:12:01 +08:00
Height="8"
Stretch="Uniform"
Width="8" />
2025-07-11 09:20:23 +08:00
</Button>
2025-07-31 20:12:01 +08:00
<!-- 月份视图 -->
<Grid
2025-07-31 20:12:24 +08:00
Grid.Column="0"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="3"
Grid.Row="1"
HorizontalAlignment="Center"
Margin="6,2,6,6"
Visibility="Visible"
x:Name="PART_MonthView">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>
2025-07-31 20:12:01 +08:00
<!-- 年份视图 -->
<Grid
2025-07-31 20:12:24 +08:00
Grid.Column="0"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="3"
Grid.Row="1"
HorizontalAlignment="Center"
Margin="6,2,6,6"
Visibility="Hidden"
x:Name="PART_YearView">
2025-07-11 09:20:23 +08:00
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>
</Grid>
</Border>
2025-07-31 20:12:01 +08:00
<!-- 禁用遮罩 -->
<Rectangle
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource BackgroundLayoutBrush}"
2025-07-31 20:12:01 +08:00
Margin="4"
Opacity="0"
RadiusX="6"
RadiusY="6"
Stretch="Fill"
Visibility="Collapsed"
x:Name="PART_DisabledVisual" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation
Duration="0"
Storyboard.TargetName="PART_DisabledVisual"
Storyboard.TargetProperty="Opacity"
To="0.5" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" TargetName="PART_DisabledVisual" Value="Visible" />
</Trigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
2025-07-11 09:20:23 +08:00
<Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
<Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
</DataTrigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
2025-07-11 09:20:23 +08:00
<Setter Property="Visibility" TargetName="PART_MonthView" Value="Hidden" />
<Setter Property="Visibility" TargetName="PART_YearView" Value="Visible" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<Style TargetType="{x:Type Calendar}" x:Key="CalendarDefault">
2025-07-11 09:20:23 +08:00
<Setter Property="CalendarItemStyle" Value="{StaticResource CalendarItemDefault}" />
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonDefault}" />
<Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonDefault}" />
2025-08-12 23:08:54 +08:00
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
2025-07-11 09:20:23 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Calendar}">
2025-07-31 20:12:01 +08:00
<StackPanel HorizontalAlignment="Center" x:Name="PART_Root">
<CalendarItem
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Style="{TemplateBinding CalendarItemStyle}"
x:Name="PART_CalendarItem" />
2025-07-11 09:20:23 +08:00
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-07-31 20:12:01 +08:00
<Style BasedOn="{StaticResource CalendarDefault}" TargetType="{x:Type Calendar}" />
<Style
BasedOn="{StaticResource CalendarDefault}"
TargetType="{x:Type Calendar}"
x:Key="PickerCalendarStyle">
<Setter Property="Margin" Value="8" />
2025-07-11 09:20:23 +08:00
</Style>
</ResourceDictionary>