Skip to content

Commit

Permalink
Fix: AirSpace fixer screenshot & AWS profile check null (#2209)
Browse files Browse the repository at this point in the history
* Fix: AirSpace fixer screenshot & AWS profile check null

* Docs: #2209
  • Loading branch information
BornToBeRoot authored Apr 25, 2023
1 parent af6793c commit aa11cc1
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 102 deletions.
24 changes: 24 additions & 0 deletions Source/NETworkManager.Profiles/ProfileFileInfoArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@ namespace NETworkManager.Profiles;

public class ProfileFileInfoArgs : EventArgs
{
/// <summary>
/// Profile file info which is loaded or should be loaded.
/// </summary>
public ProfileFileInfo ProfileFileInfo { get; set; }

/// <summary>
/// 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).
/// </summary>
public bool ProfileFileUpdating { get; set; }

/// <summary>
/// Creates a new instance of the <see cref="ProfileFileInfoArgs"/> class with the specified parameters.
/// </summary>
/// <param name="profileFileInfo">Profile file info which is loaded.</param>
public ProfileFileInfoArgs(ProfileFileInfo profileFileInfo)
{
ProfileFileInfo = profileFileInfo;
ProfileFileUpdating = false;
}

/// <summary>
/// Creates a new instance of the <see cref="ProfileFileInfoArgs"/> class with the specified parameters.
/// </summary>
/// <param name="profileFileInfo">Profile file info which should be loaded.</param>
/// <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>
public ProfileFileInfoArgs(ProfileFileInfo profileFileInfo, bool profileFileUpdating)
{
ProfileFileInfo = profileFileInfo;
ProfileFileUpdating = profileFileUpdating;
}
}
36 changes: 9 additions & 27 deletions Source/NETworkManager.Profiles/ProfileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System.Linq;
using System.Security;
using System.Text;
using System.Text.Json;
using System.Xml.Serialization;
using NETworkManager.Settings;
using NETworkManager.Utilities;
using Newtonsoft.Json;

namespace NETworkManager.Profiles;

Expand Down Expand Up @@ -84,26 +82,10 @@ public static ProfileFileInfo LoadedProfileFile
/// Method to fire the <see cref="OnLoadedProfileFileChangedEvent"/>.
/// </summary>
/// <param name="profileFileInfo">Loaded <see cref="ProfileFileInfo"/>.</param>
private static void LoadedProfileFileChanged(ProfileFileInfo profileFileInfo)
private static void LoadedProfileFileChanged(ProfileFileInfo profileFileInfo, bool profileFileUpdating = false)
{
OnLoadedProfileFileChangedEvent?.Invoke(null, new ProfileFileInfoArgs(profileFileInfo));
}

/// <summary>
/// Event is fired if the UI needs to update the displayed profile file (e.g. after a
/// profile file was deleted). The /// <see cref="ProfileFileInfo"/> with the current
/// loaded profile file is passed as argument.
/// </summary>
public static event EventHandler<ProfileFileInfoArgs> OnSwitchProfileFileViaUIEvent;

/// <summary>
/// Method to fire the <see cref="OnSwitchProfileFileViaUIEvent"/>.
/// </summary>
/// <param name="info">Loaded <see cref="ProfileFileInfo"/>.</param>
private static void SwitchProfileFileViaUI(ProfileFileInfo info)
{
OnSwitchProfileFileViaUIEvent?.Invoke(null, new ProfileFileInfoArgs(info));
}
OnLoadedProfileFileChangedEvent?.Invoke(null, new ProfileFileInfoArgs(profileFileInfo, profileFileUpdating));
}

