private void UpdateFormatList() { _pendingFormat = null; isUpdatingFormatList = true; cbFormats.BeginUpdate(); cbFormats.Items.Clear(); try { if (_camera != null) { foreach (NMediaFormat format in _camera.GetFormats()) { cbFormats.Items.Add(format); } NMediaFormat currentFormat = _camera.GetCurrentFormat(); if (currentFormat != null) { int index = cbFormats.Items.IndexOf(currentFormat); if (index == -1) { cbFormats.Items.Add(currentFormat); } cbFormats.SelectedItem = currentFormat; } } } finally { cbFormats.EndUpdate(); cbFormats.Enabled = cbFormats.Items.Count > 0; isUpdatingFormatList = false; } }
private void btCaptureDevicePhoto_Click(object sender, EventArgs e) { try { buttonUseImage.Enabled = true; _croppedImage = null; var camera = _cameras[comboBoxCameras.SelectedIndex]; _cvfs = activeCamera.GetFormats(); timer.Start(); backgroundWorker.RunWorkerAsync(camera); } catch (Exception exp) { _errorLog.Append(exp.ToString() + Environment.NewLine); } finally { btCaptureDevicePhoto.Enabled = false; buttonStopCapture.Enabled = true; } }