private void comboBoxResolutionList_SelectedIndexChanged(object sender, EventArgs e) { if (!cameraControl.CameraCreated) { return; } int comboBoxResolutionIndex = comboBoxResolutionList.SelectedIndex; if (comboBoxResolutionIndex < 0) { return; } resolutions = Camera.GetResolutionList(cameraControl.Moniker); if (resolutions == null) { return; } if (comboBoxResolutionIndex >= resolutions.Count) { return; // throw } if (0 == resolutions[comboBoxResolutionIndex].CompareTo(cameraControl.Resolution)) { // this resolution is already selected return; } // Recreate camera SetCamera(cameraControl.Moniker, resolutions[comboBoxResolutionIndex]); }
private void FillResolutionList() { comboBoxResolutionList.Items.Clear(); if (!cameraControl.CameraCreated) { return; } resolutions = Camera.GetResolutionList(cameraControl.Moniker); if (resolutions == null) { return; } int index_to_select = -1; for (int index = 0; index < resolutions.Count; index++) { comboBoxResolutionList.Items.Add(resolutions[index].ToString()); if (resolutions[index].CompareTo(cameraControl.Resolution) == 0) { index_to_select = index; } } // select current resolution if (index_to_select >= 0) { comboBoxResolutionList.SelectedIndex = index_to_select; } }