1.1 --- a/Server/MainForm.cs Sat Sep 26 11:56:49 2015 +0200
1.2 +++ b/Server/MainForm.cs Sat Sep 26 16:35:27 2015 +0200
1.3 @@ -59,7 +59,7 @@
1.4 public delegate void SetLayoutDelegate(string SessionId, TableLayout aLayout);
1.5 public delegate void SetClientNameDelegate(string aSessionId, string aName);
1.6 public delegate void PlainUpdateDelegate();
1.7 -
1.8 + public delegate void WndProcDelegate(ref Message aMessage);
1.9
1.10 /// <summary>
1.11 /// Our Display manager main form
1.12 @@ -92,8 +92,13 @@
1.13 private MMDevice iMultiMediaDevice;
1.14 //Network
1.15 private NetworkManager iNetworkManager;
1.16 +
1.17 + /// <summary>
1.18 + /// CEC - Consumer Electronic Control.
1.19 + /// Notably used to turn TV on and off as Windows broadcast monitor on and off notifications.
1.20 + /// </summary>
1.21 + private ConsumerElectronicControl iCecManager;
1.22
1.23 -
1.24 /// <summary>
1.25 /// Manage run when Windows startup option
1.26 /// </summary>
1.27 @@ -104,6 +109,11 @@
1.28 /// </summary>
1.29 private NotifyIconAdv iNotifyIcon;
1.30
1.31 + /// <summary>
1.32 + /// Allow user to receive window messages;
1.33 + /// </summary>
1.34 + public event WndProcDelegate OnWndProc;
1.35 +
1.36 public MainForm()
1.37 {
1.38 iSkipFrameRendering = false;
1.39 @@ -174,8 +184,13 @@
1.40 iNetworkManager.OnConnectivityChanged += OnConnectivityChanged;
1.41 UpdateNetworkStatus();
1.42
1.43 - //Setup notification icon
1.44 - SetupTrayIcon();
1.45 + //CEC
1.46 + iCecManager = new ConsumerElectronicControl();
1.47 + OnWndProc += iCecManager.OnWndProc;
1.48 + iCecManager.Start(Handle,"CEC", 2);
1.49 +
1.50 + //Setup notification icon
1.51 + SetupTrayIcon();
1.52
1.53 // To make sure start up with minimize to tray works
1.54 if (WindowState == FormWindowState.Minimized && Properties.Settings.Default.MinimizeToTray)
1.55 @@ -1279,6 +1294,7 @@
1.56
1.57 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
1.58 {
1.59 + iCecManager.Stop();
1.60 iNetworkManager.Dispose();
1.61 CloseDisplayConnection();
1.62 StopServer();
1.63 @@ -2188,5 +2204,19 @@
1.64 Properties.Settings.Default.OpticalDriveToEject = comboBoxOpticalDrives.SelectedItem.ToString();
1.65 Properties.Settings.Default.Save();
1.66 }
1.67 +
1.68 + /// <summary>
1.69 + /// Broadcast messages to subscribers.
1.70 + /// </summary>
1.71 + /// <param name="message"></param>
1.72 + protected override void WndProc(ref Message aMessage)
1.73 + {
1.74 + if (OnWndProc!=null)
1.75 + {
1.76 + OnWndProc(ref aMessage);
1.77 + }
1.78 +
1.79 + base.WndProc(ref aMessage);
1.80 + }
1.81 }
1.82 }