private void comboBoxResolutionList_SelectedIndexChanged(object sender, EventArgs e) { if (this._Camera == null) { return; } int comboBoxResolutionIndex = comboBoxResolutionList.SelectedIndex; if (comboBoxResolutionIndex < 0) { return; } ResolutionList resolutions = CameraHelpers.GetResolutionList(this._Camera.Moniker); if (resolutions == null) { return; } if (comboBoxResolutionIndex >= resolutions.Count) { return; // throw } if (0 == resolutions[comboBoxResolutionIndex].CompareTo(this._Camera.Resolution)) { // this resolution is already selected return; } // Recreate camera this.SetCamera(this._Camera.Moniker, resolutions[comboBoxResolutionIndex]); }
private void FillResolutionList() { comboBoxResolutionList.Items.Clear(); this.comboBoxResolutionList.Enabled = false; if (this._Camera == null) { return; } if (this._Camera.Resolution == null) { return; } ResolutionList resolutions = CameraHelpers.GetResolutionList(this._Camera.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(this._Camera.Resolution) == 0) { index_to_select = index; } } // select current resolution if (index_to_select >= 0) { this.comboBoxResolutionList.SelectedIndex = index_to_select; this.comboBoxResolutionList.Enabled = true; } }