Files
ShrlAlgoToolkit/Melskin/Controls/Calendar.xaml

342 lines
19 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-20 15:31:44 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Melskin.Controls">
2025-07-31 20:12:24 +08:00
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="FlattenButton.xaml" />
</ResourceDictionary.MergedDictionaries>
2025-07-31 20:12:01 +08:00
<!-- 年月按钮 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="DefaultCalendarButtonStyle" TargetType="{x:Type CalendarButton}">
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
2026-02-20 15:31:44 +08:00
x:Name="SelectionMark"
2026-01-02 17:30:30 +08:00
Margin="2"
2026-02-20 15:31:44 +08:00
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
StrokeThickness="{TemplateBinding BorderThickness}"
2026-02-20 15:31:44 +08:00
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<Border
2026-02-20 15:31:44 +08:00
x:Name="SelectedBorder"
Margin="2"
2025-08-12 23:08:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
2025-07-31 20:12:01 +08:00
CornerRadius="4"
2026-02-20 15:31:44 +08:00
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="NormalText"
2025-07-31 20:12:01 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasSelectedDays" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="SelectedBorder" Property="Visibility" Value="Visible" />
<Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource TextAccentBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="SelectionMark" Property="Visibility" Value="Visible" />
<Setter TargetName="SelectedBorder" Property="Background" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsInactive" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="NormalText" Property="TextElement.Foreground" 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
<!-- 日期按钮 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="DefaultCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
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
2026-02-20 15:31:44 +08:00
x:Name="SelectedBackground"
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundSelectedBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
2026-02-20 15:31:44 +08:00
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<!-- 鼠标划过背景 -->
<Rectangle
2026-02-20 15:31:44 +08:00
x:Name="HighlightBackground"
2025-08-12 23:08:54 +08:00
Fill="{DynamicResource ControlBackgroundHoverBrush}"
2025-07-31 20:12:01 +08:00
RadiusX="4"
RadiusY="4"
2026-02-20 15:31:44 +08:00
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<!-- 今日背景 -->
<Rectangle
2026-02-20 15:31:44 +08:00
x:Name="TodayBackground"
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"
2026-02-20 15:31:44 +08:00
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="NormalText"
2026-01-02 17:30:30 +08:00
Margin="5,1,5,1"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2025-07-31 20:12:01 +08:00
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2026-02-20 15:31:44 +08:00
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-07-31 20:12:01 +08:00
<!-- 叉 -->
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="Blackout"
2026-01-02 17:30:30 +08:00
Margin="4"
2026-02-20 15:31:44 +08:00
Foreground="{DynamicResource ErrorBrush}"
2025-07-31 20:12:01 +08:00
Opacity="0"
RenderTransformOrigin="0.5,0.5"
2026-02-20 15:31:44 +08:00
Symbol="Close" />
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="HighlightBackground" Property="Visibility" Value="Visible" />
<Setter TargetName="TodayBackground" Property="Fill" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="TodayBackground" Property="StrokeThickness" Value="1" />
<Setter TargetName="SelectedBackground" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsToday" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="NormalText" Property="TextElement.Foreground" Value="#e0e0e0" />
<Setter TargetName="TodayBackground" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsBlackedOut" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Blackout" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger Property="IsInactive" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="NormalText" Property="TextElement.Foreground" Value="{DynamicResource TextSecondaryBrush}" />
2025-07-11 09:20:23 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2026-02-20 15:31:44 +08:00
<Style x:Key="DefaultCalendarItemStyle" TargetType="{x:Type CalendarItem}">
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
2026-02-20 15:31:44 +08:00
Margin="0,6,0,6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
2025-07-31 20:12:01 +08:00
FontFamily="Verdana"
FontSize="12"
FontWeight="Bold"
Foreground="{DynamicResource PrimaryVariantBrush}"
2026-02-20 15:31:44 +08:00
Text="{Binding}" />
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
2026-02-20 15:31:44 +08:00
Margin="4"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8"
2026-02-20 15:31:44 +08:00
Effect="{DynamicResource PopupShadow}">
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
2026-01-02 17:30:30 +08:00
Grid.ColumnSpan="3"
2026-02-20 15:31:44 +08:00
Margin="2"
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="6,6,0,0" />
2025-07-31 20:12:01 +08:00
<!-- 向左按钮 -->
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_PreviousButton"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="0"
2025-07-31 20:12:01 +08:00
Margin="3"
Padding="4"
2026-02-20 15:31:44 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
Focusable="False"
Style="{StaticResource FlattenButtonStyle}">
<controls:IconElement Foreground="#e0e0e0" Symbol="ArrowBackIos" />
2025-07-11 09:20:23 +08:00
</Button>
2025-07-31 20:12:01 +08:00
<!-- 中间按钮 -->
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_HeaderButton"
Grid.Row="0"
Grid.Column="1"
Margin="0,3"
HorizontalAlignment="Stretch"
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"
Foreground="#e0e0e0"
2026-02-20 15:31:44 +08:00
Style="{StaticResource FlattenButtonStyle}" />
2025-07-31 20:12:01 +08:00
<!-- 右侧按钮 -->
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_NextButton"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2026-02-20 15:31:44 +08:00
Grid.Column="2"
2025-07-31 20:12:01 +08:00
Margin="3"
Padding="4"
2026-02-20 15:31:44 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
Focusable="False"
Style="{StaticResource FlattenButtonStyle}">
<controls:IconElement Foreground="#e0e0e0" Symbol="ArrowForwardIos" />
2025-07-11 09:20:23 +08:00
</Button>
2025-07-31 20:12:01 +08:00
<!-- 月份视图 -->
<Grid
2026-02-20 15:31:44 +08:00
x:Name="PART_MonthView"
Grid.Row="1"
2025-07-31 20:12:24 +08:00
Grid.Column="0"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="3"
2026-01-02 17:30:30 +08:00
Margin="6,2,6,6"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Center"
Visibility="Visible">
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
2026-02-20 15:31:44 +08:00
x:Name="PART_YearView"
Grid.Row="1"
2025-07-31 20:12:24 +08:00
Grid.Column="0"
2025-07-31 20:12:01 +08:00
Grid.ColumnSpan="3"
2026-01-02 17:30:30 +08:00
Margin="6,2,6,6"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Center"
Visibility="Hidden">
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
2026-02-20 15:31:44 +08:00
x:Name="PART_DisabledVisual"
2026-01-02 17:30:30 +08:00
Margin="4"
2026-02-20 15:31:44 +08:00
Fill="{DynamicResource ControlBackgroundDisabledBrush}"
2025-07-31 20:12:01 +08:00
Opacity="0"
RadiusX="6"
RadiusY="6"
Stretch="Fill"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-07-31 20:12:01 +08:00
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="PART_DisabledVisual"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
To="0.5"
Duration="0" />
2025-07-31 20:12:01 +08:00
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
2025-07-11 09:20:23 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_DisabledVisual" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</Trigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Year">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" />
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</DataTrigger>
2025-07-31 20:12:01 +08:00
<DataTrigger Binding="{Binding DisplayMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Calendar}}}" Value="Decade">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" />
<Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" />
2025-07-11 09:20:23 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2026-02-20 15:31:44 +08:00
<Style x:Key="DefaultCalendarStyle" TargetType="{x:Type Calendar}">
2025-10-10 11:19:58 +08:00
<Setter Property="CalendarItemStyle" Value="{StaticResource DefaultCalendarItemStyle}" />
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource DefaultCalendarDayButtonStyle}" />
<Setter Property="CalendarButtonStyle" Value="{StaticResource DefaultCalendarButtonStyle}" />
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<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}">
2026-02-20 15:31:44 +08:00
<StackPanel x:Name="PART_Root" HorizontalAlignment="Center">
2025-07-31 20:12:01 +08:00
<CalendarItem
2026-02-20 15:31:44 +08:00
x:Name="PART_CalendarItem"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-02-20 15:31:44 +08:00
Style="{TemplateBinding CalendarItemStyle}" />
2025-07-11 09:20:23 +08:00
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-10-10 11:19:58 +08:00
<Style BasedOn="{StaticResource DefaultCalendarStyle}" TargetType="{x:Type Calendar}" />
2025-07-31 20:12:01 +08:00
<Style
2026-02-20 15:31:44 +08:00
x:Key="DefaultCalendarPickerStyle"
2025-10-10 11:19:58 +08:00
BasedOn="{StaticResource DefaultCalendarStyle}"
2026-02-20 15:31:44 +08:00
TargetType="{x:Type Calendar}">
2025-07-31 20:12:01 +08:00
<Setter Property="Margin" Value="8" />
2025-07-11 09:20:23 +08:00
</Style>
</ResourceDictionary>