void SaveProxyConfig() { if (Proxy != null) { DSCameraProxy cam = (DSCameraProxy)Proxy; using (StreamWriter sw = File.CreateText(ConfigPath)) { using (XmlWriter writer = XmlWriter.Create(sw)) { writer.WriteStartDocument(); writer.WriteStartElement("Config"); writer.WriteStartAttribute("Type"); writer.WriteValue(cam.GetType().ToString()); writer.WriteEndAttribute(); writer.WriteStartAttribute("HardwareId"); writer.WriteValue(cam.HardwareId); writer.WriteEndAttribute(); List <DirectShowLib.CameraControlProperty> list = Enum.GetValues(typeof(DirectShowLib.CameraControlProperty)).Cast <DirectShowLib.CameraControlProperty>().ToList(); foreach (DirectShowLib.CameraControlProperty prop in list) { DSCameraProxy.ControlPropertyInfo info = cam.GetControlPropertyInfo(prop, true); if (info != null) { writer.WriteStartElement("Prop"); writer.WriteStartAttribute("Name"); writer.WriteValue(prop.ToString()); writer.WriteEndAttribute(); writer.WriteStartAttribute("Value"); writer.WriteValue(info.Value); writer.WriteEndAttribute(); writer.WriteEndElement(); } } writer.WriteEndDocument(); } } //TODO // SAVE TO Program.HardwareConfigPath\[PROXYTYPE].HARDWARE.XML } }
private void AlignFromCamera() { DSCameraProxy.ControlPropertyInfo info = GetPropertyInfo(); this.Enabled = info != null; if (info != null) { LoadingProps = true; try { this.TrackBar.Minimum = info.Min; this.TrackBar.Maximum = info.Max; this.TrackBar.SmallChange = info.Delta; this.TrackBar.LargeChange = info.Delta * 2; this.TrackBar.Value = info.Value; this.AutoCheckBox.Checked = info.ValueFlags == DirectShowLib.CameraControlFlags.Auto; this.TrackBar.Enabled = !this.AutoCheckBox.Checked; if (this.AutoCheckBox.Checked) { this.ValueLabel.Text = "Auto"; } else { this.ValueLabel.Text = info.Value.ToString(); } } catch { this.Enabled = false; } LoadingProps = false; } if (!this.Enabled) { this.ValueLabel.Text = string.Empty; } }