This commit is contained in:
Jose Conde
2025-09-06 14:59:10 +02:00
parent 94e6ef651e
commit dc57da8136
5 changed files with 43 additions and 19 deletions

View File

@@ -38,6 +38,10 @@ namespace ModVersionChecker
{
Console.WriteLine("Application is shutting down...");
});
lifetime.ApplicationStopping.Register(() =>
{
Console.WriteLine("Application is shutting down...");
});
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
@@ -78,7 +82,13 @@ namespace ModVersionChecker
var contextMenu = new ContextMenuStrip();
contextMenu.Items.Add("Configure", null, openFormHandler);
contextMenu.Items.Add("Exit", null, (s, e) => Application.Exit());
contextMenu.Items.Add("Exit", null, (s, e) =>
{
notifyIcon.Visible = false;
Application.Exit();
lifetime.StopApplication();
//host.StopAsync().GetAwaiter().GetResult();
});
notifyIcon.ContextMenuStrip = contextMenu;
notifyIcon.DoubleClick += openFormHandler;
@@ -117,23 +127,16 @@ namespace ModVersionChecker
};
}
}
// Add to startup
// AddToStartup();
host.Start();
Application.Run(); // Keep app running for tray icon
host.StopAsync().GetAwaiter().GetResult();
}
host.RunAsync().GetAwaiter().GetResult();
}
static void AddToStartup()
{
using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
{
key?.SetValue("XintanalabsUpdateChecker", $"\"{Application.ExecutablePath}\"");
}
}
}