public void EnumerateAndSetWebcams() { Store.Data.Webcam.Webcams.Clear(); InitializeWebcamObsSource(null); ObsProperties webcamProperties = Store.Data.Webcam.Source.GetProperties(); ObsProperty[] webcamPropertyList = webcamProperties.GetPropertyList(); for (int i = 0; i < webcamPropertyList.Length; i++) { if (webcamPropertyList[i].Name.Equals("video_device_id")) { string[] propertyNames = webcamPropertyList[i].GetListItemNames(); object[] propertyValues = webcamPropertyList[i].GetListItemValues(); for (int j = 0; j < propertyNames.Length; j++) { Store.Data.Webcam.Webcams.Add(new WebcamDevice(propertyNames[j], (string)propertyValues[j])); } } } }
/// <param name="focusProperty"> Optional: Sets focus to control of this property.</param> private void RefreshProperties(ObsProperty focusProperty = null) { // prevent properties triggering another refresh when previous refresh is still ongoing if (++refreshCount > 0) { return; } ScrollableControl parent = (Parent as ScrollableControl); var oldScrollPos = parent != null ? parent.VerticalScroll.Value : 0; List <Control> controls = new List <Control>(); Control focusControl = null; do { refreshCount = 0; controls.Clear(); ObsProperty[] propertyList = properties.GetPropertyList(); foreach (ObsProperty property in propertyList) { PropertyControl control = new PropertyControl(this, property, settings) { Enabled = property.Enabled, Visible = property.Visible }; if (focusProperty != null && property.GetPointer() == focusProperty.GetPointer()) { focusControl = control.Controls[1]; } controls.Add(control); } }while (refreshCount > 0); panel.SuspendLayout(); panel.Controls.Clear(); panel.Controls.AddRange(controls.ToArray()); panel.Select(); panel.Focus(); // restore last focused control and scroll state if (focusControl != null) { focusControl.Focus(); focusControl.Select(); } if (parent != null) { parent.VerticalScroll.Value = oldScrollPos; } panel.ResumeLayout(); PerformLayout(); refreshCount = -1; }