Repository navigation
Expand file tree
/
Copy pathAllowlistManagerWindow.xaml
More file actions
402 lines (379 loc) · 21.5 KB
/
Copy pathAllowlistManagerWindow.xaml
File metadata and controls
402 lines (379 loc) · 21.5 KB
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<Window x:Class="NetStatAnalyzer.AllowlistManagerWindow"
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:NetStatAnalyzer"
mc:Ignorable="d"
Icon="pack://application:,,,/assets/icon.ico"
Title="Gerenciador de Conexões Confiáveis - NetStatAnalyzer"
Height="540" Width="850"
MinHeight="450" MinWidth="680"
WindowStartupLocation="CenterOwner"
Background="#181B22"
Foreground="#F8FAFC"
FontFamily="Segoe UI, Arial, sans-serif">
<Window.Resources>
<Style x:Key="ModernPrimaryButton" TargetType="Button">
<Setter Property="Background" Value="#2563EB" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="14,7" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border"
Background="{TemplateBinding Background}"
BorderThickness="0"
CornerRadius="6"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#1D4ED8" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="border" Property="Background" Value="#1E40AF" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ModernSecondaryButton" TargetType="Button">
<Setter Property="Background" Value="#2A303F" />
<Setter Property="Foreground" Value="#F1F5F9" />
<Setter Property="BorderBrush" Value="#3D465C" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontWeight" Value="Medium" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="14,7" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="secBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="6"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="secBorder" Property="Background" Value="#373F54" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="secBorder" Property="Background" Value="#222734" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ModernDangerButton" TargetType="Button">
<Setter Property="Background" Value="#991B1B" />
<Setter Property="Foreground" Value="#FEE2E2" />
<Setter Property="BorderBrush" Value="#B91C1C" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontWeight" Value="Medium" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="12,6" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="dangBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="6"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="dangBorder" Property="Background" Value="#DC2626" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="dangBorder" Property="Background" Value="#7F1D1D" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="RowIconDangerButton" TargetType="Button">
<Setter Property="Background" Value="#262D3D" />
<Setter Property="Foreground" Value="#F87171" />
<Setter Property="BorderBrush" Value="#3D465C" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="7,4" />
<Setter Property="Margin" Value="2,0" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="btnBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="btnBorder" Property="Background" Value="#DC2626" />
<Setter TargetName="btnBorder" Property="BorderBrush" Value="#EF4444" />
<Setter Property="Foreground" Value="#FFFFFF" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="btnBorder" Property="Background" Value="#991B1B" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ModernTextBox" TargetType="TextBox">
<Setter Property="Background" Value="#151821" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="CaretBrush" Value="#60A5FA" />
<Setter Property="BorderBrush" Value="#3D465C" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="10,6" />
<Setter Property="FontSize" Value="12" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border x:Name="tbBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="6">
<ScrollViewer x:Name="PART_ContentHost" Margin="0" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="tbBorder" Property="BorderBrush" Value="#3B82F6" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#13161F" />
<Setter Property="Foreground" Value="#94A3B8" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Padding" Value="8,6" />
<Setter Property="BorderBrush" Value="#282E3E" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="MinHeight" Value="36" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#1E2433" />
<Setter Property="Foreground" Value="#FFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="#1C202A" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="BorderThickness" Value="0,1,0,1" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="MinHeight" Value="36" />
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#222734" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#2C364D" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#1D4ED8" />
<Setter Property="BorderBrush" Value="#60A5FA" />
<Setter Property="Foreground" Value="#FFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="DataGridCell">
<Setter Property="Padding" Value="10,6" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="#FFFFFF" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border Padding="{TemplateBinding Padding}" Background="Transparent">
<ContentPresenter VerticalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#FFFFFF" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid Margin="18">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,0,0,14">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="Conexões Confiáveis" FontSize="18" FontWeight="Bold" Foreground="#FFFFFF" />
<Border Background="#065F46" BorderBrush="#059669" BorderThickness="1" CornerRadius="4" Margin="10,0,0,0" Padding="8,2" VerticalAlignment="Center">
<TextBlock x:Name="RuleCountTextBlock" Text="0 Conexões Confiáveis" FontSize="11" FontWeight="Bold" Foreground="#6EE7B7" />
</Border>
</StackPanel>
<TextBlock Text="Conexões que correspondem à combinação de Processo + IP são reconhecidas e marcadas como confiáveis." FontSize="12" Foreground="#94A3B8" Margin="0,4,0,0" />
</StackPanel>
</Grid>
<Border Grid.Row="1" Background="#222630" BorderBrush="#2F3543" BorderThickness="1" CornerRadius="8" Padding="12" Margin="0,0,0,12">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="SearchTextBox"
Style="{StaticResource ModernTextBox}"
Height="34"
TextChanged="SearchTextBox_TextChanged"
VerticalAlignment="Center" />
<TextBlock Text="Filtrar conexões por processo ou IP..."
IsHitTestVisible="False"
Foreground="#64748B"
FontSize="12"
VerticalAlignment="Center"
Margin="12,0,0,0"
Visibility="{Binding ElementName=SearchTextBox, Path=Text.IsEmpty, Converter={x:Static local:EmptyStringToVisibilityConverter.Instance}}" />
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="8,0,0,0">
<Button Content="Limpar Filtro" Style="{StaticResource ModernSecondaryButton}" Height="34" Click="ClearFilter_Click" />
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="2" Background="#1C202A" BorderBrush="#2D3344" BorderThickness="1" CornerRadius="8" ClipToBounds="True">
<DataGrid x:Name="RulesDataGrid"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserResizeColumns="True"
CanUserReorderColumns="True"
CanUserSortColumns="True"
IsReadOnly="True"
SelectionMode="Extended"
SelectionUnit="FullRow"
AlternationCount="2"
GridLinesVisibility="Horizontal"
HorizontalGridLinesBrush="#282E3E"
HeadersVisibility="Column"
Background="#1C202A"
Foreground="#FFFFFF"
BorderThickness="0">
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#1D4ED8" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="#1E40AF" />
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#FFFFFF" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="#FFFFFF" />
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn Header="PROCESSO" SortMemberPath="ProcessName" Width="160" MinWidth="130">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ProcessName}" FontWeight="Bold" Foreground="#FFFFFF" VerticalAlignment="Center" Margin="6,0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="PROTOCOLO" SortMemberPath="Protocol" Width="95" MinWidth="80">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Background="#1E293B" CornerRadius="4" Padding="6,2" HorizontalAlignment="Left" Margin="4,0">
<TextBlock Text="{Binding Protocol}" FontSize="11" FontWeight="Bold" Foreground="#60A5FA" />
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="ENDEREÇO LOCAL" SortMemberPath="LocalAddress" Width="180" MinWidth="140">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LocalAddress}" FontFamily="Cascadia Code, Consolas, monospace" FontWeight="SemiBold" Foreground="#34D399" VerticalAlignment="Center" Margin="6,0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="ENDEREÇO REMOTO" SortMemberPath="ForeignAddress" Width="180" MinWidth="140">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding ForeignAddress}" FontFamily="Cascadia Code, Consolas, monospace" Foreground="#E2E8F0" VerticalAlignment="Center" Margin="6,0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="ADICIONADO EM" SortMemberPath="AddedAt" Width="135" MinWidth="115">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding AddedAt, StringFormat='dd/MM/yyyy HH:mm'}" Foreground="#CBD5E1" VerticalAlignment="Center" Margin="6,0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="AÇÕES" CanUserSort="False" Width="95" MinWidth="85">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Style="{StaticResource RowIconDangerButton}"
Content="Remover"
ToolTip="Remover esta conexão da lista de confiáveis"
Click="DeleteRule_Click"
HorizontalAlignment="Center" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
<Grid Grid.Row="3" Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Button Content="Importar JSON"
Style="{StaticResource ModernSecondaryButton}"
Height="34" Margin="0,0,8,0"
Click="ImportJson_Click" />
<Button Content="Exportar JSON"
Style="{StaticResource ModernSecondaryButton}"
Height="34" Margin="0,0,8,0"
Click="ExportJson_Click" />
<Button Content="Limpar Tudo"
Style="{StaticResource ModernDangerButton}"
Height="34"
Click="ClearAll_Click" />
</StackPanel>
<Button Grid.Column="1"
Content="Fechar"
Style="{StaticResource ModernPrimaryButton}"
Height="34" Width="90"
Click="Close_Click" />
</Grid>
</Grid>
</Window>