Skip to content

Commit aa11cc1

Browse files
authored
Fix: AirSpace fixer screenshot & AWS profile check null (#2209)
* Fix: AirSpace fixer screenshot & AWS profile check null * Docs: #2209
1 parent af6793c commit aa11cc1

15 files changed

+104
-102
lines changed

Source/NETworkManager.Profiles/ProfileFileInfoArgs.cs

+24
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,35 @@ namespace NETworkManager.Profiles;
44

55
public class ProfileFileInfoArgs : EventArgs
66
{
7+
/// <summary>
8+
/// Profile file info which is loaded or should be loaded.
9+
/// </summary>
710
public ProfileFileInfo ProfileFileInfo { get; set; }
811

12+
/// <summary>
13+
/// If true, the profile will be updated in the UI, but does not trigger a
14+
/// profile load event (e.g. to enter the password for decryption).
15+
/// </summary>
16+
public bool ProfileFileUpdating { get; set; }
917

18+
/// <summary>
19+
/// Creates a new instance of the <see cref="ProfileFileInfoArgs"/> class with the specified parameters.
20+
/// </summary>
21+
/// <param name="profileFileInfo">Profile file info which is loaded.</param>
1022
public ProfileFileInfoArgs(ProfileFileInfo profileFileInfo)
1123
{
1224
ProfileFileInfo = profileFileInfo;
25+
ProfileFileUpdating = false;
26+
}
27+
28+
/// <summary>
29+
/// Creates a new instance of the <see cref="ProfileFileInfoArgs"/> class with the specified parameters.
30+
/// </summary>
31+
/// <param name="profileFileInfo">Profile file info which should be loaded.</param>
32+
/// <param name="profileFileUpdating">If true, the profile will be updated in the UI, but does not trigger a profile load event (e.g. to enter the password for decryption).</param>
33+
public ProfileFileInfoArgs(ProfileFileInfo profileFileInfo, bool profileFileUpdating)
34+
{
35+
ProfileFileInfo = profileFileInfo;
36+
ProfileFileUpdating = profileFileUpdating;
1337
}
1438
}

Source/NETworkManager.Profiles/ProfileManager.cs

+9-27
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
using System.Linq;
66
using System.Security;
77
using System.Text;
8-
using System.Text.Json;
98
using System.Xml.Serialization;
109
using NETworkManager.Settings;
1110
using NETworkManager.Utilities;
12-
using Newtonsoft.Json;
1311

1412
namespace NETworkManager.Profiles;
1513

@@ -84,26 +82,10 @@ public static ProfileFileInfo LoadedProfileFile
8482
/// Method to fire the <see cref="OnLoadedProfileFileChangedEvent"/>.
8583
/// </summary>
8684
/// <param name="profileFileInfo">Loaded <see cref="ProfileFileInfo"/>.</param>
87-
private static void LoadedProfileFileChanged(ProfileFileInfo profileFileInfo)
85+
private static void LoadedProfileFileChanged(ProfileFileInfo profileFileInfo, bool profileFileUpdating = false)
8886
{
89-
OnLoadedProfileFileChangedEvent?.Invoke(null, new ProfileFileInfoArgs(profileFileInfo));
90-
}
91-
92-
/// <summary>
93-
/// Event is fired if the UI needs to update the displayed profile file (e.g. after a
94-
/// profile file was deleted). The /// <see cref="ProfileFileInfo"/> with the current
95-
/// loaded profile file is passed as argument.
96-
/// </summary>
97-
public static event EventHandler<ProfileFileInfoArgs> OnSwitchProfileFileViaUIEvent;
98-
99-
/// <summary>
100-
/// Method to fire the <see cref="OnSwitchProfileFileViaUIEvent"/>.
101-
/// </summary>
102-
/// <param name="info">Loaded <see cref="ProfileFileInfo"/>.</param>
103-
private static void SwitchProfileFileViaUI(ProfileFileInfo info)
104-
{
105-
OnSwitchProfileFileViaUIEvent?.Invoke(null, new ProfileFileInfoArgs(info));
106-
}
87+
OnLoadedProfileFileChangedEvent?.Invoke(null, new ProfileFileInfoArgs(profileFileInfo, profileFileUpdating));
88+
}
10789

