This repository has been archived by the owner on Feb 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputDialog.xaml
191 lines (191 loc) · 6.45 KB
/
InputDialog.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<Window x:Class="Com.Xenthrax.WindowsDataVisualizer.InputDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:XAML="clr-namespace:Com.Xenthrax.WindowsDataVisualizer.XAML"
Title="Input Dialog"
Height="160"
Width="410"
Loaded="Window_Loaded"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
WindowStartupLocation="CenterOwner"
WindowStyle="ToolWindow"
ResizeMode="CanMinimize">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.Resources>
<ControlTemplate x:Key="ErrorTemplate">
<ControlTemplate.Resources>
<Storyboard AutoReverse="False" x:Key="FadeInStoryboard">
<DoubleAnimation From="0"
To="1"
BeginTime="0:0:0"
Duration="0:0:0.50"
Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</ControlTemplate.Resources>
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Bottom"
BorderBrush="DarkRed"
BorderThickness="1"
CornerRadius="2"
Opacity="0"
Margin="1,2,1,0">
<Border.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource FadeInStoryboard}"/>
</EventTrigger>
</Border.Triggers>
<TextBlock Background="Red"
Foreground="White"
TextWrapping="Wrap"
Text="{Binding ElementName=ErrorElement, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
</Border>
<Border BorderBrush="Red"
BorderThickness="1"
CornerRadius="{Binding ElementName=ErrorElement, Path=AdornedElement.Tag}"
Grid.Column="1"
Grid.Row="1">
<AdornedElementPlaceholder Name="ErrorElement"/>
</Border>
</DockPanel>
</ControlTemplate>
</Grid.Resources>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Padding="5,4,10,4">Input File:</Label>
<TextBox Grid.Column="1"
MouseDoubleClick="InputFileBox_MouseDoubleClick"
KeyDown="InputFileBox_KeyDown"
Name="InputFileBox"
TabIndex="0"
Tag="2"
Validation.ErrorTemplate="{StaticResource ErrorTemplate}">
<TextBox.Text>
<Binding Path="InputFile" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<XAML:DataStealerFileValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="TextBox.ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Padding="5,4,10,4">Certificate:</Label>
<ComboBox Grid.Column="1"
Name="Certificates"
IsEnabled="{Binding IsEncrypted}"
TabIndex="1"
Tag="4"
Validation.ErrorTemplate="{StaticResource ErrorTemplate}">
<ComboBox.SelectedValue>
<Binding Path="Certificate">
<Binding.ValidationRules>
<XAML:CertificateValidationRule x:Name="CertificateValidation" Verify="False" NeedsPrivateKey="True"/>
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedValue>
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Subject}"/>
<TextBlock Text="{Binding Issuer, StringFormat={}Issuer: {0}}"/>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}Valid From: {0:d/MM/yyyy} to {1:d/MM/yyyy}">
<Binding Path="NotBefore"/>
<Binding Path="NotAfter"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
<Button Grid.Column="3"
Padding="7,0,7,0"
Click="CertificateView_Click">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsEncrypted}" Value="False">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=Certificates, Path=SelectedValue}" Value="{x:Null}">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
View
</Button>
</Grid>
<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="10"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Name="OK"
Click="OK_Click"
TabIndex="3">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=InputFileBox, Path=(Validation.HasError)}" Value="True">
<Setter Property="Button.IsEnabled" Value="False"/>
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEncrypted}" Value="True"/>
<Condition Binding="{Binding ElementName=Certificates, Path=(Validation.HasError)}" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Button.IsEnabled" Value="False"/>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
OK
</Button>
<Button Grid.Column="2"
Name="Cancel"
Click="Cancel_Click"
TabIndex="4">
Cancel
</Button>
</Grid>
</Grid>
</Window>