diff --git a/Config.cs b/Config.cs index d046475..357872d 100644 --- a/Config.cs +++ b/Config.cs @@ -1,59 +1,70 @@ -using Microsoft.WindowsAPICodePack.Dialogs; -using System; -using System.IO; - -namespace SystemTrayMenu -{ - public class Config - { - public static string Language = "en"; - - public static string Path - { - get - { - return Properties.Settings.Default.PathDirectory; - } - } - - public static bool LoadOrSetByUser() +using Microsoft.WindowsAPICodePack.Dialogs; +using System.IO; + +namespace SystemTrayMenu +{ + public class Config + { + public static string Language = "en"; + + public static string Path { - Properties.Settings.Default.Upgrade(); // configs located at "%localappdata%\\" - bool pathOK = Directory.Exists(Properties.Settings.Default.PathDirectory); - if (!pathOK) - { - pathOK = SetFolderByUser(); - } - return pathOK; - } - - public static bool SetFolderByUser() - { - bool pathOK = false; - bool userAborted = false; - CommonOpenFileDialog dialog = new CommonOpenFileDialog(); - dialog.InitialDirectory = Path; - dialog.IsFolderPicker = true; - do - { - if (dialog.ShowDialog() == CommonFileDialogResult.Ok) - { - if (Directory.Exists(dialog.FileName)) - { - pathOK = true; - Properties.Settings.Default.PathDirectory = - dialog.FileName; - Properties.Settings.Default.Save(); - } - } - else - { - userAborted = true; - } - } - while (!pathOK && !userAborted); - - return pathOK; - } - } -} + get + { + return Properties.Settings.Default.PathDirectory; + } + } + + public static void UpgradeIfNotUpgraded() + { + if (!Properties.Settings.Default.IsUpgraded) + { + // configs located at "%localappdata%\\" + Properties.Settings.Default.Upgrade(); + Properties.Settings.Default.IsUpgraded = true; + Properties.Settings.Default.Save(); + } + } + + public static bool LoadOrSetByUser() + { + bool pathOK = Directory.Exists( + Properties.Settings.Default.PathDirectory); + + if (!pathOK) + { + pathOK = SetFolderByUser(); + } + return pathOK; + } + + public static bool SetFolderByUser() + { + bool pathOK = false; + bool userAborted = false; + CommonOpenFileDialog dialog = new CommonOpenFileDialog(); + dialog.InitialDirectory = Path; + dialog.IsFolderPicker = true; + do + { + if (dialog.ShowDialog() == CommonFileDialogResult.Ok) + { + if (Directory.Exists(dialog.FileName)) + { + pathOK = true; + Properties.Settings.Default.PathDirectory = + dialog.FileName; + Properties.Settings.Default.Save(); + } + } + else + { + userAborted = true; + } + } + while (!pathOK && !userAborted); + + return pathOK; + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index b5709c9..5fbe7ab 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.9.1.243")] -[assembly: AssemblyFileVersion("0.9.1.243")] +[assembly: AssemblyVersion("0.9.1.244")] +[assembly: AssemblyFileVersion("0.9.1.244")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 5064ec5..30bb0b8 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -70,5 +70,17 @@ namespace SystemTrayMenu.Properties { this["HotKey"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool IsUpgraded { + get { + return ((bool)(this["IsUpgraded"])); + } + set { + this["IsUpgraded"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index e9f3f3b..7744cdf 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -14,5 +14,8 @@ + + False + \ No newline at end of file diff --git a/SystemTrayMenuHandler.cs b/SystemTrayMenuHandler.cs index fca4799..b127c9c 100644 --- a/SystemTrayMenuHandler.cs +++ b/SystemTrayMenuHandler.cs @@ -211,6 +211,7 @@ namespace SystemTrayMenu messageFilter.MouseLeave += fastLeave.Start; fastLeave.Leave += FadeHalfOrOutIfNeeded; + Config.UpgradeIfNotUpgraded(); if (!Config.LoadOrSetByUser()) { cancelAppRun = true; diff --git a/app.config b/app.config index c25b42e..fdb3352 100644 --- a/app.config +++ b/app.config @@ -19,6 +19,9 @@ + + False +