# HG changeset patch # User StephaneLenclud # Date 1453830696 -3600 # Node ID 549e7d88727188c2f4b711a8a6401930f9bb1a67 # Parent e10744f29ef3ced96479282f0b6dccda20673fe1 Timer know disabled when no display connection. diff -r e10744f29ef3 -r 549e7d887271 Server/ConsumerElectronicControl.cs --- a/Server/ConsumerElectronicControl.cs Mon Jan 25 23:16:35 2016 +0100 +++ b/Server/ConsumerElectronicControl.cs Tue Jan 26 18:51:36 2016 +0100 @@ -24,7 +24,7 @@ /// public void Start(IntPtr aWndHandle, string aDeviceName, byte aHdmiPort, bool aMonitorOn, bool aMonitorOff) { - //Create our power setting notifier and register the event we are insterrested in + //Create our power setting notifier and register the event we are interested in iPowerSettingNotifier = new PowerManager.SettingNotifier(aWndHandle); // diff -r e10744f29ef3 -r 549e7d887271 Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Mon Jan 25 23:16:35 2016 +0100 +++ b/Server/MainForm.Designer.cs Tue Jan 26 18:51:36 2016 +0100 @@ -201,7 +201,6 @@ // // timer // - this.timer.Enabled = true; this.timer.Interval = 50; this.timer.Tick += new System.EventHandler(this.timer_Tick); // diff -r e10744f29ef3 -r 549e7d887271 Server/MainForm.cs --- a/Server/MainForm.cs Mon Jan 25 23:16:35 2016 +0100 +++ b/Server/MainForm.cs Tue Jan 26 18:51:36 2016 +0100 @@ -237,8 +237,8 @@ /// private void OnDisplayOpened(Display aDisplay) { - //Make sure we resume frame rendering - iSkipFrameRendering = false; + //Make sure we resume frame rendering + iSkipFrameRendering = false; //Set our screen size now that our display is connected //Our panelDisplay is the container of our tableLayoutPanel @@ -272,8 +272,8 @@ /// private void OnDisplayClosed(Display aDisplay) { - //Our display was just closed, update our UI consequently - UpdateStatus(); + //Our display was just closed, update our UI consequently + UpdateStatus(); } public void OnConnectivityChanged(NetworkManager aNetwork, NLM_CONNECTIVITY newConnectivity) @@ -1148,8 +1148,9 @@ if (iDisplay.IsOpen()) { - //We have a display connection - //Reflect that in our UI + //We have a display connection + //Reflect that in our UI + StartTimer(); iTableLayoutPanel.Enabled = true; panelDisplay.Enabled = true; @@ -1220,9 +1221,16 @@ } else { - //Display is connection not available - //Reflect that in our UI - checkBoxShowVolumeLabel.Enabled = false; + //Display connection not available + //Reflect that in our UI +#if DEBUG + //In debug start our timer even if we don't have a display connection + StartTimer(); +#else + //In production environment we don't need our timer if no display connection + StopTimer(); +#endif + checkBoxShowVolumeLabel.Enabled = false; iTableLayoutPanel.Enabled = false; panelDisplay.Enabled = false; buttonFill.Enabled = false; @@ -1434,8 +1442,32 @@ private void buttonSuspend_Click(object sender, EventArgs e) { + ToggleTimer(); + } + + private void StartTimer() + { + LastTickTime = DateTime.Now; //Reset timer to prevent jump + timer.Enabled = true; + UpdateSuspendButton(); + } + + private void StopTimer() + { + LastTickTime = DateTime.Now; //Reset timer to prevent jump + timer.Enabled = false; + UpdateSuspendButton(); + } + + private void ToggleTimer() + { LastTickTime = DateTime.Now; //Reset timer to prevent jump timer.Enabled = !timer.Enabled; + UpdateSuspendButton(); + } + + private void UpdateSuspendButton() + { if (!timer.Enabled) { buttonSuspend.Text = "Run"; @@ -1446,6 +1478,7 @@ } } + private void buttonCloseClients_Click(object sender, EventArgs e) { BroadcastCloseEvent(); @@ -2305,7 +2338,7 @@ } else { - // Display a message that the app MUST reboot. Display the minimum required version. + // Display a message that the application MUST reboot. Display the minimum required version. MessageBox.Show("This application has detected a mandatory update from your current " + "version to version " + info.MinimumRequiredVersion.ToString() + ". The application will now install the update and restart.",