home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / Managed / DirectSound / CaptureSound / Devices.cs < prev    next >
Encoding:
Text File  |  2004-09-27  |  3.3 KB  |  102 lines

  1. //----------------------------------------------------------------------------
  2. // File: Devices.cs
  3. //
  4. // Copyright (c) Microsoft Corp. All rights reserved.
  5. //-----------------------------------------------------------------------------
  6. using System;
  7. using System.Drawing;
  8. using System.Windows.Forms;
  9. using Microsoft.DirectX.DirectSound;
  10.  
  11. public class DevicesForm : Form
  12. {
  13.     private Button buttonOk;
  14.     private Button buttonCancel;
  15.     private Label labelStatic;
  16.     private ComboBox comboboxCaptureDeviceCombo;
  17.     private MainForm mf = null;
  18.  
  19.     CaptureDevicesCollection devices = new CaptureDevicesCollection();
  20.  
  21.     public DevicesForm(MainForm mf)
  22.     {
  23.         //
  24.         // Required for Windows Form Designer support
  25.         //
  26.         InitializeComponent();
  27.         this.mf = mf;
  28.  
  29.         foreach (DeviceInformation info in devices)
  30.             comboboxCaptureDeviceCombo.Items.Add(info.Description);
  31.  
  32.         comboboxCaptureDeviceCombo.SelectedIndex = 0;
  33.     }
  34.     #region InitializeComponent code
  35.     private void InitializeComponent()
  36.     {
  37.         this.buttonOk = new System.Windows.Forms.Button();
  38.         this.buttonCancel = new System.Windows.Forms.Button();
  39.         this.labelStatic = new System.Windows.Forms.Label();
  40.         this.comboboxCaptureDeviceCombo = new System.Windows.Forms.ComboBox();
  41.         this.SuspendLayout();
  42.         // 
  43.         // buttonOk
  44.         // 
  45.         this.buttonOk.Location = new System.Drawing.Point(10, 41);
  46.         this.buttonOk.Name = "buttonOk";
  47.         this.buttonOk.TabIndex = 0;
  48.         this.buttonOk.Text = "OK";
  49.         this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
  50.         // 
  51.         // buttonCancel
  52.         // 
  53.         this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  54.         this.buttonCancel.Location = new System.Drawing.Point(231, 41);
  55.         this.buttonCancel.Name = "buttonCancel";
  56.         this.buttonCancel.TabIndex = 1;
  57.         this.buttonCancel.Text = "Cancel";
  58.         // 
  59.         // labelStatic
  60.         // 
  61.         this.labelStatic.Location = new System.Drawing.Point(10, 14);
  62.         this.labelStatic.Name = "labelStatic";
  63.         this.labelStatic.Size = new System.Drawing.Size(78, 13);
  64.         this.labelStatic.TabIndex = 2;
  65.         this.labelStatic.Text = "Capture Device:";
  66.         // 
  67.         // comboboxCaptureDeviceCombo
  68.         // 
  69.         this.comboboxCaptureDeviceCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  70.         this.comboboxCaptureDeviceCombo.Location = new System.Drawing.Point(93, 11);
  71.         this.comboboxCaptureDeviceCombo.Name = "comboboxCaptureDeviceCombo";
  72.         this.comboboxCaptureDeviceCombo.Size = new System.Drawing.Size(213, 21);
  73.         this.comboboxCaptureDeviceCombo.Sorted = true;
  74.         this.comboboxCaptureDeviceCombo.TabIndex = 3;
  75.         // 
  76.         // DevicesForm
  77.         // 
  78.         this.AcceptButton = this.buttonOk;
  79.         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  80.         this.CancelButton = this.buttonCancel;
  81.         this.ClientSize = new System.Drawing.Size(316, 79);
  82.         this.Controls.AddRange(new System.Windows.Forms.Control[] {
  83.                                                                       this.buttonOk,
  84.                                                                       this.buttonCancel,
  85.                                                                       this.labelStatic,
  86.                                                                       this.comboboxCaptureDeviceCombo});
  87.         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  88.         this.Name = "DevicesForm";
  89.         this.Text = "Select Capture Device";
  90.         this.ResumeLayout(false);
  91.  
  92.     }
  93.     #endregion
  94.     private void buttonOk_Click(object sender, System.EventArgs e)
  95.     {
  96.         if (0 < comboboxCaptureDeviceCombo.Items.Count)
  97.             mf.CaptureDeviceGuid = devices[0].DriverGuid;
  98.         
  99.         Close();
  100.     }
  101. }
  102.