示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aConfig"></param>
        private void PopulateTreeViewHarmony(HarmonyHub.Config aConfig)
        {
            iTreeViewHarmony.Nodes.Clear();
            //Add our devices
            foreach (HarmonyHub.Device device in aConfig.Devices)
            {
                TreeNode deviceNode = iTreeViewHarmony.Nodes.Add(device.Id, $"{device.Label} ({device.DeviceTypeDisplayName}/{device.Model})");
                deviceNode.Tag = device;

                foreach (HarmonyHub.ControlGroup cg in device.ControlGroups)
                {
                    TreeNode cgNode = deviceNode.Nodes.Add(cg.Name);
                    cgNode.Tag = cg;

                    foreach (HarmonyHub.Function f in cg.Functions)
                    {
                        TreeNode fNode = cgNode.Nodes.Add(f.Label);
                        fNode.Tag = f;
                    }
                }
            }

            //treeViewConfig.ExpandAll();
        }
示例#2
0
        public void Init()
        {
            DiscoveryService service = new DiscoveryService();

            service.HubFound += async(sender, e) => {
                // stop discovery once we've found one hub
                service.StopDiscovery();
                try
                {
                    _harmonyHub = new HarmonyHub.Client(e.HubInfo.IP);
                    _harmonyHub.OnActivityChanged += CurrentActivityUpdated;
                    await _harmonyHub.OpenAsync();

                    _config = await _harmonyHub.GetConfigAsync();

                    _currentActivityId = await _harmonyHub.GetCurrentActivityAsync();
                }
                catch
                {
                    // nothing to fix
                }
            };
            service.StartDiscovery();
        }