private void btnOk_Click(object sender, EventArgs e) { // I'm making sure that filters actually contains something. if (rdoCaptureDevice.Checked && filters.Count > 0) // Chose to use a capture videoSource. { // create video source VideoCaptureDevice localSource = new VideoCaptureDevice(); localSource.Source = filters[deviceCombo.SelectedIndex].MonikerString; localSource.DesiredFrameSize = new Size(int.Parse(txtWidth.Text), int.Parse(txtHeight.Text)); videoSource = localSource; } // Make sure that the text box contains a path. else if (!txtFileName.Text.Equals(String.Empty)) // Chose to load a movie. { // create video source AVIFileVideoSource fileSource = new AVIFileVideoSource(); fileSource.Source = txtFileName.Text; videoSource = fileSource; } else if (!txtMjpegUrl.Text.Equals(String.Empty)) // Chose to load a url. { MJPEGStream stream = new MJPEGStream(txtMjpegUrl.Text); videoSource = stream; } else if (!txtJpgUrl.Text.Equals(String.Empty)) // Chose to load a url. { JPEGStream stream = new JPEGStream(txtJpgUrl.Text); videoSource = stream; } else // Unable to display. { showErrorMessage("No video source was chosen."); return; } DialogResult = DialogResult.OK; Hide(); }
// "Open" menu item clieck - open AVI file private void openToolStripMenuItem_Click( object sender, EventArgs e ) { if ( openFileDialog.ShowDialog( ) == DialogResult.OK ) { // create video source AVIFileVideoSource fileSource = new AVIFileVideoSource( openFileDialog.FileName ); OpenVideoSource( fileSource ); } }