Small fixes

This commit is contained in:
Stone_Red
2024-12-28 16:40:06 +01:00
parent c2474e6425
commit 793dcbad38
2 changed files with 16 additions and 16 deletions
+12 -14
View File
@@ -73,26 +73,24 @@ public partial class App : Application
// Setup global event handler // Setup global event handler
eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew); eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, AppGuid, out bool createdNew);
//check if creating new was successful // Check if creating new was successful
if (!createdNew) if (!createdNew)
{ {
Setup(false); Setup(false);
Logger.LogWarn("Shutting down because other instance already running.", source: "Setup"); Logger.LogWarn("Shutting down because other instance already running.", source: "Setup");
//Shutdown Application // Shutdown Application
_ = eventWaitHandle.Set(); _ = eventWaitHandle.Set();
Current.Shutdown(); Current.Shutdown();
} }
else else
{ {
eventThread = new Thread( eventThread = new Thread(() =>
() => {
while (eventWaitHandle.WaitOne())
{ {
while (eventWaitHandle.WaitOne()) _ = Current.Dispatcher.BeginInvoke(() => ((MainWindow)Current.MainWindow).RestoreWindow());
{ }
_ = Current.Dispatcher.BeginInvoke( });
() => ((MainWindow)Current.MainWindow).RestoreWindow());
}
});
eventThread.Start(); eventThread.Start();
Setup(true); Setup(true);
@@ -118,22 +116,22 @@ public partial class App : Application
try try
{ {
if (Directory.Exists(PreviousApplicationDataPath)) if (Directory.Exists(PreviousApplicationDataPath) && !Directory.Exists(ApplicationDataPath))
{ {
Directory.Move(PreviousApplicationDataPath, ApplicationDataPath); Directory.Move(PreviousApplicationDataPath, ApplicationDataPath);
Logger.LogInfo("Migrated ApplicationData Folder", source: "Setup"); Logger.LogInfo("Migrated ApplicationData folder", source: "Setup");
} }
if (!Directory.Exists(ApplicationDataPath)) if (!Directory.Exists(ApplicationDataPath))
{ {
_ = Directory.CreateDirectory(ApplicationDataPath); _ = Directory.CreateDirectory(ApplicationDataPath);
Logger.LogInfo("Created ApplicationData Folder", source: "Setup"); Logger.LogInfo("Created ApplicationData folder", source: "Setup");
} }
if (!Directory.Exists(PluginsPath)) if (!Directory.Exists(PluginsPath))
{ {
_ = Directory.CreateDirectory(PluginsPath); _ = Directory.CreateDirectory(PluginsPath);
Logger.LogInfo("Created Plugins Folder", source: "Setup"); Logger.LogInfo("Created Plugins folder", source: "Setup");
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -50,9 +50,11 @@ public partial class PluginWindow : Window
WindowStyle = WindowStyle.ToolWindow, WindowStyle = WindowStyle.ToolWindow,
ShowInTaskbar = false ShowInTaskbar = false
}; };
w.Show();
WindowInteropHelper helper = new WindowInteropHelper(w);
_ = helper.EnsureHandle();
Owner = w; Owner = w;
w.Hide();
settings.Theme.PropertyChanged += (e, s) => ThemeChanged(); settings.Theme.PropertyChanged += (e, s) => ThemeChanged();