Server/MainForm.cs
changeset 97 be7183f8c14c
parent 96 f3322473db40
child 99 cf60911d08a7
     1.1 --- a/Server/MainForm.cs	Sun Jan 18 19:01:29 2015 +0100
     1.2 +++ b/Server/MainForm.cs	Sun Jan 18 19:25:56 2015 +0100
     1.3 @@ -124,9 +124,7 @@
     1.4  
     1.5  #if !DEBUG
     1.6  			//When not debugging we want the screen to be empty until a client takes over 
     1.7 -			tableLayoutPanel.Controls.Clear();
     1.8 -			tableLayoutPanel.RowStyles.Clear();
     1.9 -			tableLayoutPanel.ColumnStyles.Clear();
    1.10 +			ClearLayout();
    1.11  #endif
    1.12          }
    1.13  
    1.14 @@ -821,8 +819,23 @@
    1.15                      Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(client, false)[0]);
    1.16                  }
    1.17              }
    1.18 +
    1.19 +			if (iClients.Count==0)
    1.20 +			{
    1.21 +				ClearLayout();
    1.22 +			}
    1.23          }
    1.24  
    1.25 +		/// <summary>
    1.26 +		/// Just remove all our fields.
    1.27 +		/// </summary>
    1.28 +		private void ClearLayout()
    1.29 +		{
    1.30 +			tableLayoutPanel.Controls.Clear();
    1.31 +			tableLayoutPanel.RowStyles.Clear();
    1.32 +			tableLayoutPanel.ColumnStyles.Clear();
    1.33 +		}
    1.34 +
    1.35          private void buttonStartClient_Click(object sender, EventArgs e)
    1.36          {
    1.37              Thread clientThread = new Thread(SharpDisplayClient.Program.Main);
    1.38 @@ -901,14 +914,20 @@
    1.39                      Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
    1.40                  }
    1.41  
    1.42 -                if (iClosing && iClients.Count == 0)
    1.43 -                {
    1.44 -                    //We were closing our form
    1.45 -                    //All clients are now closed
    1.46 -                    //Just resume our close operation
    1.47 -                    iClosing = false;
    1.48 -                    Close();
    1.49 -                }
    1.50 +				if (iClients.Count == 0)
    1.51 +				{
    1.52 +					//Clear our screen when last client disconnects
    1.53 +					ClearLayout();
    1.54 +
    1.55 +					if (iClosing)
    1.56 +					{
    1.57 +						//We were closing our form
    1.58 +						//All clients are now closed
    1.59 +						//Just resume our close operation
    1.60 +						iClosing = false;
    1.61 +						Close();
    1.62 +					}
    1.63 +				}
    1.64              }
    1.65          }
    1.66