| 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.Input" |
| 4 | xmlns:base="clr-namespace:UI.Controls.Base" |
| 5 | xmlns:sys="clr-namespace:System;assembly=mscorlib" |
| 6 | > |
| 7 | <Style TargetType="{x:Type local:InputBox}"> |
| 8 | <Setter Property="CornerRadius" Value="6"/> |
| 9 | <Setter Property="Width" Value="AUTO"/> |
| 10 | <Setter Property="Height" Value="37"/> |
| 11 | <Setter Property="SnapsToDevicePixels" |
| 12 | Value="True" /> |
| 13 | <Setter Property="IconMargin" Value="5,0,0,0"/> |
| 14 | <Setter Property="IconColor" Value="#333"/> |
| 15 | <Setter Property="TitleColor" Value="#333"/> |
| 16 | <Setter Property="IconSize" Value="16"/> |
| 17 | <Setter Property="TitleSize" Value="12"/> |
| 18 | <Setter Property="TitleMargin" Value="0,0,0,5"/> |
| 19 | <Setter Property="BoxPadding" Value="0"/> |
| 20 | <Setter Property="Foreground" Value="{DynamicResource DefaultTextBrush}"/> |
| 21 | |
| 22 | <Setter Property="Background" Value="{DynamicResource InputBoxBgBrush}"/> |
| 23 | <Setter Property="Template"> |
| 24 | <Setter.Value> |
| 25 | <ControlTemplate TargetType="{x:Type local:InputBox}"> |
| 26 | <Grid> |
| 27 | <Border x:Name="Shadow" Visibility="Collapsed" BorderBrush="{Binding ElementName=BoxBorder,Path=BorderBrush}" BorderThickness="{Binding ElementName=BoxBorder,Path=BorderThickness}" Panel.ZIndex="-1" Width="{Binding ElementName=BoxBorder,Path=ActualWidth}" Height="{Binding ElementName=BoxBorder,Path=ActualHeight}" CornerRadius="{Binding ElementName=BoxBorder,Path=CornerRadius}" Background="{Binding ElementName=BoxBorder,Path=Background}"> |
| 28 | <Border.Effect> |
| 29 | <DropShadowEffect Color="#d8d2d2" BlurRadius="1" Direction="300" ShadowDepth="4" Opacity="0.1" RenderingBias="Performance" ></DropShadowEffect> |
| 30 | </Border.Effect> |
| 31 | </Border> |
| 32 | <Border x:Name="BoxBorder" BorderBrush="Transparent" Background="{TemplateBinding Background}" BorderThickness="2" CornerRadius="{TemplateBinding CornerRadius}" Padding="{TemplateBinding BoxPadding}"> |
| 33 | <Grid> |
| 34 | <Grid.ColumnDefinitions> |
| 35 | <ColumnDefinition Width="auto"/> |
| 36 | <ColumnDefinition Width="*"/> |
| 37 | <ColumnDefinition Width="auto"/> |
| 38 | </Grid.ColumnDefinitions> |
| 39 | <base:Icon x:Name="Icon" IconType="{TemplateBinding Icon}" Margin="{TemplateBinding IconMargin}" Foreground="{TemplateBinding IconColor}" RenderTransformOrigin=".5,.5" FontSize="{TemplateBinding IconSize}"> |
| 40 | <base:Icon.RenderTransform> |
| 41 | <ScaleTransform ScaleX="1" ScaleY="1"/> |
| 42 | </base:Icon.RenderTransform> |
| 43 | </base:Icon> |
| 44 | |
| 45 | <StackPanel Grid.Column="1" Margin="5,0" |
| 46 | VerticalAlignment="Center" > |
| 47 | <TextBlock x:Name="Title" Text="{TemplateBinding Title}" Foreground="{TemplateBinding TitleColor}" FontSize="{TemplateBinding TitleSize}" Margin="{TemplateBinding TitleMargin}"/> |
| 48 | <Grid> |
| 49 | <TextBlock x:Name="Placeholder" Text="{TemplateBinding Placeholder}" Foreground="#a3a3a3" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Center" |
| 50 | Visibility="Collapsed" Padding="{TemplateBinding Padding}"/> |
| 51 | <ScrollViewer |
| 52 | x:Name="PART_ContentHost" VerticalAlignment="Center" /> |
| 53 | </Grid> |
| 54 | </StackPanel> |
| 55 | <base:Icon x:Name="ErrorIcon" IconType="Error" Grid.Column="2" Visibility="Collapsed" Margin="0,0,5,0" Foreground="White"/> |
| 56 | </Grid> |
| 57 | |
| 58 | </Border> |
| 59 | <Popup |
| 60 | x:Name="ErrorPopup" |
| 61 | AllowsTransparency="True" |
| 62 | IsOpen="{TemplateBinding IsShowError}" |
| 63 | Placement="Bottom" |
| 64 | PlacementTarget="{Binding ElementName=BoxBorder}" |
| 65 | PopupAnimation="Slide" |
| 66 | StaysOpen="False"> |
| 67 | <Border |
| 68 | Background="Red" |
| 69 | CornerRadius="12" |
| 70 | Padding="10" |
| 71 | Margin="10"> |
| 72 | <Border.Effect> |
| 73 | <DropShadowEffect BlurRadius="10" ShadowDepth="0" Direction="0" Color="Gray" Opacity=".2"/> |
| 74 | </Border.Effect> |
| 75 | |
| 76 | <Grid> |
| 77 | <Path |
| 78 | Width="15" |
| 79 | Height="15" |
| 80 | SnapsToDevicePixels="False" |
| 81 | Data="M 0 15 L 7.5 7.5 L 15 15" Fill="Red" |
| 82 | Stroke="Red" |
| 83 | StrokeThickness="1" |
| 84 | VerticalAlignment="Top" |
| 85 | HorizontalAlignment="Left" |
| 86 | Margin="0,-25,0,0" |
| 87 | /> |
| 88 | <TextBlock Foreground="White" Text="{TemplateBinding Error}"/> |
| 89 | </Grid> |
| 90 | |
| 91 | </Border> |
| 92 | </Popup> |
| 93 | <VisualStateManager.VisualStateGroups> |
| 94 | <VisualStateGroup x:Name="CommonStates"> |
| 95 | <VisualState x:Name="Normal" /> |
| 96 | <VisualState x:Name="Disabled"/> |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | <VisualState Name="Focused"> |
| 102 | <Storyboard> |
| 103 | <DoubleAnimation Duration="0:0:.3" Storyboard.TargetName="Icon" Storyboard.TargetProperty="(RenderTransform).(ScaleTransform.ScaleX)" To="0.8"> |
| 104 | <DoubleAnimation.EasingFunction> |
| 105 | <BackEase EasingMode="EaseIn"/> |
| 106 | </DoubleAnimation.EasingFunction> |
| 107 | </DoubleAnimation> |
| 108 | <DoubleAnimation Duration="0:0:.3" Storyboard.TargetName="Icon" Storyboard.TargetProperty="(RenderTransform).(ScaleTransform.ScaleY)" To="0.8"> |
| 109 | <DoubleAnimation.EasingFunction> |
| 110 | <BackEase EasingMode="EaseIn"/> |
| 111 | </DoubleAnimation.EasingFunction> |
| 112 | </DoubleAnimation> |
| 113 | <ColorAnimation Storyboard.TargetName="BoxBorder" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" |
| 114 | To="{DynamicResource InputBoxFocusedBgColor}" |
| 115 | Duration="0:0:.18"> |
| 116 | </ColorAnimation> |
| 117 | <ColorAnimation Storyboard.TargetName="BoxBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" |
| 118 | To="{DynamicResource ThemeColor}" |
| 119 | Duration="0:0:.18"> |
| 120 | </ColorAnimation> |
| 121 | <ColorAnimation Storyboard.TargetName="Icon" Storyboard.TargetProperty="(Foreground).(SolidColorBrush.Color)" |
| 122 | To="{DynamicResource ThemeColor}" |
| 123 | Duration="0:0:.18"> |
| 124 | </ColorAnimation> |
| 125 | </Storyboard> |
| 126 | </VisualState> |
| 127 | |
| 128 | <VisualState x:Name="MouseOver"> |
| 129 | <Storyboard> |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | <ColorAnimation Storyboard.TargetName="BoxBorder" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" |
| 135 | To="{DynamicResource InputBoxHoverColor}" |
| 136 | Duration="0:0:.18"> |
| 137 | </ColorAnimation> |
| 138 | </Storyboard> |
| 139 | </VisualState> |
| 140 | </VisualStateGroup> |
| 141 | </VisualStateManager.VisualStateGroups> |
| 142 | </Grid> |
| 143 | |
| 144 | <ControlTemplate.Triggers> |
| 145 | <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="{x:Static sys:String.Empty}"> |
| 146 | <Setter TargetName="Placeholder" Property="Visibility" Value="Visible" /> |
| 147 | </DataTrigger> |
| 148 | <Trigger Property="IsFocused" Value="True"> |
| 149 | <Setter TargetName="Shadow" Property="Visibility" Value="Visible"/> |
| 150 | <Setter TargetName="ErrorIcon" Property="Visibility" Value="Collapsed"/> |
| 151 | |
| 152 | </Trigger> |
| 153 | <Trigger Property="Title" Value="{x:Null}"> |
| 154 | <Setter TargetName="Title" Property="Visibility" Value="Collapsed"/> |
| 155 | |
| 156 | </Trigger> |
| 157 | <Trigger Property="Icon" Value="None"> |
| 158 | <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/> |
| 159 | </Trigger> |
| 160 | <Trigger Property="IsError" Value="True"> |
| 161 | <Setter TargetName="BoxBorder" Property="Background" Value="red"/> |
| 162 | <Setter TargetName="Shadow" Property="Visibility" Value="Visible"/> |
| 163 | <Setter TargetName="ErrorIcon" Property="Visibility" Value="Visible"/> |
| 164 | </Trigger> |
| 165 | <MultiTrigger> |
| 166 | <MultiTrigger.Conditions> |
| 167 | <Condition Property="IsError" Value="True"/> |
| 168 | <Condition Property="IsFocused" Value="False"/> |
| 169 | </MultiTrigger.Conditions> |
| 170 | <Setter Property="Foreground" Value="White"/> |
| 171 | <Setter TargetName="Icon" Property="Foreground" Value="White"/> |
| 172 | <Setter TargetName="Title" Property="Foreground" Value="White"/> |
| 173 | </MultiTrigger> |
| 174 | <Trigger Property="IsEnabled" Value="False"> |
| 175 | <Setter TargetName="Icon" Property="Foreground" Value="{DynamicResource DisabledTextBrush}"/> |
| 176 | <Setter TargetName="Placeholder" Property="Foreground" Value="{DynamicResource DisabledTextBrush}"/> |
| 177 | <Setter Property="Foreground" Value="{DynamicResource DisabledTextBrush}"/> |
| 178 | <Setter TargetName="BoxBorder" Property="Background" Value="{DynamicResource DisabledBackgroundBrush}"/> |
| 179 | </Trigger> |
| 180 | </ControlTemplate.Triggers> |
| 181 | </ControlTemplate> |
| 182 | </Setter.Value> |
| 183 | </Setter> |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | </Style> |
| 269 | </ResourceDictionary> |