Server/FormMain.cs
changeset 280 f90d1e101932
parent 279 10f0de70b69b
child 283 f18d6170a223
     1.1 --- a/Server/FormMain.cs	Sun Jan 15 18:49:06 2017 +0100
     1.2 +++ b/Server/FormMain.cs	Sun Feb 26 18:00:10 2017 +0100
     1.3 @@ -255,8 +255,22 @@
     1.4              }
     1.5  
     1.6  #if !DEBUG
     1.7 -    //When not debugging we want the screen to be empty until a client takes over
     1.8 +            // When not debugging we want the screen to be empty until a client takes over
     1.9  			ClearLayout(iTableLayoutPanelCurrentClient);
    1.10 +
    1.11 +            // Display layout should be empty too
    1.12 +            // TODO: Eventually we will need to dynamically create and destroy our client table layout
    1.13 +            DoClearLayout(iTableLayoutPanelDisplay);
    1.14 +            iTableLayoutPanelDisplay.ColumnCount = 1;
    1.15 +            iTableLayoutPanelDisplay.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
    1.16 +            iTableLayoutPanelDisplay.RowCount = 1;
    1.17 +            iTableLayoutPanelDisplay.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
    1.18 +            //
    1.19 +            iTableLayoutPanelDisplay.SetRowSpan(iTableLayoutPanelCurrentClient, 1);
    1.20 +            iTableLayoutPanelDisplay.SetColumnSpan(iTableLayoutPanelCurrentClient, 1);
    1.21 +            iTableLayoutPanelDisplay.Controls.Add(iTableLayoutPanelCurrentClient,0,0);
    1.22 +
    1.23 +            // Is that needed? Why just in release?
    1.24              iCurrentClientData = null;
    1.25  #else
    1.26              //When developing we want at least one client for testing
    1.27 @@ -1625,14 +1639,23 @@
    1.28              while (aPanel.Controls.Count>0)
    1.29              {
    1.30                  // Dispose our last item
    1.31 -                aPanel.Controls[aPanel.Controls.Count-1].Dispose();
    1.32 +                aPanel.Controls[aPanel.Controls.Count - 1].Dispose();
    1.33              }
    1.34  
    1.35 +            DoClearLayout(aPanel);
    1.36 +        }
    1.37 +
    1.38 +        /// <summary>
    1.39 +        /// 
    1.40 +        /// </summary>
    1.41 +        /// <param name="aPanel"></param>
    1.42 +        static private void DoClearLayout(TableLayoutPanel aPanel)
    1.43 +        {
    1.44              aPanel.Controls.Clear();
    1.45              aPanel.RowStyles.Clear();
    1.46              aPanel.ColumnStyles.Clear();
    1.47              aPanel.RowCount = 0;
    1.48 -            aPanel.ColumnCount = 0;            
    1.49 +            aPanel.ColumnCount = 0;
    1.50          }
    1.51  
    1.52          /// <summary>
    1.53 @@ -2274,7 +2297,7 @@
    1.54  
    1.55          /// <summary>
    1.56          /// Update our display table layout.
    1.57 -        /// Will instanciated every field control as defined by our client.
    1.58 +        /// Will instanciate every field control as defined by our client.
    1.59          /// Fields must be specified by rows from the left.
    1.60          /// </summary>
    1.61          /// <param name="aLayout"></param>
    1.62 @@ -2412,8 +2435,11 @@
    1.63                  picture.Margin = new System.Windows.Forms.Padding(0);
    1.64                  picture.Name = "pictureBox" + aField;
    1.65  
    1.66 -                // Make sure visualization is running
    1.67 -                iAudioManager.AddVisualizer();
    1.68 +                // Make sure visualization is running                
    1.69 +                if (iAudioManager != null) // When closing main form with multiple client audio manager can be null. I guess we should fix the core issue instead.
    1.70 +                {
    1.71 +                    iAudioManager.AddVisualizer();
    1.72 +                }
    1.73  
    1.74                  // Notify audio manager when we don't need audio visualizer anymore
    1.75                  picture.Disposed += (sender, e) =>