Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/NETworkManager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Threading;
using System.Windows;
using NETworkManager.Properties;

namespace NETworkManager
{
Expand Down Expand Up @@ -90,10 +91,13 @@ protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
}

private void Application_Exit(object sender, ExitEventArgs e)
{
{
// Save settings, when the application is normally closed
if (!_singleInstanceClose && !ImportExportManager.ForceRestart && !CommandLineManager.Current.Help)
{
// Save local settings (custom settings path in AppData/Local)
Settings.Default.Save();

if (SettingsManager.Current.SettingsChanged) // This will also create the "Settings" folder, if it does not exist
SettingsManager.Save();

Expand Down
4 changes: 2 additions & 2 deletions Source/NETworkManager/ApplicationViewManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MahApps.Metro.IconPacks;
using NETworkManager.Models.Settings;
using System.Collections.Generic;
using System.Windows;

namespace NETworkManager
{
Expand Down Expand Up @@ -33,7 +33,7 @@ public static List<ApplicationViewInfo> List

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

public enum Name
Expand Down
4 changes: 2 additions & 2 deletions Source/NETworkManager/Controls/PuTTYControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ private async void Connect()
catch (Exception ex)
{
MetroDialogSettings settings = AppearanceManager.MetroDialog;
settings.AffirmativeButtonText = Application.Current.Resources["String_Button_OK"] as string;
settings.AffirmativeButtonText = LocalizationManager.GetStringByKey("String_Button_OK");

ConfigurationManager.Current.FixAirspace = true;

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

ConfigurationManager.Current.FixAirspace = false;
}
Expand Down
7 changes: 4 additions & 3 deletions Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Windows.Threading;
using NETworkManager.Utilities;
using NETworkManager.Models.Settings;

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

private const string RemoteDesktopDisconnectReasonIdentifier = "String_RemoteDesktopDisconnectReason_";

private RemoteDesktopSessionInfo _rdpSessionInfo;
private Models.RemoteDesktop.RemoteDesktopSessionInfo _rdpSessionInfo;

DispatcherTimer reconnectAdjustScreenTimer = new DispatcherTimer();

Expand Down Expand Up @@ -90,7 +91,7 @@ public string DisconnectReason
#endregion

#region Constructor, load
public RemoteDesktopControl(RemoteDesktopSessionInfo info)
public RemoteDesktopControl(Models.RemoteDesktop.RemoteDesktopSessionInfo info)
{
InitializeComponent();
DataContext = this;
Expand Down Expand Up @@ -219,7 +220,7 @@ private string GetDisconnectReasonFromResource(string reason)
{
try
{
return Application.Current.Resources[RemoteDesktopDisconnectReasonIdentifier + reason] as string;
return LocalizationManager.GetStringByKey(RemoteDesktopDisconnectReasonIdentifier + reason);
}
catch (NullReferenceException ex) // This happens when the application gets closed and the resources have already been released
{
Expand Down
4 changes: 2 additions & 2 deletions Source/NETworkManager/Converters/AccentToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MahApps.Metro;
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

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

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

if (string.IsNullOrEmpty(name))
name = accent.Name;
Expand Down
4 changes: 2 additions & 2 deletions Source/NETworkManager/Converters/AppThemeToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MahApps.Metro;
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

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

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

if (string.IsNullOrEmpty(name))
name = theme.Name;
Expand Down
8 changes: 4 additions & 4 deletions Source/NETworkManager/Converters/BooleanToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

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

return Application.Current.Resources["String_No"] as string;
return LocalizationManager.GetStringByKey("String_No");
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
6 changes: 3 additions & 3 deletions Source/NETworkManager/Converters/IPStatusToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Net.NetworkInformation;
using System.Windows;
using System.Windows.Data;

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

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

if (string.IsNullOrEmpty(status))
return ipStatus.ToString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using static NETworkManager.Models.Network.PortInfo;

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

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

if (string.IsNullOrEmpty(status))
return portStatus.ToString();
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@
</TextBlock>
</Grid>
</Button>
<TextBlock Grid.Column="1" VerticalAlignment="Center" Height="48" TextAlignment="Center" Style="{StaticResource HeaderTextBlock}" Text="{DynamicResource String_Header_Settings}" Foreground="{DynamicResource GrayBrush3}" Margin="10,0" />
<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" />
</Grid>
</Border>
<ContentControl Grid.Row="1" x:Name="contentControlSettings" />
Expand Down
16 changes: 8 additions & 8 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public MainWindow()

// Set windows title if admin
if (ConfigurationManager.Current.IsAdmin)
Title = string.Format("[{0}] {1}", System.Windows.Application.Current.Resources["String_Administrator"] as string, Title);
Title = string.Format("[{0}] {1}", LocalizationManager.GetStringByKey("String_Administrator"), Title);

// Set the version text
Version = string.Format("Version {0}", AssemblyManager.Current.Version);
Expand Down Expand Up @@ -367,14 +367,14 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)

MetroDialogSettings settings = AppearanceManager.MetroDialog;

settings.AffirmativeButtonText = System.Windows.Application.Current.Resources["String_Button_Close"] as string;
settings.NegativeButtonText = System.Windows.Application.Current.Resources["String_Button_Cancel"] as string;
settings.AffirmativeButtonText = LocalizationManager.GetStringByKey("String_Button_Close");
settings.NegativeButtonText = LocalizationManager.GetStringByKey("String_Button_Cancel");
settings.DefaultButtonFocus = MessageDialogResult.Affirmative;

// Fix airspace issues
ConfigurationManager.Current.FixAirspace = true;

MessageDialogResult result = await this.ShowMessageAsync(System.Windows.Application.Current.Resources["String_Header_Confirm"] as string, System.Windows.Application.Current.Resources["String_ConfirmCloseQuesiton"] as string, MessageDialogStyle.AffirmativeAndNegative, settings);
MessageDialogResult result = await this.ShowMessageAsync(LocalizationManager.GetStringByKey("String_Header_Confirm"), LocalizationManager.GetStringByKey("String_ConfirmCloseQuesiton"), MessageDialogStyle.AffirmativeAndNegative, settings);

ConfigurationManager.Current.FixAirspace = false;

Expand Down Expand Up @@ -585,7 +585,7 @@ private void Updater_Error(object sender, EventArgs e)

private void Updater_UpdateAvailable(object sender, UpdateAvailableArgs e)
{
UpdateText = string.Format(System.Windows.Application.Current.Resources["String_VersionxxAvailable"] as string, e.Version);
UpdateText = string.Format(LocalizationManager.GetStringByKey("String_VersionxxAvailable"), e.Version);
UpdateAvailable = true;
}
#endregion
Expand Down Expand Up @@ -836,13 +836,13 @@ private async void CloseSettingsAction()

MetroDialogSettings settings = AppearanceManager.MetroDialog;

settings.AffirmativeButtonText = System.Windows.Application.Current.Resources["String_Button_RestartNow"] as string;
settings.NegativeButtonText = System.Windows.Application.Current.Resources["String_Button_OK"] as string;
settings.AffirmativeButtonText = LocalizationManager.GetStringByKey("String_Button_RestartNow");
settings.NegativeButtonText = LocalizationManager.GetStringByKey("String_Button_OK");
settings.DefaultButtonFocus = MessageDialogResult.Affirmative;

ConfigurationManager.Current.FixAirspace = true;

if (await this.ShowMessageAsync(System.Windows.Application.Current.Resources["String_RestartRequired"] as string, System.Windows.Application.Current.Resources["String_RestartRequiredAfterSettingsChanged"] as string, MessageDialogStyle.AffirmativeAndNegative, settings) == MessageDialogResult.Affirmative)
if (await this.ShowMessageAsync(LocalizationManager.GetStringByKey("String_RestartRequired"), LocalizationManager.GetStringByKey("String_RestartRequiredAfterSettingsChanged"), MessageDialogStyle.AffirmativeAndNegative, settings) == MessageDialogResult.Affirmative)
{
RestartApplication();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ private static List<PortScannerProfileInfo> GetDefaultProfiles()
{
return new List<PortScannerProfileInfo>
{
new PortScannerProfileInfo("1-1023 (well known)",string.Empty, "1-1023", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("FTP",string.Empty,"20; 21", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("LDAP/LDAPS", string.Empty,"389; 636", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("RDP", string.Empty,"3389", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("SSH",string.Empty, "22", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("Webserver", string.Empty, "80; 443", Application.Current.Resources["String_Default"] as string),
new PortScannerProfileInfo("1-1023 (well known)",string.Empty, "1-1023", LocalizationManager.GetStringByKey("String_Default")),
new PortScannerProfileInfo("FTP",string.Empty,"20; 21", LocalizationManager.GetStringByKey("String_Default")),
new PortScannerProfileInfo("LDAP/LDAPS", string.Empty,"389; 636", LocalizationManager.GetStringByKey("String_Default")),
new PortScannerProfileInfo("RDP", string.Empty,"3389", LocalizationManager.GetStringByKey("String_Default")),
new PortScannerProfileInfo("SSH",string.Empty, "22", LocalizationManager.GetStringByKey("String_Default")),
new PortScannerProfileInfo("Webserver", string.Empty, "80; 443", LocalizationManager.GetStringByKey("String_Default")),
};
}

Expand Down
31 changes: 16 additions & 15 deletions Source/NETworkManager/Models/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ public static string GetSettingsLocation()
if (GetIsPortable())
return GetPortableSettingsLocation();

string settingsLocation = GetCustomSettingsLocation();

if (!string.IsNullOrEmpty(settingsLocation) && Directory.Exists(settingsLocation))
return settingsLocation;

return GetDefaultSettingsLocation();
return GetSettingsLocationNotPortable();
}

public static string GetSettingsLocationNotPortable()
Expand Down Expand Up @@ -133,20 +128,26 @@ public static void Save()
Current.SettingsChanged = false;
}

public static Task MoveSettingsAsync(string sourceLocation, string targedLocation)
public static Task MoveSettingsAsync(string sourceLocation, string targedLocation, bool overwrite)
{
return Task.Run(() => MoveSettings(sourceLocation, targedLocation));
return Task.Run(() => MoveSettings(sourceLocation, targedLocation, overwrite));
}

private static void MoveSettings(string sourceLocation, string targedLocation)
private static void MoveSettings(string sourceLocation, string targedLocation, bool overwrite)
{
string[] sourceFiles = Directory.GetFiles(sourceLocation);

// Create the dircetory and copy the files to the new location
Directory.CreateDirectory(targedLocation);

foreach (string file in sourceFiles)
File.Copy(file, Path.Combine(targedLocation, Path.GetFileName(file)), true);
{
// Skip if file exists and user don't want to overwrite it
if (!overwrite && File.Exists(file))
continue;

File.Copy(file, Path.Combine(targedLocation, Path.GetFileName(file)), overwrite);
}

// Delete the old files
foreach (string file in sourceFiles)
Expand All @@ -157,23 +158,23 @@ private static void MoveSettings(string sourceLocation, string targedLocation)
Directory.Delete(sourceLocation);
}

public static Task MakePortableAsync(bool isPortable)
public static Task MakePortableAsync(bool isPortable, bool overwrite)
{
return Task.Run(() => MakePortable(isPortable));
return Task.Run(() => MakePortable(isPortable, overwrite));
}

public static void MakePortable(bool isPortable)
public static void MakePortable(bool isPortable, bool overwrite)
{
if (isPortable)
{
MoveSettings(GetSettingsLocationNotPortable(), GetPortableSettingsLocation());
MoveSettings(GetSettingsLocationNotPortable(), GetPortableSettingsLocation(), overwrite);

// After moving the files, set the indicator that the settings are now portable
File.Create(GetIsPortableFilePath());
}
else
{
MoveSettings(GetPortableSettingsLocation(), GetSettingsLocationNotPortable());
MoveSettings(GetPortableSettingsLocation(), GetSettingsLocationNotPortable(), overwrite);

// Remove the indicator after moving the files...
File.Delete(GetIsPortableFilePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<system:String x:Key="String_Header_IPScanner">IP-Scanner</system:String>
<system:String x:Key="String_Header_PuTTY">PuTTY</system:String>
<system:String x:Key="String_Header_EditGroup">Gruppe bearbeiten</system:String>
<system:String x:Key="String_Header_Overwrite">Überschreiben?</system:String>

<!-- Normal strings -->
<system:String x:Key="String_ProductName">NETworkManager</system:String>
Expand Down Expand Up @@ -391,6 +392,7 @@
<system:String x:Key="String_NewSession">Neue Sitzung</system:String>
<system:String x:Key="String_Gitter">Gitter</system:String>
<system:String x:Key="String_GitHub">GitHub</system:String>
<system:String x:Key="String_OverwriteSettingsInTheDestinationFolder">Einstellungen im Zielordner überschreiben?\n\nWenn Sie auf "Verschieben &amp; neu starten" klicken, werden die restlichen Dateien kopiert und die Anwendung danach mit den neuen Einstellungen neu gestartet!</system:String>

<!-- Documentation title -->
<system:String x:Key="String_DocumentationTitle_00001">Wie installiere ich RDP 8.1 unter Windows 7 / Server 2008 R2?</system:String>
Expand Down Expand Up @@ -452,6 +454,10 @@
<system:String x:Key="String_Button_CheckForUpdaptes">Auf Updates prüfen</system:String>
<system:String x:Key="String_Button_ConfigurePuTTY">PuTTY konfigurieren</system:String>
<system:String x:Key="String_Button_FlushDNSCache">DNS-Cache leeren</system:String>
<system:String x:Key="String_Button_Yes">Ja</system:String>
<system:String x:Key="String_Button_No">Nein</system:String>
<system:String x:Key="String_Button_Overwrite">Überschreiben</system:String>
<system:String x:Key="String_Button_MoveAndRestart">Verschieben &amp; neu starten</system:String>

<!-- ContextMenuItem.Header -->
<system:String x:Key="String_ContextMenu_Cut">Ausschneiden</system:String>
Expand Down
Loading