private void MainForm_Load(object sender, EventArgs e) { m_Capture = new VideoCaptureGraph(); m_Capture.VideoControl = this.pbPreview; m_Capture.OnPlaybackStart += new EventHandler(Playback_OnPlaybackStart); m_Capture.OnPlaybackStop += new EventHandler(Playback_OnPlaybackStop); Playback_OnPlaybackStop(sender, e); btnCapture.Enabled = false; List <DSDevice> _devices = (new DSVideoCaptureCategory()).Objects; foreach (DSDevice _device in _devices) { cmboCaptureDevice.Items.Add(_device); } if (cmboCaptureDevice.Items.Count > 0) { cmboCaptureDevice.SelectedIndex = 0; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { m_Capture.Dispose(); m_Capture = null; }