跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

InputBox.xaml

269 行 · 16.7 KB历史下载
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"
46VerticalAlignment="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"
50Visibility="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 <!--Right here-->
98
99 <!--<VisualState Name="Unfocused"/>-->
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 <!--<ColorAnimation Storyboard.TargetName="BoxBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
131 To="{DynamicResource ThemeColor}"
132 Duration="0:0:.18">
133 </ColorAnimation>-->
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 <!--<Setter Property="SnapsToDevicePixels"
185 Value="true" />
186 <Setter Property="Width" Value="auto"/>
187
188 <Setter Property="Height" Value="35"/>
189 <Setter Property="Cursor" Value="IBeam"/>
190
191 <Setter Property="Background" Value="Transparent"/>
192 <Setter Property="Template">
193 <Setter.Value>
194 <ControlTemplate TargetType="{x:Type local:InputBox}">
195 <Border Background="{TemplateBinding Background}" x:Name="Border">
196
197 <Grid>
198 <Border x:Name="BoxBorder" BorderBrush="#a3a3a3" BorderThickness="2" CornerRadius="4">
199 <Grid>
200 <TextBlock Margin="5,0" x:Name="Placeholder" Text="{TemplateBinding Placeholder}" Foreground="#a3a3a3" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Center" Visibility="Collapsed"/>
201 <ScrollViewer Margin="5,0"
202 x:Name="PART_ContentHost" VerticalAlignment="Center"/>
203 </Grid>
204
205 </Border>
206 <Popup
207 x:Name="ErrorPopup"
208 AllowsTransparency="True"
209 IsOpen="{TemplateBinding IsShowError}"
210 Placement="Bottom"
211 PlacementTarget="{Binding ElementName=BoxBorder}"
212 PopupAnimation="Slide"
213 StaysOpen="False">
214 <Border
215 Background="Red"
216 CornerRadius="12"
217 Padding="10"
218 Margin="10">
219 <Border.Effect>
220 <DropShadowEffect BlurRadius="10" ShadowDepth="0" Direction="0" Color="Gray" Opacity=".2"/>
221 </Border.Effect>
222
223 <Grid>
224 <Path
225 Width="15"
226 Height="15"
227 SnapsToDevicePixels="False"
228 Data="M 0 15 L 7.5 7.5 L 15 15" Fill="Red"
229 Stroke="Red"
230 StrokeThickness="1"
231 VerticalAlignment="Top"
232 HorizontalAlignment="Left"
233 Margin="0,-25,0,0"
234 />
235 <TextBlock Foreground="White" Text="{TemplateBinding Error}"/>
236 </Grid>
237
238 </Border>
239 </Popup>
240
241 </Grid>
242 <VisualStateManager.VisualStateGroups>
243 <VisualStateGroup Name="FocusStates">
244 <VisualState Name="Unfocused"/>
245 --><!--Right here--><!--
246 <VisualState Name="Focused">
247 <Storyboard>
248 <ColorAnimation Storyboard.TargetName="BoxBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
249 To="{DynamicResource ThemeColor}"
250 Duration="0:0:.4">
251 <ColorAnimation.EasingFunction>
252 <QuadraticEase/>
253 </ColorAnimation.EasingFunction>
254 </ColorAnimation>
255 </Storyboard>
256 </VisualState>
257 </VisualStateGroup>
258 </VisualStateManager.VisualStateGroups>
259 </Border>
260 <ControlTemplate.Triggers>
261 <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="{x:Static sys:String.Empty}">
262 <Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
263 </DataTrigger>
264 </ControlTemplate.Triggers>
265 </ControlTemplate>
266 </Setter.Value>
267 </Setter>-->
268 </Style>
269</ResourceDictionary>