Clock.xaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
  4. xmlns:hc="clr-namespace:HandyControl.Controls"
  5. xmlns:ex="clr-namespace:HandyControl.Tools.Extension">
  6. <Style x:Key="ClockRadioButtonStyle" TargetType="hc:ClockRadioButton">
  7. <Setter Property="BorderThickness" Value="1"/>
  8. <Setter Property="VerticalContentAlignment" Value="Center"/>
  9. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  10. <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
  11. <Setter Property="Focusable" Value="False"/>
  12. <Setter Property="Width" Value="28"/>
  13. <Setter Property="Height" Value="28"/>
  14. <Setter Property="Background" Value="{DynamicResource DangerBrush}"/>
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="hc:ClockRadioButton">
  18. <ControlTemplate.Resources>
  19. <Storyboard x:Key="Storyboard1">
  20. <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="optionMark">
  21. <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
  22. </DoubleAnimationUsingKeyFrames>
  23. </Storyboard>
  24. <Storyboard x:Key="Storyboard2">
  25. <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="optionMark">
  26. <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
  27. </DoubleAnimationUsingKeyFrames>
  28. </Storyboard>
  29. </ControlTemplate.Resources>
  30. <hc:SimplePanel x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
  31. <Ellipse x:Name="optionMark" Fill="{TemplateBinding Background}" MinWidth="6" MinHeight="6" Opacity="0"/>
  32. <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  33. </hc:SimplePanel>
  34. <ControlTemplate.Triggers>
  35. <Trigger Property="IsChecked" Value="true">
  36. <Trigger.EnterActions>
  37. <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
  38. </Trigger.EnterActions>
  39. <Trigger.ExitActions>
  40. <BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
  41. </Trigger.ExitActions>
  42. </Trigger>
  43. </ControlTemplate.Triggers>
  44. </ControlTemplate>
  45. </Setter.Value>
  46. </Setter>
  47. <Style.Triggers>
  48. <Trigger Property="IsChecked" Value="True">
  49. <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
  50. </Trigger>
  51. </Style.Triggers>
  52. </Style>
  53. <Style x:Key="ClockBaseStyle" TargetType="hc:Clock">
  54. <Setter Property="BorderThickness" Value="0"/>
  55. <Setter Property="Margin" Value="8 0"/>
  56. <Setter Property="Focusable" Value="False"/>
  57. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  58. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  59. <Setter Property="ClockRadioButtonStyle" Value="{StaticResource ClockRadioButtonStyle}"/>
  60. <Setter Property="hc:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
  61. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  62. <Setter Property="Template">
  63. <Setter.Value>
  64. <ControlTemplate TargetType="hc:Clock">
  65. <hc:SimplePanel Margin="0,4,0,8" HorizontalAlignment="Center" VerticalAlignment="Center">
  66. <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Effect="{StaticResource EffectShadow2}"/>
  67. <Grid>
  68. <Grid.RowDefinitions>
  69. <RowDefinition Height="50"/>
  70. <RowDefinition/>
  71. </Grid.RowDefinitions>
  72. <Grid.ColumnDefinitions>
  73. <ColumnDefinition/>
  74. <ColumnDefinition/>
  75. <ColumnDefinition/>
  76. </Grid.ColumnDefinitions>
  77. <Border Margin="4" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Grid.ColumnSpan="3" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Name="PART_BorderTitle">
  78. <TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Foreground="{DynamicResource TextIconBrush}"/>
  79. </Border>
  80. <Canvas Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="16,16,16,62" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
  81. <Border Background="{DynamicResource SecondaryRegionBrush}" Width="178" Height="178" CornerRadius="89"/>
  82. <hc:CirclePanel Diameter="130" x:Name="PART_PanelNum" KeepVertical="True" Margin="24,24,0,0" OffsetAngle="-60"/>
  83. <Border Focusable="False" Name="PART_BorderClock" Background="{DynamicResource PrimaryBrush}" RenderTransformOrigin="0.5,1" Height="63" Width="2" Canvas.Left="88" Canvas.Top="26"/>
  84. <Ellipse Fill="White" Width="8" Height="8" StrokeThickness="2" Stroke="{DynamicResource PrimaryBrush}" Canvas.Top="85" Canvas.Left="85"/>
  85. </Canvas>
  86. <hc:ClockRadioButton Grid.Row="1" Background="{DynamicResource PrimaryBrush}" Grid.Column="0" x:Name="PART_ButtonAm" IsChecked="True" Height="30" Width="30" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="16,0,0,16" Content="{ex:Lang Key={x:Static langs:LangKeys.Am}}" Style="{StaticResource ClockRadioButtonStyle}"/>
  87. <hc:ClockRadioButton Grid.Row="1" Background="{DynamicResource PrimaryBrush}" Grid.Column="2" x:Name="PART_ButtonPm" Height="30" Width="30" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,16,16" Content="{ex:Lang Key={x:Static langs:LangKeys.Pm}}" Style="{StaticResource ClockRadioButtonStyle}"/>
  88. <Button Grid.Row="1" Grid.Column="1" Visibility="{TemplateBinding ShowConfirmButton,Converter={StaticResource Boolean2VisibilityConverter}}" Name="PART_ButtonConfirm" Content="{ex:Lang Key={x:Static langs:LangKeys.Confirm}}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" Margin="0,0,0,19" Height="24" Width="60" VerticalAlignment="Bottom" Background="Transparent" Style="{StaticResource ButtonCustom}"/>
  89. </Grid>
  90. </hc:SimplePanel>
  91. </ControlTemplate>
  92. </Setter.Value>
  93. </Setter>
  94. </Style>
  95. <Style TargetType="hc:Clock" BasedOn="{StaticResource ClockBaseStyle}"/>
  96. <Style x:Key="ClockListBoxItemStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
  97. <Style.Triggers>
  98. <Trigger Property="IsMouseOver" Value="true">
  99. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  100. </Trigger>
  101. <Trigger Property="IsSelected" Value="true">
  102. <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  103. <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
  104. </Trigger>
  105. <Trigger Property="IsEnabled" Value="false">
  106. <Setter Property="Opacity" Value=".4"/>
  107. </Trigger>
  108. <Trigger Property="hc:EdgeElement.ShowEdgeContent" Value="true">
  109. <Setter Property="Template">
  110. <Setter.Value>
  111. <ControlTemplate TargetType="ListBoxItem">
  112. <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
  113. <StackPanel Orientation="Horizontal">
  114. <ContentControl Width="16" Height="16" Content="{Binding Path=(hc:EdgeElement.LeftContent),RelativeSource={RelativeSource TemplatedParent}}"/>
  115. <ContentPresenter Margin="6,0,0,0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  116. </StackPanel>
  117. </Border>
  118. </ControlTemplate>
  119. </Setter.Value>
  120. </Setter>
  121. </Trigger>
  122. </Style.Triggers>
  123. </Style>
  124. <Style x:Key="ClockListBoxStyle" TargetType="ListBox" BasedOn="{StaticResource ListBoxBaseStyle}">
  125. <Setter Property="MaxHeight" Value="180"/>
  126. <Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
  127. <Setter Property="BorderThickness" Value="0"/>
  128. <Setter Property="ItemContainerStyle" Value="{StaticResource ClockListBoxItemStyle}"/>
  129. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  130. </Style>
  131. <Style x:Key="ListClockBaseStyle" TargetType="hc:ListClock">
  132. <Setter Property="BorderThickness" Value="0"/>
  133. <Setter Property="Margin" Value="8 0"/>
  134. <Setter Property="Focusable" Value="False"/>
  135. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  136. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  137. <Setter Property="hc:TitleElement.Background" Value="{DynamicResource TitleBrush}"/>
  138. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  139. <Setter Property="Template">
  140. <Setter.Value>
  141. <ControlTemplate TargetType="hc:ListClock">
  142. <hc:SimplePanel Margin="0,4,0,8" HorizontalAlignment="Center" VerticalAlignment="Center">
  143. <Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Effect="{StaticResource EffectShadow2}"/>
  144. <Grid Margin="0,4" Width="210">
  145. <Grid.ColumnDefinitions>
  146. <ColumnDefinition/>
  147. <ColumnDefinition/>
  148. <ColumnDefinition/>
  149. </Grid.ColumnDefinitions>
  150. <Grid.RowDefinitions>
  151. <RowDefinition/>
  152. <RowDefinition Height="Auto"/>
  153. </Grid.RowDefinitions>
  154. <ListBox hc:BorderElement.CornerRadius="0" Padding="0" x:Name="PART_HourList" Style="{StaticResource ClockListBoxStyle}"/>
  155. <ListBox hc:BorderElement.CornerRadius="0" Padding="0" Grid.Row="0" Grid.Column="1" x:Name="PART_MinuteList" Style="{StaticResource ClockListBoxStyle}" BorderThickness="1,0"/>
  156. <ListBox hc:BorderElement.CornerRadius="0" Padding="0" Grid.Row="0" Grid.Column="2" x:Name="PART_SecondList" Style="{StaticResource ClockListBoxStyle}"/>
  157. <Border VerticalAlignment="Bottom" Visibility="{Binding Visibility,ElementName=PART_ButtonConfirm}" Height="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Background="{DynamicResource BorderBrush}"/>
  158. <Button Margin="0,10" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" Visibility="{TemplateBinding ShowConfirmButton,Converter={StaticResource Boolean2VisibilityConverter}}" Name="PART_ButtonConfirm" Content="{ex:Lang Key={x:Static langs:LangKeys.Confirm}}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" Background="Transparent" Style="{StaticResource ButtonCustom}"/>
  159. </Grid>
  160. </hc:SimplePanel>
  161. </ControlTemplate>
  162. </Setter.Value>
  163. </Setter>
  164. </Style>
  165. <Style TargetType="hc:ListClock" BasedOn="{StaticResource ListClockBaseStyle}"/>
  166. </ResourceDictionary>