private void btnApplySettings_Click(object sender, EventArgs e) { var mainForm = (FrmPrincipal)Application.OpenForms["FrmPrincipal"]; if (mainForm == null) { MessageBox.Show(@"Can not reached Main Form.", @"Warning"); return; } var deviceSignature = cbCaptureDevices.SelectedValue; var deviceResolution = cbVideoResolutions.SelectedIndex; if (deviceSignature == null || deviceResolution == -1) { MessageBox.Show(@"Can not reached the device and/or device resolution properties.", @"Warning"); return; } var currDevice = _captureDeviceManager.GetCaptureDevices().FirstOrDefault(i => i.DeviceSignature.Equals(deviceSignature)); if (currDevice == null) { MessageBox.Show(@"Can not reached the device.", @"Warning"); return; } currDevice.Resolution = deviceResolution; mainForm.Camara = currDevice; DialogResult = DialogResult.OK; }
private void btnApplySettings_Click(object sender, EventArgs e) { var mainForm = (FormDetection)Application.OpenForms["FormDetection"]; if (mainForm == null) { MessageBox.Show(@"Не может достичь главной формы", @"Ошибка"); return; } var deviceSignature = cbCaptureDevices.SelectedValue; var deviceResolution = cbVideoResolutions.SelectedIndex; if (deviceSignature == null || deviceResolution == -1) { MessageBox.Show(@"Недостижимое разрешение устройства.", @"Ошибка"); return; } var currDevice = captureDeviceManager.GetCaptureDevices().FirstOrDefault(i => i.DeviceSignature.Equals(deviceSignature)); if (currDevice == null) { MessageBox.Show(@"Недостижимое устройство.", @"Ошибка"); return; } currDevice.Resolution = deviceResolution; mainForm.CurrCaptureDevice = currDevice; DialogResult = DialogResult.OK; }