using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using WebCamLib;

namespace Qurtaba
{
    public partial class MainForm : Form
    {        
        public MainForm()
        {
            InitializeComponent();
        }

        private void btnSelectDevice_Click(object sender, EventArgs e) 
        {
            Device d = DeviceManager.GetDevice(cmbDevices.SelectedIndex);
            d.ShowWindow(this.picCapture);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {            
            Device[] devices = DeviceManager.GetAllDevices();

            foreach (Device d in devices)
            {
                cmbDevices.Items.Add(d);
            }

            if (devices.Length > 0)
            {
                cmbDevices.SelectedIndex = 0;
            }            
        }

        private void btnStopCam_Click(object sender, EventArgs e)
        {
            Device d = DeviceManager.GetDevice(cmbDevices.SelectedIndex);
            d.Stop();
        }

    }
}