Starting renaming to HTCIC.
Setup update and test.
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.ComponentModel;
9 using System.Threading.Tasks;
10 using System.Windows.Forms;
11 using CodeProject.Dialog;
13 namespace SharpDisplayManager
15 public partial class FormSelectHarmonyCommand : Form
17 public FormSelectHarmonyCommand()
19 InitializeComponent();
22 public string DeviceId;
23 public string Command;
28 /// <param name="sender"></param>
29 /// <param name="e"></param>
30 private void FormSelectHarmonyCommand_Load(object sender, EventArgs e)
32 if (Program.HarmonyConfig != null)
34 PopulateTreeViewHarmony(Program.HarmonyConfig);
38 ErrBox.Show("No Harmony Hub configuration!");
46 /// <param name="aConfig"></param>
47 private void PopulateTreeViewHarmony(HarmonyHub.Config aConfig)
49 iTreeViewHarmony.Nodes.Clear();
51 foreach (HarmonyHub.Device device in aConfig.Devices)
53 TreeNode deviceNode = iTreeViewHarmony.Nodes.Add(device.Id, $"{device.Label} ({device.DeviceTypeDisplayName}/{device.Model})");
54 deviceNode.Tag = device;
56 foreach (HarmonyHub.ControlGroup cg in device.ControlGroups)
58 TreeNode cgNode = deviceNode.Nodes.Add(cg.Name);
61 foreach (HarmonyHub.Function f in cg.Functions)
63 TreeNode fNode = cgNode.Nodes.Add(f.Label);
69 //treeViewConfig.ExpandAll();
75 /// <param name="sender"></param>
76 /// <param name="e"></param>
77 private async void iTreeViewHarmony_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
79 //Upon function node double click we execute it, so that user can test
80 var tag = e.Node.Tag as HarmonyHub.Function;
81 if (tag != null && e.Node.Parent.Parent.Tag is HarmonyHub.Device)
83 HarmonyHub.Function f = tag;
84 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
86 Trace.WriteLine($"Harmony: Sending {f.Label} to {d.Label}...");
88 await Program.HarmonyClient.TrySendKeyPressAsync(d.Id, f.Action.Command);
95 /// <param name="sender"></param>
96 /// <param name="e"></param>
97 private void iTreeViewHarmony_AfterSelect(object sender, TreeViewEventArgs e)
99 //Enable ok button if a function is selected
100 iButtonOk.Enabled = e.Node.Tag is HarmonyHub.Function;
102 // Get selected device ID and function name
103 HarmonyHub.Function f = e.Node.Tag as HarmonyHub.Function;
104 if (f != null && e.Node.Parent.Parent.Tag is HarmonyHub.Device)
106 HarmonyHub.Device d = (HarmonyHub.Device)e.Node.Parent.Parent.Tag;
109 Command = f.Action.Command;