private void btn_Detect_Click(object sender, EventArgs e) { string strNewIP = YeelightVideo.GetLightIP(txt_Gateway.Text); if (!string.IsNullOrEmpty(strNewIP)) { txt_IP.Text = strNewIP; } }
private void btn_Start_Click(object sender, EventArgs e) { if (bInitialized) { timer_Preview.Enabled = false; btn_Start.Text = "Start"; yeeLightVideo.Stop(); yeeLightVideo = new YeelightVideo(); GC.Collect(); bInitialized = false; EnableForm(); return; } if (!yeeLightVideo.Initialize(this.txt_IP.Text, combo_Displays.SelectedIndex, (ColorAlgorithm)arrAlgorithms.GetValue(combo_Algorithms.SelectedIndex), (int)numeric_Interval.Value, (double)num_colorBrightness.Value, (double)num_BrightFactor.Value, check_UpdateBrightness.Checked, check_Preview.Checked, check_allPreview.Checked)) { MessageBox.Show("Failed connecting to camera IP"); return; } bInitialized = true; btn_Start.Text = "Stop"; timer_Preview.Enabled = check_Preview.Checked; if (check_Preview.Checked) { picture_Preview.Image = yeeLightVideo.PreviewImage; timer_Preview.Interval = (int)numeric_Interval.Value; } combo_Displays.Enabled = false; txt_IP.Enabled = false; combo_Algorithms.Enabled = false; numeric_Interval.Enabled = false; check_Preview.Enabled = false; check_UpdateBrightness.Enabled = false; yeeLightVideo.Execute(); }
private void Initialize() { Screen[] allScreens = Screen.AllScreens; for (int i = 0; i < allScreens.Length; i++) { Screen scr = allScreens[i]; string strScreen = $"{i + 1} - {scr.Bounds.Width}x{scr.Bounds.Height}"; combo_Displays.Items.Add(strScreen); } combo_Displays.SelectedIndex = 0; arrAlgorithms = Enum.GetValues(typeof(ColorAlgorithm)); for (int i = 0; i < arrAlgorithms.Length; i++) { object algo = arrAlgorithms.GetValue(i); combo_Algorithms.Items.Add(algo); } combo_Algorithms.SelectedIndex = 0; yeeLightVideo = new YeelightVideo(); }