Skip to content

Commit

Permalink
Save form reference so it doesn't have to be loaded multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandroSWR committed Dec 11, 2021
1 parent ad89346 commit aa1ca75
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions SteamMaster/SMBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public partial class SMBase : Form
private Panel _LeftBorderBtn;
private Form _CurrentChildForm;

private Form _GameSelector;
private Form _Main;

private Size _FormSize;

private int _BorderSize;
Expand Down Expand Up @@ -78,7 +81,7 @@ private void OpenChildForm(Form childForm)
{
if (_CurrentChildForm != null)
{
_CurrentChildForm.Close();
_CurrentChildForm.Visible = false;
}
_CurrentChildForm = childForm;
_CurrentChildForm.TopLevel = false;
Expand All @@ -93,13 +96,25 @@ private void OpenChildForm(Form childForm)
private void _BttMain_Click(object sender, EventArgs e)
{
ActivateButton(sender);
OpenChildForm(new SMMain());

if (_Main == null)
{
_Main = new SMMain();
}

OpenChildForm(_Main);
}

private void _BttSelectGame_Click(object sender, EventArgs e)
{
ActivateButton(sender);
OpenChildForm(new SMGameSelector(_UserID));

if (_GameSelector == null)
{
_GameSelector = new SMGameSelector(_UserID);
}

OpenChildForm(_GameSelector);
}

private void _BttIdle_Click(object sender, EventArgs e)
Expand Down

0 comments on commit aa1ca75

Please sign in to comment.