-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainWindow.xaml
320 lines (318 loc) · 22.5 KB
/
MainWindow.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF_dnscrypt_proxy_md"
xmlns:dgx="clr-namespace:DataGridExtensions;assembly=DataGridExtensions"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:dd="urn:gong-wpf-dragdrop"
x:Class="WPF_dnscrypt_proxy_md.MainWindow"
mc:Ignorable="d"
Title="MainWindow" WindowStartupLocation="CenterScreen" Height="800" Width="1200">
<Window.Resources>
<Image x:Key="imgBtn1" Source="Resources/Images/image1.ico" Width="30"/>
<Image x:Key="imgBtn2" Source="Resources/Images/image2.ico" Width="30"/>
<Image x:Key="imgBtn3" Source="Resources/Images/image3.ico" Width="30"/>
<ControlTemplate x:Key="FilterWithPopup">
<local:PopupEnumFilter Filter="{Binding Filter, RelativeSource={RelativeSource AncestorType={x:Type dgx:DataGridFilterColumnControl}, Mode=FindAncestor}}" />
</ControlTemplate>
<Style TargetType="{x:Type StackPanel}" x:Key="ShowStackPanel">
<Style.Triggers>
<DataTrigger Binding="{Binding STAMP}" Value="{x:Null}">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
<ControlTemplate x:Key="validationTemplate">
<DockPanel>
<AdornedElementPlaceholder Name="gucci"/>
<TextBlock Foreground="Red" FontSize="18" FontStretch="UltraExpanded" Margin="10,0,0,0">
<Run>👀</Run>
<Run FontSize="8" FontStyle="Italic">
<Binding Path="AdornedElement.(Validation.Errors)/ErrorContent" ElementName="gucci"/>
</Run>
</TextBlock>
</DockPanel>
</ControlTemplate>
</Window.Resources>
<x:Code>
<![CDATA[
private void LV_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
ListViewItem item = (ListViewItem)sender;
item.IsSelected = true;
}
private void LV_DEL_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (null != lv.SelectedItem)
{
lv.Items.Remove(lv.SelectedItem);
var gvrps = lv.FindVisualChild<GridViewRowPresenter>();
foreach(var gvrp in gvrps)
{
var cell = VisualTreeHelper.GetChild(gvrp, 0) as TextBlock;
var be = cell.GetBindingExpression(TextBlock.TextProperty);
be.UpdateTarget();
}
}
}
]]>
</x:Code>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<GroupBox Grid.Column="0" Margin="0,0,0,0" BorderBrush="#FF6BE681">
<GroupBox.Header>
<StackPanel Orientation="Horizontal" Height="25">
<TextBlock Text="DNSCRYPT PROXY Reference File:" FontWeight="Bold" FontStyle="Italic" FontSize="18"/>
<TextBlock x:Name="FileName" Text="" Foreground="LightSkyBlue" Margin="10,0,0,5" VerticalAlignment="Bottom"/>
</StackPanel>
</GroupBox.Header>
<GroupBox.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFAE55AE" Offset="0.003"/>
<GradientStop Color="#FF5DAE55" Offset="1"/>
<GradientStop Color="#FF5DAE55" Offset="0.278"/>
<GradientStop Color="#FFD658CB" Offset="0.438"/>
<GradientStop Color="#FFA1E09A" Offset="0.266"/>
</LinearGradientBrush>
</GroupBox.Foreground>
<DataGrid dd:DragDrop.IsDragSource="True" Grid.Column="0" x:Name="MyGrid" RowDetailsVisibilityMode="Visible" dgx:DataGridFilter.IsAutoFilterEnabled="True" AutoGenerateColumns="False"
RowHeight="25" Margin="0,0,10,0" ItemsSource="{Binding Source={x:Static local:App.GridShow}}">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Border BorderThickness="0" Padding="10">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<TextBlock FontSize="8" Text="Description:" VerticalAlignment="Center" />
<TextBlock FontSize="12" Background="Red" Foreground="MintCream" Text="{Binding Description}" VerticalAlignment="Center" MaxWidth="500" TextTrimming="CharacterEllipsis" TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Orientation="Vertical" Style="{StaticResource ShowStackPanel}">
<TextBlock FontSize="8" Text="RAW STAMP:" VerticalAlignment="Center" />
<TextBlock FontSize="12" Background="BlueViolet" Foreground="MistyRose" Text="{Binding STAMP, Mode=OneWay}" VerticalAlignment="Center" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name, Mode=OneWay}" Width="110" Header="Name"/>
<!--<DataGridTextColumn Binding="{Binding T, Mode=OneWay}" Width="50" Header="T"/>-->
<DataGridTextColumn Binding="{Binding Description, Mode=OneWay}" MaxWidth="90" Header="DESC"/>
<DataGridTextColumn Binding="{Binding STAMP.ServerAddrStr, Mode=OneWay}" Width="115" Header="IP"/>
<!--<DataGridTextColumn Binding="{Binding Path=STAMP.Props}" Header="Flags RAW"/>
<DataGridTextColumn Binding="{Binding Path=STAMP.Proto}" Header="Protocol RAW"/>-->
<DataGridTemplateColumn IsReadOnly="True" Header="Flags" dgx:DataGridFilterColumn.Template="{StaticResource FilterWithPopup}" SortMemberPath="STAMP.Props">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<xctk:CheckComboBox Delimiter=" | " BorderThickness="0" DisplayMemberPath="Value" ValueMemberPath="Key"
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type Grid}, Mode=FindAncestor}}"
ItemsSource="{Binding Source={local:EnumList {x:Type local:ServerFlag}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding STAMP.Props, Converter={local:EnumConverter}, ConverterParameter={x:Type local:ServerFlag}, Mode=TwoWay}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="True" Header="Protocol" dgx:DataGridFilterColumn.Template="{StaticResource FilterWithPopup}" SortMemberPath="STAMP.Proto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<xctk:CheckComboBox DisplayMemberPath="Value" ValueMemberPath="Key"
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type Grid}, Mode=FindAncestor}}"
ItemsSource="{Binding Source={local:EnumList {x:Type local:Protocol}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding STAMP.Proto, Converter={local:EnumConverter}, ConverterParameter={x:Type local:Protocol}, Mode=TwoWay}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding STAMP.ProviderName, Mode=OneWay}" Width="200" Header="Domain/Identity"/>
</DataGrid.Columns>
</DataGrid>
</GroupBox>
<GridSplitter Grid.Column ="1" Background="IndianRed" Width="5"
HorizontalAlignment="Center" ShowsPreview="True" Margin="0,0,0,0" ResizeDirection="Columns" Padding="30,0,30,0"/>
<GroupBox Grid.Column="2" Margin="0,0,0,0" BorderBrush="#FFAE1818">
<GroupBox.Header>
<StackPanel Orientation="Horizontal" Height="25">
<TextBlock Text="Your Customized List:" FontWeight="Bold" FontStyle="Italic" FontSize="18"/>
</StackPanel>
</GroupBox.Header>
<GroupBox.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFAE55AE" Offset="0.003"/>
<GradientStop Color="#FF5DAE55" Offset="1"/>
<GradientStop Color="#FF5DAE55" Offset="0.278"/>
<GradientStop Color="Gold" Offset="0.585"/>
<GradientStop Color="#FFDE4F24" Offset="0.464"/>
<GradientStop Color="#FFD19257" Offset="0.765"/>
<GradientStop Color="#FFCE5A2A" Offset="0.421"/>
<GradientStop Color="#FF66A35F" Offset="0.241"/>
</LinearGradientBrush>
</GroupBox.Foreground>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="80*"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>
<ListView dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{local:ListDropTarget}" Grid.Column="0" Grid.Row="0" Name="lv"
IsManipulationEnabled="True" SelectionMode="Single">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Converter={local:IndexConverter}}"
Header="#" Width="25"/>
<GridViewColumn Header="Name" Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Foreground="Fuchsia" Validation.ErrorTemplate="{StaticResource validationTemplate}">
<TextBox.Text>
<Binding Path="Name" Mode="TwoWay" BindsDirectlyToSource="True">
<Binding.ValidationRules>
<local:NamesRule Source="{x:Reference lv}" ValidationStep="CommittedValue"/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
<ListView.InputBindings>
<KeyBinding Key="Delete" Command="{Binding Path=ApplicationCommands.Delete}"/>
</ListView.InputBindings>
<ListView.CommandBindings>
<CommandBinding Command="ApplicationCommands.Delete" Executed="LV_DEL_Executed"/>
</ListView.CommandBindings>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="PreviewGotKeyboardFocus" Handler="LV_PreviewGotKeyboardFocus"/>
<EventSetter Event="Loaded" Handler="ValidateListViewItems" x:Name="Dior"/>
<EventSetter Event="Unloaded" Handler="ValidateListViewItems" x:Name="Armani"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
<xctk:PropertyGrid Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" Margin="0,10,0,0" VerticalAlignment="Top" SelectedObject="{Binding SelectedItem.STAMP, ElementName=lv}"
ShowTitle="False" IsReadOnly="False" ShowSortOptions="False" ShowAdvancedOptions="True" ShowSummary="True" ShowSearchBox="False" IsVirtualizing="True" IsMiscCategoryLabelHidden="False" IsManipulationEnabled="True" MinHeight="300">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition DisplayOrder="-1" DisplayName="Pin Set" TargetProperties="Hashes" Description="hash of TBS Certificate which is different from Fingerprint/Pin" />
<xctk:PropertyDefinition DisplayOrder="-2" DisplayName="Domain/Identity/Uri" TargetProperties="ProviderName">
<xctk:PropertyDefinition.Description>
<sys:String xml:space="preserve">
<![CDATA[There are three types of ProviderName:
For DNSCrypt, it is a plaintext whatever called dnscrypt-cert. The normal form is 2.dnscrypt-cert.example.com
For DoT or DoH, it is SNI with port number, however it can be overridden by SNIShadow used in dnscrypt-proxy-r2. The port number can be omitted
For Proxy, it is Uri of HTTP, HTTPS, SOCKS5. e.g. https://user:[email protected]:8080 socks5://proxy.com]]>
</sys:String>
</xctk:PropertyDefinition.Description>
</xctk:PropertyDefinition>
<xctk:PropertyDefinition DisplayOrder="-3" DisplayName="Flags" TargetProperties="Props" Description="Always read the terms of service by yourself and alter this flag base on recognition" />
<xctk:PropertyDefinition DisplayOrder="-4" DisplayName="Protocol" TargetProperties="Proto" Description="Proxy and Ex Stamps can only be used in dnscrypt-proxy-r2
Plains are forbidden in dnscrypt-proxy-r2" />
<xctk:PropertyDefinition DisplayOrder="1" DisplayName="Path" TargetProperties="Path" Description="Path of DoH query"/>
<xctk:PropertyDefinition DisplayOrder="2" DisplayName="Proxies" TargetProperties="Proxies" Description="'Proxies' uses semicolon as delimiter; 'Proxies' is an individual proxy list of Proxy Stamps for current server in order.
e.g. proxy-name1;proxy-name2"/>
<xctk:PropertyDefinition DisplayOrder="3" DisplayName="Tags" TargetProperties="Tags">
<xctk:PropertyDefinition.Description>
<sys:String xml:space="preserve">
<![CDATA['Tags' uses semicolon as delimiter
e.g. canada;DNS-BOOST-GROUP;NO-PROXY
Predefined Well-known Tag Name:
HTTP-USE-GET
DNS-BOOST-GROUP
DNSCRPT-OBTAIN-FAST-KEY
NO-PROXY]]>
</sys:String>
</xctk:PropertyDefinition.Description>
</xctk:PropertyDefinition>
</xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyGrid.PropertyContainerStyle>
<Style>
<Setter Property="ItemsControl.Background" Value="ForestGreen"/>
<Setter Property="ItemsControl.Foreground" Value="Fuchsia"/>
</Style>
</xctk:PropertyGrid.PropertyContainerStyle>
<xctk:PropertyGrid.Style>
<Style>
<Style.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="Name" Value="PG_Item_Name">
<Setter Property="Foreground" Value="Goldenrod"/>
<Setter Property="FontWeight" Value="Light"/>
<Setter Property="TextAlignment" Value="Center"/>
</Trigger>
<Trigger Property="Name" Value="PG_Item_Desc">
<Setter Property="Foreground" Value="GhostWhite"/>
<Setter Property="FontWeight" Value="ExtraBlack"/>
<Setter Property="FontSize" Value="8pt" />
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
</xctk:PropertyGrid.Style>
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition TargetProperties="ProviderName">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<TextBox Background="ForestGreen" Foreground="Fuchsia" Text="{Binding Value}">
</TextBox>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition TargetProperties="Hashes">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<xctk:MultiLineTextEditor DropDownWidth="350" Text="{Binding Value, Converter={local:PinSetConverter}}">
</xctk:MultiLineTextEditor>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition TargetProperties="Props">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<xctk:CheckComboBox DisplayMemberPath="Value" ValueMemberPath="Key"
ItemsSource="{Binding Source={local:EnumList {x:Type local:ServerFlag}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding Value, Converter={local:EnumConverter}, ConverterParameter={x:Type local:ServerFlag}, Mode=TwoWay}"/>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition TargetProperties="Proto">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<xctk:CheckComboBox DisplayMemberPath="Value" ValueMemberPath="Key"
ItemsSource="{Binding Source={local:EnumList {x:Type local:Protocol}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding Value, Converter={local:EnumConverter}, ConverterParameter={x:Type local:Protocol}, Mode=TwoWay}"/>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition TargetProperties="SNIBlotUp">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<xctk:CheckComboBox DisplayMemberPath="Value" ValueMemberPath="Key"
ItemsSource="{Binding Source={local:EnumList {x:Type local:SNIBlotUpType}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding Value, Converter={local:EnumConverter}, ConverterParameter={x:Type local:SNIBlotUpType}, Mode=TwoWay}"/>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Height="90" Margin="10" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<xctk:IconButton Width="100" Margin="10" Background="Aqua" IconLocation="Left" Icon="{StaticResource imgBtn1}" Click="IconButton_Click_1">
<TextBlock Text="Open Reference File" TextWrapping="Wrap" TextAlignment="Center"/>
</xctk:IconButton>
<xctk:IconButton Width="100" Margin="10" Background="Beige" IconLocation="Left" Icon="{StaticResource imgBtn2}" Click="IconButton_Click_2">
<TextBlock Text="Verify Signature(Reference File)" TextWrapping="Wrap" TextAlignment="Center"/>
</xctk:IconButton>
<xctk:IconButton Width="100" Margin="10" Background="CadetBlue" IconLocation="Left" Icon="{StaticResource imgBtn3}" Click="IconButton_Click_3">
<TextBlock Text="Save File &Recreate Signature☂" TextWrapping="Wrap" TextAlignment="Center"/>
</xctk:IconButton>
</StackPanel>
</Grid>
</GroupBox>
</Grid>
</Window>