/// <summary>
/// Event is fired if the profiles have changed.
Expand Down Expand Up @@ -240,7 +222,7 @@ public static void RenameProfileFile(ProfileFileInfo profileFileInfo, string new
if (switchProfile)
{
Switch(newProfileFileInfo, false);
LoadedProfileFileChanged(LoadedProfileFile);
LoadedProfileFileChanged(LoadedProfileFile, true);
}

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

File.Delete(profileFileInfo.Path);
ProfileFiles.Remove(profileFileInfo);
Expand Down Expand Up @@ -302,7 +284,7 @@ public static void EnableEncryption(ProfileFileInfo profileFileInfo, SecureStrin
if (switchProfile)
{
Switch(newProfileFileInfo, false);
LoadedProfileFileChanged(LoadedProfileFile);
LoadedProfileFileChanged(LoadedProfileFile, true);
}

// Remove the old profile file
Expand Down Expand Up @@ -353,7 +335,7 @@ public static void ChangeMasterPassword(ProfileFileInfo profileFileInfo, SecureS
if (switchProfile)
{
Switch(newProfileFileInfo, false);
LoadedProfileFileChanged(LoadedProfileFile);
LoadedProfileFileChanged(LoadedProfileFile, true);
}

// Remove the old profile file
Expand Down Expand Up @@ -394,7 +376,7 @@ public static void DisableEncryption(ProfileFileInfo profileFileInfo, SecureStri
if (switchProfile)
{
Switch(newProfileFileInfo, false);
LoadedProfileFileChanged(LoadedProfileFile);
LoadedProfileFileChanged(LoadedProfileFile, true);
}

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

if (loadedProfileUpdated)
LoadedProfileFileChanged(LoadedProfileFile);
LoadedProfileFileChanged(LoadedProfileFile, true);
}

/// <summary>
Expand Down
24 changes: 14 additions & 10 deletions Source/NETworkManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
xmlns:resources="clr-namespace:NETworkManager.Properties"
xmlns:networkManager="clr-namespace:NETworkManager"
mc:Ignorable="d"
Style="{DynamicResource DefaultWindow}" MinWidth="800" Width="1024" Height="768" MinHeight="600" Activated="MetroMainWindow_Activated" SaveWindowPosition="True" TitleAlignment="Left" Closing="MetroWindowMain_Closing" StateChanged="MetroWindowMain_StateChanged"
Style="{DynamicResource DefaultWindow}"
MinWidth="800" Width="1024" Height="768" MinHeight="600"
SaveWindowPosition="True" TitleAlignment="Left"
ContentRendered="MetroMainWindow_ContentRendered" StateChanged="MetroWindowMain_StateChanged"
Activated="MetroMainWindow_Activated" Closing="MetroWindowMain_Closing"
d:DataContext="{d:DesignInstance networkManager:MainWindow}">
<!-- MetroDialogStyles.xaml must be adjusted if MinWidth/MinHeight is changed -->
<Window.Resources>
Expand Down Expand Up @@ -59,7 +63,7 @@
</MenuItem>
</ContextMenu>
</Window.Resources>
<mah:MetroWindow.WindowButtonCommands>
<mah:MetroWindow.WindowButtonCommands>
<mah:WindowButtonCommands Template="{DynamicResource MahApps.Templates.WindowButtonCommands.Win10}" />
</mah:MetroWindow.WindowButtonCommands>
<mah:MetroWindow.LeftWindowCommands>
Expand All @@ -68,7 +72,7 @@
<StackPanel Orientation="Horizontal" Margin="-2,-1,0,0">
<Grid Background="{DynamicResource MahApps.Brushes.Gray8}" Visibility="{Binding Source={x:Static settings:ConfigurationManager.Current}, Path=IsAdmin, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
<TextBlock Text="Administrator" Foreground="{DynamicResource MahApps.Brushes.Gray3}" Style="{StaticResource CenterTextBlock}" Margin="10,0" />
</Grid>
</Grid>
</StackPanel>
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
Expand All @@ -90,7 +94,7 @@
<Rectangle Width="20" Height="20" Fill="{DynamicResource MahApps.Brushes.Accent}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=RocketLaunchOutline}" />
</Rectangle.OpacityMask>
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Text="{x:Static localization:Strings.UpdateAvailable}" Style="{StaticResource LinkTextBlock}" VerticalAlignment="Center" Margin="5,0,0,0" />
</StackPanel>
Expand Down Expand Up @@ -141,10 +145,10 @@
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
</Rectangle.Style>
</Rectangle>
<TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Name}" />
</Grid>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Expand All @@ -159,7 +163,7 @@
</Button>
<Button Command="{Binding OpenWebsiteCommand}" ToolTip="{x:Static localization:Strings.ReportAnIssueOrCreateAFeatureRequest}" CommandParameter="{x:Static resources:Resources.NETworkManager_NewIssueUrl}" Cursor="Hand">
<StackPanel Orientation="Horizontal">
<Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle Width="20" Height="20" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Modern Kind=Bug}" />
</Rectangle.OpacityMask>
Expand Down Expand Up @@ -446,9 +450,9 @@
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" Value="True" >
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Accent}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}" Value="True" >
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
Expand Down
Loading

0 comments on commit aa11cc1

Please sign in to comment.