Skip to content

Commit cc45bb1

Browse files
committed
v1 cleanup... profile/settings upgrade removed...
1 parent e03606a commit cc45bb1

4 files changed

Lines changed: 22 additions & 87 deletions

File tree

Source/NETworkManager/App.xaml.cs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111

1212
namespace NETworkManager
1313
{
14+
/*
15+
* Class: App
16+
* 1) Get command line args
17+
* 2) Detect current configuration
18+
* 3) Get assembly info
19+
* 4) Load settings
20+
* 5) Load localization / language
21+
*
22+
* Class: MainWindow
23+
* 6) Load appearance
24+
* 7) Load profiles
25+
*/
26+
1427
public partial class App
1528
{
1629
// Single instance identifier
@@ -46,51 +59,25 @@ private void Application_Startup(object sender, StartupEventArgs e)
4659
// Get assembly informations
4760
AssemblyManager.Load();
4861

49-
bool profileUpdateRequired = false;
62+
// Update integrated settings %LocalAppData%\NETworkManager\NETworkManager_GUID (custom settings path)
63+
if (Settings.Default.UpgradeRequired)
64+
{
65+
Settings.Default.Upgrade();
66+
Settings.Default.UpgradeRequired = false;
67+
}
5068

51-
// Load application settings
69+
// Load settings
5270
try
5371
{
54-
// Update integrated settings %LocalAppData%\NETworkManager\NETworkManager_GUID (custom settings path)
55-
if (Settings.Default.UpgradeRequired)
56-
{
57-
Settings.Default.Upgrade();
58-
Settings.Default.UpgradeRequired = false;
59-
}
60-
6172
SettingsManager.Load();
62-
63-
// Update settings (Default --> %AppData%\NETworkManager\Settings)
64-
Version assemblyVersion = AssemblyManager.Current.Version;
65-
Version settingsVersion = new Version(SettingsManager.Current.SettingsVersion);
66-
67-
if (AssemblyManager.Current.Version > settingsVersion)
68-
{
69-
SettingsManager.Update(AssemblyManager.Current.Version, settingsVersion);
70-
}
7173
}
7274
catch (InvalidOperationException)
7375
{
7476
SettingsManager.InitDefault();
7577

76-
profileUpdateRequired = true; // Because we don't know if a profile update is required
77-
7878
ConfigurationManager.Current.ShowSettingsResetNoteOnStartup = true;
7979
}
8080

81-
// Upgrade profile if version has changed or settings have been reset (mthis happens mostly, because the version has changed and values are wrong)
82-
if(profileUpdateRequired)
83-
{
84-
try
85-
{
86-
ProfileManager.Upgrade();
87-
}
88-
catch (Exception ex)
89-
{
90-
MessageBox.Show("Failed to update profiles...\n\n" + ex.Message, "Profile Manager - Update Error", MessageBoxButton.OK, MessageBoxImage.Error);
91-
}
92-
}
93-
9481
// Load localization (requires settings to be loaded first)
9582
LocalizationManager.Load();
9683

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ public MainWindow()
278278
ConfigurationManager.Current.IsTransparencyEnabled = true;
279279
}
280280

281-
// NotifyIcon for Autostart
281+
// NotifyIcon for autostart
282282
if (CommandLineManager.Current.Autostart && SettingsManager.Current.Autostart_StartMinimizedInTray || SettingsManager.Current.TrayIcon_AlwaysShowIcon)
283283
InitNotifyIcon();
284284

285285
// Set windows title if admin
286286
if (ConfigurationManager.Current.IsAdmin)
287287
Title = $"[{NETworkManager.Resources.Localization.Strings.Administrator}] {Title}";
288288

289-
// Load Profiles
289+
// Load profiles
290290
ProfileManager.Load();
291291

292292
// Load settings

Source/NETworkManager/Models/Profile/ProfileManager.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Windows;
66
using System.Windows.Threading;
7-
using System.Xml;
87
using System.Xml.Serialization;
98
using MahApps.Metro.Controls.Dialogs;
109
using NETworkManager.Enum;
@@ -437,33 +436,5 @@ public static async void ShowEditGroupDialog(IProfileManager viewModel, IDialogC
437436
await dialogCoordinator.ShowMetroDialogAsync(viewModel, customDialog);
438437
}
439438
#endregion
440-
441-
#region Upgrade
442-
public static void Upgrade()
443-
{
444-
string filePath = GetProfilesFilePath();
445-
446-
if (!File.Exists(filePath))
447-
return;
448-
449-
XmlDocument xmlDocument = new XmlDocument();
450-
xmlDocument.Load(filePath);
451-
452-
/* Version 1.10.1.0 */
453-
454-
// RemoteDesktop_KeyboardHookMode has changed from integer to enum
455-
foreach (XmlNode x in xmlDocument.SelectNodes(@"/ArrayOfProfileInfo/ProfileInfo/RemoteDesktop_KeyboardHookMode"))
456-
{
457-
if (x.InnerText == "0")
458-
x.InnerText = "OnThisComputer";
459-
else if (x.InnerText == "1")
460-
x.InnerText = "OnTheRemoteComputer";
461-
else if (x.InnerText == "2")
462-
x.InnerText = "OnlyWhenUsingTheFullScreen";
463-
}
464-
465-
xmlDocument.Save(filePath);
466-
}
467-
#endregion
468439
}
469440
}

Source/NETworkManager/Models/Settings/SettingsManager.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Reflection;
55
using System.Threading.Tasks;
66
using System.Xml.Serialization;
7-
using NETworkManager.Controls;
87

98
namespace NETworkManager.Models.Settings
109
{
@@ -201,27 +200,5 @@ public static void Reset()
201200

202201
ForceRestart = true;
203202
}
204-
205-
public static void Update(Version assemblyVersion, Version settingsVersion)
206-
{
207-
// Version is 0.0.0.0 on first run or settings reset --> skip updates
208-
if (settingsVersion > new Version("0.0.0.0"))
209-
{
210-
var reorderApplications = false;
211-
212-
// Features added in 2.0.0.0
213-
if (settingsVersion < new Version("2.0.0.0"))
214-
{
215-
216-
}
217-
218-
// Reorder application view
219-
if (reorderApplications)
220-
Current.General_ApplicationList = new ObservableSetCollection<ApplicationViewInfo>(Current.General_ApplicationList.OrderBy(info => info.Name));
221-
}
222-
223-
// Update settings version
224-
Current.SettingsVersion = assemblyVersion.ToString();
225-
}
226203
}
227204
}

0 commit comments

Comments
 (0)