Esempio n. 1
0
        private async void getGroups()
        {
            groupByName = new Dictionary <string, HueObject>();
            groupList   = new List <HueObject>();
            comboBoxGroup.Items.Clear();
            var groups = await client.GetGroupsAsync();

            if (groups != null)
            {
                foreach (Group grp in groups)
                {
                    HueObject info = new HueObject(grp);
                    if (groupByName.ContainsKey(info.Name.ToLower()))
                    {
                        MessageBox.Show(String.Format("The name {0} appears multiple times." +
                                                      "This might cause confusion when addressing items by their name.", info.Name.ToLower()),
                                        "Warning",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                    else
                    {
                        groupByName.Add(info.Name.ToLower(), info);
                    }
                    groupList.Add(info);
                    comboBoxGroup.Items.Add(info);
                }
            }

            var lights = await client.GetLightsAsync();

            if (lights != null)
            {
                foreach (Light light in lights)
                {
                    HueObject info = new HueObject(light);
                    if (groupByName.ContainsKey(info.Name.ToLower()))
                    {
                        MessageBox.Show(String.Format("The name {0} appears multiple times." +
                                                      "This might cause confusion when addressing items by their name.", info.Name.ToLower()),
                                        "Warning",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                    }
                    else
                    {
                        groupByName.Add(info.Name.ToLower(), info);
                    }
                    groupList.Add(info);
                    comboBoxGroup.Items.Add(info);
                }
            }

            if (comboBoxGroup.Items.Count > 0)
            {
                buttonInfoZone.Enabled      =
                    comboBoxGroup.Enabled   = true;
                comboBoxGroup.SelectedIndex = 0;
            }
        }
Esempio n. 2
0
        private void buttonInfoZone_Click(object sender, EventArgs e)
        {
            HueObject     info = (HueObject)comboBoxGroup.SelectedItem;
            StringBuilder sb   = new StringBuilder();

            if (info.IsBridge)
            {
                sb.AppendLine(String.Format("Bridge {0} ({1})", info.ID, info.Name));
            }
            else if (info.IsLight)
            {
                sb.AppendLine(String.Format("Light {0} ({1})", info.ID, info.Name));
            }
            else
            {
                Group group = (Group)info.Value;
                sb.AppendLine(String.Format("Group {0} ({1}, {2})", info.ID, info.Name, group.Type));
                foreach (string id in info.LightIDs)
                {
                    sb.AppendLine(String.Format("  Contains light : {0}", id));
                }
            }
            sb.AppendLine();
            textBoxResults.Text = sb.ToString();
        }