Files
Shrlalgo.RvKits/Melskin/Controls/TimePicker.xaml

195 lines
11 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:13 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-01-02 17:30:41 +08:00
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
2026-01-02 17:30:30 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Controls/FlattenButton.xaml" />
</ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:30 +08:00
<Style TargetType="ListBoxItem" x:Key="TimePickerFlyoutListBoxItemStyle">
2025-08-20 12:10:13 +08:00
<Setter Property="Padding" Value="5,8" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border
Background="{TemplateBinding Background}"
CornerRadius="4"
2026-01-02 17:30:30 +08:00
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true"
x:Name="Bd">
2025-08-20 12:10:13 +08:00
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2026-01-02 17:30:30 +08:00
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
2025-08-20 12:10:13 +08:00
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundHoverBrush}" />
2025-08-20 12:10:13 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="Foreground" Value="White" />
2025-08-20 12:10:13 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 主 TimePicker 样式 -->
<Style TargetType="{x:Type controls:TimePicker}">
2025-08-24 13:49:55 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
2025-12-28 11:47:54 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-24 13:49:55 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
2025-12-28 11:47:54 +08:00
<Setter Property="BorderThickness" Value="0" />
2025-12-23 21:35:54 +08:00
<Setter Property="FontSize" Value="14" />
2025-12-28 11:47:54 +08:00
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
2025-08-20 12:10:13 +08:00
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Padding" Value="10,4" />
2025-08-20 12:10:13 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TimePicker}">
<Grid x:Name="templateRoot">
2025-12-28 11:47:54 +08:00
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
2025-08-20 12:10:13 +08:00
<Popup
AllowsTransparency="True"
Effect="{DynamicResource PopupShadow}"
2025-08-20 12:10:13 +08:00
IsOpen="{Binding IsChecked, ElementName=PART_ToggleButton, Mode=TwoWay}"
Placement="Bottom"
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
PopupAnimation="Fade"
2026-01-02 17:30:30 +08:00
StaysOpen="True"
assists:BehaviorAssist.SimulateNativeBehavior="True"
x:Name="TimePickerPopup">
2025-08-20 12:10:13 +08:00
<Border
Background="{DynamicResource BackgroundFloatingBrush}"
2025-08-20 12:10:13 +08:00
CornerRadius="8"
2026-01-02 17:30:30 +08:00
Effect="{DynamicResource PopupShadow}"
Margin="10"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
2025-08-20 12:10:13 +08:00
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Margin="2"
2025-08-20 12:10:13 +08:00
Orientation="Horizontal">
<ListBox
Background="Transparent"
BorderThickness="0"
2026-01-02 17:30:30 +08:00
ItemContainerStyle="{StaticResource TimePickerFlyoutListBoxItemStyle}"
2025-12-23 21:35:54 +08:00
MaxHeight="240"
2026-01-02 17:30:30 +08:00
Width="80"
x:Name="HourSelector" />
<ListBox
2025-08-20 12:10:13 +08:00
Background="Transparent"
BorderThickness="0"
2026-01-02 17:30:30 +08:00
ItemContainerStyle="{StaticResource TimePickerFlyoutListBoxItemStyle}"
2025-12-23 21:35:54 +08:00
MaxHeight="240"
2026-01-02 17:30:30 +08:00
Width="80"
x:Name="MinuteSelector" />
<ListBox
2025-08-20 12:10:13 +08:00
Background="Transparent"
BorderThickness="0"
2026-01-02 17:30:30 +08:00
ItemContainerStyle="{StaticResource TimePickerFlyoutListBoxItemStyle}"
MaxHeight="240"
Width="80"
x:Name="PeriodSelector" />
2025-08-20 12:10:13 +08:00
</StackPanel>
<Border
2025-12-23 21:35:54 +08:00
BorderBrush="{TemplateBinding BorderBrush}"
2026-01-02 17:30:30 +08:00
BorderThickness="0,1,0,0"
Grid.Row="1"
Padding="5">
2025-08-20 12:10:13 +08:00
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button
2025-10-10 11:19:58 +08:00
Style="{StaticResource FlattenButtonStyle}"
2026-01-02 17:30:30 +08:00
ToolTip="Accept"
x:Name="AcceptButton">
<controls:IconElement Symbol="Check" />
</Button>
2025-08-20 12:10:13 +08:00
<Button
Margin="5,0,0,0"
2025-10-10 11:19:58 +08:00
Style="{StaticResource FlattenButtonStyle}"
2026-01-02 17:30:30 +08:00
ToolTip="Dismiss"
x:Name="DismissButton">
<controls:IconElement Symbol="Close" />
</Button>
2025-08-20 12:10:13 +08:00
</StackPanel>
</Border>
</Grid>
</Border>
</Popup>
<!-- Header -->
<ContentPresenter
2026-01-02 17:30:30 +08:00
Content="{TemplateBinding Header}"
ContentSource="Header"
2025-12-28 11:47:54 +08:00
Grid.Column="0"
2026-01-02 17:30:30 +08:00
Grid.Row="0"
2025-10-10 11:19:58 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Center" />
2025-08-20 12:10:13 +08:00
<!-- 使用ToggleButton作为点击触发器 -->
<ToggleButton
Background="{TemplateBinding Background}"
2025-12-28 11:47:54 +08:00
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-01-02 17:30:30 +08:00
Cursor="Hand"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
x:Name="PART_ToggleButton">
<!-- 主显示区域 -->
2026-01-02 17:30:30 +08:00
<Border HorizontalAlignment="Center" x:Name="ContentBorder">
<StackPanel Orientation="Horizontal">
<TextBlock
2025-12-23 21:35:54 +08:00
Padding="0,0,6,0"
2026-01-02 17:30:30 +08:00
Text="--"
VerticalAlignment="Center"
2026-01-02 17:30:30 +08:00
x:Name="HourTextBlock" />
2025-10-10 11:19:58 +08:00
<TextBlock
Margin="4,0"
2026-01-02 17:30:30 +08:00
Text=":"
VerticalAlignment="Center" />
<TextBlock
2025-12-23 21:35:54 +08:00
Padding="6,0,0,0"
2026-01-02 17:30:30 +08:00
Text="--"
VerticalAlignment="Center"
2026-01-02 17:30:30 +08:00
x:Name="MinuteTextBlock" />
<TextBlock
Margin="8,0"
2026-01-02 17:30:30 +08:00
Text="AM"
x:Name="PeriodTextBlock" />
</StackPanel>
</Border>
2025-08-20 12:10:13 +08:00
</ToggleButton>
</Grid>
<ControlTemplate.Triggers>
2025-12-28 11:47:54 +08:00
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
2025-08-20 12:10:13 +08:00
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.5" />
</Trigger>
<Trigger Property="ClockIdentifier" Value="Clock24Hour">
2026-01-02 17:30:30 +08:00
<Setter Property="Visibility" TargetName="PeriodTextBlock" Value="Collapsed" />
<Setter Property="Visibility" TargetName="PeriodSelector" Value="Collapsed" />
2025-08-20 12:10:13 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>