Skip to content

Commit

Permalink
Hide tray icon at exit via ctrl-C
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Aug 20, 2022
1 parent 2f3d817 commit 6ee4107
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 7 additions & 5 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions GUI/Main/Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@
<data name="cKANSettingsToolStripMenuItem1.Text" xml:space="preserve"><value>CKAN Settings</value></data>
<data name="quitToolStripMenuItem.Text" xml:space="preserve"><value>Quit</value></data>
<data name="viewPlayTimeStripMenuItem.Text" xml:space="preserve"><value>Play time...</value></data>
<data name="minimizeNotifyIcon.Text" xml:space="preserve"><value>CKAN</value></data>
</root>
2 changes: 1 addition & 1 deletion GUI/Main/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,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;
Expand Down
5 changes: 4 additions & 1 deletion GUI/Main/MainTrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public partial class Main
{
#region Tray Behaviour

private bool enableTrayIcon;
private bool minimizeToTray;

public void CheckTrayState()
{
enableTrayIcon = configuration.EnableTrayIcon;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6ee4107

Please sign in to comment.