| 1 | <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 2 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 3 | xmlns:local="clr-namespace:UI.Controls.Select" xmlns:base="clr-namespace:UI.Controls.Base" xmlns:button="clr-namespace:UI.Controls.Button" xmlns:converter="clr-namespace:UI.Controls.Converters"> |
| 4 | <converter:ToStringConverter x:Key="ToStringConverter"/> |
| 5 | |
| 6 | <SolidColorBrush x:Key="ThemeLightBrush" Color="{DynamicResource ThemeColor}" Opacity=".1"/> |
| 7 | |
| 8 | <Style TargetType="{x:Type local:DateSelect}"> |
| 9 | <Setter Property="SnapsToDevicePixels" |
| 10 | Value="true" /> |
| 11 | |
| 12 | <Setter Property="Background" Value="Transparent"/> |
| 13 | |
| 14 | <Setter Property="Template"> |
| 15 | <Setter.Value> |
| 16 | <ControlTemplate TargetType="{x:Type local:DateSelect}"> |
| 17 | <Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" HorizontalAlignment="Left" > |
| 18 | <Grid> |
| 19 | |
| 20 | <Border Background="{Binding ElementName=Main,Path=Background}" Panel.ZIndex="-1" Width="{Binding ElementName=Main,Path=ActualWidth}" Height="{Binding ElementName=Main,Path=ActualHeight}" CornerRadius="{Binding ElementName=Main,Path=CornerRadius}"> |
| 21 | <Border.Effect> |
| 22 | <DropShadowEffect Color="#d8d2d2" BlurRadius="1" Direction="300" ShadowDepth="4" Opacity="0.1" RenderingBias="Performance" ></DropShadowEffect> |
| 23 | </Border.Effect> |
| 24 | </Border> |
| 25 | <Border x:Name="Main" Margin="0,0,0,0" Background="{DynamicResource StandardBackgroundBrush}" HorizontalAlignment="Left" Padding="18,10" CornerRadius="5"> |
| 26 | <Border.InputBindings> |
| 27 | <MouseBinding Gesture="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=ShowSelectCommand}"/> |
| 28 | </Border.InputBindings> |
| 29 | |
| 30 | <StackPanel Orientation="Horizontal"> |
| 31 | <base:Icon x:Name="Icon" IconType="Calendar" Foreground="{DynamicResource StandardTextBrush}"/> |
| 32 | <TextBlock Foreground="{DynamicResource StandardTextBrush}" Text="{TemplateBinding DateStr}" VerticalAlignment="Center" Margin="5,0,0,0"/> |
| 33 | </StackPanel> |
| 34 | </Border> |
| 35 | |
| 36 | |
| 37 | <Popup |
| 38 | x:Name="Popup" |
| 39 | Placement="Bottom" |
| 40 | PlacementTarget="{Binding ElementName=Main}" |
| 41 | IsOpen="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=IsOpen,Mode=TwoWay}" AllowsTransparency="True" PopupAnimation="Slide"> |
| 42 | <Border |
| 43 | x:Name="SelectContainer" |
| 44 | CornerRadius="10" |
| 45 | BorderBrush="{DynamicResource PopupBorderBrush}" |
| 46 | BorderThickness="1" |
| 47 | Background="{DynamicResource PopupBackgroundBrush}" Padding="10" Margin="10"> |
| 48 | <Border.Effect> |
| 49 | <DropShadowEffect BlurRadius="10" ShadowDepth="2" Direction="315" Color="Gray" Opacity=".1"/> |
| 50 | </Border.Effect> |
| 51 | <Grid> |
| 52 | <Grid.RowDefinitions> |
| 53 | <RowDefinition Height="40"/> |
| 54 | <RowDefinition Height="auto"/> |
| 55 | <RowDefinition Height="auto"/> |
| 56 | |
| 57 | </Grid.RowDefinitions> |
| 58 | |
| 59 | <Border> |
| 60 | <Grid> |
| 61 | <Grid.ColumnDefinitions> |
| 62 | <ColumnDefinition Width="*"/> |
| 63 | <ColumnDefinition Width="*"/> |
| 64 | |
| 65 | </Grid.ColumnDefinitions> |
| 66 | |
| 67 | <StackPanel Orientation="Horizontal"> |
| 68 | <button:IconButton Icon="ChevronLeft" FontSize="12" VerticalAlignment="Center" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SetYearCommand}" CommandParameter="-1"/> |
| 69 | <TextBlock Width="50" Foreground="{DynamicResource StandardTextBrush}" TextAlignment="Center" Margin="5,0" VerticalAlignment="Center" > |
| 70 | <Run Text="{TemplateBinding Year ,Converter= {StaticResource ToStringConverter}}"/> |
| 71 | <Run Text="年"/> |
| 72 | </TextBlock> |
| 73 | <button:IconButton Icon="ChevronRight" FontSize="12" VerticalAlignment="Center" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SetYearCommand}" CommandParameter="1"/> |
| 74 | |
| 75 | </StackPanel> |
| 76 | <StackPanel Grid.Column="1" Orientation="Horizontal" x:Name="MonthSelect" Visibility="Collapsed"> |
| 77 | <button:IconButton Icon="ChevronLeft" FontSize="12" VerticalAlignment="Center" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SetMonthCommand}" CommandParameter="-1"/> |
| 78 | <TextBlock Width="30" Foreground="{DynamicResource StandardTextBrush}" TextAlignment="Center" Margin="5,0" VerticalAlignment="Center"> |
| 79 | <Run Text="{TemplateBinding Month ,Converter= {StaticResource ToStringConverter}}"/> |
| 80 | <Run Text="月"/> |
| 81 | </TextBlock> |
| 82 | |
| 83 | <button:IconButton Icon="ChevronRight" FontSize="12" VerticalAlignment="Center" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=SetMonthCommand}" CommandParameter="1"/> |
| 84 | |
| 85 | </StackPanel> |
| 86 | </Grid> |
| 87 | |
| 88 | </Border> |
| 89 | |
| 90 | <Border Grid.Row="1" Width="250" x:Name="DaySelect" Visibility="Collapsed"> |
| 91 | <Grid> |
| 92 | <Grid.RowDefinitions> |
| 93 | <RowDefinition Height="auto"/> |
| 94 | <RowDefinition Height="auto"/> |
| 95 | </Grid.RowDefinitions> |
| 96 | <Border Grid.Row="0" Margin="0,15,0,0" BorderBrush="{DynamicResource SettingPanelSpliteLineBrush}" BorderThickness="0,0,0,.5" Padding="0,0,0,10"> |
| 97 | <Grid > |
| 98 | <Grid.ColumnDefinitions> |
| 99 | <ColumnDefinition Width="35"/> |
| 100 | <ColumnDefinition Width="35"/> |
| 101 | <ColumnDefinition Width="35"/> |
| 102 | <ColumnDefinition Width="35"/> |
| 103 | <ColumnDefinition Width="35"/> |
| 104 | <ColumnDefinition Width="35"/> |
| 105 | <ColumnDefinition Width="35"/> |
| 106 | </Grid.ColumnDefinitions> |
| 107 | <TextBlock Grid.Column="0" Text="一" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 108 | <TextBlock Grid.Column="1" Text="二" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 109 | <TextBlock Grid.Column="2" Text="三" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 110 | <TextBlock Grid.Column="3" Text="四" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 111 | <TextBlock Grid.Column="4" Text="五" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 112 | <TextBlock Grid.Column="5" Text="六" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 113 | <TextBlock Grid.Column="6" Text="日" HorizontalAlignment="Center" Foreground="{DynamicResource SubTextBrush}"/> |
| 114 | |
| 115 | </Grid> |
| 116 | </Border> |
| 117 | <ListView Grid.Row="1" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=Days}" SelectedItem="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=Day,Mode=TwoWay}" Margin="0,10,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" > |
| 118 | <ListBox.Resources> |
| 119 | <Style TargetType="{x:Type ListView}"> |
| 120 | <Setter Property="OverridesDefaultStyle" Value="True"/> |
| 121 | |
| 122 | <Setter Property="Template"> |
| 123 | <Setter.Value> |
| 124 | <ControlTemplate TargetType="{x:Type ListView}"> |
| 125 | <Border> |
| 126 | <ItemsPresenter /> |
| 127 | </Border> |
| 128 | </ControlTemplate> |
| 129 | </Setter.Value> |
| 130 | </Setter> |
| 131 | </Style> |
| 132 | <Style TargetType="{x:Type ListViewItem}"> |
| 133 | <Setter Property="OverridesDefaultStyle" Value="True"/> |
| 134 | <Setter Property="Foreground" Value="{DynamicResource StandardTextBrush}"/> |
| 135 | |
| 136 | <Setter Property="Template"> |
| 137 | <Setter.Value> |
| 138 | <ControlTemplate TargetType="{x:Type ListViewItem}"> |
| 139 | <Border BorderBrush="Transparent" BorderThickness="2" x:Name="Border" Background="Transparent" Margin="0,0,0,0" Padding="0" Width="35" Height="35" CornerRadius="5"> |
| 140 | <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/> |
| 141 | </Border> |
| 142 | <ControlTemplate.Triggers> |
| 143 | <DataTrigger Binding="{Binding IsOut}" Value="True"> |
| 144 | <Setter Property="Foreground" Value="{DynamicResource DisabledTextBrush}"/> |
| 145 | <Setter Property="IsEnabled" Value="False"/> |
| 146 | </DataTrigger> |
| 147 | <DataTrigger Binding="{Binding IsDisabled}" Value="True"> |
| 148 | <Setter Property="Foreground" Value="{DynamicResource DisabledTextBrush}"/> |
| 149 | <Setter Property="IsEnabled" Value="False"/> |
| 150 | </DataTrigger> |
| 151 | <DataTrigger Binding="{Binding IsToday}" Value="True"> |
| 152 | <Setter TargetName="Border" Property="Background" Value="{StaticResource ThemeLightBrush}"/> |
| 153 | <Setter Property="Foreground" Value="{DynamicResource ThemeBrush}"/> |
| 154 | |
| 155 | </DataTrigger> |
| 156 | <Trigger Property="IsMouseOver" Value="True"> |
| 157 | <Setter TargetName="Border" Property="Background" Value="{DynamicResource HoverBackgroundBrush}"/> |
| 158 | |
| 159 | |
| 160 | </Trigger> |
| 161 | <Trigger Property="IsSelected" Value="True"> |
| 162 | <Setter TargetName="Border" Property="Background" Value="{DynamicResource ThemeBrush}"/> |
| 163 | <Setter Property="Foreground" Value="White"/> |
| 164 | |
| 165 | |
| 166 | |
| 167 | </Trigger> |
| 168 | </ControlTemplate.Triggers> |
| 169 | </ControlTemplate> |
| 170 | </Setter.Value> |
| 171 | </Setter> |
| 172 | |
| 173 | </Style> |
| 174 | </ListBox.Resources> |
| 175 | <ListBox.ItemsPanel> |
| 176 | <ItemsPanelTemplate> |
| 177 | <WrapPanel/> |
| 178 | </ItemsPanelTemplate> |
| 179 | </ListBox.ItemsPanel> |
| 180 | <ListView.ItemTemplate> |
| 181 | <DataTemplate> |
| 182 | |
| 183 | <WrapPanel Orientation="Horizontal"> |
| 184 | <Border > |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | <TextBlock Text="{Binding DayText}" /> |
| 191 | |
| 192 | </Border> |
| 193 | |
| 194 | </WrapPanel> |
| 195 | |
| 196 | </DataTemplate> |
| 197 | </ListView.ItemTemplate> |
| 198 | </ListView> |
| 199 | </Grid> |
| 200 | |
| 201 | </Border> |
| 202 | <Border Grid.Row="2" HorizontalAlignment="Right" Margin="0,10,0,0"> |
| 203 | <StackPanel Orientation="Horizontal"> |
| 204 | <button:Button Content="确认" Width="100" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DateSelect}}, Path=DoneCommand}"/> |
| 205 | </StackPanel> |
| 206 | </Border> |
| 207 | </Grid> |
| 208 | |
| 209 | </Border> |
| 210 | </Popup> |
| 211 | </Grid> |
| 212 | </Border> |
| 213 | <ControlTemplate.Triggers> |
| 214 | <Trigger Property="SelectType" Value="Day"> |
| 215 | <Setter Property="Visibility" TargetName="DaySelect" Value="Visible"/> |
| 216 | <Setter Property="Visibility" TargetName="MonthSelect" Value="Visible"/> |
| 217 | </Trigger> |
| 218 | <Trigger Property="SelectType" Value="Month"> |
| 219 | <Setter Property="Visibility" TargetName="DaySelect" Value="Collapsed"/> |
| 220 | <Setter Property="Visibility" TargetName="MonthSelect" Value="Visible"/> |
| 221 | |
| 222 | </Trigger> |
| 223 | <Trigger Property="SelectType" Value="Year"> |
| 224 | <Setter Property="Visibility" TargetName="DaySelect" Value="Collapsed"/> |
| 225 | <Setter Property="Visibility" TargetName="MonthSelect" Value="Collapsed"/> |
| 226 | </Trigger> |
| 227 | <Trigger Property="IsMouseOver" Value="True"> |
| 228 | <Setter Property="Background" TargetName="Main" Value="{DynamicResource HoverBackgroundBrush}"/> |
| 229 | <Setter TargetName="Icon" Property="Foreground" Value="{DynamicResource ThemeBrush}"/> |
| 230 | </Trigger> |
| 231 | </ControlTemplate.Triggers> |
| 232 | </ControlTemplate> |
| 233 | </Setter.Value> |
| 234 | </Setter> |
| 235 | </Style> |
| 236 | </ResourceDictionary> |