[BUG] Do not restart if DisplayChange was due to STM open (#223), version 1.0.24.1

This commit is contained in:
Markus Hofknecht 2021-10-25 18:55:34 +02:00
parent ae34aded47
commit 9189b0629d
6 changed files with 24 additions and 39 deletions

View file

@ -21,26 +21,29 @@ namespace SystemTrayMenu
public App()
{
AppRestart.BeforeRestarting += Dispose;
SystemEvents.DisplaySettingsChanged += AppRestart.ByDisplaySettings;
SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
menus.LoadStarted += menuNotifyIcon.LoadingStart;
menus.LoadStopped += menuNotifyIcon.LoadingStop;
menuNotifyIcon.Exit += Application.Exit;
menuNotifyIcon.Restart += AppRestart.ByMenuNotifyIcon;
menuNotifyIcon.Click += MenuNotifyIcon_Click;
void MenuNotifyIcon_Click()
{
menus.SwitchOpenClose(true);
}
menuNotifyIcon.Click += () => menus.SwitchOpenClose(true);
menuNotifyIcon.OpenLog += Log.OpenLogFile;
menus.MainPreload();
}
public void Dispose()
{
SystemEvents.DisplaySettingsChanged -= AppRestart.ByDisplaySettings;
SystemEvents.DisplaySettingsChanged -= SystemEvents_DisplaySettingsChanged;
menus.Dispose();
menuNotifyIcon.Dispose();
}
private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
if (!menus.IsOpenCloseStateOpening())
{
AppRestart.ByDisplaySettings();
}
}
}
}

View file

@ -53,11 +53,7 @@ namespace SystemTrayMenu.Handler
try
{
hook.RegisterHotKey();
hook.KeyPressed += Hook_KeyPressed;
void Hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
HotKeyPressed?.Invoke();
}
hook.KeyPressed += (s, e) => HotKeyPressed?.Invoke();
}
catch (InvalidOperationException ex)
{

View file

@ -231,12 +231,7 @@ namespace SystemTrayMenu.Business
keyboardInput = new KeyboardInput(menus);
keyboardInput.RegisterHotKey();
keyboardInput.HotKeyPressed += KeyboardInput_HotKeyPressed;
void KeyboardInput_HotKeyPressed()
{
SwitchOpenClose(false);
}
keyboardInput.HotKeyPressed += () => SwitchOpenClose(false);
keyboardInput.ClosePressed += MenusFadeOut;
keyboardInput.RowDeselected += waitToOpenMenu.RowDeselected;
keyboardInput.EnterPressed += waitToOpenMenu.EnterOpensInstantly;
@ -259,11 +254,7 @@ namespace SystemTrayMenu.Business
}
}
waitLeave.LeaveTriggered += LeaveTriggered;
void LeaveTriggered()
{
FadeHalfOrOutIfNeeded();
}
waitLeave.LeaveTriggered += FadeHalfOrOutIfNeeded;
}
internal event EventHandlerEmpty LoadStarted;
@ -485,6 +476,11 @@ namespace SystemTrayMenu.Business
return menuData;
}
internal bool IsOpenCloseStateOpening()
{
return openCloseState == OpenCloseState.Opening;
}
internal void SwitchOpenClose(bool byClick)
{
waitToOpenMenu.MouseActive = byClick;
@ -657,12 +653,7 @@ namespace SystemTrayMenu.Business
}
menu.SetTitle(title);
menu.UserClickedOpenFolder += OpenFolderInExplorer;
void OpenFolderInExplorer()
{
OpenFolder(path);
}
menu.UserClickedOpenFolder += () => OpenFolder(path);
menu.Level = menuData.Level;
menu.MouseWheel += AdjustMenusSizeAndLocation;
menu.MouseLeave += waitLeave.Start;

View file

@ -27,12 +27,7 @@ namespace SystemTrayMenu
Config.LoadOrSetByUser();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += ThreadException;
static void ThreadException(object s, ThreadExceptionEventArgs t)
{
AskUserSendError(t.Exception);
}
Application.ThreadException += (s, t) => AskUserSendError(t.Exception);
Scaling.Initialize();
FolderOptions.Initialize();

View file

@ -39,5 +39,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("1.0.24.0")]
[assembly: AssemblyFileVersion("1.0.24.0")]
[assembly: AssemblyVersion("1.0.24.1")]
[assembly: AssemblyFileVersion("1.0.24.1")]

View file

@ -24,7 +24,7 @@ namespace SystemTrayMenu.Utilities
Restart(GetCurrentMethod());
}
internal static void ByDisplaySettings(object sender, EventArgs e)
internal static void ByDisplaySettings()
{
Restart(GetCurrentMethod());
}