diff --git a/CHANGELOG.md b/CHANGELOG.md
index 25ba8cd90b..26051751a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
## Bugfixes
- [GUI] Auto-size buttons in bottom panels (#3576 by: HebaruSan; reviewed: techman83)
+- [GUI] Hide tray icon at exit via ctrl-C (#3639 by: HebaruSan; reviewed: techman83)
### Internal
diff --git a/GUI/Main/Main.cs b/GUI/Main/Main.cs
index 536331b4ef..5e15516916 100644
--- a/GUI/Main/Main.cs
+++ b/GUI/Main/Main.cs
@@ -48,9 +48,6 @@ public GameInstanceManager Manager
public GUIUser currentUser;
- private bool enableTrayIcon;
- private bool minimizeToTray;
-
public static Main Instance { get; private set; }
public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
@@ -391,6 +388,11 @@ protected override void OnLoad(EventArgs e)
bool autoUpdating = CheckForCKANUpdate();
CheckTrayState();
+ Console.CancelKeyPress += (sender, evt) =>
+ {
+ // Hide tray icon on Ctrl-C
+ minimizeNotifyIcon.Visible = false;
+ };
InitRefreshTimer();
URLHandlers.RegisterURLHandler(configuration, currentUser);
@@ -462,7 +464,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
// Copy metadata panel split height to app settings
configuration.ModInfoPosition = ModInfo.ModMetaSplitPosition;
- // Save settings.
+ // Save settings
configuration.Save();
if (needRegistrySave)
@@ -530,7 +532,7 @@ private void CKANSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
// Flipping enabled here hides the main form itself.
Enabled = false;
- new SettingsDialog(currentUser).ShowDialog();
+ new SettingsDialog(currentUser).ShowDialog(this);
Enabled = true;
}
diff --git a/GUI/Main/Main.resx b/GUI/Main/Main.resx
index 6bb11b714f..ebc91a3e77 100644
--- a/GUI/Main/Main.resx
+++ b/GUI/Main/Main.resx
@@ -174,4 +174,5 @@
CKAN Settings
Quit
Play time...
+ CKAN
diff --git a/GUI/Main/MainInstall.cs b/GUI/Main/MainInstall.cs
index 96aab74914..2e5fa9dbdf 100644
--- a/GUI/Main/MainInstall.cs
+++ b/GUI/Main/MainInstall.cs
@@ -370,7 +370,7 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
}
// Now pretend they clicked the menu option for the settings
Enabled = false;
- new SettingsDialog(currentUser).ShowDialog();
+ new SettingsDialog(currentUser).ShowDialog(this);
Enabled = true;
}
break;
diff --git a/GUI/Main/MainTrayIcon.cs b/GUI/Main/MainTrayIcon.cs
index 44346d4c91..0ef200cba8 100644
--- a/GUI/Main/MainTrayIcon.cs
+++ b/GUI/Main/MainTrayIcon.cs
@@ -10,6 +10,9 @@ public partial class Main
{
#region Tray Behaviour
+ private bool enableTrayIcon;
+ private bool minimizeToTray;
+
public void CheckTrayState()
{
enableTrayIcon = configuration.EnableTrayIcon;
@@ -112,7 +115,7 @@ private void openCKANToolStripMenuItem_Click(object sender, EventArgs e)
private void cKANSettingsToolStripMenuItem1_Click(object sender, EventArgs e)
{
OpenWindow();
- new SettingsDialog(currentUser).ShowDialog();
+ new SettingsDialog(currentUser).ShowDialog(this);
}
private void minimizedContextMenuStrip_Opening(object sender, CancelEventArgs e)