|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using dshow;
using dshow.Core;
namespace Gui
{
/// <summary>
/// Summary description for CaptureDeviceForm.
/// </summary>
internal class CaptureDeviceForm : System.Windows.Forms.Form
{
FilterCollection filters;
private System.Windows.Forms.ComboBox deviceCombo;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
private string device;
private System.Windows.Forms.Label lblCapture;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
// Device
internal string Device
{
get { return device; }
}
// Constructor
internal CaptureDeviceForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
try
{
filters = new FilterCollection(FilterCategory.VideoInputDevice);
if (filters.Count == 0)
throw new ApplicationException();
// add all devices to combo
foreach (Filter filter in filters)
{
deviceCombo.Items.Add(filter.Name);
}
}
catch (ApplicationException)
{
deviceCombo.Items.Add("No local capture devices");
deviceCombo.Enabled = false;
okButton.Enabled = false;
}
deviceCombo.SelectedIndex = 0;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CaptureDeviceForm));
this.lblCapture = new System.Windows.Forms.Label();
this.deviceCombo = new System.Windows.Forms.ComboBox();
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// lblCapture
//
this.lblCapture.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblCapture.Location = new System.Drawing.Point(56, 8);
this.lblCapture.Name = "lblCapture";
this.lblCapture.Size = new System.Drawing.Size(248, 31);
this.lblCapture.TabIndex = 0;
this.lblCapture.Text = "Please select a local capture device.";
this.lblCapture.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// deviceCombo
//
this.deviceCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.deviceCombo.Location = new System.Drawing.Point(8, 56);
this.deviceCombo.Name = "deviceCombo";
this.deviceCombo.Size = new System.Drawing.Size(296, 21);
this.deviceCombo.TabIndex = 6;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cancelButton.Location = new System.Drawing.Point(232, 90);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(72, 23);
this.cancelButton.TabIndex = 9;
this.cancelButton.Text = "Cancel";
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.okButton.Location = new System.Drawing.Point(144, 90);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 24);
this.okButton.TabIndex = 8;
this.okButton.Text = "Ok";
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Controls.Add(this.lblCapture);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(312, 46);
this.panel1.TabIndex = 10;
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(44, 32);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// CaptureDeviceForm
//
this.AcceptButton = this.okButton;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(312, 119);
this.Controls.Add(this.panel1);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.deviceCombo);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CaptureDeviceForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Open Local Capture Device";
this.Load += new System.EventHandler(this.CaptureDeviceForm_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
// On "Ok" button
private void okButton_Click(object sender, System.EventArgs e)
{
device = filters[deviceCombo.SelectedIndex].MonikerString;
}
private void CaptureDeviceForm_Load(object sender, System.EventArgs e)
{
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.