public bool Init(Control control, int x, int y, string cameraName) { if (this.IsOpen && this.DeviceName.Equals(cameraName)) { throw new Exception("This camera is opend."); } this.DeviceName = cameraName; this.Width = x; this.Height = y; if (this.DeviceNames.Count <= 0) { throw new Exception("Not find this camera device."); } if (!this.DeviceNames.Contains(DeviceName)) { throw new Exception("Not find this set name device."); } if (control == null) { throw new Exception("The target control parent is null."); } control.Controls.Add(this.CameraControl); this.CameraControl.Dock = DockStyle.Fill; int cameraIndex = this.DeviceNames.IndexOf(DeviceName); var moniker = this.CameraChoice.Devices[cameraIndex].Mon; ResolutionList resolutions = Camera_NET.Camera.GetResolutionList(moniker); if (resolutions == null) { throw new Exception("This camera is not find resolutions"); } var resolution = resolutions.Find(delegate(Resolution a) { return(a.Height == y && a.Width == x); }); if (resolution == null) { throw new Exception("This resolution is not find."); } this.CameraControl.SetCamera(moniker, resolution); isOpen = true; return(IsOpen); }
private void SetCameraControlSourceAndResolution(string camName, string res) { LogDebug(String.Format("Setting camera to {0} at res {1}", camName, res)); CameraChoice chooser = new CameraChoice(); chooser.UpdateDeviceList(); DsDevice chosenCam = chooser.GetCameraByName(camName); ResolutionList resolutions = Camera.GetResolutionList(chosenCam.Mon); Camera_NET.Resolution chosenRes = resolutions.Find(x => x.ToString() == res); camControl.SetCamera(chosenCam.Mon, chosenRes); }