Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to prevent the main form from minimizing #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions NohBoard/NohBoard/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion NohBoard/NohBoard/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,26 @@ private void mnuExit_Click(object sender, EventArgs e)

#region Rendering

/// <summary>
/// Whether the main form can be minimized or not. A minimized form will not call OnPaint upon Refresh.
/// This makes sure that OnPaint is always called by Refresh.
/// </summary>
private bool PreventMinimize;

private void mnuPreventMinimize_Click(object sender, EventArgs e)
{
this.PreventMinimize = !this.PreventMinimize;
if (this.PreventMinimize)
{
this.MinimizeBox = false;
this.mnuPreventMinimize.Checked = true;
}
else
{
this.MinimizeBox = true;
this.mnuPreventMinimize.Checked = false;
}
}
/// <summary>
/// Paints the keyboard on the screen.
/// </summary>
Expand Down Expand Up @@ -685,10 +705,13 @@ private void Render(
}

/// <summary>
/// Forces an update if any of the key or mouse states have changed.
/// Forces an update if any of the key or mouse states have changed, and makes sure that the form is not
/// minimized if PreventMinimize is on.
/// </summary>
private void UpdateTimer_Tick(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized && this.PreventMinimize)
this.WindowState = FormWindowState.Normal;
if (KeyboardState.Updated || MouseState.Updated)
this.Refresh();
}
Expand Down