Timer know disabled when no display connection.
authorStephaneLenclud
Tue, 26 Jan 2016 18:51:36 +0100
changeset 187549e7d887271
parent 186 e10744f29ef3
child 188 12372d6d7a47
Timer know disabled when no display connection.
Server/ConsumerElectronicControl.cs
Server/MainForm.Designer.cs
Server/MainForm.cs
     1.1 --- a/Server/ConsumerElectronicControl.cs	Mon Jan 25 23:16:35 2016 +0100
     1.2 +++ b/Server/ConsumerElectronicControl.cs	Tue Jan 26 18:51:36 2016 +0100
     1.3 @@ -24,7 +24,7 @@
     1.4          /// <param name="aHdmiPort"></param>
     1.5          public void Start(IntPtr aWndHandle, string aDeviceName, byte aHdmiPort, bool aMonitorOn, bool aMonitorOff)
     1.6          {
     1.7 -            //Create our power setting notifier and register the event we are insterrested in
     1.8 +            //Create our power setting notifier and register the event we are interested in
     1.9              iPowerSettingNotifier = new PowerManager.SettingNotifier(aWndHandle);
    1.10  
    1.11              //
     2.1 --- a/Server/MainForm.Designer.cs	Mon Jan 25 23:16:35 2016 +0100
     2.2 +++ b/Server/MainForm.Designer.cs	Tue Jan 26 18:51:36 2016 +0100
     2.3 @@ -201,7 +201,6 @@
     2.4              // 
     2.5              // timer
     2.6              // 
     2.7 -            this.timer.Enabled = true;
     2.8              this.timer.Interval = 50;
     2.9              this.timer.Tick += new System.EventHandler(this.timer_Tick);
    2.10              // 
     3.1 --- a/Server/MainForm.cs	Mon Jan 25 23:16:35 2016 +0100
     3.2 +++ b/Server/MainForm.cs	Tue Jan 26 18:51:36 2016 +0100
     3.3 @@ -237,8 +237,8 @@
     3.4  		/// <param name="aDisplay"></param>
     3.5  		private void OnDisplayOpened(Display aDisplay)
     3.6  		{
     3.7 -			//Make sure we resume frame rendering
     3.8 -			iSkipFrameRendering = false;
     3.9 +            //Make sure we resume frame rendering
    3.10 +            iSkipFrameRendering = false;
    3.11  
    3.12  			//Set our screen size now that our display is connected
    3.13  			//Our panelDisplay is the container of our tableLayoutPanel
    3.14 @@ -272,8 +272,8 @@
    3.15  		/// <param name="aDisplay"></param>
    3.16  		private void OnDisplayClosed(Display aDisplay)
    3.17  		{
    3.18 -			//Our display was just closed, update our UI consequently
    3.19 -			UpdateStatus();
    3.20 +            //Our display was just closed, update our UI consequently
    3.21 +            UpdateStatus();
    3.22  		}
    3.23  
    3.24  		public void OnConnectivityChanged(NetworkManager aNetwork, NLM_CONNECTIVITY newConnectivity)
    3.25 @@ -1148,8 +1148,9 @@
    3.26  
    3.27              if (iDisplay.IsOpen())
    3.28              {
    3.29 -				//We have a display connection
    3.30 -				//Reflect that in our UI
    3.31 +                //We have a display connection
    3.32 +                //Reflect that in our UI
    3.33 +                StartTimer();
    3.34  
    3.35  				iTableLayoutPanel.Enabled = true;
    3.36  				panelDisplay.Enabled = true;
    3.37 @@ -1220,9 +1221,16 @@
    3.38              }
    3.39              else
    3.40              {
    3.41 -				//Display is connection not available
    3.42 -				//Reflect that in our UI
    3.43 -				checkBoxShowVolumeLabel.Enabled = false;
    3.44 +                //Display connection not available
    3.45 +                //Reflect that in our UI
    3.46 +#if DEBUG
    3.47 +                //In debug start our timer even if we don't have a display connection
    3.48 +                StartTimer();
    3.49 +#else
    3.50 +                //In production environment we don't need our timer if no display connection
    3.51 +                StopTimer();
    3.52 +#endif
    3.53 +                checkBoxShowVolumeLabel.Enabled = false;
    3.54  				iTableLayoutPanel.Enabled = false;
    3.55  				panelDisplay.Enabled = false;
    3.56                  buttonFill.Enabled = false;
    3.57 @@ -1434,8 +1442,32 @@
    3.58  
    3.59          private void buttonSuspend_Click(object sender, EventArgs e)
    3.60          {
    3.61 +            ToggleTimer();
    3.62 +        }
    3.63 +
    3.64 +        private void StartTimer()
    3.65 +        {
    3.66 +            LastTickTime = DateTime.Now; //Reset timer to prevent jump
    3.67 +            timer.Enabled = true;
    3.68 +            UpdateSuspendButton();
    3.69 +        }
    3.70 +
    3.71 +        private void StopTimer()
    3.72 +        {
    3.73 +            LastTickTime = DateTime.Now; //Reset timer to prevent jump
    3.74 +            timer.Enabled = false;
    3.75 +            UpdateSuspendButton();
    3.76 +        }
    3.77 +
    3.78 +        private void ToggleTimer()
    3.79 +        {
    3.80              LastTickTime = DateTime.Now; //Reset timer to prevent jump
    3.81              timer.Enabled = !timer.Enabled;
    3.82 +            UpdateSuspendButton();
    3.83 +        }
    3.84 +
    3.85 +        private void UpdateSuspendButton()
    3.86 +        {
    3.87              if (!timer.Enabled)
    3.88              {
    3.89                  buttonSuspend.Text = "Run";
    3.90 @@ -1446,6 +1478,7 @@
    3.91              }
    3.92          }
    3.93  
    3.94 +
    3.95          private void buttonCloseClients_Click(object sender, EventArgs e)
    3.96          {
    3.97              BroadcastCloseEvent();
    3.98 @@ -2305,7 +2338,7 @@
    3.99  					}
   3.100  					else
   3.101  					{
   3.102 -						// Display a message that the app MUST reboot. Display the minimum required version.
   3.103 +						// Display a message that the application MUST reboot. Display the minimum required version.
   3.104  						MessageBox.Show("This application has detected a mandatory update from your current " +
   3.105  							"version to version " + info.MinimumRequiredVersion.ToString() +
   3.106  							". The application will now install the update and restart.",