Server/MainForm.cs
changeset 168 2568261f74fb
parent 167 d2295c186ce1
child 171 151e11cac3b2
     1.1 --- a/Server/MainForm.cs	Sat Sep 26 16:35:27 2015 +0200
     1.2 +++ b/Server/MainForm.cs	Sat Sep 26 17:55:51 2015 +0200
     1.3 @@ -187,7 +187,8 @@
     1.4              //CEC
     1.5              iCecManager = new ConsumerElectronicControl();
     1.6              OnWndProc += iCecManager.OnWndProc;
     1.7 -            iCecManager.Start(Handle,"CEC", 2);
     1.8 +            ResetCec();
     1.9 +
    1.10  
    1.11              //Setup notification icon
    1.12              SetupTrayIcon();
    1.13 @@ -1095,8 +1096,13 @@
    1.14                  comboBoxOpticalDrives.SelectedIndex = 0;
    1.15              }
    1.16  
    1.17 +            //CEC settings
    1.18 +            checkBoxCecEnabled.Checked = Properties.Settings.Default.CecEnabled;
    1.19 +            checkBoxCecMonitorOn.Checked = Properties.Settings.Default.CecMonitorOn;
    1.20 +            checkBoxCecMonitorOff.Checked = Properties.Settings.Default.CecMonitorOff;
    1.21 +            comboBoxHdmiPort.SelectedIndex = Properties.Settings.Default.CecHdmiPort - 1;
    1.22  
    1.23 -
    1.24 +            //Mini Display settings
    1.25              checkBoxReverseScreen.Checked = cds.ReverseScreen;
    1.26              checkBoxInverseColors.Checked = cds.InverseColors;
    1.27  			checkBoxShowVolumeLabel.Checked = cds.ShowVolumeLabel;
    1.28 @@ -2218,5 +2224,62 @@
    1.29              
    1.30              base.WndProc(ref aMessage);
    1.31          }
    1.32 +
    1.33 +        private void checkBoxCecEnabled_CheckedChanged(object sender, EventArgs e)
    1.34 +        {
    1.35 +            //Save CEC enabled status
    1.36 +            Properties.Settings.Default.CecEnabled = checkBoxCecEnabled.Checked;
    1.37 +            Properties.Settings.Default.Save();
    1.38 +            //
    1.39 +            ResetCec();
    1.40 +        }
    1.41 +
    1.42 +        private void comboBoxHdmiPort_SelectedIndexChanged(object sender, EventArgs e)
    1.43 +        {
    1.44 +            //Save CEC HDMI port
    1.45 +            Properties.Settings.Default.CecHdmiPort = Convert.ToByte(comboBoxHdmiPort.SelectedIndex);
    1.46 +            Properties.Settings.Default.CecHdmiPort++;
    1.47 +            Properties.Settings.Default.Save();
    1.48 +            //
    1.49 +            ResetCec();
    1.50 +        }
    1.51 +
    1.52 +        private void checkBoxCecMonitorOff_CheckedChanged(object sender, EventArgs e)
    1.53 +        {
    1.54 +            Properties.Settings.Default.CecMonitorOff = checkBoxCecMonitorOff.Checked;
    1.55 +            Properties.Settings.Default.Save();
    1.56 +            //
    1.57 +            ResetCec();
    1.58 +        }
    1.59 +
    1.60 +        private void checkBoxCecMonitorOn_CheckedChanged(object sender, EventArgs e)
    1.61 +        {
    1.62 +            Properties.Settings.Default.CecMonitorOn = checkBoxCecMonitorOn.Checked;
    1.63 +            Properties.Settings.Default.Save();
    1.64 +            //
    1.65 +            ResetCec();
    1.66 +        }
    1.67 +
    1.68 +        /// <summary>
    1.69 +        /// 
    1.70 +        /// </summary>
    1.71 +        private void ResetCec()
    1.72 +        {
    1.73 +            if (iCecManager==null)
    1.74 +            {
    1.75 +                //Thus skipping initial UI setup
    1.76 +                return;
    1.77 +            }
    1.78 +
    1.79 +            iCecManager.Stop();
    1.80 +            //
    1.81 +            if (Properties.Settings.Default.CecEnabled)
    1.82 +            {
    1.83 +                iCecManager.Start(Handle, "CEC",
    1.84 +                Properties.Settings.Default.CecHdmiPort,
    1.85 +                Properties.Settings.Default.CecMonitorOn,
    1.86 +                Properties.Settings.Default.CecMonitorOff);
    1.87 +            }
    1.88 +        }
    1.89      }
    1.90  }