-upgrade earlier before load shortcut
-logging upgrade of settings / config and write config location into log

[BUG] Nullref when shortcut not possible to register #29 https://github.com/Hofknecht/SystemTrayMenu/issues/29
-nullref exception still possible -> do not start contextmenu before shortcut registered
This commit is contained in:
Markus Hofknecht 2019-07-08 19:57:15 +02:00
parent 87e00358ed
commit 828fda03af
4 changed files with 19 additions and 8 deletions

View file

@ -1,5 +1,8 @@
using Microsoft.WindowsAPICodePack.Dialogs;
using Clearcove.Logging;
using Microsoft.WindowsAPICodePack.Dialogs;
using System.Diagnostics;
using System.IO;
using System.Reflection;
namespace SystemTrayMenu
{
@ -21,8 +24,14 @@ namespace SystemTrayMenu
{
// configs located at "%localappdata%\<AssemblyCompany>\"
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.IsUpgraded = true;
Properties.Settings.Default.Save();
FileVersionInfo versionInfo = FileVersionInfo.
GetVersionInfo(Assembly.GetEntryAssembly().Location);
new Logger(nameof(Config)).Info($"Settings upgraded from " +
$"%localappdata%\\{versionInfo.CompanyName}\\");
}
}

View file

@ -67,7 +67,7 @@ namespace SystemTrayMenu
{
if (e.Button == MouseButtons.Left)
{
HandleClick?.Invoke();
HandleClick.Invoke();
}
}
@ -76,7 +76,7 @@ namespace SystemTrayMenu
{
if (e.Button == MouseButtons.Left)
{
HandleClick?.Invoke();
HandleClick.Invoke();
}
}
}

View file

@ -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.244")]
[assembly: AssemblyFileVersion("0.9.1.244")]
[assembly: AssemblyVersion("0.9.1.245")]
[assembly: AssemblyFileVersion("0.9.1.245")]

View file

@ -28,7 +28,7 @@ namespace SystemTrayMenu
int iMenuKey = 0;
string keyInput = string.Empty;
MenuNotifyIcon menuNotifyIcon = new MenuNotifyIcon();
MenuNotifyIcon menuNotifyIcon = null;
WaitFastLeave fastLeave = new WaitFastLeave();
Menu[] menus = new Menu[MenuDefines.MenusMax];
bool isMainMenuOpen = false;
@ -44,6 +44,8 @@ namespace SystemTrayMenu
GetName().Version.ToString() +
$" ScalingFactor={Program.ScalingFactor}");
Config.UpgradeIfNotUpgraded();
if (!string.IsNullOrEmpty(Properties.Settings.Default.HotKey))
{
var cvt = new KeysConverter();
@ -64,9 +66,10 @@ namespace SystemTrayMenu
Properties.Settings.Default.HotKey = string.Empty;
Properties.Settings.Default.Save();
MessageBox.Show(ex.Message);
ApplicationRestart();
}
}
menuNotifyIcon = new MenuNotifyIcon();
void hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
SwitchOpenClose();
@ -211,7 +214,6 @@ namespace SystemTrayMenu
messageFilter.MouseLeave += fastLeave.Start;
fastLeave.Leave += FadeHalfOrOutIfNeeded;
Config.UpgradeIfNotUpgraded();
if (!Config.LoadOrSetByUser())
{
cancelAppRun = true;