Example #1
0
 private void ProcessMessages(string msg)
 {
     if (msg.StartsWith("Msg"))
     {
         MessageBox.Show(msg.Substring(3, msg.Length - 3), "Messasge", MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
     }
     else if (msg == "Live")
     {
         camera = new WebCam();
         if (!camera.IsConnected())
         {
             camera.Connect();
             cameraWorker.RunWorkerAsync();
         }
         else
         {
             cameraWorker.CancelAsync();
         }
     }
     else if (msg == "ScreenCap")
     {
         ScreenCap(true);
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
    if (!camera.IsConnected())
         {
             camera.Connect();
             camera.Update();
             MemoryStream ms = new MemoryStream();
             camera.CalcBitmap().Save(ms, ImageFormat.Bmp);
             byte[] bitmapData = ms.ToArray();
             MemoryStream stream = new MemoryStream(bitmapData);
             pictureBox1.Image = new Bitmap(stream);
         }
         else
         {
             Application.Exit();
         }
 }