# HG changeset patch # User sl # Date 1421605556 -3600 # Node ID be7183f8c14ca5bd0af5ceec0d87ae4a3acb7276 # Parent f3322473db4057f172f9a7fd53fd7a100ff8196c Clearing screen when last client disconnects. diff -r f3322473db40 -r be7183f8c14c Server/MainForm.cs --- a/Server/MainForm.cs Sun Jan 18 19:01:29 2015 +0100 +++ b/Server/MainForm.cs Sun Jan 18 19:25:56 2015 +0100 @@ -124,9 +124,7 @@ #if !DEBUG //When not debugging we want the screen to be empty until a client takes over - tableLayoutPanel.Controls.Clear(); - tableLayoutPanel.RowStyles.Clear(); - tableLayoutPanel.ColumnStyles.Clear(); + ClearLayout(); #endif } @@ -821,8 +819,23 @@ Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(client, false)[0]); } } + + if (iClients.Count==0) + { + ClearLayout(); + } } + /// + /// Just remove all our fields. + /// + private void ClearLayout() + { + tableLayoutPanel.Controls.Clear(); + tableLayoutPanel.RowStyles.Clear(); + tableLayoutPanel.ColumnStyles.Clear(); + } + private void buttonStartClient_Click(object sender, EventArgs e) { Thread clientThread = new Thread(SharpDisplayClient.Program.Main); @@ -901,14 +914,20 @@ Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]); } - if (iClosing && iClients.Count == 0) - { - //We were closing our form - //All clients are now closed - //Just resume our close operation - iClosing = false; - Close(); - } + if (iClients.Count == 0) + { + //Clear our screen when last client disconnects + ClearLayout(); + + if (iClosing) + { + //We were closing our form + //All clients are now closed + //Just resume our close operation + iClosing = false; + Close(); + } + } } }