Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Controls/Calendar.axaml
2024-06-20 01:07:24 +08:00

263 lines
13 KiB
XML

<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<Design.PreviewWith>
<StackPanel Margin="20" Spacing="5">
<u:CalendarView />
</StackPanel>
</Design.PreviewWith>
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type u:CalendarDayButton}" TargetType="u:CalendarDayButton">
<Setter Property="MinWidth" Value="32" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Margin" Value="0 2" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Template">
<ControlTemplate TargetType="u:CalendarDayButton">
<Panel>
<Border
Name="PART_Background"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter
Name="PART_ContentPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</Border>
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^:in-range">
<Setter Property="Background" Value="{DynamicResource SemiBlue1}" />
<Setter Property="CornerRadius" Value="0" />
<Setter Property="BorderThickness" Value="0" />
</Style>
<Style Selector="^:today">
<Setter Property="Background" Value="{DynamicResource SemiGrey1}" />
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}" />
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style Selector="^:not-current-month">
<Setter Property="Foreground" Value="{DynamicResource SemiGrey3}" />
</Style>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiGrey1}" />
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="White" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiBlue6}" />
</Style>
</Style>
<Style Selector="^:start-date">
<Setter Property="CornerRadius" Value="3 0 0 3" />
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiBlue5}" />
<Setter Property="Foreground" Value="White" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiBlue6}" />
</Style>
</Style>
<Style Selector="^:start-date:in-range">
<Setter Property="CornerRadius" Value="3 0 0 3" />
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiGrey5}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style Selector="^:end-date">
<Setter Property="CornerRadius" Value="0 3 3 0" />
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiBlue5}" />
<Setter Property="Foreground" Value="White" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiBlue6}" />
</Style>
</Style>
<Style Selector="^:end-date:in-range">
<Setter Property="CornerRadius" Value="0 3 3 0" />
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiGrey5}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style Selector="^:preview-start-date">
<Setter Property="CornerRadius" Value="3 0 0 3" />
<Setter Property="Background" Value="{DynamicResource SemiBlue2}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiBlue2}" />
</Style>
<Style Selector="^:preview-end-date">
<Setter Property="CornerRadius" Value="0 3 3 0" />
<Setter Property="Background" Value="{DynamicResource SemiBlue2}" />
<Setter Property="BorderBrush" Value="{DynamicResource SemiBlue2}" />
</Style>
<Style Selector="^:blackout">
<Setter Property="Foreground" Value="{DynamicResource SemiGrey3}" />
<Setter Property="Cursor" Value="No" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:CalendarYearButton}" TargetType="u:CalendarYearButton">
<Setter Property="MinWidth" Value="32" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Margin" Value="0 2" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Template">
<ControlTemplate TargetType="u:CalendarDayButton">
<Panel>
<Border
Name="PART_Background"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ContentPresenter
Name="PART_ContentPresenter"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</Border>
</Panel>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiGrey1}" />
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource SemiBlue5}" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="White" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource SemiBlue6}" />
</Style>
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:CalendarView}" TargetType="u:CalendarView">
<Setter Property="MinHeight" Value="300" />
<Setter Property="MinWidth" Value="300" />
<Setter Property="Template">
<ControlTemplate TargetType="u:CalendarView">
<Panel>
<Grid RowDefinitions="Auto, *">
<Grid Grid.Row="0" ColumnDefinitions="Auto, Auto,*, Auto, Auto">
<Button
Name="{x:Static u:CalendarView.PART_PreviousYearButton}"
Grid.Column="0"
HorizontalContentAlignment="Left"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource CalendarItemPreviousIconGlyph}"
Foreground="{DynamicResource CalendarItemIconForeground}" />
</Button>
<Button
Name="{x:Static u:CalendarView.PART_PreviousButton}"
Grid.Column="1"
HorizontalContentAlignment="Left"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource CalendarItemPreviousIconGlyph}"
Foreground="{DynamicResource CalendarItemIconForeground}" />
</Button>
<Grid Grid.Column="2" ColumnDefinitions="*, *">
<Button
Name="{x:Static u:CalendarView.PART_YearButton}"
Grid.Column="0"
HorizontalContentAlignment="Center"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}" />
<Button
Name="{x:Static u:CalendarView.PART_MonthButton}"
Grid.Column="1"
HorizontalContentAlignment="Center"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}" />
<Button
Name="{x:Static u:CalendarView.PART_HeaderButton}"
Grid.Column="0"
IsVisible="True"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center" />
</Grid>
<Button
Name="{x:Static u:CalendarView.PART_NextButton}"
Grid.Column="3"
HorizontalContentAlignment="Left"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource CalendarItemNextIconGlyph}"
Foreground="{DynamicResource CalendarItemIconForeground}" />
</Button>
<Button
Name="{x:Static u:CalendarView.PART_NextYearButton}"
Grid.Column="4"
HorizontalContentAlignment="Left"
Foreground="{TemplateBinding Foreground}"
Theme="{DynamicResource BorderlessButton}">
<PathIcon
Width="12"
Height="12"
Data="{DynamicResource CalendarItemNextIconGlyph}"
Foreground="{DynamicResource CalendarItemIconForeground}" />
</Button>
</Grid>
<Grid
Name="{x:Static u:CalendarView.PART_MonthGrid}"
Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ColumnDefinitions="*, *, *, *, *, *, *"
RowDefinitions="*, Auto, *, *, *, *, *, *" />
<Grid
Name="{x:Static u:CalendarView.PART_YearGrid}"
Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ColumnDefinitions="*, *, *"
RowDefinitions="*, *, *, *" />
</Grid>
</Panel>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>