Adding Harmony tab.
authorStephaneLenclud
Mon, 15 Aug 2016 12:11:26 +0200
changeset 2332b9541e54f7d
parent 232 5a739e2e5255
child 234 0c75dec19d39
Adding Harmony tab.
Server/App.config
Server/FormMain.Designer.cs
Server/FormMain.Hid.cs
Server/FormMain.cs
Server/Program.cs
Server/Properties/Settings.Designer.cs
Server/Properties/Settings.settings
Server/SharpDisplayManager.csproj
Server/packages.config
     1.1 --- a/Server/App.config	Sat Aug 13 23:26:54 2016 +0200
     1.2 +++ b/Server/App.config	Mon Aug 15 12:11:26 2016 +0200
     1.3 @@ -40,6 +40,12 @@
     1.4              <setting name="StartIdleClient" serializeAs="String">
     1.5                  <value>True</value>
     1.6              </setting>
     1.7 +            <setting name="HarmonyEnabled" serializeAs="String">
     1.8 +                <value>False</value>
     1.9 +            </setting>
    1.10 +            <setting name="HarmonyHubAddress" serializeAs="String">
    1.11 +                <value>HarmonyHub</value>
    1.12 +            </setting>
    1.13          </SharpDisplayManager.Properties.Settings>
    1.14      </userSettings>
    1.15  </configuration>
     2.1 --- a/Server/FormMain.Designer.cs	Sat Aug 13 23:26:54 2016 +0200
     2.2 +++ b/Server/FormMain.Designer.cs	Mon Aug 15 12:11:26 2016 +0200
     2.3 @@ -109,6 +109,16 @@
     2.4              this.checkBoxCecEnabled = new System.Windows.Forms.CheckBox();
     2.5              this.labelHdmiPort = new System.Windows.Forms.Label();
     2.6              this.comboBoxHdmiPort = new System.Windows.Forms.ComboBox();
     2.7 +            this.tabPageHarmony = new System.Windows.Forms.TabPage();
     2.8 +            this.iCheckBoxHarmonyEnabled = new System.Windows.Forms.CheckBox();
     2.9 +            this.iTreeViewHarmony = new System.Windows.Forms.TreeView();
    2.10 +            this.iButtonHarmonyConnect = new System.Windows.Forms.Button();
    2.11 +            this.label2 = new System.Windows.Forms.Label();
    2.12 +            this.iTextBoxLogitechPassword = new System.Windows.Forms.TextBox();
    2.13 +            this.labelLogitechUserName = new System.Windows.Forms.Label();
    2.14 +            this.iTextBoxLogitechUserName = new System.Windows.Forms.TextBox();
    2.15 +            this.label1 = new System.Windows.Forms.Label();
    2.16 +            this.iTextBoxHarmonyHubAddress = new System.Windows.Forms.TextBox();
    2.17              this.tabPageEvent = new System.Windows.Forms.TabPage();
    2.18              this.buttonEventEdit = new System.Windows.Forms.Button();
    2.19              this.buttonEventDelete = new System.Windows.Forms.Button();
    2.20 @@ -147,6 +157,7 @@
    2.21              ((System.ComponentModel.ISupportInitialize)(this.pictureBoxGreenStart)).BeginInit();
    2.22              this.tabPageCec.SuspendLayout();
    2.23              this.groupBoxCecLogOptions.SuspendLayout();
    2.24 +            this.tabPageHarmony.SuspendLayout();
    2.25              this.tabPageEvent.SuspendLayout();
    2.26              this.tabPageApp.SuspendLayout();
    2.27              this.tabPageLogs.SuspendLayout();
    2.28 @@ -576,6 +587,7 @@
    2.29              this.tabControl.Controls.Add(this.tabPageAudio);
    2.30              this.tabControl.Controls.Add(this.tabPageInput);
    2.31              this.tabControl.Controls.Add(this.tabPageCec);
    2.32 +            this.tabControl.Controls.Add(this.tabPageHarmony);
    2.33              this.tabControl.Controls.Add(this.tabPageEvent);
    2.34              this.tabControl.Controls.Add(this.tabPageApp);
    2.35              this.tabControl.Controls.Add(this.tabPageLogs);
    2.36 @@ -975,6 +987,113 @@
    2.37              this.comboBoxHdmiPort.TabIndex = 19;
    2.38              this.comboBoxHdmiPort.SelectedIndexChanged += new System.EventHandler(this.comboBoxHdmiPort_SelectedIndexChanged);
    2.39              // 
    2.40 +            // tabPageHarmony
    2.41 +            // 
    2.42 +            this.tabPageHarmony.Controls.Add(this.iCheckBoxHarmonyEnabled);
    2.43 +            this.tabPageHarmony.Controls.Add(this.iTreeViewHarmony);
    2.44 +            this.tabPageHarmony.Controls.Add(this.iButtonHarmonyConnect);
    2.45 +            this.tabPageHarmony.Controls.Add(this.label2);
    2.46 +            this.tabPageHarmony.Controls.Add(this.iTextBoxLogitechPassword);
    2.47 +            this.tabPageHarmony.Controls.Add(this.labelLogitechUserName);
    2.48 +            this.tabPageHarmony.Controls.Add(this.iTextBoxLogitechUserName);
    2.49 +            this.tabPageHarmony.Controls.Add(this.label1);
    2.50 +            this.tabPageHarmony.Controls.Add(this.iTextBoxHarmonyHubAddress);
    2.51 +            this.tabPageHarmony.Location = new System.Drawing.Point(4, 22);
    2.52 +            this.tabPageHarmony.Name = "tabPageHarmony";
    2.53 +            this.tabPageHarmony.Padding = new System.Windows.Forms.Padding(3);
    2.54 +            this.tabPageHarmony.Size = new System.Drawing.Size(752, 385);
    2.55 +            this.tabPageHarmony.TabIndex = 10;
    2.56 +            this.tabPageHarmony.Text = "Harmony";
    2.57 +            this.tabPageHarmony.UseVisualStyleBackColor = true;
    2.58 +            // 
    2.59 +            // iCheckBoxHarmonyEnabled
    2.60 +            // 
    2.61 +            this.iCheckBoxHarmonyEnabled.AutoSize = true;
    2.62 +            this.iCheckBoxHarmonyEnabled.Location = new System.Drawing.Point(6, 6);
    2.63 +            this.iCheckBoxHarmonyEnabled.Name = "iCheckBoxHarmonyEnabled";
    2.64 +            this.iCheckBoxHarmonyEnabled.Size = new System.Drawing.Size(104, 17);
    2.65 +            this.iCheckBoxHarmonyEnabled.TabIndex = 22;
    2.66 +            this.iCheckBoxHarmonyEnabled.Text = "Enable Harmony";
    2.67 +            this.iCheckBoxHarmonyEnabled.UseVisualStyleBackColor = true;
    2.68 +            this.iCheckBoxHarmonyEnabled.CheckedChanged += new System.EventHandler(this.iCheckBoxHarmonyEnabled_CheckedChanged);
    2.69 +            // 
    2.70 +            // iTreeViewHarmony
    2.71 +            // 
    2.72 +            this.iTreeViewHarmony.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    2.73 +            | System.Windows.Forms.AnchorStyles.Left) 
    2.74 +            | System.Windows.Forms.AnchorStyles.Right)));
    2.75 +            this.iTreeViewHarmony.Location = new System.Drawing.Point(84, 49);
    2.76 +            this.iTreeViewHarmony.Name = "iTreeViewHarmony";
    2.77 +            this.iTreeViewHarmony.Size = new System.Drawing.Size(662, 330);
    2.78 +            this.iTreeViewHarmony.TabIndex = 15;
    2.79 +            this.iTreeViewHarmony.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.iTreeViewHarmony_NodeMouseDoubleClick);
    2.80 +            // 
    2.81 +            // iButtonHarmonyConnect
    2.82 +            // 
    2.83 +            this.iButtonHarmonyConnect.Location = new System.Drawing.Point(3, 49);
    2.84 +            this.iButtonHarmonyConnect.Name = "iButtonHarmonyConnect";
    2.85 +            this.iButtonHarmonyConnect.Size = new System.Drawing.Size(75, 23);
    2.86 +            this.iButtonHarmonyConnect.TabIndex = 14;
    2.87 +            this.iButtonHarmonyConnect.Text = "Connect";
    2.88 +            this.iButtonHarmonyConnect.UseVisualStyleBackColor = true;
    2.89 +            this.iButtonHarmonyConnect.Click += new System.EventHandler(this.iButtonHarmonyConnect_Click);
    2.90 +            // 
    2.91 +            // label2
    2.92 +            // 
    2.93 +            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    2.94 +            this.label2.AutoSize = true;
    2.95 +            this.label2.Location = new System.Drawing.Point(597, 7);
    2.96 +            this.label2.Name = "label2";
    2.97 +            this.label2.Size = new System.Drawing.Size(99, 13);
    2.98 +            this.label2.TabIndex = 13;
    2.99 +            this.label2.Text = "Logitech password:";
   2.100 +            // 
   2.101 +            // iTextBoxLogitechPassword
   2.102 +            // 
   2.103 +            this.iTextBoxLogitechPassword.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
   2.104 +            this.iTextBoxLogitechPassword.Location = new System.Drawing.Point(600, 23);
   2.105 +            this.iTextBoxLogitechPassword.Name = "iTextBoxLogitechPassword";
   2.106 +            this.iTextBoxLogitechPassword.PasswordChar = '*';
   2.107 +            this.iTextBoxLogitechPassword.Size = new System.Drawing.Size(134, 20);
   2.108 +            this.iTextBoxLogitechPassword.TabIndex = 12;
   2.109 +            // 
   2.110 +            // labelLogitechUserName
   2.111 +            // 
   2.112 +            this.labelLogitechUserName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
   2.113 +            this.labelLogitechUserName.AutoSize = true;
   2.114 +            this.labelLogitechUserName.Location = new System.Drawing.Point(433, 7);
   2.115 +            this.labelLogitechUserName.Name = "labelLogitechUserName";
   2.116 +            this.labelLogitechUserName.Size = new System.Drawing.Size(141, 13);
   2.117 +            this.labelLogitechUserName.TabIndex = 11;
   2.118 +            this.labelLogitechUserName.Text = "Logitech user name / e-mail:";
   2.119 +            // 
   2.120 +            // iTextBoxLogitechUserName
   2.121 +            // 
   2.122 +            this.iTextBoxLogitechUserName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
   2.123 +            this.iTextBoxLogitechUserName.Location = new System.Drawing.Point(436, 23);
   2.124 +            this.iTextBoxLogitechUserName.Name = "iTextBoxLogitechUserName";
   2.125 +            this.iTextBoxLogitechUserName.Size = new System.Drawing.Size(134, 20);
   2.126 +            this.iTextBoxLogitechUserName.TabIndex = 10;
   2.127 +            // 
   2.128 +            // label1
   2.129 +            // 
   2.130 +            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
   2.131 +            this.label1.AutoSize = true;
   2.132 +            this.label1.Location = new System.Drawing.Point(279, 7);
   2.133 +            this.label1.Name = "label1";
   2.134 +            this.label1.Size = new System.Drawing.Size(116, 13);
   2.135 +            this.label1.TabIndex = 9;
   2.136 +            this.label1.Text = "Harmony Hub Address:";
   2.137 +            // 
   2.138 +            // iTextBoxHarmonyHubAddress
   2.139 +            // 
   2.140 +            this.iTextBoxHarmonyHubAddress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
   2.141 +            this.iTextBoxHarmonyHubAddress.Location = new System.Drawing.Point(282, 23);
   2.142 +            this.iTextBoxHarmonyHubAddress.Name = "iTextBoxHarmonyHubAddress";
   2.143 +            this.iTextBoxHarmonyHubAddress.Size = new System.Drawing.Size(100, 20);
   2.144 +            this.iTextBoxHarmonyHubAddress.TabIndex = 8;
   2.145 +            this.iTextBoxHarmonyHubAddress.Text = "HarmonyHub";
   2.146 +            // 
   2.147              // tabPageEvent
   2.148              // 
   2.149              this.tabPageEvent.Controls.Add(this.buttonEventEdit);
   2.150 @@ -1281,6 +1400,8 @@
   2.151              this.tabPageCec.PerformLayout();
   2.152              this.groupBoxCecLogOptions.ResumeLayout(false);
   2.153              this.groupBoxCecLogOptions.PerformLayout();
   2.154 +            this.tabPageHarmony.ResumeLayout(false);
   2.155 +            this.tabPageHarmony.PerformLayout();
   2.156              this.tabPageEvent.ResumeLayout(false);
   2.157              this.tabPageApp.ResumeLayout(false);
   2.158              this.tabPageApp.PerformLayout();
   2.159 @@ -1386,6 +1507,16 @@
   2.160          private System.Windows.Forms.Button buttonEventDelete;
   2.161          private System.Windows.Forms.Button buttonEventAdd;
   2.162          private System.Windows.Forms.Button buttonEventEdit;
   2.163 +        private System.Windows.Forms.TabPage tabPageHarmony;
   2.164 +        private System.Windows.Forms.TreeView iTreeViewHarmony;
   2.165 +        private System.Windows.Forms.Button iButtonHarmonyConnect;
   2.166 +        private System.Windows.Forms.Label label2;
   2.167 +        private System.Windows.Forms.TextBox iTextBoxLogitechPassword;
   2.168 +        private System.Windows.Forms.Label labelLogitechUserName;
   2.169 +        private System.Windows.Forms.TextBox iTextBoxLogitechUserName;
   2.170 +        private System.Windows.Forms.Label label1;
   2.171 +        private System.Windows.Forms.TextBox iTextBoxHarmonyHubAddress;
   2.172 +        private System.Windows.Forms.CheckBox iCheckBoxHarmonyEnabled;
   2.173      }
   2.174  }
   2.175  
     3.1 --- a/Server/FormMain.Hid.cs	Sat Aug 13 23:26:54 2016 +0200
     3.2 +++ b/Server/FormMain.Hid.cs	Mon Aug 15 12:11:26 2016 +0200
     3.3 @@ -45,31 +45,31 @@
     3.4              int i = 0;
     3.5              rid[i].usUsagePage = (ushort)SharpLib.Hid.UsagePage.WindowsMediaCenterRemoteControl;
     3.6              rid[i].usUsage = (ushort)SharpLib.Hid.UsageCollection.WindowsMediaCenter.WindowsMediaCenterRemoteControl;
     3.7 -            rid[i].dwFlags = Const.RIDEV_INPUTSINK;
     3.8 +            rid[i].dwFlags = RawInputDeviceFlags.RIDEV_INPUTSINK;
     3.9              rid[i].hwndTarget = Handle;
    3.10  
    3.11              i++;
    3.12              rid[i].usUsagePage = (ushort)SharpLib.Hid.UsagePage.Consumer;
    3.13              rid[i].usUsage = (ushort)SharpLib.Hid.UsageCollection.Consumer.ConsumerControl;
    3.14 -            rid[i].dwFlags = Const.RIDEV_INPUTSINK;
    3.15 +            rid[i].dwFlags = RawInputDeviceFlags.RIDEV_INPUTSINK;
    3.16              rid[i].hwndTarget = Handle;
    3.17  
    3.18              i++;
    3.19              rid[i].usUsagePage = (ushort)SharpLib.Hid.UsagePage.Consumer;
    3.20              rid[i].usUsage = (ushort)SharpLib.Hid.UsageCollection.Consumer.Selection;
    3.21 -            rid[i].dwFlags = Const.RIDEV_INPUTSINK;
    3.22 +            rid[i].dwFlags = RawInputDeviceFlags.RIDEV_INPUTSINK;
    3.23              rid[i].hwndTarget = Handle;
    3.24  
    3.25              i++;
    3.26              rid[i].usUsagePage = (ushort)SharpLib.Hid.UsagePage.GenericDesktopControls;
    3.27              rid[i].usUsage = (ushort)SharpLib.Hid.UsageCollection.GenericDesktop.SystemControl;
    3.28 -            rid[i].dwFlags = Const.RIDEV_INPUTSINK;
    3.29 +            rid[i].dwFlags = RawInputDeviceFlags.RIDEV_INPUTSINK;
    3.30              rid[i].hwndTarget = Handle;
    3.31  
    3.32              i++;
    3.33              rid[i].usUsagePage = (ushort)SharpLib.Hid.UsagePage.GenericDesktopControls;
    3.34              rid[i].usUsage = (ushort)SharpLib.Hid.UsageCollection.GenericDesktop.GamePad;
    3.35 -            rid[i].dwFlags = Const.RIDEV_INPUTSINK;
    3.36 +            rid[i].dwFlags = RawInputDeviceFlags.RIDEV_INPUTSINK;
    3.37              rid[i].hwndTarget = Handle;
    3.38  
    3.39              //i++;
     4.1 --- a/Server/FormMain.cs	Sat Aug 13 23:26:54 2016 +0200
     4.2 +++ b/Server/FormMain.cs	Mon Aug 15 12:11:26 2016 +0200
     4.3 @@ -233,6 +233,9 @@
     4.4              OnWndProc += iCecManager.OnWndProc;
     4.5              ResetCec();
     4.6  
     4.7 +            //Harmony
     4.8 +            ResetHarmony();
     4.9 +
    4.10              //Setup Events
    4.11              PopulateEventsTreeView();
    4.12  
    4.13 @@ -1265,6 +1268,10 @@
    4.14                  comboBoxOpticalDrives.SelectedIndex = 0;
    4.15              }
    4.16  
    4.17 +            //Harmony settings
    4.18 +            iCheckBoxHarmonyEnabled.Checked = Properties.Settings.Default.HarmonyEnabled;
    4.19 +            iTextBoxHarmonyHubAddress.Text = Properties.Settings.Default.HarmonyHubAddress;
    4.20 +
    4.21              //CEC settings
    4.22              checkBoxCecEnabled.Checked = Properties.Settings.Default.CecEnabled;
    4.23              comboBoxHdmiPort.SelectedIndex = Properties.Settings.Default.CecHdmiPort - 1;
    4.24 @@ -2693,6 +2700,27 @@
    4.25          /// <summary>
    4.26          /// 
    4.27          /// </summary>
    4.28 +        private async void ResetHarmony()
    4.29 +        {
    4.30 +            // ConnectAsync already if we have an existing session cookie
    4.31 +            if (Properties.Settings.Default.HarmonyEnabled && File.Exists("SessionToken"))
    4.32 +            {
    4.33 +
    4.34 +                iButtonHarmonyConnect.Enabled = false;
    4.35 +                try
    4.36 +                {
    4.37 +                    await ConnectHarmonyAsync();
    4.38 +                }
    4.39 +                finally
    4.40 +                {
    4.41 +                    iButtonHarmonyConnect.Enabled = true;
    4.42 +                }
    4.43 +            }
    4.44 +        }
    4.45 +
    4.46 +        /// <summary>
    4.47 +        /// 
    4.48 +        /// </summary>
    4.49          private void SetupCecLogLevel()
    4.50          {
    4.51              //Setup log level
    4.52 @@ -3061,5 +3089,106 @@
    4.53              //Make sure our event tree never looses focus
    4.54              ((TreeView) sender).Focus();
    4.55          }
    4.56 +
    4.57 +        private async void iButtonHarmonyConnect_Click(object sender, EventArgs e)
    4.58 +        {
    4.59 +            //Save hub address
    4.60 +            Properties.Settings.Default.HarmonyHubAddress = iTextBoxHarmonyHubAddress.Text;
    4.61 +            Properties.Settings.Default.Save();
    4.62 +
    4.63 +            iButtonHarmonyConnect.Enabled = false;
    4.64 +            try
    4.65 +            {
    4.66 +                await ConnectHarmonyAsync();
    4.67 +            }
    4.68 +            catch (Exception)
    4.69 +            {
    4.70 +                iButtonHarmonyConnect.Enabled = true;
    4.71 +            }
    4.72 +
    4.73 +        }
    4.74 +
    4.75 +
    4.76 +        private async Task ConnectHarmonyAsync()
    4.77 +        {
    4.78 +            Console.WriteLine("Harmony: Connecting... ");
    4.79 +            //First create our client and login
    4.80 +            if (File.Exists("SessionToken"))
    4.81 +            {
    4.82 +                var sessionToken = File.ReadAllText("SessionToken");
    4.83 +                Console.WriteLine("Harmony: Reusing token: {0}", sessionToken);
    4.84 +                Program.HarmonyClient = HarmonyHub.HarmonyClient.Create(iTextBoxHarmonyHubAddress.Text, sessionToken);
    4.85 +            }
    4.86 +            else
    4.87 +            {
    4.88 +                if (string.IsNullOrEmpty(iTextBoxLogitechPassword.Text))
    4.89 +                {
    4.90 +                    Console.WriteLine("Harmony: Credentials missing!");
    4.91 +                    return;
    4.92 +                }
    4.93 +
    4.94 +                Console.WriteLine("Harmony: Authenticating with Logitech servers...");
    4.95 +                Program.HarmonyClient = await HarmonyHub.HarmonyClient.Create(iTextBoxHarmonyHubAddress.Text, iTextBoxLogitechUserName.Text, iTextBoxLogitechPassword.Text);
    4.96 +                File.WriteAllText("SessionToken", Program.HarmonyClient.Token);
    4.97 +            }
    4.98 +
    4.99 +            Console.WriteLine("Harmony: Fetching Harmony Hub configuration...");
   4.100 +
   4.101 +            //Fetch our config
   4.102 +            var harmonyConfig = await Program.HarmonyClient.GetConfigAsync();
   4.103 +            PopulateTreeViewHarmony(harmonyConfig);
   4.104 +
   4.105 +            Console.WriteLine("Harmony: Ready");
   4.106 +        }
   4.107 +
   4.108 +        /// <summary>
   4.109 +        /// 
   4.110 +        /// </summary>
   4.111 +        /// <param name="aConfig"></param>
   4.112 +        private void PopulateTreeViewHarmony(HarmonyHub.Entities.Response.Config aConfig)
   4.113 +        {
   4.114 +            iTreeViewHarmony.Nodes.Clear();
   4.115 +            //Add our devices
   4.116 +            foreach (HarmonyHub.Entities.Response.Device device in aConfig.Devices)
   4.117 +            {
   4.118 +                TreeNode deviceNode = iTreeViewHarmony.Nodes.Add(device.Id, $"{device.Label} ({device.DeviceTypeDisplayName}/{device.Model})");
   4.119 +                deviceNode.Tag = device;
   4.120 +
   4.121 +                foreach (HarmonyHub.Entities.Response.ControlGroup cg in device.ControlGroups)
   4.122 +                {
   4.123 +                    TreeNode cgNode = deviceNode.Nodes.Add(cg.Name);
   4.124 +                    cgNode.Tag = cg;
   4.125 +
   4.126 +                    foreach (HarmonyHub.Entities.Response.Function f in cg.Functions)
   4.127 +                    {
   4.128 +                        TreeNode fNode = cgNode.Nodes.Add(f.Name);
   4.129 +                        fNode.Tag = f;
   4.130 +                    }
   4.131 +                }
   4.132 +            }
   4.133 +
   4.134 +            //treeViewConfig.ExpandAll();
   4.135 +        }
   4.136 +
   4.137 +        private void iCheckBoxHarmonyEnabled_CheckedChanged(object sender, EventArgs e)
   4.138 +        {
   4.139 +            Properties.Settings.Default.HarmonyEnabled = iCheckBoxHarmonyEnabled.Checked;
   4.140 +            Properties.Settings.Default.Save();
   4.141 +        }
   4.142 +
   4.143 +        private async void iTreeViewHarmony_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
   4.144 +        {
   4.145 +            //Upon function node double click we execute it
   4.146 +            var tag = e.Node.Tag as HarmonyHub.Entities.Response.Function;
   4.147 +            if (tag != null && e.Node.Parent.Parent.Tag is HarmonyHub.Entities.Response.Device)
   4.148 +            {
   4.149 +                HarmonyHub.Entities.Response.Function f = tag;
   4.150 +                HarmonyHub.Entities.Response.Device d = (HarmonyHub.Entities.Response.Device)e.Node.Parent.Parent.Tag;
   4.151 +
   4.152 +                Console.WriteLine($"Harmony: Sending {f.Name} to {d.Label}...");
   4.153 +
   4.154 +                await Program.HarmonyClient.SendCommandAsync(d.Id, f.Name);
   4.155 +            }
   4.156 +        }
   4.157      }
   4.158  }
     5.1 --- a/Server/Program.cs	Sat Aug 13 23:26:54 2016 +0200
     5.2 +++ b/Server/Program.cs	Mon Aug 15 12:11:26 2016 +0200
     5.3 @@ -18,13 +18,10 @@
     5.4  //
     5.5  
     5.6  using System;
     5.7 -using System.Collections.Generic;
     5.8 -using System.Linq;
     5.9 -using System.Threading.Tasks;
    5.10  using System.Windows.Forms;
    5.11  using System.Security.Principal;
    5.12 -using System.Diagnostics;
    5.13 -using System.Reflection;
    5.14 +using HarmonyHub;
    5.15 +
    5.16  
    5.17  namespace SharpDisplayManager
    5.18  {
    5.19 @@ -33,6 +30,9 @@
    5.20          //WARNING: This is assuming we have a single instance of our program.
    5.21          //That is what we want but we should enforce it somehow.
    5.22          public static FormMain iFormMain;
    5.23 +
    5.24 +        //
    5.25 +        public static HarmonyClient HarmonyClient { get; set; }
    5.26          /// <summary>
    5.27          /// The main entry point for the application.
    5.28          /// </summary>
     6.1 --- a/Server/Properties/Settings.Designer.cs	Sat Aug 13 23:26:54 2016 +0200
     6.2 +++ b/Server/Properties/Settings.Designer.cs	Mon Aug 15 12:11:26 2016 +0200
     6.3 @@ -164,5 +164,29 @@
     6.4                  this["Events"] = value;
     6.5              }
     6.6          }
     6.7 +        
     6.8 +        [global::System.Configuration.UserScopedSettingAttribute()]
     6.9 +        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    6.10 +        [global::System.Configuration.DefaultSettingValueAttribute("False")]
    6.11 +        public bool HarmonyEnabled {
    6.12 +            get {
    6.13 +                return ((bool)(this["HarmonyEnabled"]));
    6.14 +            }
    6.15 +            set {
    6.16 +                this["HarmonyEnabled"] = value;
    6.17 +            }
    6.18 +        }
    6.19 +        
    6.20 +        [global::System.Configuration.UserScopedSettingAttribute()]
    6.21 +        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    6.22 +        [global::System.Configuration.DefaultSettingValueAttribute("HarmonyHub")]
    6.23 +        public string HarmonyHubAddress {
    6.24 +            get {
    6.25 +                return ((string)(this["HarmonyHubAddress"]));
    6.26 +            }
    6.27 +            set {
    6.28 +                this["HarmonyHubAddress"] = value;
    6.29 +            }
    6.30 +        }
    6.31      }
    6.32  }
     7.1 --- a/Server/Properties/Settings.settings	Sat Aug 13 23:26:54 2016 +0200
     7.2 +++ b/Server/Properties/Settings.settings	Mon Aug 15 12:11:26 2016 +0200
     7.3 @@ -38,5 +38,11 @@
     7.4      <Setting Name="Events" Type="SharpLib.Ear.ManagerEventAction" Scope="User">
     7.5        <Value Profile="(Default)" />
     7.6      </Setting>
     7.7 +    <Setting Name="HarmonyEnabled" Type="System.Boolean" Scope="User">
     7.8 +      <Value Profile="(Default)">False</Value>
     7.9 +    </Setting>
    7.10 +    <Setting Name="HarmonyHubAddress" Type="System.String" Scope="User">
    7.11 +      <Value Profile="(Default)">HarmonyHub</Value>
    7.12 +    </Setting>
    7.13    </Settings>
    7.14  </SettingsFile>
    7.15 \ No newline at end of file
     8.1 --- a/Server/SharpDisplayManager.csproj	Sat Aug 13 23:26:54 2016 +0200
     8.2 +++ b/Server/SharpDisplayManager.csproj	Mon Aug 15 12:11:26 2016 +0200
     8.3 @@ -107,6 +107,14 @@
     8.4      <TargetZone>LocalIntranet</TargetZone>
     8.5    </PropertyGroup>
     8.6    <ItemGroup>
     8.7 +    <Reference Include="agsXMPP, Version=1.3.1.0, Culture=neutral, PublicKeyToken=ff839b81f1debe86, processorArchitecture=MSIL">
     8.8 +      <HintPath>..\packages\Loamen.agsXMPP.1.3.1\lib\net45\agsXMPP.dll</HintPath>
     8.9 +      <Private>True</Private>
    8.10 +    </Reference>
    8.11 +    <Reference Include="HarmonyHub, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    8.12 +      <HintPath>..\packages\SharpLibHarmony.0.2.1\lib\net451\HarmonyHub.dll</HintPath>
    8.13 +      <Private>True</Private>
    8.14 +    </Reference>
    8.15      <Reference Include="LibCecSharp, Version=2.2.0.0, Culture=neutral, processorArchitecture=x86">
    8.16        <HintPath>.\LibCecSharp.dll</HintPath>
    8.17        <SpecificVersion>False</SpecificVersion>
    8.18 @@ -125,7 +133,7 @@
    8.19        <Private>True</Private>
    8.20      </Reference>
    8.21      <Reference Include="SharpLibHid, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
    8.22 -      <HintPath>..\packages\SharpLibHid.1.3.1\lib\net20\SharpLibHid.dll</HintPath>
    8.23 +      <HintPath>..\packages\SharpLibHid.1.4.2\lib\net40\SharpLibHid.dll</HintPath>
    8.24        <Private>True</Private>
    8.25      </Reference>
    8.26      <Reference Include="SharpLibNotification, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
    8.27 @@ -133,8 +141,8 @@
    8.28        <Private>True</Private>
    8.29      </Reference>
    8.30      <Reference Include="SharpLibWin32, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
    8.31 -      <SpecificVersion>False</SpecificVersion>
    8.32 -      <HintPath>..\packages\SharpLibWin32.0.0.7\lib\net20\SharpLibWin32.dll</HintPath>
    8.33 +      <HintPath>..\packages\SharpLibWin32.0.0.9\lib\net20\SharpLibWin32.dll</HintPath>
    8.34 +      <Private>True</Private>
    8.35      </Reference>
    8.36      <Reference Include="System" />
    8.37      <Reference Include="System.Configuration" />
     9.1 --- a/Server/packages.config	Sat Aug 13 23:26:54 2016 +0200
     9.2 +++ b/Server/packages.config	Mon Aug 15 12:11:26 2016 +0200
     9.3 @@ -1,9 +1,11 @@
     9.4  <?xml version="1.0" encoding="utf-8"?>
     9.5  <packages>
     9.6    <package id="LibMiniDisplay" version="1.1.8" targetFramework="net46" />
     9.7 +  <package id="Loamen.agsXMPP" version="1.3.1" targetFramework="net46" />
     9.8    <package id="NAudio" version="1.7.3" targetFramework="net45" />
     9.9    <package id="SharpLibDisplay" version="0.2.5" targetFramework="net46" />
    9.10 -  <package id="SharpLibHid" version="1.3.1" targetFramework="net46" />
    9.11 +  <package id="SharpLibHarmony" version="0.2.1" targetFramework="net46" />
    9.12 +  <package id="SharpLibHid" version="1.4.2" targetFramework="net46" />
    9.13    <package id="SharpLibNotification" version="0.0.1" targetFramework="net46" />
    9.14 -  <package id="SharpLibWin32" version="0.0.7" targetFramework="net45" />
    9.15 +  <package id="SharpLibWin32" version="0.0.9" targetFramework="net46" />
    9.16  </packages>
    9.17 \ No newline at end of file