コード例 #1
0
        private void Devices_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "YeeControl " + GlobalVariables.VERSION + " | www.yeecontrol.com";

            yeelightControlDevices = YeeControlDeviceHelper.GetYeeControlDevices();
            RefreshDeviceList();
            groupBoxActions.Enabled = false;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: iRequire/yeecontrol
        private async void MainForm_Load(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "YeeControl " + GlobalVariables.VERSION + " | www.yeecontrol.com";
            this.Size = defaultSize;

            foreach (YeeControlDevice ycd in YeeControlDeviceHelper.GetYeeControlDevices())
            {
                allDevices.Add(new Device(ycd.Hostname));
            }
            await allDevices.Connect();


            RefreshPresets();
            RefreshCheckedListBox();
            RefreshLightState();

            listBox1.SelectedIndexChanged += listBox1_SelectedIndexChanged;

            RT(() => RefreshLightState(), 7, cts.Token);
        }
コード例 #3
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();
                }
            }
        }
コード例 #4
0
        private async void button_Discover_Click(object sender, EventArgs e)
        {
            button_Discover.BeginInvoke((MethodInvoker) delegate()
            {
                button_Discover.Enabled = false;
            });
            button_Open.BeginInvoke((MethodInvoker) delegate()
            {
                button_Open.Enabled = false;
            });
            await GetDevicesAsync();

            button_Discover.BeginInvoke((MethodInvoker) delegate()
            {
                button_Discover.Enabled = true;
            });
            button_Open.BeginInvoke((MethodInvoker) delegate()
            {
                button_Open.Enabled = true;
            });

            YeeControlDeviceHelper.SaveYeeControlDevices(yeelightControlDevices);
            RefreshDeviceList();
        }