Adding action move and test buttons.
authorStephaneLenclud
Wed, 27 Jul 2016 15:05:58 +0200
changeset 223f6272f65d8fc
parent 222 0e8c6c2f4777
child 224 471cb4c8a09a
Adding action move and test buttons.
Server/Actions/ActionCecActiveSource.cs
Server/Actions/ActionCecClose.cs
Server/Actions/ActionCecDevicePowerOn.cs
Server/Actions/ActionCecDeviceStandby.cs
Server/Actions/ActionCecInactiveSource.cs
Server/Actions/ActionCecOpen.cs
Server/Actions/ActionCecScan.cs
Server/Actions/ActionCecUserControlPressed.cs
Server/Actions/ActionCecUserControlReleased.cs
Server/FormEditAction.cs
Server/MainForm.Designer.cs
Server/MainForm.cs
SharpLibEar/Action.cs
SharpLibEar/ActionCallback.cs
SharpLibEar/ActionSleep.cs
     1.1 --- a/Server/Actions/ActionCecActiveSource.cs	Wed Jul 27 11:07:35 2016 +0200
     1.2 +++ b/Server/Actions/ActionCecActiveSource.cs	Wed Jul 27 15:05:58 2016 +0200
     1.3 @@ -25,7 +25,7 @@
     1.4          /// <summary>
     1.5          /// Set the defined device type as active source.
     1.6          /// </summary>
     1.7 -        public override void Execute()
     1.8 +        public override void DoExecute()
     1.9          {
    1.10              if (Cec.Client.Static == null)
    1.11              {
     2.1 --- a/Server/Actions/ActionCecClose.cs	Wed Jul 27 11:07:35 2016 +0200
     2.2 +++ b/Server/Actions/ActionCecClose.cs	Wed Jul 27 15:05:58 2016 +0200
     2.3 @@ -13,7 +13,7 @@
     2.4      [AttributeAction(Id = "Cec.Close", Name = "CEC Close", Description = "Close CEC connection.")]
     2.5      class ActionCecClose : SharpLib.Ear.Action
     2.6      {
     2.7 -        public override void Execute()
     2.8 +        public override void DoExecute()
     2.9          {
    2.10              if (Cec.Client.Static == null)
    2.11              {
     3.1 --- a/Server/Actions/ActionCecDevicePowerOn.cs	Wed Jul 27 11:07:35 2016 +0200
     3.2 +++ b/Server/Actions/ActionCecDevicePowerOn.cs	Wed Jul 27 15:05:58 2016 +0200
     3.3 @@ -26,7 +26,7 @@
     3.4          /// <summary>
     3.5          /// 
     3.6          /// </summary>
     3.7 -        public override void Execute()
     3.8 +        public override void DoExecute()
     3.9          {
    3.10              if (Cec.Client.Static == null)
    3.11              {
     4.1 --- a/Server/Actions/ActionCecDeviceStandby.cs	Wed Jul 27 11:07:35 2016 +0200
     4.2 +++ b/Server/Actions/ActionCecDeviceStandby.cs	Wed Jul 27 15:05:58 2016 +0200
     4.3 @@ -26,7 +26,7 @@
     4.4          /// <summary>
     4.5          /// 
     4.6          /// </summary>
     4.7 -        public override void Execute()
     4.8 +        public override void DoExecute()
     4.9          {
    4.10              if (Cec.Client.Static == null)
    4.11              {
     5.1 --- a/Server/Actions/ActionCecInactiveSource.cs	Wed Jul 27 11:07:35 2016 +0200
     5.2 +++ b/Server/Actions/ActionCecInactiveSource.cs	Wed Jul 27 15:05:58 2016 +0200
     5.3 @@ -13,7 +13,7 @@
     5.4      [AttributeAction(Id = "Cec.InactiveSource", Name = "CEC Inactive Source", Description = "Set this CEC device as inactive source.")]
     5.5      class ActionCecInactiveSource : SharpLib.Ear.Action
     5.6      {
     5.7 -        public override void Execute()
     5.8 +        public override void DoExecute()
     5.9          {
    5.10              if (Cec.Client.Static == null)
    5.11              {
     6.1 --- a/Server/Actions/ActionCecOpen.cs	Wed Jul 27 11:07:35 2016 +0200
     6.2 +++ b/Server/Actions/ActionCecOpen.cs	Wed Jul 27 15:05:58 2016 +0200
     6.3 @@ -13,7 +13,7 @@
     6.4      [AttributeAction(Id = "Cec.Open", Name = "CEC Open", Description = "Open CEC connection.")]
     6.5      class ActionCecOpen : SharpLib.Ear.Action
     6.6      {
     6.7 -        public override void Execute()
     6.8 +        public override void DoExecute()
     6.9          {
    6.10              if (Cec.Client.Static == null)
    6.11              {
     7.1 --- a/Server/Actions/ActionCecScan.cs	Wed Jul 27 11:07:35 2016 +0200
     7.2 +++ b/Server/Actions/ActionCecScan.cs	Wed Jul 27 15:05:58 2016 +0200
     7.3 @@ -14,7 +14,7 @@
     7.4      [AttributeAction(Id = "Cec.Scan", Name = "CEC Scan", Description = "Scan devices on your CEC HDMI network.")]
     7.5      class ActionCecScan : SharpLib.Ear.Action
     7.6      {
     7.7 -        public override void Execute()
     7.8 +        public override void DoExecute()
     7.9          {
    7.10              if (Cec.Client.Static == null)
    7.11              {
     8.1 --- a/Server/Actions/ActionCecUserControlPressed.cs	Wed Jul 27 11:07:35 2016 +0200
     8.2 +++ b/Server/Actions/ActionCecUserControlPressed.cs	Wed Jul 27 15:05:58 2016 +0200
     8.3 @@ -56,7 +56,7 @@
     8.4          /// <summary>
     8.5          /// 
     8.6          /// </summary>
     8.7 -        public override void Execute()
     8.8 +        public override void DoExecute()
     8.9          {
    8.10              if (Cec.Client.Static == null)
    8.11              {
     9.1 --- a/Server/Actions/ActionCecUserControlReleased.cs	Wed Jul 27 11:07:35 2016 +0200
     9.2 +++ b/Server/Actions/ActionCecUserControlReleased.cs	Wed Jul 27 15:05:58 2016 +0200
     9.3 @@ -48,7 +48,7 @@
     9.4          /// <summary>
     9.5          /// 
     9.6          /// </summary>
     9.7 -        public override void Execute()
     9.8 +        public override void DoExecute()
     9.9          {
    9.10              if (Cec.Client.Static == null)
    9.11              {
    10.1 --- a/Server/FormEditAction.cs	Wed Jul 27 11:07:35 2016 +0200
    10.2 +++ b/Server/FormEditAction.cs	Wed Jul 27 15:05:58 2016 +0200
    10.3 @@ -142,7 +142,7 @@
    10.4                  //Data source is fine but it gives us duplicate entries for duplicated enum values
    10.5                  //ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
    10.6  
    10.7 -                //Therefore we need to explicitly create our items  
    10.8 +                //Therefore we need to explicitly create our items
    10.9                  foreach (string name in aInfo.PropertyType.GetEnumNames())
   10.10                  {
   10.11                      ctrl.Items.Add(name.ToString());
   10.12 @@ -252,7 +252,8 @@
   10.13  
   10.14                  //Add our editor to our form
   10.15                  iTableLayoutPanel.Controls.Add(ctrl, 1, iTableLayoutPanel.RowCount - 1);
   10.16 -
   10.17 +                //Add tooltip to editor too
   10.18 +                toolTip.SetToolTip(ctrl, attribute.Description);
   10.19  
   10.20              }        
   10.21  
    11.1 --- a/Server/MainForm.Designer.cs	Wed Jul 27 11:07:35 2016 +0200
    11.2 +++ b/Server/MainForm.Designer.cs	Wed Jul 27 15:05:58 2016 +0200
    11.3 @@ -110,6 +110,9 @@
    11.4              this.labelHdmiPort = new System.Windows.Forms.Label();
    11.5              this.comboBoxHdmiPort = new System.Windows.Forms.ComboBox();
    11.6              this.tabPageEvent = new System.Windows.Forms.TabPage();
    11.7 +            this.buttonActionMoveUp = new System.Windows.Forms.Button();
    11.8 +            this.buttonActionMoveDown = new System.Windows.Forms.Button();
    11.9 +            this.buttonTestAction = new System.Windows.Forms.Button();
   11.10              this.buttonDeleteAction = new System.Windows.Forms.Button();
   11.11              this.buttonAddAction = new System.Windows.Forms.Button();
   11.12              this.iTreeViewEvents = new System.Windows.Forms.TreeView();
   11.13 @@ -969,6 +972,9 @@
   11.14              // 
   11.15              // tabPageEvent
   11.16              // 
   11.17 +            this.tabPageEvent.Controls.Add(this.buttonActionMoveUp);
   11.18 +            this.tabPageEvent.Controls.Add(this.buttonActionMoveDown);
   11.19 +            this.tabPageEvent.Controls.Add(this.buttonTestAction);
   11.20              this.tabPageEvent.Controls.Add(this.buttonDeleteAction);
   11.21              this.tabPageEvent.Controls.Add(this.buttonAddAction);
   11.22              this.tabPageEvent.Controls.Add(this.iTreeViewEvents);
   11.23 @@ -980,6 +986,39 @@
   11.24              this.tabPageEvent.Text = "Events";
   11.25              this.tabPageEvent.UseVisualStyleBackColor = true;
   11.26              // 
   11.27 +            // buttonActionMoveUp
   11.28 +            // 
   11.29 +            this.buttonActionMoveUp.Enabled = false;
   11.30 +            this.buttonActionMoveUp.Location = new System.Drawing.Point(6, 327);
   11.31 +            this.buttonActionMoveUp.Name = "buttonActionMoveUp";
   11.32 +            this.buttonActionMoveUp.Size = new System.Drawing.Size(96, 23);
   11.33 +            this.buttonActionMoveUp.TabIndex = 24;
   11.34 +            this.buttonActionMoveUp.Text = "Move Up";
   11.35 +            this.buttonActionMoveUp.UseVisualStyleBackColor = true;
   11.36 +            this.buttonActionMoveUp.Click += new System.EventHandler(this.buttonActionMoveUp_Click);
   11.37 +            // 
   11.38 +            // buttonActionMoveDown
   11.39 +            // 
   11.40 +            this.buttonActionMoveDown.Enabled = false;
   11.41 +            this.buttonActionMoveDown.Location = new System.Drawing.Point(6, 356);
   11.42 +            this.buttonActionMoveDown.Name = "buttonActionMoveDown";
   11.43 +            this.buttonActionMoveDown.Size = new System.Drawing.Size(96, 23);
   11.44 +            this.buttonActionMoveDown.TabIndex = 23;
   11.45 +            this.buttonActionMoveDown.Text = "Move Down";
   11.46 +            this.buttonActionMoveDown.UseVisualStyleBackColor = true;
   11.47 +            this.buttonActionMoveDown.Click += new System.EventHandler(this.buttonActionMoveDown_Click);
   11.48 +            // 
   11.49 +            // buttonTestAction
   11.50 +            // 
   11.51 +            this.buttonTestAction.Enabled = false;
   11.52 +            this.buttonTestAction.Location = new System.Drawing.Point(6, 64);
   11.53 +            this.buttonTestAction.Name = "buttonTestAction";
   11.54 +            this.buttonTestAction.Size = new System.Drawing.Size(96, 23);
   11.55 +            this.buttonTestAction.TabIndex = 22;
   11.56 +            this.buttonTestAction.Text = "Test Action";
   11.57 +            this.buttonTestAction.UseVisualStyleBackColor = true;
   11.58 +            this.buttonTestAction.Click += new System.EventHandler(this.buttonTestAction_Click);
   11.59 +            // 
   11.60              // buttonDeleteAction
   11.61              // 
   11.62              this.buttonDeleteAction.Enabled = false;
   11.63 @@ -1007,6 +1046,7 @@
   11.64              this.iTreeViewEvents.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
   11.65              | System.Windows.Forms.AnchorStyles.Left) 
   11.66              | System.Windows.Forms.AnchorStyles.Right)));
   11.67 +            this.iTreeViewEvents.HideSelection = false;
   11.68              this.iTreeViewEvents.Location = new System.Drawing.Point(111, 3);
   11.69              this.iTreeViewEvents.Name = "iTreeViewEvents";
   11.70              this.iTreeViewEvents.Size = new System.Drawing.Size(638, 376);
   11.71 @@ -1273,6 +1313,9 @@
   11.72          private System.Windows.Forms.TreeView iTreeViewEvents;
   11.73          private System.Windows.Forms.Button buttonDeleteAction;
   11.74          private System.Windows.Forms.Button buttonAddAction;
   11.75 +        private System.Windows.Forms.Button buttonActionMoveUp;
   11.76 +        private System.Windows.Forms.Button buttonActionMoveDown;
   11.77 +        private System.Windows.Forms.Button buttonTestAction;
   11.78      }
   11.79  }
   11.80  
    12.1 --- a/Server/MainForm.cs	Wed Jul 27 11:07:35 2016 +0200
    12.2 +++ b/Server/MainForm.cs	Wed Jul 27 15:05:58 2016 +0200
    12.3 @@ -52,23 +52,33 @@
    12.4  {
    12.5      //Types declarations
    12.6      public delegate uint ColorProcessingDelegate(int aX, int aY, uint aPixel);
    12.7 +
    12.8      public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
    12.9 +
   12.10      //Delegates are used for our thread safe method
   12.11      public delegate void AddClientDelegate(string aSessionId, ICallback aCallback);
   12.12 +
   12.13      public delegate void RemoveClientDelegate(string aSessionId);
   12.14 +
   12.15      public delegate void SetFieldDelegate(string SessionId, DataField aField);
   12.16 +
   12.17      public delegate void SetFieldsDelegate(string SessionId, System.Collections.Generic.IList<DataField> aFields);
   12.18 +
   12.19      public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
   12.20 +
   12.21      public delegate void SetClientNameDelegate(string aSessionId, string aName);
   12.22 +
   12.23      public delegate void SetClientPriorityDelegate(string aSessionId, uint aPriority);
   12.24 +
   12.25      public delegate void PlainUpdateDelegate();
   12.26 +
   12.27      public delegate void WndProcDelegate(ref Message aMessage);
   12.28  
   12.29      /// <summary>
   12.30      /// Our Display manager main form
   12.31      /// </summary>
   12.32 -	[System.ComponentModel.DesignerCategory("Form")]
   12.33 -	public partial class MainForm : MainFormHid, IMMNotificationClient
   12.34 +    [System.ComponentModel.DesignerCategory("Form")]
   12.35 +    public partial class MainForm : MainFormHid, IMMNotificationClient
   12.36      {
   12.37          //public ManagerEventAction iManager = new ManagerEventAction();        
   12.38          DateTime LastTickTime;
   12.39 @@ -83,35 +93,35 @@
   12.40          ClientData iCurrentClientData;
   12.41          //
   12.42          public bool iClosing;
   12.43 -		//
   12.44 -		public bool iSkipFrameRendering;
   12.45 +        //
   12.46 +        public bool iSkipFrameRendering;
   12.47          //Function pointer for pixel color filtering
   12.48          ColorProcessingDelegate iColorFx;
   12.49          //Function pointer for pixel X coordinate intercept
   12.50          CoordinateTranslationDelegate iScreenX;
   12.51          //Function pointer for pixel Y coordinate intercept
   12.52          CoordinateTranslationDelegate iScreenY;
   12.53 -		//NAudio
   12.54 -		private MMDeviceEnumerator iMultiMediaDeviceEnumerator;
   12.55 -		private MMDevice iMultiMediaDevice;
   12.56 -		//Network
   12.57 -		private NetworkManager iNetworkManager;
   12.58 +        //NAudio
   12.59 +        private MMDeviceEnumerator iMultiMediaDeviceEnumerator;
   12.60 +        private MMDevice iMultiMediaDevice;
   12.61 +        //Network
   12.62 +        private NetworkManager iNetworkManager;
   12.63  
   12.64          /// <summary>
   12.65          /// CEC - Consumer Electronic Control.
   12.66          /// Notably used to turn TV on and off as Windows broadcast monitor on and off notifications.
   12.67          /// </summary>
   12.68          private ConsumerElectronicControl iCecManager;
   12.69 -		
   12.70 -		/// <summary>
   12.71 -		/// Manage run when Windows startup option
   12.72 -		/// </summary>
   12.73 -		private StartupManager iStartupManager;
   12.74 -
   12.75 -		/// <summary>
   12.76 -		/// System notification icon used to hide our application from the task bar.
   12.77 -		/// </summary>
   12.78 -		private SharpLib.Notification.Control iNotifyIcon;
   12.79 +
   12.80 +        /// <summary>
   12.81 +        /// Manage run when Windows startup option
   12.82 +        /// </summary>
   12.83 +        private StartupManager iStartupManager;
   12.84 +
   12.85 +        /// <summary>
   12.86 +        /// System notification icon used to hide our application from the task bar.
   12.87 +        /// </summary>
   12.88 +        private SharpLib.Notification.Control iNotifyIcon;
   12.89  
   12.90          /// <summary>
   12.91          /// System recording notification icon.
   12.92 @@ -145,18 +155,18 @@
   12.93                  ManagerEventAction.Current.Init();
   12.94              }
   12.95              iSkipFrameRendering = false;
   12.96 -			iClosing = false;
   12.97 +            iClosing = false;
   12.98              iCurrentClientSessionId = "";
   12.99              iCurrentClientData = null;
  12.100              LastTickTime = DateTime.Now;
  12.101 -			//Instantiate our display and register for events notifications
  12.102 +            //Instantiate our display and register for events notifications
  12.103              iDisplay = new Display();
  12.104 -			iDisplay.OnOpened += OnDisplayOpened;
  12.105 -			iDisplay.OnClosed += OnDisplayClosed;
  12.106 -			//
  12.107 -			iClients = new Dictionary<string, ClientData>();
  12.108 -			iStartupManager = new StartupManager();
  12.109 -			iNotifyIcon = new SharpLib.Notification.Control();
  12.110 +            iDisplay.OnOpened += OnDisplayOpened;
  12.111 +            iDisplay.OnClosed += OnDisplayClosed;
  12.112 +            //
  12.113 +            iClients = new Dictionary<string, ClientData>();
  12.114 +            iStartupManager = new StartupManager();
  12.115 +            iNotifyIcon = new SharpLib.Notification.Control();
  12.116              iRecordingNotification = new SharpLib.Notification.Control();
  12.117  
  12.118              //Have our designer initialize its controls
  12.119 @@ -172,50 +182,51 @@
  12.120              //Populate optical drives
  12.121              PopulateOpticalDrives();
  12.122  
  12.123 -			//Initial status update 
  12.124 +            //Initial status update 
  12.125              UpdateStatus();
  12.126  
  12.127              //We have a bug when drawing minimized and reusing our bitmap
  12.128              //Though I could not reproduce it on Windows 10
  12.129 -            iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height, PixelFormat.Format32bppArgb);
  12.130 +            iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height,
  12.131 +                PixelFormat.Format32bppArgb);
  12.132              iCreateBitmap = false;
  12.133  
  12.134 -			//Minimize our window if desired
  12.135 -			if (Properties.Settings.Default.StartMinimized)
  12.136 -			{
  12.137 -				WindowState = FormWindowState.Minimized;
  12.138 -			}
  12.139 +            //Minimize our window if desired
  12.140 +            if (Properties.Settings.Default.StartMinimized)
  12.141 +            {
  12.142 +                WindowState = FormWindowState.Minimized;
  12.143 +            }
  12.144  
  12.145          }
  12.146  
  12.147 -		/// <summary>
  12.148 -		///
  12.149 -		/// </summary>
  12.150 -		/// <param name="sender"></param>
  12.151 -		/// <param name="e"></param>
  12.152 +        /// <summary>
  12.153 +        ///
  12.154 +        /// </summary>
  12.155 +        /// <param name="sender"></param>
  12.156 +        /// <param name="e"></param>
  12.157          private void MainForm_Load(object sender, EventArgs e)
  12.158          {
  12.159 -			//Check if we are running a Click Once deployed application
  12.160 -			if (ApplicationDeployment.IsNetworkDeployed)
  12.161 -			{
  12.162 -				//This is a proper Click Once installation, fetch and show our version number
  12.163 -				this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
  12.164 -			}
  12.165 -			else
  12.166 -			{
  12.167 -				//Not a proper Click Once installation, assuming development build then
  12.168 -				this.Text += " - development";
  12.169 -			}
  12.170 -
  12.171 -			//NAudio
  12.172 -			iMultiMediaDeviceEnumerator = new MMDeviceEnumerator();
  12.173 -			iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);			
  12.174 -			UpdateAudioDeviceAndMasterVolumeThreadSafe();
  12.175 -
  12.176 -			//Network
  12.177 -			iNetworkManager = new NetworkManager();
  12.178 -			iNetworkManager.OnConnectivityChanged += OnConnectivityChanged;
  12.179 -			UpdateNetworkStatus();
  12.180 +            //Check if we are running a Click Once deployed application
  12.181 +            if (ApplicationDeployment.IsNetworkDeployed)
  12.182 +            {
  12.183 +                //This is a proper Click Once installation, fetch and show our version number
  12.184 +                this.Text += " - v" + ApplicationDeployment.CurrentDeployment.CurrentVersion;
  12.185 +            }
  12.186 +            else
  12.187 +            {
  12.188 +                //Not a proper Click Once installation, assuming development build then
  12.189 +                this.Text += " - development";
  12.190 +            }
  12.191 +
  12.192 +            //NAudio
  12.193 +            iMultiMediaDeviceEnumerator = new MMDeviceEnumerator();
  12.194 +            iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);
  12.195 +            UpdateAudioDeviceAndMasterVolumeThreadSafe();
  12.196 +
  12.197 +            //Network
  12.198 +            iNetworkManager = new NetworkManager();
  12.199 +            iNetworkManager.OnConnectivityChanged += OnConnectivityChanged;
  12.200 +            UpdateNetworkStatus();
  12.201  
  12.202              //CEC
  12.203              iCecManager = new ConsumerElectronicControl();
  12.204 @@ -233,29 +244,29 @@
  12.205  
  12.206              // To make sure start up with minimize to tray works
  12.207              if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
  12.208 -			{
  12.209 -				Visible = false;
  12.210 -			}
  12.211 +            {
  12.212 +                Visible = false;
  12.213 +            }
  12.214  
  12.215  #if !DEBUG
  12.216 -			//When not debugging we want the screen to be empty until a client takes over
  12.217 +    //When not debugging we want the screen to be empty until a client takes over
  12.218  			ClearLayout();
  12.219  #else
  12.220 -			//When developing we want at least one client for testing
  12.221 -			StartNewClient("abcdefghijklmnopqrst-0123456789","ABCDEFGHIJKLMNOPQRST-0123456789");
  12.222 +            //When developing we want at least one client for testing
  12.223 +            StartNewClient("abcdefghijklmnopqrst-0123456789", "ABCDEFGHIJKLMNOPQRST-0123456789");
  12.224  #endif
  12.225  
  12.226 -			//Open display connection on start-up if needed
  12.227 -			if (Properties.Settings.Default.DisplayConnectOnStartup)
  12.228 -			{
  12.229 -				OpenDisplayConnection();
  12.230 -			}
  12.231 -
  12.232 -			//Start our server so that we can get client requests
  12.233 -			StartServer();
  12.234 -
  12.235 -			//Register for HID events
  12.236 -			RegisterHidDevices();
  12.237 +            //Open display connection on start-up if needed
  12.238 +            if (Properties.Settings.Default.DisplayConnectOnStartup)
  12.239 +            {
  12.240 +                OpenDisplayConnection();
  12.241 +            }
  12.242 +
  12.243 +            //Start our server so that we can get client requests
  12.244 +            StartServer();
  12.245 +
  12.246 +            //Register for HID events
  12.247 +            RegisterHidDevices();
  12.248  
  12.249              //Start Idle client if needed
  12.250              if (Properties.Settings.Default.StartIdleClient)
  12.251 @@ -264,40 +275,40 @@
  12.252              }
  12.253          }
  12.254  
  12.255 -		/// <summary>
  12.256 -		/// Called when our display is opened.
  12.257 -		/// </summary>
  12.258 -		/// <param name="aDisplay"></param>
  12.259 -		private void OnDisplayOpened(Display aDisplay)
  12.260 -		{
  12.261 +        /// <summary>
  12.262 +        /// Called when our display is opened.
  12.263 +        /// </summary>
  12.264 +        /// <param name="aDisplay"></param>
  12.265 +        private void OnDisplayOpened(Display aDisplay)
  12.266 +        {
  12.267              //Make sure we resume frame rendering
  12.268              iSkipFrameRendering = false;
  12.269  
  12.270 -			//Set our screen size now that our display is connected
  12.271 -			//Our panelDisplay is the container of our tableLayoutPanel
  12.272 -			//tableLayoutPanel will resize itself to fit the client size of our panelDisplay
  12.273 -			//panelDisplay needs an extra 2 pixels for borders on each sides
  12.274 -			//tableLayoutPanel will eventually be the exact size of our display
  12.275 -			Size size = new Size(iDisplay.WidthInPixels() + 2, iDisplay.HeightInPixels() + 2);
  12.276 -			panelDisplay.Size = size;
  12.277 -
  12.278 -			//Our display was just opened, update our UI
  12.279 -			UpdateStatus();
  12.280 -			//Initiate asynchronous request
  12.281 -			iDisplay.RequestFirmwareRevision();
  12.282 -
  12.283 -			//Audio
  12.284 -			UpdateMasterVolumeThreadSafe();
  12.285 -			//Network
  12.286 -			UpdateNetworkStatus();
  12.287 +            //Set our screen size now that our display is connected
  12.288 +            //Our panelDisplay is the container of our tableLayoutPanel
  12.289 +            //tableLayoutPanel will resize itself to fit the client size of our panelDisplay
  12.290 +            //panelDisplay needs an extra 2 pixels for borders on each sides
  12.291 +            //tableLayoutPanel will eventually be the exact size of our display
  12.292 +            Size size = new Size(iDisplay.WidthInPixels() + 2, iDisplay.HeightInPixels() + 2);
  12.293 +            panelDisplay.Size = size;
  12.294 +
  12.295 +            //Our display was just opened, update our UI
  12.296 +            UpdateStatus();
  12.297 +            //Initiate asynchronous request
  12.298 +            iDisplay.RequestFirmwareRevision();
  12.299 +
  12.300 +            //Audio
  12.301 +            UpdateMasterVolumeThreadSafe();
  12.302 +            //Network
  12.303 +            UpdateNetworkStatus();
  12.304  
  12.305  #if DEBUG
  12.306 -			//Testing icon in debug, no arm done if icon not supported
  12.307 -			//iDisplay.SetIconStatus(Display.TMiniDisplayIconType.EMiniDisplayIconRecording, 0, 1);
  12.308 -			//iDisplay.SetAllIconsStatus(2);
  12.309 +            //Testing icon in debug, no arm done if icon not supported
  12.310 +            //iDisplay.SetIconStatus(Display.TMiniDisplayIconType.EMiniDisplayIconRecording, 0, 1);
  12.311 +            //iDisplay.SetAllIconsStatus(2);
  12.312  #endif
  12.313  
  12.314 -		}
  12.315 +        }
  12.316  
  12.317          /// <summary>
  12.318          /// Populate tree view with events and actions
  12.319 @@ -309,6 +320,8 @@
  12.320              buttonDeleteAction.Enabled = false;
  12.321  
  12.322              Event currentEvent = CurrentEvent();
  12.323 +            SharpLib.Ear.Action currentAction = CurrentAction();
  12.324 +            TreeNode treeNodeToSelect = null;
  12.325  
  12.326              //Reset our tree
  12.327              iTreeViewEvents.Nodes.Clear();
  12.328 @@ -316,7 +329,7 @@
  12.329              foreach (string key in ManagerEventAction.Current.Events.Keys)
  12.330              {
  12.331                  Event e = ManagerEventAction.Current.Events[key];
  12.332 -                TreeNode eventNode = iTreeViewEvents.Nodes.Add(key,e.Name);
  12.333 +                TreeNode eventNode = iTreeViewEvents.Nodes.Add(key, e.Name);
  12.334                  eventNode.Tag = e;
  12.335                  eventNode.Nodes.Add(key + ".Description", e.Description);
  12.336                  TreeNode actionsNodes = eventNode.Nodes.Add(key + ".Actions", "Actions");
  12.337 @@ -326,82 +339,96 @@
  12.338                  {
  12.339                      TreeNode actionNode = actionsNodes.Nodes.Add(a.Brief());
  12.340                      actionNode.Tag = a;
  12.341 +                    if (a == currentAction)
  12.342 +                    {
  12.343 +                        treeNodeToSelect = actionNode;
  12.344 +                    }
  12.345                  }
  12.346              }
  12.347  
  12.348              iTreeViewEvents.ExpandAll();
  12.349              SelectEvent(currentEvent);
  12.350 -            //Select the last action if any 
  12.351 -            if (iTreeViewEvents.SelectedNode!= null && iTreeViewEvents.SelectedNode.Nodes[1].GetNodeCount(false) > 0)
  12.352 +            
  12.353 +            if (treeNodeToSelect != null)
  12.354              {
  12.355 -                iTreeViewEvents.SelectedNode = iTreeViewEvents.SelectedNode.Nodes[1].Nodes[iTreeViewEvents.SelectedNode.Nodes[1].GetNodeCount(false)-1];
  12.356 +                iTreeViewEvents.SelectedNode = treeNodeToSelect;
  12.357              }
  12.358 +            else if (iTreeViewEvents.SelectedNode != null && iTreeViewEvents.SelectedNode.Nodes[1].GetNodeCount(false) > 0)
  12.359 +            {
  12.360 +                //Select the last action if any 
  12.361 +                iTreeViewEvents.SelectedNode =
  12.362 +                    iTreeViewEvents.SelectedNode.Nodes[1].Nodes[
  12.363 +                        iTreeViewEvents.SelectedNode.Nodes[1].GetNodeCount(false) - 1];
  12.364 +            }
  12.365  
  12.366          }
  12.367  
  12.368 -		/// <summary>
  12.369 -		/// Called when our display is closed.
  12.370 -		/// </summary>
  12.371 -		/// <param name="aDisplay"></param>
  12.372 -		private void OnDisplayClosed(Display aDisplay)
  12.373 -		{
  12.374 +        /// <summary>
  12.375 +        /// Called when our display is closed.
  12.376 +        /// </summary>
  12.377 +        /// <param name="aDisplay"></param>
  12.378 +        private void OnDisplayClosed(Display aDisplay)
  12.379 +        {
  12.380              //Our display was just closed, update our UI consequently
  12.381              UpdateStatus();
  12.382 -		}
  12.383 -
  12.384 -		public void OnConnectivityChanged(NetworkManager aNetwork, NLM_CONNECTIVITY newConnectivity)
  12.385 -		{
  12.386 -			//Update network status
  12.387 -			UpdateNetworkStatus();			
  12.388 -		}
  12.389 -
  12.390 -		/// <summary>
  12.391 -		/// Update our Network Status
  12.392 -		/// </summary>
  12.393 -		private void UpdateNetworkStatus()
  12.394 -		{
  12.395 -			if (iDisplay.IsOpen())
  12.396 -			{
  12.397 -                iDisplay.SetIconOnOff(MiniDisplay.IconType.Internet, iNetworkManager.NetworkListManager.IsConnectedToInternet);
  12.398 +        }
  12.399 +
  12.400 +        public void OnConnectivityChanged(NetworkManager aNetwork, NLM_CONNECTIVITY newConnectivity)
  12.401 +        {
  12.402 +            //Update network status
  12.403 +            UpdateNetworkStatus();
  12.404 +        }
  12.405 +
  12.406 +        /// <summary>
  12.407 +        /// Update our Network Status
  12.408 +        /// </summary>
  12.409 +        private void UpdateNetworkStatus()
  12.410 +        {
  12.411 +            if (iDisplay.IsOpen())
  12.412 +            {
  12.413 +                iDisplay.SetIconOnOff(MiniDisplay.IconType.Internet,
  12.414 +                    iNetworkManager.NetworkListManager.IsConnectedToInternet);
  12.415                  iDisplay.SetIconOnOff(MiniDisplay.IconType.NetworkSignal, iNetworkManager.NetworkListManager.IsConnected);
  12.416 -			}
  12.417 -		}
  12.418 -
  12.419 -
  12.420 -		int iLastNetworkIconIndex = 0;
  12.421 -		int iUpdateCountSinceLastNetworkAnimation = 0;
  12.422 -
  12.423 -		/// <summary>
  12.424 -		/// 
  12.425 -		/// </summary>
  12.426 -		private void UpdateNetworkSignal(DateTime aLastTickTime, DateTime aNewTickTime)
  12.427 -		{
  12.428 -			iUpdateCountSinceLastNetworkAnimation++;
  12.429 -			iUpdateCountSinceLastNetworkAnimation = iUpdateCountSinceLastNetworkAnimation % 4;
  12.430 -
  12.431 -			if (iDisplay.IsOpen() && iNetworkManager.NetworkListManager.IsConnected && iUpdateCountSinceLastNetworkAnimation==0)
  12.432 -			{
  12.433 +            }
  12.434 +        }
  12.435 +
  12.436 +
  12.437 +        int iLastNetworkIconIndex = 0;
  12.438 +        int iUpdateCountSinceLastNetworkAnimation = 0;
  12.439 +
  12.440 +        /// <summary>
  12.441 +        /// 
  12.442 +        /// </summary>
  12.443 +        private void UpdateNetworkSignal(DateTime aLastTickTime, DateTime aNewTickTime)
  12.444 +        {
  12.445 +            iUpdateCountSinceLastNetworkAnimation++;
  12.446 +            iUpdateCountSinceLastNetworkAnimation = iUpdateCountSinceLastNetworkAnimation%4;
  12.447 +
  12.448 +            if (iDisplay.IsOpen() && iNetworkManager.NetworkListManager.IsConnected &&
  12.449 +                iUpdateCountSinceLastNetworkAnimation == 0)
  12.450 +            {
  12.451                  int iconCount = iDisplay.IconCount(MiniDisplay.IconType.NetworkSignal);
  12.452 -				if (iconCount <= 0)
  12.453 -				{
  12.454 -					//Prevents div by zero and other undefined behavior
  12.455 -					return;
  12.456 -				}
  12.457 -				iLastNetworkIconIndex++;
  12.458 -				iLastNetworkIconIndex = iLastNetworkIconIndex % (iconCount*2);
  12.459 -				for (int i=0;i<iconCount;i++)
  12.460 -				{
  12.461 -					if (i < iLastNetworkIconIndex && !(i == 0 && iLastNetworkIconIndex > 3) && !(i == 1 && iLastNetworkIconIndex > 4))
  12.462 -					{
  12.463 +                if (iconCount <= 0)
  12.464 +                {
  12.465 +                    //Prevents div by zero and other undefined behavior
  12.466 +                    return;
  12.467 +                }
  12.468 +                iLastNetworkIconIndex++;
  12.469 +                iLastNetworkIconIndex = iLastNetworkIconIndex%(iconCount*2);
  12.470 +                for (int i = 0; i < iconCount; i++)
  12.471 +                {
  12.472 +                    if (i < iLastNetworkIconIndex && !(i == 0 && iLastNetworkIconIndex > 3) &&
  12.473 +                        !(i == 1 && iLastNetworkIconIndex > 4))
  12.474 +                    {
  12.475                          iDisplay.SetIconOn(MiniDisplay.IconType.NetworkSignal, i);
  12.476 -					}
  12.477 -					else
  12.478 -					{
  12.479 +                    }
  12.480 +                    else
  12.481 +                    {
  12.482                          iDisplay.SetIconOff(MiniDisplay.IconType.NetworkSignal, i);
  12.483 -					}
  12.484 -				}				
  12.485 -			}
  12.486 -		}
  12.487 +                    }
  12.488 +                }
  12.489 +            }
  12.490 +        }
  12.491  
  12.492  
  12.493  
  12.494 @@ -411,7 +438,7 @@
  12.495          /// <param name="data"></param>
  12.496          public void OnVolumeNotificationThreadSafe(AudioVolumeNotificationData data)
  12.497          {
  12.498 -			UpdateMasterVolumeThreadSafe();
  12.499 +            UpdateMasterVolumeThreadSafe();
  12.500          }
  12.501  
  12.502          /// <summary>
  12.503 @@ -421,42 +448,50 @@
  12.504          /// <param name="e"></param>
  12.505          private void trackBarMasterVolume_Scroll(object sender, EventArgs e)
  12.506          {
  12.507 -			//Just like Windows Volume Mixer we unmute if the volume is adjusted
  12.508 -			iMultiMediaDevice.AudioEndpointVolume.Mute = false;
  12.509 -			//Set volume level according to our volume slider new position
  12.510 -			iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value / 100.0f;
  12.511 +            //Just like Windows Volume Mixer we unmute if the volume is adjusted
  12.512 +            iMultiMediaDevice.AudioEndpointVolume.Mute = false;
  12.513 +            //Set volume level according to our volume slider new position
  12.514 +            iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value/100.0f;
  12.515          }
  12.516  
  12.517  
  12.518 -		/// <summary>
  12.519 -		/// Mute check box changed.
  12.520 -		/// </summary>
  12.521 -		/// <param name="sender"></param>
  12.522 -		/// <param name="e"></param>
  12.523 -		private void checkBoxMute_CheckedChanged(object sender, EventArgs e)
  12.524 -		{
  12.525 -			iMultiMediaDevice.AudioEndpointVolume.Mute = checkBoxMute.Checked;
  12.526 -		}
  12.527 +        /// <summary>
  12.528 +        /// Mute check box changed.
  12.529 +        /// </summary>
  12.530 +        /// <param name="sender"></param>
  12.531 +        /// <param name="e"></param>
  12.532 +        private void checkBoxMute_CheckedChanged(object sender, EventArgs e)
  12.533 +        {
  12.534 +            iMultiMediaDevice.AudioEndpointVolume.Mute = checkBoxMute.Checked;
  12.535 +        }
  12.536  
  12.537          /// <summary>
  12.538          /// Device State Changed
  12.539          /// </summary>
  12.540 -        public void OnDeviceStateChanged([MarshalAs(UnmanagedType.LPWStr)] string deviceId, [MarshalAs(UnmanagedType.I4)] DeviceState newState){}
  12.541 +        public void OnDeviceStateChanged([MarshalAs(UnmanagedType.LPWStr)] string deviceId,
  12.542 +            [MarshalAs(UnmanagedType.I4)] DeviceState newState)
  12.543 +        {
  12.544 +        }
  12.545  
  12.546          /// <summary>
  12.547          /// Device Added
  12.548          /// </summary>
  12.549 -        public void OnDeviceAdded([MarshalAs(UnmanagedType.LPWStr)] string pwstrDeviceId) { }
  12.550 +        public void OnDeviceAdded([MarshalAs(UnmanagedType.LPWStr)] string pwstrDeviceId)
  12.551 +        {
  12.552 +        }
  12.553  
  12.554          /// <summary>
  12.555          /// Device Removed
  12.556          /// </summary>
  12.557 -        public void OnDeviceRemoved([MarshalAs(UnmanagedType.LPWStr)] string deviceId) { }
  12.558 +        public void OnDeviceRemoved([MarshalAs(UnmanagedType.LPWStr)] string deviceId)
  12.559 +        {
  12.560 +        }
  12.561  
  12.562          /// <summary>
  12.563          /// Default Device Changed
  12.564          /// </summary>
  12.565 -        public void OnDefaultDeviceChanged(DataFlow flow, Role role, [MarshalAs(UnmanagedType.LPWStr)] string defaultDeviceId)
  12.566 +        public void OnDefaultDeviceChanged(DataFlow flow, Role role,
  12.567 +            [MarshalAs(UnmanagedType.LPWStr)] string defaultDeviceId)
  12.568          {
  12.569              if (role == Role.Multimedia && flow == DataFlow.Render)
  12.570              {
  12.571 @@ -469,73 +504,77 @@
  12.572          /// </summary>
  12.573          /// <param name="pwstrDeviceId"></param>
  12.574          /// <param name="key"></param>
  12.575 -        public void OnPropertyValueChanged([MarshalAs(UnmanagedType.LPWStr)] string pwstrDeviceId, PropertyKey key){}
  12.576 -
  12.577 -
  12.578 -        
  12.579 -
  12.580 -		/// <summary>
  12.581 -		/// Update master volume indicators based our current system states.
  12.582 -		/// This typically includes volume levels and mute status.
  12.583 -		/// </summary>
  12.584 -		private void UpdateMasterVolumeThreadSafe()
  12.585 -		{
  12.586 -			if (this.InvokeRequired)
  12.587 -			{
  12.588 -				//Not in the proper thread, invoke ourselves
  12.589 -				PlainUpdateDelegate d = new PlainUpdateDelegate(UpdateMasterVolumeThreadSafe);
  12.590 -				this.Invoke(d, new object[] { });
  12.591 -				return;
  12.592 -			}
  12.593 -
  12.594 -			//Update volume slider
  12.595 -			float volumeLevelScalar = iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar;
  12.596 -			trackBarMasterVolume.Value = Convert.ToInt32(volumeLevelScalar * 100);
  12.597 -			//Update mute checkbox
  12.598 -			checkBoxMute.Checked = iMultiMediaDevice.AudioEndpointVolume.Mute;
  12.599 -
  12.600 -			//If our display connection is open we need to update its icons
  12.601 -			if (iDisplay.IsOpen())
  12.602 -			{
  12.603 -				//First take care our our volume level icons
  12.604 +        public void OnPropertyValueChanged([MarshalAs(UnmanagedType.LPWStr)] string pwstrDeviceId, PropertyKey key)
  12.605 +        {
  12.606 +        }
  12.607 +
  12.608 +
  12.609 +
  12.610 +
  12.611 +        /// <summary>
  12.612 +        /// Update master volume indicators based our current system states.
  12.613 +        /// This typically includes volume levels and mute status.
  12.614 +        /// </summary>
  12.615 +        private void UpdateMasterVolumeThreadSafe()
  12.616 +        {
  12.617 +            if (this.InvokeRequired)
  12.618 +            {
  12.619 +                //Not in the proper thread, invoke ourselves
  12.620 +                PlainUpdateDelegate d = new PlainUpdateDelegate(UpdateMasterVolumeThreadSafe);
  12.621 +                this.Invoke(d, new object[] {});
  12.622 +                return;
  12.623 +            }
  12.624 +
  12.625 +            //Update volume slider
  12.626 +            float volumeLevelScalar = iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar;
  12.627 +            trackBarMasterVolume.Value = Convert.ToInt32(volumeLevelScalar*100);
  12.628 +            //Update mute checkbox
  12.629 +            checkBoxMute.Checked = iMultiMediaDevice.AudioEndpointVolume.Mute;
  12.630 +
  12.631 +            //If our display connection is open we need to update its icons
  12.632 +            if (iDisplay.IsOpen())
  12.633 +            {
  12.634 +                //First take care our our volume level icons
  12.635                  int volumeIconCount = iDisplay.IconCount(MiniDisplay.IconType.Volume);
  12.636 -				if (volumeIconCount > 0)
  12.637 -				{					
  12.638 -					//Compute current volume level from system level and the number of segments in our display volume bar.
  12.639 -					//That tells us how many segments in our volume bar needs to be turned on.
  12.640 -					float currentVolume = volumeLevelScalar * volumeIconCount;
  12.641 -					int segmentOnCount = Convert.ToInt32(currentVolume);
  12.642 -					//Check if our segment count was rounded up, this will later be used for half brightness segment
  12.643 -					bool roundedUp = segmentOnCount > currentVolume;
  12.644 -
  12.645 -					for (int i = 0; i < volumeIconCount; i++)
  12.646 -					{
  12.647 -						if (i < segmentOnCount)
  12.648 -						{
  12.649 -							//If we are dealing with our last segment and our segment count was rounded up then we will use half brightness.
  12.650 -							if (i == segmentOnCount - 1 && roundedUp)
  12.651 -							{
  12.652 -								//Half brightness
  12.653 -                                iDisplay.SetIconStatus(MiniDisplay.IconType.Volume, i, (iDisplay.IconStatusCount(MiniDisplay.IconType.Volume) - 1) / 2);
  12.654 -							}
  12.655 -							else
  12.656 -							{
  12.657 -								//Full brightness
  12.658 -                                iDisplay.SetIconStatus(MiniDisplay.IconType.Volume, i, iDisplay.IconStatusCount(MiniDisplay.IconType.Volume) - 1);
  12.659 -							}
  12.660 -						}
  12.661 -						else
  12.662 -						{
  12.663 +                if (volumeIconCount > 0)
  12.664 +                {
  12.665 +                    //Compute current volume level from system level and the number of segments in our display volume bar.
  12.666 +                    //That tells us how many segments in our volume bar needs to be turned on.
  12.667 +                    float currentVolume = volumeLevelScalar*volumeIconCount;
  12.668 +                    int segmentOnCount = Convert.ToInt32(currentVolume);
  12.669 +                    //Check if our segment count was rounded up, this will later be used for half brightness segment
  12.670 +                    bool roundedUp = segmentOnCount > currentVolume;
  12.671 +
  12.672 +                    for (int i = 0; i < volumeIconCount; i++)
  12.673 +                    {
  12.674 +                        if (i < segmentOnCount)
  12.675 +                        {
  12.676 +                            //If we are dealing with our last segment and our segment count was rounded up then we will use half brightness.
  12.677 +                            if (i == segmentOnCount - 1 && roundedUp)
  12.678 +                            {
  12.679 +                                //Half brightness
  12.680 +                                iDisplay.SetIconStatus(MiniDisplay.IconType.Volume, i,
  12.681 +                                    (iDisplay.IconStatusCount(MiniDisplay.IconType.Volume) - 1)/2);
  12.682 +                            }
  12.683 +                            else
  12.684 +                            {
  12.685 +                                //Full brightness
  12.686 +                                iDisplay.SetIconStatus(MiniDisplay.IconType.Volume, i,
  12.687 +                                    iDisplay.IconStatusCount(MiniDisplay.IconType.Volume) - 1);
  12.688 +                            }
  12.689 +                        }
  12.690 +                        else
  12.691 +                        {
  12.692                              iDisplay.SetIconStatus(MiniDisplay.IconType.Volume, i, 0);
  12.693 -						}
  12.694 -					}
  12.695 -				}
  12.696 -
  12.697 -				//Take care of our mute icon
  12.698 +                        }
  12.699 +                    }
  12.700 +                }
  12.701 +
  12.702 +                //Take care of our mute icon
  12.703                  iDisplay.SetIconOnOff(MiniDisplay.IconType.Mute, iMultiMediaDevice.AudioEndpointVolume.Mute);
  12.704 -			}
  12.705 -
  12.706 -		}
  12.707 +            }
  12.708 +
  12.709 +        }
  12.710  
  12.711          /// <summary>
  12.712          /// 
  12.713 @@ -545,48 +584,48 @@
  12.714              if (this.InvokeRequired)
  12.715              {
  12.716                  //Not in the proper thread, invoke ourselves
  12.717 -				PlainUpdateDelegate d = new PlainUpdateDelegate(UpdateAudioDeviceAndMasterVolumeThreadSafe);
  12.718 -                this.Invoke(d, new object[] { });
  12.719 +                PlainUpdateDelegate d = new PlainUpdateDelegate(UpdateAudioDeviceAndMasterVolumeThreadSafe);
  12.720 +                this.Invoke(d, new object[] {});
  12.721                  return;
  12.722              }
  12.723 -            
  12.724 +
  12.725              //We are in the correct thread just go ahead.
  12.726              try
  12.727 -            {                
  12.728 +            {
  12.729                  //Get our master volume            
  12.730 -				iMultiMediaDevice = iMultiMediaDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
  12.731 -				//Update our label
  12.732 -				labelDefaultAudioDevice.Text = iMultiMediaDevice.FriendlyName;
  12.733 +                iMultiMediaDevice = iMultiMediaDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
  12.734 +                //Update our label
  12.735 +                labelDefaultAudioDevice.Text = iMultiMediaDevice.FriendlyName;
  12.736  
  12.737                  //Show our volume in our track bar
  12.738 -				UpdateMasterVolumeThreadSafe();
  12.739 +                UpdateMasterVolumeThreadSafe();
  12.740  
  12.741                  //Register to get volume modifications
  12.742 -				iMultiMediaDevice.AudioEndpointVolume.OnVolumeNotification += OnVolumeNotificationThreadSafe;
  12.743 +                iMultiMediaDevice.AudioEndpointVolume.OnVolumeNotification += OnVolumeNotificationThreadSafe;
  12.744                  //
  12.745 -				trackBarMasterVolume.Enabled = true;
  12.746 +                trackBarMasterVolume.Enabled = true;
  12.747              }
  12.748              catch (Exception ex)
  12.749              {
  12.750                  Debug.WriteLine("Exception thrown in UpdateAudioDeviceAndMasterVolume");
  12.751                  Debug.WriteLine(ex.ToString());
  12.752                  //Something went wrong S/PDIF device ca throw exception I guess
  12.753 -				trackBarMasterVolume.Enabled = false;
  12.754 +                trackBarMasterVolume.Enabled = false;
  12.755              }
  12.756          }
  12.757  
  12.758 -		/// <summary>
  12.759 -		/// 
  12.760 -		/// </summary>
  12.761 -		private void PopulateDeviceTypes()
  12.762 -		{
  12.763 -			int count = Display.TypeCount();
  12.764 -
  12.765 -			for (int i = 0; i < count; i++)
  12.766 -			{
  12.767 -				comboBoxDisplayType.Items.Add(Display.TypeName((MiniDisplay.Type)i));
  12.768 -			}
  12.769 -		}
  12.770 +        /// <summary>
  12.771 +        /// 
  12.772 +        /// </summary>
  12.773 +        private void PopulateDeviceTypes()
  12.774 +        {
  12.775 +            int count = Display.TypeCount();
  12.776 +
  12.777 +            for (int i = 0; i < count; i++)
  12.778 +            {
  12.779 +                comboBoxDisplayType.Items.Add(Display.TypeName((MiniDisplay.Type) i));
  12.780 +            }
  12.781 +        }
  12.782  
  12.783          /// <summary>
  12.784          /// 
  12.785 @@ -604,12 +643,12 @@
  12.786                  Debug.WriteLine("Drive " + d.Name);
  12.787                  Debug.WriteLine("  Drive type: {0}", d.DriveType);
  12.788  
  12.789 -                if (d.DriveType==DriveType.CDRom)
  12.790 +                if (d.DriveType == DriveType.CDRom)
  12.791                  {
  12.792                      //This is an optical drive, add it now
  12.793 -                    comboBoxOpticalDrives.Items.Add(d.Name.Substring(0,2));
  12.794 -                }                
  12.795 -            }           
  12.796 +                    comboBoxOpticalDrives.Items.Add(d.Name.Substring(0, 2));
  12.797 +                }
  12.798 +            }
  12.799          }
  12.800  
  12.801          /// <summary>
  12.802 @@ -623,44 +662,44 @@
  12.803  
  12.804  
  12.805  
  12.806 -		/// <summary>
  12.807 -		///
  12.808 -		/// </summary>
  12.809 -		private void SetupTrayIcon()
  12.810 -		{
  12.811 -			iNotifyIcon.Icon = GetIcon("vfd.ico");
  12.812 -			iNotifyIcon.Text = "Sharp Display Manager";
  12.813 -			iNotifyIcon.Visible = true;
  12.814 -
  12.815 -			//Double click toggles visibility - typically brings up the application
  12.816 -			iNotifyIcon.DoubleClick += delegate(object obj, EventArgs args)
  12.817 -			{
  12.818 -				SysTrayHideShow();
  12.819 -			};
  12.820 -
  12.821 -			//Adding a context menu, useful to be able to exit the application
  12.822 -			ContextMenu contextMenu = new ContextMenu();
  12.823 -			//Context menu item to toggle visibility
  12.824 -			MenuItem hideShowItem = new MenuItem("Hide/Show");
  12.825 -			hideShowItem.Click += delegate(object obj, EventArgs args)
  12.826 -			{
  12.827 -				SysTrayHideShow();
  12.828 -			};
  12.829 -			contextMenu.MenuItems.Add(hideShowItem);
  12.830 -
  12.831 -			//Context menu item separator
  12.832 -			contextMenu.MenuItems.Add(new MenuItem("-"));
  12.833 -
  12.834 -			//Context menu exit item
  12.835 -			MenuItem exitItem = new MenuItem("Exit");
  12.836 -			exitItem.Click += delegate(object obj, EventArgs args)
  12.837 -			{
  12.838 -				Application.Exit();
  12.839 -			};
  12.840 -			contextMenu.MenuItems.Add(exitItem);
  12.841 -
  12.842 -			iNotifyIcon.ContextMenu = contextMenu;
  12.843 -		}
  12.844 +        /// <summary>
  12.845 +        ///
  12.846 +        /// </summary>
  12.847 +        private void SetupTrayIcon()
  12.848 +        {
  12.849 +            iNotifyIcon.Icon = GetIcon("vfd.ico");
  12.850 +            iNotifyIcon.Text = "Sharp Display Manager";
  12.851 +            iNotifyIcon.Visible = true;
  12.852 +
  12.853 +            //Double click toggles visibility - typically brings up the application
  12.854 +            iNotifyIcon.DoubleClick += delegate(object obj, EventArgs args)
  12.855 +            {
  12.856 +                SysTrayHideShow();
  12.857 +            };
  12.858 +
  12.859 +            //Adding a context menu, useful to be able to exit the application
  12.860 +            ContextMenu contextMenu = new ContextMenu();
  12.861 +            //Context menu item to toggle visibility
  12.862 +            MenuItem hideShowItem = new MenuItem("Hide/Show");
  12.863 +            hideShowItem.Click += delegate(object obj, EventArgs args)
  12.864 +            {
  12.865 +                SysTrayHideShow();
  12.866 +            };
  12.867 +            contextMenu.MenuItems.Add(hideShowItem);
  12.868 +
  12.869 +            //Context menu item separator
  12.870 +            contextMenu.MenuItems.Add(new MenuItem("-"));
  12.871 +
  12.872 +            //Context menu exit item
  12.873 +            MenuItem exitItem = new MenuItem("Exit");
  12.874 +            exitItem.Click += delegate(object obj, EventArgs args)
  12.875 +            {
  12.876 +                Application.Exit();
  12.877 +            };
  12.878 +            contextMenu.MenuItems.Add(exitItem);
  12.879 +
  12.880 +            iNotifyIcon.ContextMenu = contextMenu;
  12.881 +        }
  12.882  
  12.883          /// <summary>
  12.884          ///
  12.885 @@ -678,22 +717,22 @@
  12.886          /// <param name="aName"></param>
  12.887          /// <returns></returns>
  12.888          public static Icon GetIcon(string aName)
  12.889 -		{
  12.890 -			string[] names =  Assembly.GetExecutingAssembly().GetManifestResourceNames();
  12.891 -			foreach (string name in names)
  12.892 -			{
  12.893 +        {
  12.894 +            string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
  12.895 +            foreach (string name in names)
  12.896 +            {
  12.897                  //Find a resource name that ends with the given name
  12.898 -				if (name.EndsWith(aName))
  12.899 -				{
  12.900 -					using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
  12.901 -					{
  12.902 -						return new Icon(stream);
  12.903 -					}
  12.904 -				}
  12.905 -			}
  12.906 -
  12.907 -			return null;
  12.908 -		}
  12.909 +                if (name.EndsWith(aName))
  12.910 +                {
  12.911 +                    using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
  12.912 +                    {
  12.913 +                        return new Icon(stream);
  12.914 +                    }
  12.915 +                }
  12.916 +            }
  12.917 +
  12.918 +            return null;
  12.919 +        }
  12.920  
  12.921  
  12.922          /// <summary>
  12.923 @@ -701,7 +740,7 @@
  12.924          /// This will take care of applying our client layout and set data fields.
  12.925          /// </summary>
  12.926          /// <param name="aSessionId"></param>
  12.927 -        void SetCurrentClient(string aSessionId, bool aForce=false)
  12.928 +        void SetCurrentClient(string aSessionId, bool aForce = false)
  12.929          {
  12.930              if (aSessionId == iCurrentClientSessionId)
  12.931              {
  12.932 @@ -728,7 +767,8 @@
  12.933                  //Thus a background client can set this to zero allowing any other client to interrupt at any time
  12.934                  //We could also compute this delay by looking at the requests frequencies?
  12.935                  if (!aForce &&
  12.936 -                    requestedClientData.Priority == iCurrentClientData.Priority && //Time sharing is only if clients have the same priority
  12.937 +                    requestedClientData.Priority == iCurrentClientData.Priority &&
  12.938 +                    //Time sharing is only if clients have the same priority
  12.939                      (lastSwitchToClientSecondsAgo < 30)) //Make sure a client is on for at least 30 seconds
  12.940                  {
  12.941                      //Don't switch clients too often
  12.942 @@ -773,7 +813,7 @@
  12.943                  {
  12.944                      if (ctrl is MarqueeLabel)
  12.945                      {
  12.946 -                        ((MarqueeLabel)ctrl).Font = fontDialog.Font;
  12.947 +                        ((MarqueeLabel) ctrl).Font = fontDialog.Font;
  12.948                      }
  12.949                  }
  12.950  
  12.951 @@ -809,7 +849,7 @@
  12.952              {
  12.953                  if (ctrl is MarqueeLabel)
  12.954                  {
  12.955 -                    label = (MarqueeLabel)ctrl;
  12.956 +                    label = (MarqueeLabel) ctrl;
  12.957                      break;
  12.958                  }
  12.959              }
  12.960 @@ -817,7 +857,8 @@
  12.961              //Now check font height and show a warning if needed.
  12.962              if (label != null && label.Font.Height > label.Height)
  12.963              {
  12.964 -                labelWarning.Text = "WARNING: Selected font is too height by " + (label.Font.Height - label.Height) + " pixels!";
  12.965 +                labelWarning.Text = "WARNING: Selected font is too height by " + (label.Font.Height - label.Height) +
  12.966 +                                    " pixels!";
  12.967                  labelWarning.Visible = true;
  12.968              }
  12.969              else
  12.970 @@ -834,7 +875,7 @@
  12.971              //Bitmap bmpToSave = new Bitmap(bmp);
  12.972              bmp.Save("D:\\capture.png");
  12.973  
  12.974 -            ((MarqueeLabel)iTableLayoutPanel.Controls[0]).Text = "Captured";
  12.975 +            ((MarqueeLabel) iTableLayoutPanel.Controls[0]).Text = "Captured";
  12.976  
  12.977              /*
  12.978              string outputFileName = "d:\\capture.png";
  12.979 @@ -905,11 +946,11 @@
  12.980  
  12.981          public static uint ColorChessboard(int aX, int aY, uint aPixel)
  12.982          {
  12.983 -            if ((aX % 2 == 0) && (aY % 2 == 0))
  12.984 +            if ((aX%2 == 0) && (aY%2 == 0))
  12.985              {
  12.986                  return ~aPixel;
  12.987              }
  12.988 -            else if ((aX % 2 != 0) && (aY % 2 != 0))
  12.989 +            else if ((aX%2 != 0) && (aY%2 != 0))
  12.990              {
  12.991                  return ~aPixel;
  12.992              }
  12.993 @@ -977,14 +1018,14 @@
  12.994              //Update our animations
  12.995              DateTime NewTickTime = DateTime.Now;
  12.996  
  12.997 -			UpdateNetworkSignal(LastTickTime, NewTickTime);
  12.998 +            UpdateNetworkSignal(LastTickTime, NewTickTime);
  12.999  
 12.1000              //Update animation for all our marquees
 12.1001              foreach (Control ctrl in iTableLayoutPanel.Controls)
 12.1002              {
 12.1003                  if (ctrl is MarqueeLabel)
 12.1004                  {
 12.1005 -                    ((MarqueeLabel)ctrl).UpdateAnimation(LastTickTime, NewTickTime);
 12.1006 +                    ((MarqueeLabel) ctrl).UpdateAnimation(LastTickTime, NewTickTime);
 12.1007                  }
 12.1008              }
 12.1009  
 12.1010 @@ -993,82 +1034,84 @@
 12.1011              {
 12.1012                  CheckForRequestResults();
 12.1013  
 12.1014 -				//Check if frame rendering is needed
 12.1015 -				//Typically used when showing clock
 12.1016 -				if (!iSkipFrameRendering)
 12.1017 -				{
 12.1018 -					//Draw to bitmap
 12.1019 -					if (iCreateBitmap)
 12.1020 -					{
 12.1021 -                        iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height, PixelFormat.Format32bppArgb);
 12.1022 +                //Check if frame rendering is needed
 12.1023 +                //Typically used when showing clock
 12.1024 +                if (!iSkipFrameRendering)
 12.1025 +                {
 12.1026 +                    //Draw to bitmap
 12.1027 +                    if (iCreateBitmap)
 12.1028 +                    {
 12.1029 +                        iBmp = new System.Drawing.Bitmap(iTableLayoutPanel.Width, iTableLayoutPanel.Height,
 12.1030 +                            PixelFormat.Format32bppArgb);
 12.1031                          iCreateBitmap = false;
 12.1032                      }
 12.1033 -					iTableLayoutPanel.DrawToBitmap(iBmp, iTableLayoutPanel.ClientRectangle);
 12.1034 -					//iBmp.Save("D:\\capture.png");
 12.1035 -
 12.1036 -					//Send it to our display
 12.1037 -					for (int i = 0; i < iBmp.Width; i++)
 12.1038 -					{
 12.1039 -						for (int j = 0; j < iBmp.Height; j++)
 12.1040 -						{
 12.1041 -							unchecked
 12.1042 -							{
 12.1043 -								//Get our processed pixel coordinates
 12.1044 -								int x = iScreenX(iBmp, i);
 12.1045 -								int y = iScreenY(iBmp, j);
 12.1046 -								//Get pixel color
 12.1047 -								uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
 12.1048 -								//Apply color effects
 12.1049 -								color = iColorFx(x, y, color);
 12.1050 -								//Now set our pixel
 12.1051 -								iDisplay.SetPixel(x, y, color);
 12.1052 -							}
 12.1053 -						}
 12.1054 -					}
 12.1055 -
 12.1056 -					iDisplay.SwapBuffers();
 12.1057 -				}
 12.1058 +                    iTableLayoutPanel.DrawToBitmap(iBmp, iTableLayoutPanel.ClientRectangle);
 12.1059 +                    //iBmp.Save("D:\\capture.png");
 12.1060 +
 12.1061 +                    //Send it to our display
 12.1062 +                    for (int i = 0; i < iBmp.Width; i++)
 12.1063 +                    {
 12.1064 +                        for (int j = 0; j < iBmp.Height; j++)
 12.1065 +                        {
 12.1066 +                            unchecked
 12.1067 +                            {
 12.1068 +                                //Get our processed pixel coordinates
 12.1069 +                                int x = iScreenX(iBmp, i);
 12.1070 +                                int y = iScreenY(iBmp, j);
 12.1071 +                                //Get pixel color
 12.1072 +                                uint color = (uint) iBmp.GetPixel(i, j).ToArgb();
 12.1073 +                                //Apply color effects
 12.1074 +                                color = iColorFx(x, y, color);
 12.1075 +                                //Now set our pixel
 12.1076 +                                iDisplay.SetPixel(x, y, color);
 12.1077 +                            }
 12.1078 +                        }
 12.1079 +                    }
 12.1080 +
 12.1081 +                    iDisplay.SwapBuffers();
 12.1082 +                }
 12.1083              }
 12.1084  
 12.1085              //Compute instant FPS
 12.1086 -            toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " / " + (1000/timer.Interval).ToString() + " FPS";
 12.1087 +            toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " / " +
 12.1088 +                                           (1000/timer.Interval).ToString() + " FPS";
 12.1089  
 12.1090              LastTickTime = NewTickTime;
 12.1091  
 12.1092          }
 12.1093  
 12.1094 -		/// <summary>
 12.1095 -		/// Attempt to establish connection with our display hardware.
 12.1096 -		/// </summary>
 12.1097 +        /// <summary>
 12.1098 +        /// Attempt to establish connection with our display hardware.
 12.1099 +        /// </summary>
 12.1100          private void OpenDisplayConnection()
 12.1101          {
 12.1102              CloseDisplayConnection();
 12.1103  
 12.1104 -            if (!iDisplay.Open((MiniDisplay.Type)cds.DisplayType))
 12.1105 -            {   
 12.1106 -				UpdateStatus();               
 12.1107 -				toolStripStatusLabelConnect.Text = "Connection error";
 12.1108 +            if (!iDisplay.Open((MiniDisplay.Type) cds.DisplayType))
 12.1109 +            {
 12.1110 +                UpdateStatus();
 12.1111 +                toolStripStatusLabelConnect.Text = "Connection error";
 12.1112              }
 12.1113          }
 12.1114  
 12.1115          private void CloseDisplayConnection()
 12.1116          {
 12.1117 -			//Status will be updated upon receiving the closed event
 12.1118 -
 12.1119 -			if (iDisplay == null || !iDisplay.IsOpen())
 12.1120 -			{
 12.1121 -				return;
 12.1122 -			}
 12.1123 -
 12.1124 -			//Do not clear if we gave up on rendering already.
 12.1125 -			//This means we will keep on displaying clock on MDM166AA for instance.
 12.1126 -			if (!iSkipFrameRendering)
 12.1127 -			{
 12.1128 -				iDisplay.Clear();
 12.1129 -				iDisplay.SwapBuffers();
 12.1130 -			}
 12.1131 -
 12.1132 -			iDisplay.SetAllIconsStatus(0); //Turn off all icons
 12.1133 +            //Status will be updated upon receiving the closed event
 12.1134 +
 12.1135 +            if (iDisplay == null || !iDisplay.IsOpen())
 12.1136 +            {
 12.1137 +                return;
 12.1138 +            }
 12.1139 +
 12.1140 +            //Do not clear if we gave up on rendering already.
 12.1141 +            //This means we will keep on displaying clock on MDM166AA for instance.
 12.1142 +            if (!iSkipFrameRendering)
 12.1143 +            {
 12.1144 +                iDisplay.Clear();
 12.1145 +                iDisplay.SwapBuffers();
 12.1146 +            }
 12.1147 +
 12.1148 +            iDisplay.SetAllIconsStatus(0); //Turn off all icons
 12.1149              iDisplay.Close();
 12.1150          }
 12.1151  
 12.1152 @@ -1137,13 +1180,14 @@
 12.1153          public float IsFixedWidth(Font ft)
 12.1154          {
 12.1155              Graphics g = CreateGraphics();
 12.1156 -            char[] charSizes = new char[] { 'i', 'a', 'Z', '%', '#', 'a', 'B', 'l', 'm', ',', '.' };
 12.1157 +            char[] charSizes = new char[] {'i', 'a', 'Z', '%', '#', 'a', 'B', 'l', 'm', ',', '.'};
 12.1158              float charWidth = g.MeasureString("I", ft, Int32.MaxValue, StringFormat.GenericTypographic).Width;
 12.1159  
 12.1160              bool fixedWidth = true;
 12.1161  
 12.1162              foreach (char c in charSizes)
 12.1163 -                if (g.MeasureString(c.ToString(), ft, Int32.MaxValue, StringFormat.GenericTypographic).Width != charWidth)
 12.1164 +                if (g.MeasureString(c.ToString(), ft, Int32.MaxValue, StringFormat.GenericTypographic).Width !=
 12.1165 +                    charWidth)
 12.1166                      fixedWidth = false;
 12.1167  
 12.1168              if (fixedWidth)
 12.1169 @@ -1154,14 +1198,16 @@
 12.1170              return 0.0f;
 12.1171          }
 12.1172  
 12.1173 -		/// <summary>
 12.1174 -		/// Synchronize UI with settings
 12.1175 -		/// </summary>
 12.1176 +        /// <summary>
 12.1177 +        /// Synchronize UI with settings
 12.1178 +        /// </summary>
 12.1179          private void UpdateStatus()
 12.1180 -        {            
 12.1181 +        {
 12.1182              //Load settings
 12.1183              checkBoxShowBorders.Checked = cds.ShowBorders;
 12.1184 -            iTableLayoutPanel.CellBorderStyle = (cds.ShowBorders ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
 12.1185 +            iTableLayoutPanel.CellBorderStyle = (cds.ShowBorders
 12.1186 +                ? TableLayoutPanelCellBorderStyle.Single
 12.1187 +                : TableLayoutPanelCellBorderStyle.None);
 12.1188  
 12.1189              //Set the proper font to each of our labels
 12.1190              foreach (MarqueeLabel ctrl in iTableLayoutPanel.Controls)
 12.1191 @@ -1170,20 +1216,20 @@
 12.1192              }
 12.1193  
 12.1194              CheckFontHeight();
 12.1195 -			//Check if "run on Windows startup" is enabled
 12.1196 -			checkBoxAutoStart.Checked = iStartupManager.Startup;
 12.1197 -			//
 12.1198 +            //Check if "run on Windows startup" is enabled
 12.1199 +            checkBoxAutoStart.Checked = iStartupManager.Startup;
 12.1200 +            //
 12.1201              checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
 12.1202 -			checkBoxMinimizeToTray.Checked = Properties.Settings.Default.MinimizeToTray;
 12.1203 -			checkBoxStartMinimized.Checked = Properties.Settings.Default.StartMinimized;
 12.1204 +            checkBoxMinimizeToTray.Checked = Properties.Settings.Default.MinimizeToTray;
 12.1205 +            checkBoxStartMinimized.Checked = Properties.Settings.Default.StartMinimized;
 12.1206              iCheckBoxStartIdleClient.Checked = Properties.Settings.Default.StartIdleClient;
 12.1207              labelStartFileName.Text = Properties.Settings.Default.StartFileName;
 12.1208  
 12.1209  
 12.1210              //Try find our drive in our drive list
 12.1211 -            int opticalDriveItemIndex=0;
 12.1212 +            int opticalDriveItemIndex = 0;
 12.1213              bool driveNotFound = true;
 12.1214 -            string opticalDriveToEject=Properties.Settings.Default.OpticalDriveToEject;
 12.1215 +            string opticalDriveToEject = Properties.Settings.Default.OpticalDriveToEject;
 12.1216              foreach (object item in comboBoxOpticalDrives.Items)
 12.1217              {
 12.1218                  if (opticalDriveToEject == item.ToString())
 12.1219 @@ -1209,12 +1255,12 @@
 12.1220              //Mini Display settings
 12.1221              checkBoxReverseScreen.Checked = cds.ReverseScreen;
 12.1222              checkBoxInverseColors.Checked = cds.InverseColors;
 12.1223 -			checkBoxShowVolumeLabel.Checked = cds.ShowVolumeLabel;
 12.1224 +            checkBoxShowVolumeLabel.Checked = cds.ShowVolumeLabel;
 12.1225              checkBoxScaleToFit.Checked = cds.ScaleToFit;
 12.1226              maskedTextBoxMinFontSize.Enabled = cds.ScaleToFit;
 12.1227              labelMinFontSize.Enabled = cds.ScaleToFit;
 12.1228              maskedTextBoxMinFontSize.Text = cds.MinFontSize.ToString();
 12.1229 -			maskedTextBoxScrollingSpeed.Text = cds.ScrollingSpeedInPixelsPerSecond.ToString();
 12.1230 +            maskedTextBoxScrollingSpeed.Text = cds.ScrollingSpeedInPixelsPerSecond.ToString();
 12.1231              comboBoxDisplayType.SelectedIndex = cds.DisplayType;
 12.1232              timer.Interval = cds.TimerInterval;
 12.1233              maskedTextBoxTimerInterval.Text = cds.TimerInterval.ToString();
 12.1234 @@ -1228,29 +1274,29 @@
 12.1235                  //Reflect that in our UI
 12.1236                  StartTimer();
 12.1237  
 12.1238 -				iTableLayoutPanel.Enabled = true;
 12.1239 -				panelDisplay.Enabled = true;
 12.1240 +                iTableLayoutPanel.Enabled = true;
 12.1241 +                panelDisplay.Enabled = true;
 12.1242  
 12.1243                  //Only setup brightness if display is open
 12.1244                  trackBarBrightness.Minimum = iDisplay.MinBrightness();
 12.1245                  trackBarBrightness.Maximum = iDisplay.MaxBrightness();
 12.1246 -				if (cds.Brightness < iDisplay.MinBrightness() || cds.Brightness > iDisplay.MaxBrightness())
 12.1247 -				{
 12.1248 -					//Brightness out of range, this can occur when using auto-detect
 12.1249 -					//Use max brightness instead
 12.1250 -					trackBarBrightness.Value = iDisplay.MaxBrightness();
 12.1251 -					iDisplay.SetBrightness(iDisplay.MaxBrightness());
 12.1252 -				}
 12.1253 -				else
 12.1254 -				{
 12.1255 -					trackBarBrightness.Value = cds.Brightness;
 12.1256 -					iDisplay.SetBrightness(cds.Brightness);
 12.1257 -				}
 12.1258 -
 12.1259 -				//Try compute the steps to something that makes sense
 12.1260 -                trackBarBrightness.LargeChange = Math.Max(1, (iDisplay.MaxBrightness() - iDisplay.MinBrightness()) / 5);
 12.1261 +                if (cds.Brightness < iDisplay.MinBrightness() || cds.Brightness > iDisplay.MaxBrightness())
 12.1262 +                {
 12.1263 +                    //Brightness out of range, this can occur when using auto-detect
 12.1264 +                    //Use max brightness instead
 12.1265 +                    trackBarBrightness.Value = iDisplay.MaxBrightness();
 12.1266 +                    iDisplay.SetBrightness(iDisplay.MaxBrightness());
 12.1267 +                }
 12.1268 +                else
 12.1269 +                {
 12.1270 +                    trackBarBrightness.Value = cds.Brightness;
 12.1271 +                    iDisplay.SetBrightness(cds.Brightness);
 12.1272 +                }
 12.1273 +
 12.1274 +                //Try compute the steps to something that makes sense
 12.1275 +                trackBarBrightness.LargeChange = Math.Max(1, (iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
 12.1276                  trackBarBrightness.SmallChange = 1;
 12.1277 -                
 12.1278 +
 12.1279                  //
 12.1280                  buttonFill.Enabled = true;
 12.1281                  buttonClear.Enabled = true;
 12.1282 @@ -1282,18 +1328,18 @@
 12.1283                      buttonHideClock.Enabled = false;
 12.1284                  }
 12.1285  
 12.1286 -				
 12.1287 -				//Check if Volume Label is supported. To date only MDM166AA supports that crap :)
 12.1288 -				checkBoxShowVolumeLabel.Enabled = iDisplay.IconCount(MiniDisplay.IconType.VolumeLabel)>0;
 12.1289 -
 12.1290 -				if (cds.ShowVolumeLabel)
 12.1291 -				{
 12.1292 +
 12.1293 +                //Check if Volume Label is supported. To date only MDM166AA supports that crap :)
 12.1294 +                checkBoxShowVolumeLabel.Enabled = iDisplay.IconCount(MiniDisplay.IconType.VolumeLabel) > 0;
 12.1295 +
 12.1296 +                if (cds.ShowVolumeLabel)
 12.1297 +                {
 12.1298                      iDisplay.SetIconOn(MiniDisplay.IconType.VolumeLabel);
 12.1299 -				}
 12.1300 -				else
 12.1301 -				{
 12.1302 +                }
 12.1303 +                else
 12.1304 +                {
 12.1305                      iDisplay.SetIconOff(MiniDisplay.IconType.VolumeLabel);
 12.1306 -				}
 12.1307 +                }
 12.1308              }
 12.1309              else
 12.1310              {
 12.1311 @@ -1303,12 +1349,12 @@
 12.1312                  //In debug start our timer even if we don't have a display connection
 12.1313                  StartTimer();
 12.1314  #else
 12.1315 -                //In production environment we don't need our timer if no display connection
 12.1316 +    //In production environment we don't need our timer if no display connection
 12.1317                  StopTimer();
 12.1318  #endif
 12.1319                  checkBoxShowVolumeLabel.Enabled = false;
 12.1320 -				iTableLayoutPanel.Enabled = false;
 12.1321 -				panelDisplay.Enabled = false;
 12.1322 +                iTableLayoutPanel.Enabled = false;
 12.1323 +                panelDisplay.Enabled = false;
 12.1324                  buttonFill.Enabled = false;
 12.1325                  buttonClear.Enabled = false;
 12.1326                  buttonOpen.Enabled = true;
 12.1327 @@ -1325,22 +1371,24 @@
 12.1328          }
 12.1329  
 12.1330  
 12.1331 -		/// <summary>
 12.1332 -		/// 
 12.1333 -		/// </summary>
 12.1334 -		/// <param name="sender"></param>
 12.1335 -		/// <param name="e"></param>
 12.1336 -		private void checkBoxShowVolumeLabel_CheckedChanged(object sender, EventArgs e)
 12.1337 -		{
 12.1338 -			cds.ShowVolumeLabel = checkBoxShowVolumeLabel.Checked;
 12.1339 -			Properties.Settings.Default.Save();
 12.1340 -			UpdateStatus();
 12.1341 -		}
 12.1342 +        /// <summary>
 12.1343 +        /// 
 12.1344 +        /// </summary>
 12.1345 +        /// <param name="sender"></param>
 12.1346 +        /// <param name="e"></param>
 12.1347 +        private void checkBoxShowVolumeLabel_CheckedChanged(object sender, EventArgs e)
 12.1348 +        {
 12.1349 +            cds.ShowVolumeLabel = checkBoxShowVolumeLabel.Checked;
 12.1350 +            Properties.Settings.Default.Save();
 12.1351 +            UpdateStatus();
 12.1352 +        }
 12.1353  
 12.1354          private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
 12.1355          {
 12.1356              //Save our show borders setting
 12.1357 -            iTableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
 12.1358 +            iTableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked
 12.1359 +                ? TableLayoutPanelCellBorderStyle.Single
 12.1360 +                : TableLayoutPanelCellBorderStyle.None);
 12.1361              cds.ShowBorders = checkBoxShowBorders.Checked;
 12.1362              Properties.Settings.Default.Save();
 12.1363              CheckFontHeight();
 12.1364 @@ -1353,20 +1401,20 @@
 12.1365              Properties.Settings.Default.Save();
 12.1366          }
 12.1367  
 12.1368 -		private void checkBoxMinimizeToTray_CheckedChanged(object sender, EventArgs e)
 12.1369 -		{
 12.1370 -			//Save our "Minimize to tray" setting
 12.1371 -			Properties.Settings.Default.MinimizeToTray = checkBoxMinimizeToTray.Checked;
 12.1372 -			Properties.Settings.Default.Save();
 12.1373 -
 12.1374 -		}
 12.1375 -
 12.1376 -		private void checkBoxStartMinimized_CheckedChanged(object sender, EventArgs e)
 12.1377 -		{
 12.1378 -			//Save our "Start minimized" setting
 12.1379 -			Properties.Settings.Default.StartMinimized = checkBoxStartMinimized.Checked;
 12.1380 -			Properties.Settings.Default.Save();
 12.1381 -		}
 12.1382 +        private void checkBoxMinimizeToTray_CheckedChanged(object sender, EventArgs e)
 12.1383 +        {
 12.1384 +            //Save our "Minimize to tray" setting
 12.1385 +            Properties.Settings.Default.MinimizeToTray = checkBoxMinimizeToTray.Checked;
 12.1386 +            Properties.Settings.Default.Save();
 12.1387 +
 12.1388 +        }
 12.1389 +
 12.1390 +        private void checkBoxStartMinimized_CheckedChanged(object sender, EventArgs e)
 12.1391 +        {
 12.1392 +            //Save our "Start minimized" setting
 12.1393 +            Properties.Settings.Default.StartMinimized = checkBoxStartMinimized.Checked;
 12.1394 +            Properties.Settings.Default.Save();
 12.1395 +        }
 12.1396  
 12.1397          private void checkBoxStartIdleClient_CheckedChanged(object sender, EventArgs e)
 12.1398          {
 12.1399 @@ -1375,9 +1423,9 @@
 12.1400          }
 12.1401  
 12.1402          private void checkBoxAutoStart_CheckedChanged(object sender, EventArgs e)
 12.1403 -		{
 12.1404 -			iStartupManager.Startup = checkBoxAutoStart.Checked;
 12.1405 -		}
 12.1406 +        {
 12.1407 +            iStartupManager.Startup = checkBoxAutoStart.Checked;
 12.1408 +        }
 12.1409  
 12.1410  
 12.1411          private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
 12.1412 @@ -1419,8 +1467,8 @@
 12.1413          private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 12.1414          {
 12.1415              iCecManager.Stop();
 12.1416 -			iNetworkManager.Dispose();
 12.1417 -			CloseDisplayConnection();
 12.1418 +            iNetworkManager.Dispose();
 12.1419 +            CloseDisplayConnection();
 12.1420              StopServer();
 12.1421              e.Cancel = iClosing;
 12.1422          }
 12.1423 @@ -1429,11 +1477,12 @@
 12.1424          {
 12.1425              iServiceHost = new ServiceHost
 12.1426                  (
 12.1427 -                    typeof(Session),
 12.1428 -                    new Uri[] { new Uri("net.tcp://localhost:8001/") }
 12.1429 +                typeof(Session),
 12.1430 +                new Uri[] {new Uri("net.tcp://localhost:8001/")}
 12.1431                  );
 12.1432  
 12.1433 -            iServiceHost.AddServiceEndpoint(typeof(IService), new NetTcpBinding(SecurityMode.None, true), "DisplayService");
 12.1434 +            iServiceHost.AddServiceEndpoint(typeof(IService), new NetTcpBinding(SecurityMode.None, true),
 12.1435 +                "DisplayService");
 12.1436              iServiceHost.Open();
 12.1437          }
 12.1438  
 12.1439 @@ -1447,7 +1496,9 @@
 12.1440              }
 12.1441              else if (iClosing)
 12.1442              {
 12.1443 -                if (MessageBox.Show("Force exit?", "Waiting for clients...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
 12.1444 +                if (
 12.1445 +                    MessageBox.Show("Force exit?", "Waiting for clients...", MessageBoxButtons.YesNo,
 12.1446 +                        MessageBoxIcon.Warning) == DialogResult.Yes)
 12.1447                  {
 12.1448                      iClosing = false; //We make sure we force close if asked twice
 12.1449                  }
 12.1450 @@ -1471,7 +1522,7 @@
 12.1451                      try
 12.1452                      {
 12.1453                          Trace.TraceInformation("BroadcastCloseEvent - " + client.Key);
 12.1454 -                        client.Value.Callback.OnCloseOrder(/*eventData*/);
 12.1455 +                        client.Value.Callback.OnCloseOrder( /*eventData*/);
 12.1456                      }
 12.1457                      catch (Exception ex)
 12.1458                      {
 12.1459 @@ -1485,37 +1536,39 @@
 12.1460                  foreach (var client in inactiveClients)
 12.1461                  {
 12.1462                      iClients.Remove(client);
 12.1463 -                    Program.iMainForm.iTreeViewClients.Nodes.Remove(Program.iMainForm.iTreeViewClients.Nodes.Find(client, false)[0]);
 12.1464 +                    Program.iMainForm.iTreeViewClients.Nodes.Remove(
 12.1465 +                        Program.iMainForm.iTreeViewClients.Nodes.Find(client, false)[0]);
 12.1466                  }
 12.1467              }
 12.1468  
 12.1469 -			if (iClients.Count==0)
 12.1470 -			{
 12.1471 -				ClearLayout();
 12.1472 -			}
 12.1473 +            if (iClients.Count == 0)
 12.1474 +            {
 12.1475 +                ClearLayout();
 12.1476 +            }
 12.1477          }
 12.1478  
 12.1479 -		/// <summary>
 12.1480 -		/// Just remove all our fields.
 12.1481 -		/// </summary>
 12.1482 -		private void ClearLayout()
 12.1483 -		{
 12.1484 -			iTableLayoutPanel.Controls.Clear();
 12.1485 -			iTableLayoutPanel.RowStyles.Clear();
 12.1486 -			iTableLayoutPanel.ColumnStyles.Clear();
 12.1487 -			iCurrentClientData = null;
 12.1488 -		}
 12.1489 -
 12.1490 -		/// <summary>
 12.1491 -		/// Just launch a demo client.
 12.1492 -		/// </summary>
 12.1493 -		private void StartNewClient(string aTopText = "", string aBottomText = "")
 12.1494 -		{
 12.1495 -			Thread clientThread = new Thread(SharpDisplayClient.Program.MainWithParams);
 12.1496 -			SharpDisplayClient.StartParams myParams = new SharpDisplayClient.StartParams(new Point(this.Right, this.Top),aTopText,aBottomText);
 12.1497 -			clientThread.Start(myParams);
 12.1498 -			BringToFront();
 12.1499 -		}
 12.1500 +        /// <summary>
 12.1501 +        /// Just remove all our fields.
 12.1502 +        /// </summary>
 12.1503 +        private void ClearLayout()
 12.1504 +        {
 12.1505 +            iTableLayoutPanel.Controls.Clear();
 12.1506 +            iTableLayoutPanel.RowStyles.Clear();
 12.1507 +            iTableLayoutPanel.ColumnStyles.Clear();
 12.1508 +            iCurrentClientData = null;
 12.1509 +        }
 12.1510 +
 12.1511 +        /// <summary>
 12.1512 +        /// Just launch a demo client.
 12.1513 +        /// </summary>
 12.1514 +        private void StartNewClient(string aTopText = "", string aBottomText = "")
 12.1515 +        {
 12.1516 +            Thread clientThread = new Thread(SharpDisplayClient.Program.MainWithParams);
 12.1517 +            SharpDisplayClient.StartParams myParams = new SharpDisplayClient.StartParams(
 12.1518 +                new Point(this.Right, this.Top), aTopText, aBottomText);
 12.1519 +            clientThread.Start(myParams);
 12.1520 +            BringToFront();
 12.1521 +        }
 12.1522  
 12.1523          /// <summary>
 12.1524          /// Just launch our idle client.
 12.1525 @@ -1523,7 +1576,8 @@
 12.1526          private void StartIdleClient(string aTopText = "", string aBottomText = "")
 12.1527          {
 12.1528              Thread clientThread = new Thread(SharpDisplayIdleClient.Program.MainWithParams);
 12.1529 -            SharpDisplayIdleClient.StartParams myParams = new SharpDisplayIdleClient.StartParams(new Point(this.Right, this.Top), aTopText, aBottomText);
 12.1530 +            SharpDisplayIdleClient.StartParams myParams =
 12.1531 +                new SharpDisplayIdleClient.StartParams(new Point(this.Right, this.Top), aTopText, aBottomText);
 12.1532              clientThread.Start(myParams);
 12.1533              BringToFront();
 12.1534          }
 12.1535 @@ -1531,7 +1585,7 @@
 12.1536  
 12.1537          private void buttonStartClient_Click(object sender, EventArgs e)
 12.1538          {
 12.1539 -			StartNewClient();
 12.1540 +            StartNewClient();
 12.1541          }
 12.1542  
 12.1543          private void buttonSuspend_Click(object sender, EventArgs e)
 12.1544 @@ -1587,13 +1641,13 @@
 12.1545              }
 12.1546  
 12.1547              //If the selected node is the root node of a client then switch to it
 12.1548 -            string sessionId=e.Node.Nodes[0].Text; //First child of a root node is the sessionId
 12.1549 +            string sessionId = e.Node.Nodes[0].Text; //First child of a root node is the sessionId
 12.1550              if (iClients.ContainsKey(sessionId)) //Check that's actually what we are looking at
 12.1551              {
 12.1552                  //We have a valid session just switch to that client
 12.1553 -                SetCurrentClient(sessionId,true);
 12.1554 +                SetCurrentClient(sessionId, true);
 12.1555              }
 12.1556 -            
 12.1557 +
 12.1558          }
 12.1559  
 12.1560  
 12.1561 @@ -1608,7 +1662,7 @@
 12.1562              {
 12.1563                  //Not in the proper thread, invoke ourselves
 12.1564                  AddClientDelegate d = new AddClientDelegate(AddClientThreadSafe);
 12.1565 -                this.Invoke(d, new object[] { aSessionId, aCallback });
 12.1566 +                this.Invoke(d, new object[] {aSessionId, aCallback});
 12.1567              }
 12.1568              else
 12.1569              {
 12.1570 @@ -1650,7 +1704,7 @@
 12.1571              {
 12.1572                  //Not in the proper thread, invoke ourselves
 12.1573                  RemoveClientDelegate d = new RemoveClientDelegate(RemoveClientThreadSafe);
 12.1574 -                this.Invoke(d, new object[] { aSessionId });
 12.1575 +                this.Invoke(d, new object[] {aSessionId});
 12.1576              }
 12.1577              else
 12.1578              {
 12.1579 @@ -1659,7 +1713,8 @@
 12.1580                  if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
 12.1581                  {
 12.1582                      Program.iMainForm.iClients.Remove(aSessionId);
 12.1583 -                    Program.iMainForm.iTreeViewClients.Nodes.Remove(Program.iMainForm.iTreeViewClients.Nodes.Find(aSessionId, false)[0]);
 12.1584 +                    Program.iMainForm.iTreeViewClients.Nodes.Remove(
 12.1585 +                        Program.iMainForm.iTreeViewClients.Nodes.Find(aSessionId, false)[0]);
 12.1586                      //Update recording status too whenever a client is removed
 12.1587                      UpdateRecordingNotification();
 12.1588                  }
 12.1589 @@ -1670,26 +1725,26 @@
 12.1590                      iCurrentClientData = null;
 12.1591                      //Find the client with the highest priority and set it as current
 12.1592                      ClientData newCurrentClient = FindHighestPriorityClient();
 12.1593 -                    if (newCurrentClient!=null)
 12.1594 +                    if (newCurrentClient != null)
 12.1595                      {
 12.1596                          SetCurrentClient(newCurrentClient.SessionId, true);
 12.1597 -                    }                    
 12.1598 +                    }
 12.1599                  }
 12.1600  
 12.1601                  if (iClients.Count == 0)
 12.1602 -				{
 12.1603 -					//Clear our screen when last client disconnects
 12.1604 -					ClearLayout();
 12.1605 -
 12.1606 -					if (iClosing)
 12.1607 -					{
 12.1608 -						//We were closing our form
 12.1609 -						//All clients are now closed
 12.1610 -						//Just resume our close operation
 12.1611 -						iClosing = false;
 12.1612 -						Close();
 12.1613 -					}
 12.1614 -				}
 12.1615 +                {
 12.1616 +                    //Clear our screen when last client disconnects
 12.1617 +                    ClearLayout();
 12.1618 +
 12.1619 +                    if (iClosing)
 12.1620 +                    {
 12.1621 +                        //We were closing our form
 12.1622 +                        //All clients are now closed
 12.1623 +                        //Just resume our close operation
 12.1624 +                        iClosing = false;
 12.1625 +                        Close();
 12.1626 +                    }
 12.1627 +                }
 12.1628              }
 12.1629          }
 12.1630  
 12.1631 @@ -1704,7 +1759,7 @@
 12.1632              {
 12.1633                  //Not in the proper thread, invoke ourselves
 12.1634                  SetLayoutDelegate d = new SetLayoutDelegate(SetClientLayoutThreadSafe);
 12.1635 -                this.Invoke(d, new object[] { aSessionId, aLayout });
 12.1636 +                this.Invoke(d, new object[] {aSessionId, aLayout});
 12.1637              }
 12.1638              else
 12.1639              {
 12.1640 @@ -1743,7 +1798,7 @@
 12.1641              {
 12.1642                  //Not in the proper thread, invoke ourselves
 12.1643                  SetFieldDelegate d = new SetFieldDelegate(SetClientFieldThreadSafe);
 12.1644 -                this.Invoke(d, new object[] { aSessionId, aField });
 12.1645 +                this.Invoke(d, new object[] {aSessionId, aField});
 12.1646              }
 12.1647              else
 12.1648              {
 12.1649 @@ -1762,7 +1817,7 @@
 12.1650          /// <param name="aSessionId"></param>
 12.1651          /// <param name="aField"></param>
 12.1652          private void SetClientField(string aSessionId, DataField aField)
 12.1653 -        {   
 12.1654 +        {
 12.1655              //TODO: should check if the field actually changed?
 12.1656  
 12.1657              ClientData client = iClients[aSessionId];
 12.1658 @@ -1796,22 +1851,22 @@
 12.1659                  //If we are updating a field in our current client we need to update it in our panel
 12.1660                  if (aSessionId == iCurrentClientSessionId)
 12.1661                  {
 12.1662 -                    Control ctrl=iTableLayoutPanel.GetControlFromPosition(tableField.Column, tableField.Row);
 12.1663 +                    Control ctrl = iTableLayoutPanel.GetControlFromPosition(tableField.Column, tableField.Row);
 12.1664                      if (aField.IsTextField && ctrl is MarqueeLabel)
 12.1665                      {
 12.1666 -                        TextField textField=(TextField)aField;
 12.1667 +                        TextField textField = (TextField) aField;
 12.1668                          //Text field control already in place, just change the text
 12.1669 -                        MarqueeLabel label = (MarqueeLabel)ctrl;
 12.1670 +                        MarqueeLabel label = (MarqueeLabel) ctrl;
 12.1671                          contentChanged = (label.Text != textField.Text || label.TextAlign != textField.Alignment);
 12.1672                          label.Text = textField.Text;
 12.1673                          label.TextAlign = textField.Alignment;
 12.1674                      }
 12.1675                      else if (aField.IsBitmapField && ctrl is PictureBox)
 12.1676                      {
 12.1677 -                        BitmapField bitmapField = (BitmapField)aField;
 12.1678 +                        BitmapField bitmapField = (BitmapField) aField;
 12.1679                          contentChanged = true; //TODO: Bitmap comp or should we leave that to clients?
 12.1680                          //Bitmap field control already in place just change the bitmap
 12.1681 -                        PictureBox pictureBox = (PictureBox)ctrl;
 12.1682 +                        PictureBox pictureBox = (PictureBox) ctrl;
 12.1683                          pictureBox.Image = bitmapField.Bitmap;
 12.1684                      }
 12.1685                      else
 12.1686 @@ -1821,7 +1876,7 @@
 12.1687                  }
 12.1688              }
 12.1689              else
 12.1690 -            {                
 12.1691 +            {
 12.1692                  layoutChanged = true;
 12.1693              }
 12.1694  
 12.1695 @@ -1864,7 +1919,7 @@
 12.1696              {
 12.1697                  //Not in the proper thread, invoke ourselves
 12.1698                  SetFieldsDelegate d = new SetFieldsDelegate(SetClientFieldsThreadSafe);
 12.1699 -                this.Invoke(d, new object[] { aSessionId, aFields });
 12.1700 +                this.Invoke(d, new object[] {aSessionId, aFields});
 12.1701              }
 12.1702              else
 12.1703              {
 12.1704 @@ -1912,7 +1967,7 @@
 12.1705              {
 12.1706                  //Not in the proper thread, invoke ourselves
 12.1707                  SetClientNameDelegate d = new SetClientNameDelegate(SetClientNameThreadSafe);
 12.1708 -                this.Invoke(d, new object[] { aSessionId, aName });
 12.1709 +                this.Invoke(d, new object[] {aSessionId, aName});
 12.1710              }
 12.1711              else
 12.1712              {
 12.1713 @@ -1936,7 +1991,7 @@
 12.1714              {
 12.1715                  //Not in the proper thread, invoke ourselves
 12.1716                  SetClientPriorityDelegate d = new SetClientPriorityDelegate(SetClientPriorityThreadSafe);
 12.1717 -                this.Invoke(d, new object[] { aSessionId, aPriority });
 12.1718 +                this.Invoke(d, new object[] {aSessionId, aPriority});
 12.1719              }
 12.1720              else
 12.1721              {
 12.1722 @@ -1951,7 +2006,7 @@
 12.1723                      UpdateClientTreeViewNode(client);
 12.1724                      //Change our current client as per new priority
 12.1725                      ClientData newCurrentClient = FindHighestPriorityClient();
 12.1726 -                    if (newCurrentClient!=null)
 12.1727 +                    if (newCurrentClient != null)
 12.1728                      {
 12.1729                          SetCurrentClient(newCurrentClient.SessionId);
 12.1730                      }
 12.1731 @@ -1967,7 +2022,7 @@
 12.1732          /// <returns></returns>
 12.1733          public static string Truncate(string value, int maxChars)
 12.1734          {
 12.1735 -            return value.Length <= maxChars ? value : value.Substring(0, maxChars-3) + "...";
 12.1736 +            return value.Length <= maxChars ? value : value.Substring(0, maxChars - 3) + "...";
 12.1737          }
 12.1738  
 12.1739          /// <summary>
 12.1740 @@ -1977,12 +2032,12 @@
 12.1741          {
 12.1742              //Go through each 
 12.1743              bool activeRecording = false;
 12.1744 -            string text="";
 12.1745 -            RecordingField recField=new RecordingField();
 12.1746 +            string text = "";
 12.1747 +            RecordingField recField = new RecordingField();
 12.1748              foreach (var client in iClients)
 12.1749              {
 12.1750 -                RecordingField rec=(RecordingField)client.Value.FindSameFieldAs(recField);
 12.1751 -                if (rec!=null && rec.IsActive)
 12.1752 +                RecordingField rec = (RecordingField) client.Value.FindSameFieldAs(recField);
 12.1753 +                if (rec != null && rec.IsActive)
 12.1754                  {
 12.1755                      activeRecording = true;
 12.1756                      //Don't break cause we are collecting the names/texts.
 12.1757 @@ -1995,23 +2050,23 @@
 12.1758                          //Not text for that recording, use client name instead
 12.1759                          text += client.Value.Name + " recording\n";
 12.1760                      }
 12.1761 -                    
 12.1762 +
 12.1763                  }
 12.1764              }
 12.1765  
 12.1766              //Update our text no matter what, can't have more than 63 characters otherwise it throws an exception.
 12.1767 -            iRecordingNotification.Text = Truncate(text,63);
 12.1768 +            iRecordingNotification.Text = Truncate(text, 63);
 12.1769  
 12.1770              //Change visibility of notification if needed
 12.1771              if (iRecordingNotification.Visible != activeRecording)
 12.1772 -            {                
 12.1773 +            {
 12.1774                  iRecordingNotification.Visible = activeRecording;
 12.1775                  //Assuming the notification icon is in sync with our display icon
 12.1776                  //Take care of our REC icon
 12.1777                  if (iDisplay.IsOpen())
 12.1778                  {
 12.1779                      iDisplay.SetIconOnOff(MiniDisplay.IconType.Recording, activeRecording);
 12.1780 -                }                
 12.1781 +                }
 12.1782              }
 12.1783          }
 12.1784  
 12.1785 @@ -2035,7 +2090,7 @@
 12.1786              //Check that our client node already exists
 12.1787              //Get our client root node using its key which is our session ID
 12.1788              TreeNode[] nodes = iTreeViewClients.Nodes.Find(aClient.SessionId, false);
 12.1789 -            if (nodes.Count()>0)
 12.1790 +            if (nodes.Count() > 0)
 12.1791              {
 12.1792                  //We already have a node for that client
 12.1793                  node = nodes[0];
 12.1794 @@ -2078,7 +2133,7 @@
 12.1795                      {
 12.1796                          if (field.IsTextField)
 12.1797                          {
 12.1798 -                            TextField textField = (TextField)field;
 12.1799 +                            TextField textField = (TextField) field;
 12.1800                              textsRoot.Nodes.Add(new TreeNode("[Text]" + textField.Text));
 12.1801                          }
 12.1802                          else if (field.IsBitmapField)
 12.1803 @@ -2087,7 +2142,7 @@
 12.1804                          }
 12.1805                          else if (field.IsRecordingField)
 12.1806                          {
 12.1807 -                            RecordingField recordingField = (RecordingField)field;
 12.1808 +                            RecordingField recordingField = (RecordingField) field;
 12.1809                              textsRoot.Nodes.Add(new TreeNode("[Recording]" + recordingField.IsActive));
 12.1810                          }
 12.1811                      }
 12.1812 @@ -2105,7 +2160,7 @@
 12.1813              foreach (RowStyle rowStyle in iTableLayoutPanel.RowStyles)
 12.1814              {
 12.1815                  rowStyle.SizeType = SizeType.Percent;
 12.1816 -                rowStyle.Height = 100 / iTableLayoutPanel.RowCount;
 12.1817 +                rowStyle.Height = 100/iTableLayoutPanel.RowCount;
 12.1818              }
 12.1819          }
 12.1820  
 12.1821 @@ -2119,11 +2174,11 @@
 12.1822          {
 12.1823              Debug.Print("UpdateTableLayoutPanel");
 12.1824  
 12.1825 -			if (aClient == null)
 12.1826 -			{
 12.1827 -				//Just drop it
 12.1828 -				return;
 12.1829 -			}
 12.1830 +            if (aClient == null)
 12.1831 +            {
 12.1832 +                //Just drop it
 12.1833 +                return;
 12.1834 +            }
 12.1835  
 12.1836  
 12.1837              TableLayout layout = aClient.Layout;
 12.1838 @@ -2177,7 +2232,7 @@
 12.1839                      continue;
 12.1840                  }
 12.1841  
 12.1842 -                TableField tableField = (TableField)field;
 12.1843 +                TableField tableField = (TableField) field;
 12.1844  
 12.1845                  //Create a control corresponding to the field specified for that cell
 12.1846                  Control control = CreateControlForDataField(tableField);
 12.1847 @@ -2199,7 +2254,7 @@
 12.1848          /// <param name="aField"></param>
 12.1849          private Control CreateControlForDataField(DataField aField)
 12.1850          {
 12.1851 -            Control control=null;
 12.1852 +            Control control = null;
 12.1853              if (aField.IsTextField)
 12.1854              {
 12.1855                  MarqueeLabel label = new SharpDisplayManager.MarqueeLabel();
 12.1856 @@ -2219,7 +2274,7 @@
 12.1857                  //control.TabIndex = 2;
 12.1858                  label.Font = cds.Font;
 12.1859  
 12.1860 -                TextField field = (TextField)aField;
 12.1861 +                TextField field = (TextField) aField;
 12.1862                  label.TextAlign = field.Alignment;
 12.1863                  label.UseCompatibleTextRendering = true;
 12.1864                  label.Text = field.Text;
 12.1865 @@ -2237,7 +2292,7 @@
 12.1866                  picture.Margin = new System.Windows.Forms.Padding(0);
 12.1867                  picture.Name = "pictureBox" + aField;
 12.1868                  //Set our image
 12.1869 -                BitmapField field = (BitmapField)aField;
 12.1870 +                BitmapField field = (BitmapField) aField;
 12.1871                  picture.Image = field.Bitmap;
 12.1872                  //
 12.1873                  control = picture;
 12.1874 @@ -2247,20 +2302,20 @@
 12.1875              return control;
 12.1876          }
 12.1877  
 12.1878 -		/// <summary>
 12.1879 -		/// Called when the user selected a new display type.
 12.1880 -		/// </summary>
 12.1881 -		/// <param name="sender"></param>
 12.1882 -		/// <param name="e"></param>
 12.1883 +        /// <summary>
 12.1884 +        /// Called when the user selected a new display type.
 12.1885 +        /// </summary>
 12.1886 +        /// <param name="sender"></param>
 12.1887 +        /// <param name="e"></param>
 12.1888          private void comboBoxDisplayType_SelectedIndexChanged(object sender, EventArgs e)
 12.1889          {
 12.1890 -			//Store the selected display type in our settings
 12.1891 +            //Store the selected display type in our settings
 12.1892              Properties.Settings.Default.CurrentDisplayIndex = comboBoxDisplayType.SelectedIndex;
 12.1893              cds.DisplayType = comboBoxDisplayType.SelectedIndex;
 12.1894              Properties.Settings.Default.Save();
 12.1895  
 12.1896 -			//Try re-opening the display connection if we were already connected.
 12.1897 -			//Otherwise just update our status to reflect display type change.
 12.1898 +            //Try re-opening the display connection if we were already connected.
 12.1899 +            //Otherwise just update our status to reflect display type change.
 12.1900              if (iDisplay.IsOpen())
 12.1901              {
 12.1902                  OpenDisplayConnection();
 12.1903 @@ -2296,39 +2351,39 @@
 12.1904                  {
 12.1905                      cds.MinFontSize = minFontSize;
 12.1906                      Properties.Settings.Default.Save();
 12.1907 -					//We need to recreate our layout for that change to take effect
 12.1908 -					UpdateTableLayoutPanel(iCurrentClientData);
 12.1909 +                    //We need to recreate our layout for that change to take effect
 12.1910 +                    UpdateTableLayoutPanel(iCurrentClientData);
 12.1911                  }
 12.1912              }
 12.1913          }
 12.1914  
 12.1915  
 12.1916 -		private void maskedTextBoxScrollingSpeed_TextChanged(object sender, EventArgs e)
 12.1917 -		{
 12.1918 -			if (maskedTextBoxScrollingSpeed.Text != "")
 12.1919 -			{
 12.1920 -				int scrollingSpeed = Convert.ToInt32(maskedTextBoxScrollingSpeed.Text);
 12.1921 -
 12.1922 -				if (scrollingSpeed > 0)
 12.1923 -				{
 12.1924 -					cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed;
 12.1925 -					Properties.Settings.Default.Save();
 12.1926 -					//We need to recreate our layout for that change to take effect
 12.1927 -					UpdateTableLayoutPanel(iCurrentClientData);
 12.1928 -				}
 12.1929 -			}
 12.1930 -		}
 12.1931 +        private void maskedTextBoxScrollingSpeed_TextChanged(object sender, EventArgs e)
 12.1932 +        {
 12.1933 +            if (maskedTextBoxScrollingSpeed.Text != "")
 12.1934 +            {
 12.1935 +                int scrollingSpeed = Convert.ToInt32(maskedTextBoxScrollingSpeed.Text);
 12.1936 +
 12.1937 +                if (scrollingSpeed > 0)
 12.1938 +                {
 12.1939 +                    cds.ScrollingSpeedInPixelsPerSecond = scrollingSpeed;
 12.1940 +                    Properties.Settings.Default.Save();
 12.1941 +                    //We need to recreate our layout for that change to take effect
 12.1942 +                    UpdateTableLayoutPanel(iCurrentClientData);
 12.1943 +                }
 12.1944 +            }
 12.1945 +        }
 12.1946  
 12.1947          private void textBoxScrollLoopSeparator_TextChanged(object sender, EventArgs e)
 12.1948          {
 12.1949              cds.Separator = textBoxScrollLoopSeparator.Text;
 12.1950              Properties.Settings.Default.Save();
 12.1951  
 12.1952 -			//Update our text fields
 12.1953 -			foreach (MarqueeLabel ctrl in iTableLayoutPanel.Controls)
 12.1954 -			{
 12.1955 -				ctrl.Separator = cds.Separator;
 12.1956 -			}
 12.1957 +            //Update our text fields
 12.1958 +            foreach (MarqueeLabel ctrl in iTableLayoutPanel.Controls)
 12.1959 +            {
 12.1960 +                ctrl.Separator = cds.Separator;
 12.1961 +            }
 12.1962  
 12.1963          }
 12.1964  
 12.1965 @@ -2344,12 +2399,12 @@
 12.1966  
 12.1967          private void buttonShowClock_Click(object sender, EventArgs e)
 12.1968          {
 12.1969 -			ShowClock();
 12.1970 +            ShowClock();
 12.1971          }
 12.1972  
 12.1973          private void buttonHideClock_Click(object sender, EventArgs e)
 12.1974          {
 12.1975 -			HideClock();
 12.1976 +            HideClock();
 12.1977          }
 12.1978  
 12.1979          private void buttonUpdate_Click(object sender, EventArgs e)
 12.1980 @@ -2357,39 +2412,39 @@
 12.1981              InstallUpdateSyncWithInfo();
 12.1982          }
 12.1983  
 12.1984 -		/// <summary>
 12.1985 -		/// 
 12.1986 -		/// </summary>
 12.1987 -		void ShowClock()
 12.1988 -		{
 12.1989 -			if (!iDisplay.IsOpen())
 12.1990 -			{
 12.1991 -				return;
 12.1992 -			}
 12.1993 -
 12.1994 -			//Devices like MDM166AA don't support windowing and frame rendering must be stopped while showing our clock
 12.1995 -			iSkipFrameRendering = true;
 12.1996 -			//Clear our screen 
 12.1997 -			iDisplay.Clear();
 12.1998 -			iDisplay.SwapBuffers();
 12.1999 -			//Then show our clock
 12.2000 -			iDisplay.ShowClock();
 12.2001 -		}
 12.2002 -
 12.2003 -		/// <summary>
 12.2004 -		/// 
 12.2005 -		/// </summary>
 12.2006 -		void HideClock()
 12.2007 -		{
 12.2008 -			if (!iDisplay.IsOpen())
 12.2009 -			{
 12.2010 -				return;
 12.2011 -			}
 12.2012 -
 12.2013 -			//Devices like MDM166AA don't support windowing and frame rendering must be stopped while showing our clock
 12.2014 -			iSkipFrameRendering = false;
 12.2015 -			iDisplay.HideClock();
 12.2016 -		}
 12.2017 +        /// <summary>
 12.2018 +        /// 
 12.2019 +        /// </summary>
 12.2020 +        void ShowClock()
 12.2021 +        {
 12.2022 +            if (!iDisplay.IsOpen())
 12.2023 +            {
 12.2024 +                return;
 12.2025 +            }
 12.2026 +
 12.2027 +            //Devices like MDM166AA don't support windowing and frame rendering must be stopped while showing our clock
 12.2028 +            iSkipFrameRendering = true;
 12.2029 +            //Clear our screen 
 12.2030 +            iDisplay.Clear();
 12.2031 +            iDisplay.SwapBuffers();
 12.2032 +            //Then show our clock
 12.2033 +            iDisplay.ShowClock();
 12.2034 +        }
 12.2035 +
 12.2036 +        /// <summary>
 12.2037 +        /// 
 12.2038 +        /// </summary>
 12.2039 +        void HideClock()
 12.2040 +        {
 12.2041 +            if (!iDisplay.IsOpen())
 12.2042 +            {
 12.2043 +                return;
 12.2044 +            }
 12.2045 +
 12.2046 +            //Devices like MDM166AA don't support windowing and frame rendering must be stopped while showing our clock
 12.2047 +            iSkipFrameRendering = false;
 12.2048 +            iDisplay.HideClock();
 12.2049 +        }
 12.2050  
 12.2051          private void InstallUpdateSyncWithInfo()
 12.2052          {
 12.2053 @@ -2406,125 +2461,135 @@
 12.2054                  }
 12.2055                  catch (DeploymentDownloadException dde)
 12.2056                  {
 12.2057 -                    MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
 12.2058 +                    MessageBox.Show(
 12.2059 +                        "The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " +
 12.2060 +                        dde.Message);
 12.2061                      return;
 12.2062                  }
 12.2063                  catch (InvalidDeploymentException ide)
 12.2064                  {
 12.2065 -                    MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
 12.2066 +                    MessageBox.Show(
 12.2067 +                        "Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " +
 12.2068 +                        ide.Message);
 12.2069                      return;
 12.2070                  }
 12.2071                  catch (InvalidOperationException ioe)
 12.2072                  {
 12.2073 -                    MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
 12.2074 +                    MessageBox.Show(
 12.2075 +                        "This application cannot be updated. It is likely not a ClickOnce application. Error: " +
 12.2076 +                        ioe.Message);
 12.2077                      return;
 12.2078                  }
 12.2079  
 12.2080 -				if (info.UpdateAvailable)
 12.2081 -				{
 12.2082 -					Boolean doUpdate = true;
 12.2083 -
 12.2084 -					if (!info.IsUpdateRequired)
 12.2085 -					{
 12.2086 -						DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel);
 12.2087 -						if (!(DialogResult.OK == dr))
 12.2088 -						{
 12.2089 -							doUpdate = false;
 12.2090 -						}
 12.2091 -					}
 12.2092 -					else
 12.2093 -					{
 12.2094 -						// Display a message that the application MUST reboot. Display the minimum required version.
 12.2095 -						MessageBox.Show("This application has detected a mandatory update from your current " +
 12.2096 -							"version to version " + info.MinimumRequiredVersion.ToString() +
 12.2097 -							". The application will now install the update and restart.",
 12.2098 -							"Update Available", MessageBoxButtons.OK,
 12.2099 -							MessageBoxIcon.Information);
 12.2100 -					}
 12.2101 -
 12.2102 -					if (doUpdate)
 12.2103 -					{
 12.2104 -						try
 12.2105 -						{
 12.2106 -							ad.Update();
 12.2107 -							MessageBox.Show("The application has been upgraded, and will now restart.");
 12.2108 -							Application.Restart();
 12.2109 -						}
 12.2110 -						catch (DeploymentDownloadException dde)
 12.2111 -						{
 12.2112 -							MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
 12.2113 -							return;
 12.2114 -						}
 12.2115 -					}
 12.2116 -				}
 12.2117 -				else
 12.2118 -				{
 12.2119 -					MessageBox.Show("You are already running the latest version.", "Application up-to-date");
 12.2120 -				}
 12.2121 +                if (info.UpdateAvailable)
 12.2122 +                {
 12.2123 +                    Boolean doUpdate = true;
 12.2124 +
 12.2125 +                    if (!info.IsUpdateRequired)
 12.2126 +                    {
 12.2127 +                        DialogResult dr =
 12.2128 +                            MessageBox.Show("An update is available. Would you like to update the application now?",
 12.2129 +                                "Update Available", MessageBoxButtons.OKCancel);
 12.2130 +                        if (!(DialogResult.OK == dr))
 12.2131 +                        {
 12.2132 +                            doUpdate = false;
 12.2133 +                        }
 12.2134 +                    }
 12.2135 +                    else
 12.2136 +                    {
 12.2137 +                        // Display a message that the application MUST reboot. Display the minimum required version.
 12.2138 +                        MessageBox.Show("This application has detected a mandatory update from your current " +
 12.2139 +                                        "version to version " + info.MinimumRequiredVersion.ToString() +
 12.2140 +                                        ". The application will now install the update and restart.",
 12.2141 +                            "Update Available", MessageBoxButtons.OK,
 12.2142 +                            MessageBoxIcon.Information);
 12.2143 +                    }
 12.2144 +
 12.2145 +                    if (doUpdate)
 12.2146 +                    {
 12.2147 +                        try
 12.2148 +                        {
 12.2149 +                            ad.Update();
 12.2150 +                            MessageBox.Show("The application has been upgraded, and will now restart.");
 12.2151 +                            Application.Restart();
 12.2152 +                        }
 12.2153 +                        catch (DeploymentDownloadException dde)
 12.2154 +                        {
 12.2155 +                            MessageBox.Show(
 12.2156 +                                "Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " +
 12.2157 +                                dde);
 12.2158 +                            return;
 12.2159 +                        }
 12.2160 +                    }
 12.2161 +                }
 12.2162 +                else
 12.2163 +                {
 12.2164 +                    MessageBox.Show("You are already running the latest version.", "Application up-to-date");
 12.2165 +                }
 12.2166              }
 12.2167          }
 12.2168  
 12.2169  
 12.2170 -		/// <summary>
 12.2171 -		/// Used to
 12.2172 -		/// </summary>
 12.2173 -		private void SysTrayHideShow()
 12.2174 -		{
 12.2175 -			Visible = !Visible;
 12.2176 -			if (Visible)
 12.2177 -			{
 12.2178 -				Activate();
 12.2179 -				WindowState = FormWindowState.Normal;
 12.2180 -			}
 12.2181 -		}
 12.2182 -
 12.2183 -		/// <summary>
 12.2184 -		/// Use to handle minimize events.
 12.2185 -		/// </summary>
 12.2186 -		/// <param name="sender"></param>
 12.2187 -		/// <param name="e"></param>
 12.2188 -		private void MainForm_SizeChanged(object sender, EventArgs e)
 12.2189 -		{
 12.2190 -			if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
 12.2191 -			{
 12.2192 -				if (Visible)
 12.2193 -				{
 12.2194 -					SysTrayHideShow();
 12.2195 -				}
 12.2196 -			}
 12.2197 -		}
 12.2198 -
 12.2199 -		/// <summary>
 12.2200 -		/// 
 12.2201 -		/// </summary>
 12.2202 -		/// <param name="sender"></param>
 12.2203 -		/// <param name="e"></param>
 12.2204 -		private void tableLayoutPanel_SizeChanged(object sender, EventArgs e)
 12.2205 -		{
 12.2206 -			//Our table layout size has changed which means our display size has changed.
 12.2207 -			//We need to re-create our bitmap.
 12.2208 -			iCreateBitmap = true;
 12.2209 -		}
 12.2210 -
 12.2211 -		/// <summary>
 12.2212 -		/// 
 12.2213 -		/// </summary>
 12.2214 -		/// <param name="sender"></param>
 12.2215 -		/// <param name="e"></param>
 12.2216 -		private void buttonSelectFile_Click(object sender, EventArgs e)
 12.2217 -		{
 12.2218 -			//openFileDialog1.InitialDirectory = "c:\\";
 12.2219 -			//openFileDialog.Filter = "EXE files (*.exe)|*.exe|All files (*.*)|*.*";
 12.2220 -			//openFileDialog.FilterIndex = 1;
 12.2221 -			openFileDialog.RestoreDirectory = true;
 12.2222 -
 12.2223 -			if (DlgBox.ShowDialog(openFileDialog) == DialogResult.OK)
 12.2224 -			{
 12.2225 -				labelStartFileName.Text = openFileDialog.FileName;
 12.2226 -				Properties.Settings.Default.StartFileName = openFileDialog.FileName;
 12.2227 -				Properties.Settings.Default.Save();
 12.2228 -			}
 12.2229 -		}
 12.2230 +        /// <summary>
 12.2231 +        /// Used to
 12.2232 +        /// </summary>
 12.2233 +        private void SysTrayHideShow()
 12.2234 +        {
 12.2235 +            Visible = !Visible;
 12.2236 +            if (Visible)
 12.2237 +            {
 12.2238 +                Activate();
 12.2239 +                WindowState = FormWindowState.Normal;
 12.2240 +            }
 12.2241 +        }
 12.2242 +
 12.2243 +        /// <summary>
 12.2244 +        /// Use to handle minimize events.
 12.2245 +        /// </summary>
 12.2246 +        /// <param name="sender"></param>
 12.2247 +        /// <param name="e"></param>
 12.2248 +        private void MainForm_SizeChanged(object sender, EventArgs e)
 12.2249 +        {
 12.2250 +            if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
 12.2251 +            {
 12.2252 +                if (Visible)
 12.2253 +                {
 12.2254 +                    SysTrayHideShow();
 12.2255 +                }
 12.2256 +            }
 12.2257 +        }
 12.2258 +
 12.2259 +        /// <summary>
 12.2260 +        /// 
 12.2261 +        /// </summary>
 12.2262 +        /// <param name="sender"></param>
 12.2263 +        /// <param name="e"></param>
 12.2264 +        private void tableLayoutPanel_SizeChanged(object sender, EventArgs e)
 12.2265 +        {
 12.2266 +            //Our table layout size has changed which means our display size has changed.
 12.2267 +            //We need to re-create our bitmap.
 12.2268 +            iCreateBitmap = true;
 12.2269 +        }
 12.2270 +
 12.2271 +        /// <summary>
 12.2272 +        /// 
 12.2273 +        /// </summary>
 12.2274 +        /// <param name="sender"></param>
 12.2275 +        /// <param name="e"></param>
 12.2276 +        private void buttonSelectFile_Click(object sender, EventArgs e)
 12.2277 +        {
 12.2278 +            //openFileDialog1.InitialDirectory = "c:\\";
 12.2279 +            //openFileDialog.Filter = "EXE files (*.exe)|*.exe|All files (*.*)|*.*";
 12.2280 +            //openFileDialog.FilterIndex = 1;
 12.2281 +            openFileDialog.RestoreDirectory = true;
 12.2282 +
 12.2283 +            if (DlgBox.ShowDialog(openFileDialog) == DialogResult.OK)
 12.2284 +            {
 12.2285 +                labelStartFileName.Text = openFileDialog.FileName;
 12.2286 +                Properties.Settings.Default.StartFileName = openFileDialog.FileName;
 12.2287 +                Properties.Settings.Default.Save();
 12.2288 +            }
 12.2289 +        }
 12.2290  
 12.2291          /// <summary>
 12.2292          /// 
 12.2293 @@ -2559,11 +2624,11 @@
 12.2294          {
 12.2295              LogsUpdate();
 12.2296  
 12.2297 -            if (OnWndProc!=null)
 12.2298 +            if (OnWndProc != null)
 12.2299              {
 12.2300                  OnWndProc(ref aMessage);
 12.2301              }
 12.2302 -            
 12.2303 +
 12.2304              base.WndProc(ref aMessage);
 12.2305          }
 12.2306  
 12.2307 @@ -2591,7 +2656,7 @@
 12.2308          /// </summary>
 12.2309          private void ResetCec()
 12.2310          {
 12.2311 -            if (iCecManager==null)
 12.2312 +            if (iCecManager == null)
 12.2313              {
 12.2314                  //Thus skipping initial UI setup
 12.2315                  return;
 12.2316 @@ -2602,7 +2667,7 @@
 12.2317              if (Properties.Settings.Default.CecEnabled)
 12.2318              {
 12.2319                  iCecManager.Start(Handle, "CEC",
 12.2320 -                Properties.Settings.Default.CecHdmiPort);
 12.2321 +                    Properties.Settings.Default.CecHdmiPort);
 12.2322  
 12.2323                  SetupCecLogLevel();
 12.2324              }
 12.2325 @@ -2617,19 +2682,19 @@
 12.2326              iCecManager.Client.LogLevel = 0;
 12.2327  
 12.2328              if (checkBoxCecLogError.Checked)
 12.2329 -                iCecManager.Client.LogLevel |= (int)CecLogLevel.Error;
 12.2330 +                iCecManager.Client.LogLevel |= (int) CecLogLevel.Error;
 12.2331  
 12.2332              if (checkBoxCecLogWarning.Checked)
 12.2333 -                iCecManager.Client.LogLevel |= (int)CecLogLevel.Warning;
 12.2334 +                iCecManager.Client.LogLevel |= (int) CecLogLevel.Warning;
 12.2335  
 12.2336              if (checkBoxCecLogNotice.Checked)
 12.2337 -                iCecManager.Client.LogLevel |= (int)CecLogLevel.Notice;
 12.2338 +                iCecManager.Client.LogLevel |= (int) CecLogLevel.Notice;
 12.2339  
 12.2340              if (checkBoxCecLogTraffic.Checked)
 12.2341 -                iCecManager.Client.LogLevel |= (int)CecLogLevel.Traffic;
 12.2342 +                iCecManager.Client.LogLevel |= (int) CecLogLevel.Traffic;
 12.2343  
 12.2344              if (checkBoxCecLogDebug.Checked)
 12.2345 -                iCecManager.Client.LogLevel |= (int)CecLogLevel.Debug;
 12.2346 +                iCecManager.Client.LogLevel |= (int) CecLogLevel.Debug;
 12.2347  
 12.2348              iCecManager.Client.FilterOutPollLogs = checkBoxCecLogNoPoll.Checked;
 12.2349  
 12.2350 @@ -2650,7 +2715,7 @@
 12.2351              SetupCecLogLevel();
 12.2352          }
 12.2353  
 12.2354 -       
 12.2355 +
 12.2356          /// <summary>
 12.2357          /// 
 12.2358          /// </summary>
 12.2359 @@ -2663,9 +2728,9 @@
 12.2360              }
 12.2361  
 12.2362              string key = aEvent.GetType().Name;
 12.2363 -            TreeNode[] res=iTreeViewEvents.Nodes.Find(key, false);
 12.2364 +            TreeNode[] res = iTreeViewEvents.Nodes.Find(key, false);
 12.2365              if (res.Length > 0)
 12.2366 -            {                
 12.2367 +            {
 12.2368                  iTreeViewEvents.SelectedNode = res[0];
 12.2369                  iTreeViewEvents.Focus();
 12.2370              }
 12.2371 @@ -2686,7 +2751,7 @@
 12.2372              {
 12.2373                  if (node.Tag is Event)
 12.2374                  {
 12.2375 -                    selectedEvent = (Event)node.Tag;
 12.2376 +                    selectedEvent = (Event) node.Tag;
 12.2377                      break;
 12.2378                  }
 12.2379                  node = node.Parent;
 12.2380 @@ -2728,7 +2793,7 @@
 12.2381              DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
 12.2382              if (res == DialogResult.OK)
 12.2383              {
 12.2384 -                selectedEvent.Actions.Add(ea.Action);                
 12.2385 +                selectedEvent.Actions.Add(ea.Action);
 12.2386                  Properties.Settings.Default.Actions = ManagerEventAction.Current;
 12.2387                  Properties.Settings.Default.Save();
 12.2388                  PopulateEventsTreeView();
 12.2389 @@ -2760,7 +2825,98 @@
 12.2390          {
 12.2391              //Enable buttons according to selected item
 12.2392              buttonAddAction.Enabled = CurrentEvent() != null;
 12.2393 -            buttonDeleteAction.Enabled = CurrentAction() != null;
 12.2394 +
 12.2395 +            SharpLib.Ear.Action currentAction = CurrentAction();
 12.2396 +            //If an action is selected enable the following buttons
 12.2397 +            buttonTestAction.Enabled =
 12.2398 +            buttonDeleteAction.Enabled =
 12.2399 +            buttonActionMoveUp.Enabled =
 12.2400 +            buttonActionMoveDown.Enabled =
 12.2401 +                    currentAction != null;
 12.2402 +    
 12.2403 +            if (currentAction != null)
 12.2404 +            {
 12.2405 +                //If an action is selected enable move buttons if needed
 12.2406 +                buttonActionMoveUp.Enabled = iTreeViewEvents.SelectedNode.Index != 0;
 12.2407 +                buttonActionMoveDown.Enabled = iTreeViewEvents.SelectedNode.Index <
 12.2408 +                                               iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1;
 12.2409 +            }
 12.2410 +
 12.2411 +        }
 12.2412 +
 12.2413 +        /// <summary>
 12.2414 +        /// 
 12.2415 +        /// </summary>
 12.2416 +        /// <param name="sender"></param>
 12.2417 +        /// <param name="e"></param>
 12.2418 +        private void buttonTestAction_Click(object sender, EventArgs e)
 12.2419 +        {
 12.2420 +            SharpLib.Ear.Action a = CurrentAction();
 12.2421 +            if (a != null)
 12.2422 +            {
 12.2423 +                Console.WriteLine("Action test run");
 12.2424 +                a.Execute();
 12.2425 +            }
 12.2426 +            iTreeViewEvents.Focus();
 12.2427 +        }
 12.2428 +
 12.2429 +        /// <summary>
 12.2430 +        /// 
 12.2431 +        /// </summary>
 12.2432 +        /// <param name="sender"></param>
 12.2433 +        /// <param name="e"></param>
 12.2434 +        private void buttonActionMoveUp_Click(object sender, EventArgs e)
 12.2435 +        {
 12.2436 +            SharpLib.Ear.Action a = CurrentAction();
 12.2437 +            if (a == null || 
 12.2438 +                //Action already at the top of the list
 12.2439 +                iTreeViewEvents.SelectedNode.Index == 0)
 12.2440 +            {
 12.2441 +                return;
 12.2442 +            }
 12.2443 +
 12.2444 +            //Swap actions in event's action list
 12.2445 +            Event currentEvent = CurrentEvent();
 12.2446 +            int currentIndex = iTreeViewEvents.SelectedNode.Index;
 12.2447 +            SharpLib.Ear.Action movingUp = currentEvent.Actions[currentIndex];
 12.2448 +            SharpLib.Ear.Action movingDown = currentEvent.Actions[currentIndex-1];
 12.2449 +            currentEvent.Actions[currentIndex] = movingDown;
 12.2450 +            currentEvent.Actions[currentIndex-1] = movingUp;
 12.2451 +
 12.2452 +            //Save and populate our tree again
 12.2453 +            Properties.Settings.Default.Actions = ManagerEventAction.Current;
 12.2454 +            Properties.Settings.Default.Save();
 12.2455 +            PopulateEventsTreeView();
 12.2456 +
 12.2457 +        }
 12.2458 +
 12.2459 +        /// <summary>
 12.2460 +        /// 
 12.2461 +        /// </summary>
 12.2462 +        /// <param name="sender"></param>
 12.2463 +        /// <param name="e"></param>
 12.2464 +        private void buttonActionMoveDown_Click(object sender, EventArgs e)
 12.2465 +        {
 12.2466 +            SharpLib.Ear.Action a = CurrentAction();
 12.2467 +            if (a == null ||
 12.2468 +                //Action already at the bottom of the list
 12.2469 +                iTreeViewEvents.SelectedNode.Index == iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1)
 12.2470 +            {
 12.2471 +                return;
 12.2472 +            }
 12.2473 +
 12.2474 +            //Swap actions in event's action list
 12.2475 +            Event currentEvent = CurrentEvent();
 12.2476 +            int currentIndex = iTreeViewEvents.SelectedNode.Index;
 12.2477 +            SharpLib.Ear.Action movingDown = currentEvent.Actions[currentIndex];
 12.2478 +            SharpLib.Ear.Action movingUp = currentEvent.Actions[currentIndex + 1];
 12.2479 +            currentEvent.Actions[currentIndex] = movingUp;
 12.2480 +            currentEvent.Actions[currentIndex + 1] = movingDown;
 12.2481 +
 12.2482 +            //Save and populate our tree again
 12.2483 +            Properties.Settings.Default.Actions = ManagerEventAction.Current;
 12.2484 +            Properties.Settings.Default.Save();
 12.2485 +            PopulateEventsTreeView();
 12.2486          }
 12.2487      }
 12.2488  }
    13.1 --- a/SharpLibEar/Action.cs	Wed Jul 27 11:07:35 2016 +0200
    13.2 +++ b/SharpLibEar/Action.cs	Wed Jul 27 15:05:58 2016 +0200
    13.3 @@ -12,7 +12,13 @@
    13.4      [KnownType("DerivedTypes")]
    13.5      public abstract class Action: IComparable
    13.6      {
    13.7 -        public abstract void Execute();
    13.8 +        public abstract void DoExecute();
    13.9 +
   13.10 +        public void Execute()
   13.11 +        {
   13.12 +            Console.WriteLine("Executing action: " + Brief());
   13.13 +            DoExecute();
   13.14 +        }
   13.15  
   13.16          public string Name {
   13.17              //Get the name of this object action attribute
    14.1 --- a/SharpLibEar/ActionCallback.cs	Wed Jul 27 11:07:35 2016 +0200
    14.2 +++ b/SharpLibEar/ActionCallback.cs	Wed Jul 27 15:05:58 2016 +0200
    14.3 @@ -17,7 +17,7 @@
    14.4              iCallback = aCallback;
    14.5          }
    14.6  
    14.7 -        public override void Execute()
    14.8 +        public override void DoExecute()
    14.9          {
   14.10              if (iCallback != null)
   14.11              {
    15.1 --- a/SharpLibEar/ActionSleep.cs	Wed Jul 27 11:07:35 2016 +0200
    15.2 +++ b/SharpLibEar/ActionSleep.cs	Wed Jul 27 15:05:58 2016 +0200
    15.3 @@ -43,7 +43,7 @@
    15.4          }
    15.5  
    15.6  
    15.7 -        public override void Execute()
    15.8 +        public override void DoExecute()
    15.9          {
   15.10              Thread.Sleep(TimeoutInMilliseconds);
   15.11          }