public bool IsWebCamAvailible() { var device = Configuration.GetDevice(DeviceType.WebCam); var videoDevices = new AForge.Video.DirectShow.FilterInfoCollection(FilterCategory.VideoInputDevice); //если запускаем в первый раз, то можно заодно сохранить первую попавшуюся камеру, если такая есть.. if (device.Name == "") { if (videoDevices.Count != 0) { Configuration.SaveDevice(new HWDeviceDesciption { Device = DeviceType.WebCam, Name = videoDevices[0].Name, DeviceId = videoDevices[0].MonikerString }); } return(true); } for (int i = 0; i < videoDevices.Count; i++) { if (device.Name == videoDevices[i].Name) { if (device.DeviceId == videoDevices[i].MonikerString) { return(true); } } } return(false); }
private void SaveSetting_Click(object sender, EventArgs e) { if (devices.Any()) { var selectedDevice = devices.First(p => p.Name == DevicesList.SelectedItem.ToString()); _deviceConfiguration.SaveDevice(selectedDevice); } this.Close(); }