10890
/// <summary>
10991
/// Event is fired if the profiles have changed.
@@ -240,7 +222,7 @@ public static void RenameProfileFile(ProfileFileInfo profileFileInfo, string new
240222
if (switchProfile)
241223
{
242224
Switch(newProfileFileInfo, false);
243-
LoadedProfileFileChanged(LoadedProfileFile);
225+
LoadedProfileFileChanged(LoadedProfileFile, true);
244226
}
245227

246228
File.Delete(profileFileInfo.Path);
@@ -255,7 +237,7 @@ public static void DeleteProfileFile(ProfileFileInfo profileFileInfo)
255237
{
256238
// Trigger switch via UI (to get the password if the file is encrypted), if the selected profile file is deleted
257239
if (LoadedProfileFile != null && LoadedProfileFile.Equals(profileFileInfo))
258-
SwitchProfileFileViaUI(ProfileFiles.FirstOrDefault(x => !x.Equals(profileFileInfo)));
240+
LoadedProfileFileChanged(ProfileFiles.FirstOrDefault(x => !x.Equals(profileFileInfo)));
259241

260242
File.Delete(profileFileInfo.Path);
261243
ProfileFiles.Remove(profileFileInfo);
@@ -302,7 +284,7 @@ public static void EnableEncryption(ProfileFileInfo profileFileInfo, SecureStrin
302284
if (switchProfile)
303285
{
304286
Switch(newProfileFileInfo, false);
305-
LoadedProfileFileChanged(LoadedProfileFile);
287+
LoadedProfileFileChanged(LoadedProfileFile, true);
306288
}
307289

308290
// Remove the old profile file
@@ -353,7 +335,7 @@ public static void ChangeMasterPassword(ProfileFileInfo profileFileInfo, SecureS
353335
if (switchProfile)
354336
{
355337
Switch(newProfileFileInfo, false);
356-
LoadedProfileFileChanged(LoadedProfileFile);
338+
LoadedProfileFileChanged(LoadedProfileFile, true);
357339
}
358340

359341
// Remove the old profile file
@@ -394,7 +376,7 @@ public static void DisableEncryption(ProfileFileInfo profileFileInfo, SecureStri
394376
if (switchProfile)
395377
{
396378
Switch(newProfileFileInfo, false);
397-
LoadedProfileFileChanged(LoadedProfileFile);
379+
LoadedProfileFileChanged(LoadedProfileFile, true);
398380
}
399381

400382
// Remove the old profile file
@@ -443,7 +425,7 @@ private static void Load(ProfileFileInfo profileFileInfo)
443425
LoadedProfileFile = profileFileInfo;
444426

445427
if (loadedProfileUpdated)
446-
LoadedProfileFileChanged(LoadedProfileFile);
428+
LoadedProfileFileChanged(LoadedProfileFile, true);
447429
}
448430

449431
/// <summary>

Source/NETworkManager/MainWindow.xaml

+14-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
xmlns:resources="clr-namespace:NETworkManager.Properties"
1414
xmlns:networkManager="clr-namespace:NETworkManager"
1515
mc:Ignorable="d"
16-
Style="{DynamicResource DefaultWindow}" MinWidth="800" Width="1024" Height="768" MinHeight="600" Activated="MetroMainWindow_Activated" SaveWindowPosition="True" TitleAlignment="Left" Closing="MetroWindowMain_Closing" StateChanged="MetroWindowMain_StateChanged"
16+
Style="{DynamicResource DefaultWindow}"
17+
MinWidth="800" Width="1024" Height="768" MinHeight="600"
18+
SaveWindowPosition="True" TitleAlignment="Left"
19+
ContentRendered="MetroMainWindow_ContentRendered" StateChanged="MetroWindowMain_StateChanged"
20+
Activated="MetroMainWindow_Activated" Closing="MetroWindowMain_Closing"
1721
d:DataContext="{d:DesignInstance networkManager:MainWindow}">
1822
<!-- MetroDialogStyles.xaml must be adjusted if MinWidth/MinHeight is changed -->
1923
<Window.Resources>
@@ -59,7 +63,7 @@
5963
</MenuItem>
6064
</ContextMenu>
6165
</Window.Resources>
62-
<mah:MetroWindow.WindowButtonCommands>
66+
<mah:MetroWindow.WindowButtonCommands>
6367
<mah:WindowButtonCommands Template="{DynamicResource MahApps.Templates.WindowButtonCommands.Win10}" />
6468
</mah:MetroWindow.WindowButtonCommands>
6569
<mah:MetroWindow.LeftWindowCommands>
@@ -68,7 +72,7 @@
6872
<StackPanel Orientation="Horizontal" Margin="-2,-1,0,0">
6973
<Grid Background="{DynamicResource MahApps.Brushes.Gray8}" Visibility="{Binding Source={x:Static settings:ConfigurationManager.Current}, Path=IsAdmin, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
7074
<TextBlock Text="Administrator" Foreground="{DynamicResource MahApps.Brushes.Gray3}" Style="{StaticResource CenterTextBlock}" Margin="10,0" />
71-
</Grid>
75+
</Grid>
7276
</StackPanel>
7377
</mah:WindowCommands>
7478
</mah:MetroWindow.LeftWindowCommands>
@@ -90,7 +94,7 @@
9094
<Rectangle Width="20" Height="20" Fill="{DynamicResource MahApps.Brushes.Accent}">
9195
<Rectangle.OpacityMask>
9296
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=RocketLaunchOutline}" />
93-
</Rectangle.OpacityMask>
97+
</Rectangle.OpacityMask>
9498
</Rectangle>
9599
<TextBlock Text="{x:Static localization:Strings.UpdateAvailable}" Style="{StaticResource LinkTextBlock}" VerticalAlignment="Center" Margin="5,0,0,0" />
96100
</StackPanel>
@@ -141,10 +145,10 @@
141145
</DataTrigger>
142146
</Style.Triggers>
143147
</Style>
144-
</Rectangle.Style>
148+
</Rectangle.Style>
145149
</Rectangle>
146150
<TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Name}" />
147-
</Grid>
151+
</Grid>
148152
</DataTemplate>
149153
</ComboBox.ItemTemplate>
150154
</ComboBox>
@@ -159,7 +163,7 @@
159163
</Button>
160164
<Button Command="{Binding OpenWebsiteCommand}" ToolTip="{x:Static localization:Strings.ReportAnIssueOrCreateAFeatureRequest}" CommandParameter="{x:Static resources:Resources.NETworkManager_NewIssueUrl}" Cursor="Hand">
161165
<StackPanel Orientation="Horizontal">
162-
<Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
166+
<Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
163167
<Rectangle.OpacityMask>
164168
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Modern Kind=Bug}" />
165169
</Rectangle.OpacityMask>
@@ -446,9 +450,9 @@
446450
<Rectangle.Style>
447451
<Style TargetType="{x:Type Rectangle}">
448452
<Style.Triggers>
449-
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" Value="True" >
450-
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Accent}" />
451-
</DataTrigger>
453+
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" Value="True" >
454+
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Accent}" />
455+
</DataTrigger>
452456
</Style.Triggers>
453457
</Style>
454458
</Rectangle.Style>

0 commit comments

Comments
 (0)