# HG changeset patch # User StephaneLenclud # Date 1423061288 -3600 # Node ID 14f6c8d21ec1782577b16429b6afd67a765c46a9 # Parent 7e529cdd33913db6343f14bad58b474d0af250e6 Setting layout size according to display. Added comments. diff -r 7e529cdd3391 -r 14f6c8d21ec1 Server/MainForm.cs --- a/Server/MainForm.cs Sat Jan 24 11:19:28 2015 +0100 +++ b/Server/MainForm.cs Wed Feb 04 15:48:08 2015 +0100 @@ -108,6 +108,7 @@ StartServer(); + //Open display connection on start-up if needed if (Properties.Settings.Default.DisplayConnectOnStartup) { OpenDisplayConnection(); @@ -498,6 +499,9 @@ } + /// + /// Attempt to establish connection with our display hardware. + /// private void OpenDisplayConnection() { CloseDisplayConnection(); @@ -602,9 +606,11 @@ return 0.0f; } + /// + /// Synchronize UI with settings + /// private void UpdateStatus() - { - //Synchronize UI with settings + { //Load settings checkBoxShowBorders.Checked = cds.ShowBorders; tableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None); @@ -637,6 +643,14 @@ if (iDisplay.IsOpen()) { + //We have a display connection + //Reflect that in our UI + + //Set our screen size + tableLayoutPanel.Width = iDisplay.WidthInPixels(); + tableLayoutPanel.Height = iDisplay.HeightInPixels(); + tableLayoutPanel.Enabled = true; + //Only setup brightness if display is open trackBarBrightness.Minimum = iDisplay.MinBrightness(); trackBarBrightness.Maximum = iDisplay.MaxBrightness(); @@ -677,6 +691,9 @@ } else { + //Display is connection not available + //Reflect that in our UI + tableLayoutPanel.Enabled = false; buttonFill.Enabled = false; buttonClear.Enabled = false; buttonOpen.Enabled = true; @@ -1446,11 +1463,20 @@ } } + /// + /// Called when the user selected a new display type. + /// + /// + /// private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e) { + //Store the selected display type in our settings Properties.Settings.Default.CurrentDisplayIndex = comboBoxDisplayType.SelectedIndex; cds.DisplayType = comboBoxDisplayType.SelectedIndex; Properties.Settings.Default.Save(); + + //Try re-opening the display connection if we were already connected. + //Otherwise just update our status to reflect display type change. if (iDisplay.IsOpen()) { OpenDisplayConnection();