예제 #1
0
        private void OnDeviceFound(Device device)
        {
            YeeControlDevice ycd = new YeeControlDevice();

            ycd.Hostname = device.Hostname;

            foreach (YeeControlDevice y in yeelightControlDevices)
            {
                if (y.Hostname == ycd.Hostname)
                {
                    return;
                }
            }

            yeelightControlDevices.Add(ycd);

            RefreshDeviceList();
        }
예제 #2
0
        private void button_Delete_Click(object sender, EventArgs e)
        {
            string hostname = listBox_Devices.SelectedItem?.ToString();

            if (hostname is string)
            {
                int found = -1;
                for (int i = 0; i < yeelightControlDevices.Count; i++)
                {
                    YeeControlDevice y = yeelightControlDevices[i];
                    if (y.Hostname == hostname)
                    {
                        found = i;
                        break;
                    }
                }
                if (found > -1)
                {
                    yeelightControlDevices = YeeControlDeviceHelper.DeleteYeeControlAtIndex(found);
                    RefreshDeviceList();
                }
            }
        }