Skip to content

Commit aaf41e2

Browse files
authored
Ask user to overwrite settings (#82)
* overwrite true/false added * Dialog added, ask to overwrite, move and restart or cancel * Cleanup
1 parent 182ec53 commit aaf41e2

65 files changed

Lines changed: 358 additions & 276 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/NETworkManager/App.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Threading;
77
using System.Windows;
8+
using NETworkManager.Properties;
89

910
namespace NETworkManager
1011
{
@@ -90,10 +91,13 @@ protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
9091
}
9192

9293
private void Application_Exit(object sender, ExitEventArgs e)
93-
{
94+
{
9495
// Save settings, when the application is normally closed
9596
if (!_singleInstanceClose && !ImportExportManager.ForceRestart && !CommandLineManager.Current.Help)
9697
{
98+
// Save local settings (custom settings path in AppData/Local)
99+
Settings.Default.Save();
100+
97101
if (SettingsManager.Current.SettingsChanged) // This will also create the "Settings" folder, if it does not exist
98102
SettingsManager.Save();
99103

Source/NETworkManager/ApplicationViewManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using MahApps.Metro.IconPacks;
2+
using NETworkManager.Models.Settings;
23
using System.Collections.Generic;
3-
using System.Windows;
44

55
namespace NETworkManager
66
{
@@ -33,7 +33,7 @@ public static List<ApplicationViewInfo> List
3333

3434
public static string TranslateName(Name name)
3535
{
36-
return Application.Current.Resources["String_ApplicationName_" + name] as string;
36+
return LocalizationManager.GetStringByKey("String_ApplicationName_" + name);
3737
}
3838

3939
public enum Name

Source/NETworkManager/Controls/PuTTYControl.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ private async void Connect()
138138
catch (Exception ex)
139139
{
140140
MetroDialogSettings settings = AppearanceManager.MetroDialog;
141-
settings.AffirmativeButtonText = Application.Current.Resources["String_Button_OK"] as string;
141+
settings.AffirmativeButtonText = LocalizationManager.GetStringByKey("String_Button_OK");
142142

143143
ConfigurationManager.Current.FixAirspace = true;
144144

145-
await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_Error"] as string, ex.Message, MessageDialogStyle.Affirmative, settings);
145+
await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_Error"), ex.Message, MessageDialogStyle.Affirmative, settings);
146146

147147
ConfigurationManager.Current.FixAirspace = false;
148148
}

Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.Windows.Threading;
99
using NETworkManager.Utilities;
10+
using NETworkManager.Models.Settings;
1011

1112
namespace NETworkManager.Controls
1213
{
@@ -26,7 +27,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
2627

2728
private const string RemoteDesktopDisconnectReasonIdentifier = "String_RemoteDesktopDisconnectReason_";
2829

29-
private RemoteDesktopSessionInfo _rdpSessionInfo;
30+
private Models.RemoteDesktop.RemoteDesktopSessionInfo _rdpSessionInfo;
3031

3132
DispatcherTimer reconnectAdjustScreenTimer = new DispatcherTimer();
3233

@@ -90,7 +91,7 @@ public string DisconnectReason
9091
#endregion
9192

9293
#region Constructor, load
93-
public RemoteDesktopControl(RemoteDesktopSessionInfo info)
94+
public RemoteDesktopControl(Models.RemoteDesktop.RemoteDesktopSessionInfo info)
9495
{
9596
InitializeComponent();
9697
DataContext = this;
@@ -219,7 +220,7 @@ private string GetDisconnectReasonFromResource(string reason)
219220
{
220221
try
221222
{
222-
return Application.Current.Resources[RemoteDesktopDisconnectReasonIdentifier + reason] as string;
223+
return LocalizationManager.GetStringByKey(RemoteDesktopDisconnectReasonIdentifier + reason);
223224
}
224225
catch (NullReferenceException ex) // This happens when the application gets closed and the resources have already been released
225226
{

Source/NETworkManager/Converters/AccentToStringConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using MahApps.Metro;
2+
using NETworkManager.Models.Settings;
23
using System;
34
using System.Globalization;
4-
using System.Windows;
55
using System.Windows.Data;
66

77
namespace NETworkManager.Converters
@@ -13,7 +13,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1313
{
1414
Accent accent = value as Accent;
1515

16-
string name = Application.Current.Resources["String_Accent_" + accent.Name] as string;
16+
string name = LocalizationManager.GetStringByKey("String_Accent_" + accent.Name);
1717

1818
if (string.IsNullOrEmpty(name))
1919
name = accent.Name;

Source/NETworkManager/Converters/AppThemeToStringConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using MahApps.Metro;
2+
using NETworkManager.Models.Settings;
23
using System;
34
using System.Globalization;
4-
using System.Windows;
55
using System.Windows.Data;
66

77
namespace NETworkManager.Converters
@@ -13,7 +13,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1313
{
1414
AppTheme theme = value as AppTheme;
1515

16-
string name = Application.Current.Resources["String_AppTheme_" + theme.Name] as string;
16+
string name = LocalizationManager.GetStringByKey("String_AppTheme_" + theme.Name);
1717

1818
if (string.IsNullOrEmpty(name))
1919
name = theme.Name;

Source/NETworkManager/Converters/BooleanToStringConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
1+
using NETworkManager.Models.Settings;
2+
using System;
23
using System.Globalization;
3-
using System.Windows;
44
using System.Windows.Data;
55

66
namespace NETworkManager.Converters
@@ -10,9 +10,9 @@ public sealed class BooleanToStringConverter : IValueConverter
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
1212
if ((bool)value)
13-
return Application.Current.Resources["String_Yes"] as string;
13+
return LocalizationManager.GetStringByKey("String_Yes");
1414

15-
return Application.Current.Resources["String_No"] as string;
15+
return LocalizationManager.GetStringByKey("String_No");
1616
}
1717

1818
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

Source/NETworkManager/Converters/IPStatusToStringConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using NETworkManager.Models.Settings;
2+
using System;
23
using System.Globalization;
34
using System.Net.NetworkInformation;
4-
using System.Windows;
55
using System.Windows.Data;
66

77
namespace NETworkManager.Converters
@@ -12,7 +12,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1212
{
1313
IPStatus ipStatus = (IPStatus)value;
1414

15-
string status = Application.Current.Resources["String_IPStatus_" + ipStatus.ToString()] as string;
15+
string status = LocalizationManager.GetStringByKey("String_IPStatus_" + ipStatus.ToString());
1616

1717
if (string.IsNullOrEmpty(status))
1818
return ipStatus.ToString();

Source/NETworkManager/Converters/PortStatusToStringConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
1+
using NETworkManager.Models.Settings;
2+
using System;
23
using System.Globalization;
3-
using System.Windows;
44
using System.Windows.Data;
55
using static NETworkManager.Models.Network.PortInfo;
66

@@ -12,7 +12,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1212
{
1313
PortStatus portStatus = (PortStatus)value;
1414

15-
string status = Application.Current.Resources["String_PortStatus_" + portStatus.ToString()] as string;
15+
string status = LocalizationManager.GetStringByKey("String_PortStatus_" + portStatus.ToString());
1616

1717
if (string.IsNullOrEmpty(status))
1818
return portStatus.ToString();

Source/NETworkManager/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@
626626
</TextBlock>
627627
</Grid>
628628
</Button>
629-
<TextBlock Grid.Column="1" VerticalAlignment="Center" Height="48" TextAlignment="Center" Style="{StaticResource HeaderTextBlock}" Text="{DynamicResource String_Header_Settings}" Foreground="{DynamicResource GrayBrush3}" Margin="10,0" />
629+
<TextBlock Grid.Column="1" VerticalAlignment="Center" Height="48" TextAlignment="Center" Style="{StaticResource HeaderTextBlock}" Text="{DynamicResource String_Header_Settings}" FontSize="22" Foreground="{DynamicResource GrayBrush3}" Margin="10,0" />
630630
</Grid>
631631
</Border>
632632
<ContentControl Grid.Row="1" x:Name="contentControlSettings" />

0 commit comments

Comments
 (0)