internal static void ShowInstance() { Webcam cam = WebcamManager.FindByName(Settings.CamName); if (cam != null) { if (s_instance == null) { s_instance = new NotifyForm(); } if (Settings.ScheduleMaxResultionAndQuality) { cam.Config(new WebcamConfiguration(Settings.CamConfigSizeMax, Settings.CamConfigBPPMax, Settings.CamConfigMediaSubTypeMax)); } else { cam.Config(new WebcamConfiguration(Settings.CamConfigSize, Settings.CamConfigBPP, Settings.CamConfigMediaSubType)); } s_instance.m_cam = cam; s_instance.AnimateIn(); } }
// take picture according to settings right now private void TakePicture(object sender, EventArgs e) { Webcam cam = confWebcam.SelectedItem as Webcam; WebcamWithPreview camp = cam as WebcamWithPreview; if ((m_takePictureWithPreviewAsync != null) && (sender == takePicturePicture) && (camp != null)) { camp.TakePictureEnd(); } if ((m_takePictureAsync == null) && (m_takePictureWithPreviewAsync == null) && (cam != null)) { takePictureSaveButton.Enabled = false; cam.Config(confResolution.Resolution); if (camp != null) { takePicturePicture.Text = string.Empty; BindHelp(takePicturePicture, Language.FormatString(Language.LanguageString.MainForm_Help_VideoStreamFreezeTitle), Language.FormatString(Language.LanguageString.MainForm_Help_VideoStreamFreezeText)); camp.DisplacementMap = null; if ((takePictureDisplacement.CurrentPicture != null) && (takePictureDisplacement.CurrentPicture.Picture.Length > 0)) { camp.DisplacementMap = new Bitmap(takePictureDisplacement.CurrentPicture.Picture); } takePicturePicture.DisplayBitmap = new Bitmap(confResolution.Resolution.Size.Width, confResolution.Resolution.Size.Height, confResolution.Resolution.PixelFormat); m_takePictureWithPreviewAsync = new TakePictureWithPreview(camp.TakePicture); m_takePictureWithPreviewAsync.BeginInvoke(takePicturePicture, (AsyncCallback) delegate(IAsyncResult result) { try { m_takePictureWithPreviewAsync.EndInvoke(result); confAcceptButton.Invoke((MethodInvoker) delegate() { takePictureSaveButton.Enabled = true; }); } catch (Exception ex) { try { confAcceptButton.Invoke((MethodInvoker) delegate() { takePicturePicture.Text = Language.FormatString(Language.LanguageString.MainForm_FailedToTakePicture); }); } catch (Exception) { } } finally { m_takePictureWithPreviewAsync = null; } }, null); } else { BindHelp(takePicturePicture, Language.FormatString(Language.LanguageString.MainForm_Help_PictureTitle), Language.FormatString(Language.LanguageString.MainForm_Help_PictureText)); takePicturePicture.Text = Language.FormatString(Language.LanguageString.MainForm_TakePicture_TakingPicture); m_takePictureAsync = new TakePicture(cam.TakePicture); m_takePictureAsync.BeginInvoke((AsyncCallback) delegate(IAsyncResult result) { try { takePicturePicture.DisplayBitmap = m_takePictureAsync.EndInvoke(result); confAcceptButton.Invoke((MethodInvoker) delegate() { takePictureSaveButton.Enabled = true; takePicturePicture.Text = string.Empty; }); } catch (Exception ex) { try { confAcceptButton.Invoke((MethodInvoker) delegate() { takePicturePicture.Text = Language.FormatString(Language.LanguageString.MainForm_FailedToTakePicture); }); } catch (Exception) { } } finally { m_takePictureAsync = null; } }, null); } } }