Skip to content

Commit

Permalink
Save WindowState
Browse files Browse the repository at this point in the history
  • Loading branch information
Olympic1 committed Nov 4, 2018
1 parent b6a509b commit a6938aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
31 changes: 22 additions & 9 deletions GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
configuration.WindowSize = WindowState == FormWindowState.Normal ? Size : RestoreBounds.Size;

//copy window maximized state to app settings
configuration.IsWindowMaximised = WindowState == FormWindowState.Maximized ? true : false;
configuration.IsWindowMaximised = WindowState == FormWindowState.Maximized;

// Copy panel position to app settings
configuration.PanelPosition = splitContainer1.SplitterDistance;
Expand Down Expand Up @@ -1079,14 +1079,12 @@ private void Main_Resize(object sender, EventArgs e)

private void minimizeNotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
OpenWindow();
}

private void updatesToolStripMenuItem_Click(object sender, EventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
OpenWindow();
MarkAllUpdatesToolButton_Click(sender, e);
}

Expand All @@ -1112,14 +1110,12 @@ private void pauseToolStripMenuItem_Click(object sender, EventArgs e)

private void openCKANToolStripMenuItem_Click(object sender, EventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
OpenWindow();
}

private void cKANSettingsToolStripMenuItem1_Click(object sender, EventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
OpenWindow();
new SettingsDialog().ShowDialog();
}

Expand All @@ -1139,7 +1135,15 @@ private void UpdateTrayState()
minimizeNotifyIcon.Visible = true;

if (minimizeToTray && WindowState == FormWindowState.Minimized)
{
Hide();
}
else
{
// Save the window state
configuration.IsWindowMaximised = WindowState == FormWindowState.Maximized;
configuration.Save();
}
}
else
{
Expand All @@ -1163,6 +1167,15 @@ public void UpdateTrayInfo()
}
}

/// <summary>
/// Open the GUI and set it to the correct state.
/// </summary>
public void OpenWindow()
{
Show();
WindowState = configuration.IsWindowMaximised ? FormWindowState.Maximized : FormWindowState.Normal;
}

#endregion

#region Navigation History
Expand Down
3 changes: 1 addition & 2 deletions GUI/MainRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ private void UpgradeNotification()
private void minimizeNotifyIcon_BalloonTipClicked(object sender, EventArgs e)
{
// Unminimize
Show();
WindowState = System.Windows.Forms.FormWindowState.Normal;
OpenWindow();

// Check all the upgrade checkboxes
MarkAllUpdatesToolButton_Click(null, null);
Expand Down
1 change: 1 addition & 0 deletions GUI/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void UpdateDialog()
AutoSortUpdateCheckBox.Checked = Main.Instance.configuration.AutoSortByUpdate;
EnableTrayIconCheckBox.Checked = MinimizeToTrayCheckBox.Enabled = Main.Instance.configuration.EnableTrayIcon;
MinimizeToTrayCheckBox.Checked = Main.Instance.configuration.MinimizeToTray;
PauseRefreshCheckBox.Checked = Main.Instance.configuration.RefreshPaused;

UpdateRefreshRate();

Expand Down

0 comments on commit a6938aa

Please sign in to comment.