Setting layout size according to display.
Added comments.
1.1 --- a/Server/MainForm.cs Sat Jan 24 11:19:28 2015 +0100
1.2 +++ b/Server/MainForm.cs Wed Feb 04 15:48:08 2015 +0100
1.3 @@ -108,6 +108,7 @@
1.4
1.5 StartServer();
1.6
1.7 + //Open display connection on start-up if needed
1.8 if (Properties.Settings.Default.DisplayConnectOnStartup)
1.9 {
1.10 OpenDisplayConnection();
1.11 @@ -498,6 +499,9 @@
1.12
1.13 }
1.14
1.15 + /// <summary>
1.16 + /// Attempt to establish connection with our display hardware.
1.17 + /// </summary>
1.18 private void OpenDisplayConnection()
1.19 {
1.20 CloseDisplayConnection();
1.21 @@ -602,9 +606,11 @@
1.22 return 0.0f;
1.23 }
1.24
1.25 + /// <summary>
1.26 + /// Synchronize UI with settings
1.27 + /// </summary>
1.28 private void UpdateStatus()
1.29 - {
1.30 - //Synchronize UI with settings
1.31 + {
1.32 //Load settings
1.33 checkBoxShowBorders.Checked = cds.ShowBorders;
1.34 tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
1.35 @@ -637,6 +643,14 @@
1.36
1.37 if (iDisplay.IsOpen())
1.38 {
1.39 + //We have a display connection
1.40 + //Reflect that in our UI
1.41 +
1.42 + //Set our screen size
1.43 + tableLayoutPanel.Width = iDisplay.WidthInPixels();
1.44 + tableLayoutPanel.Height = iDisplay.HeightInPixels();
1.45 + tableLayoutPanel.Enabled = true;
1.46 +
1.47 //Only setup brightness if display is open
1.48 trackBarBrightness.Minimum = iDisplay.MinBrightness();
1.49 trackBarBrightness.Maximum = iDisplay.MaxBrightness();
1.50 @@ -677,6 +691,9 @@
1.51 }
1.52 else
1.53 {
1.54 + //Display is connection not available
1.55 + //Reflect that in our UI
1.56 + tableLayoutPanel.Enabled = false;
1.57 buttonFill.Enabled = false;
1.58 buttonClear.Enabled = false;
1.59 buttonOpen.Enabled = true;
1.60 @@ -1446,11 +1463,20 @@
1.61 }
1.62 }
1.63
1.64 + /// <summary>
1.65 + /// Called when the user selected a new display type.
1.66 + /// </summary>
1.67 + /// <param name="sender"></param>
1.68 + /// <param name="e"></param>
1.69 private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e)
1.70 {
1.71 + //Store the selected display type in our settings
1.72 Properties.Settings.Default.CurrentDisplayIndex = comboBoxDisplayType.SelectedIndex;
1.73 cds.DisplayType = comboBoxDisplayType.SelectedIndex;
1.74 Properties.Settings.Default.Save();
1.75 +
1.76 + //Try re-opening the display connection if we were already connected.
1.77 + //Otherwise just update our status to reflect display type change.
1.78 if (iDisplay.IsOpen())
1.79 {
1.80 OpenDisplayConnection();