static private FormatString ( LanguageString stringName ) : string | ||
stringName | LanguageString | |
Résultat | string |
internal void TakePicture() { if ((m_takePictureAsync == null) && (m_cam != null)) { if (m_countdownTimer != null) { m_countdownTimer.Abort(); m_countdownTimer = null; } pictureBox.Text = Language.FormatString(Language.LanguageString.MainForm_TakePicture_TakingPicture); m_takePictureAsync = new TakePicture(m_cam.TakePicture); m_takePictureAsync.BeginInvoke((AsyncCallback) delegate(IAsyncResult result) { try { pictureBox.DisplayBitmap = m_takePictureAsync.EndInvoke(result); Invoke((MethodInvoker) delegate() { try { Common.SaveJPEG(pictureBox.DisplayBitmap, Path.Combine(Settings.OutputFolder, m_fileName)); pictureBox.Text = string.Empty; } catch (Exception) { pictureBox.Text = Language.FormatString(Language.LanguageString.NotifyForm_FailedToSave) + "\r\n" + m_fileName; } }); } catch (Exception) { Invoke((MethodInvoker) delegate() { pictureBox.Text = Language.FormatString(Language.LanguageString.NotifyForm_FailedToTakePicture); }); } finally { m_takePictureAsync = null; CountdownTimerSetup(); } }, null); } }
private void animatePanelOut_Click(object sender, EventArgs ev) { if (!m_animator.IsAnimating) { Control panelOut = (sender == takePictureBackButton ? takePicturePanel : infoPanel); if (m_takePictureWithPreviewAsync != null) { WebcamWithPreview camp = confWebcam.SelectedItem as WebcamWithPreview; if (camp != null) { camp.TakePictureEnd(); } } confPanel.Location = new Point(-ClientRectangle.Width, 0); confPanel.Visible = true; confPanel.Focus(); m_animator.Run((EventHandler <AnimationEventArgs>) delegate(object sendr, AnimationEventArgs e) { Invoke((MethodInvoker) delegate() { int newLeft = (int)(Math.Min(e.PercentRemaining * e.PercentRemaining * e.PercentRemaining, 1) * -ClientRectangle.Width); confPanel.Left = newLeft; panelOut.Left = newLeft + ClientRectangle.Width; if (e.IsLastCall) { Text = Application.ProductName + " - " + Language.FormatString(Language.LanguageString.MainForm_Configuration_Title); panelOut.Visible = false; } }); }); } }
internal static void ShowInstance(int initScreenIndex) { if (s_instance == null) { s_instance = new MainForm(); } if (initScreenIndex == 0) { s_instance.confPanel.Left = 0; s_instance.confPanel.Visible = true; s_instance.takePicturePanel.Visible = false; s_instance.Text = Application.ProductName + " - " + Language.FormatString(Language.LanguageString.MainForm_Configuration_Title); } else { s_instance.takePictureSaveButton.Enabled = false; s_instance.takePicturePanel.Left = 0; s_instance.takePicturePanel.Visible = true; s_instance.confPanel.Visible = false; s_instance.Text = Application.ProductName + " - " + Language.FormatString(Language.LanguageString.MainForm_TakePicture_Title); s_instance.TakePicture(null, null); } s_instance.Show(); s_instance.BringToFront(); }
private NotifyForm() { InitializeComponent(); m_fileName = Common.GenerateFilename(Settings.OutputFilename); takePictureButton.Text = Language.FormatString(Language.LanguageString.NotifyForm_TakePictureAgain); hideButton.Text = Language.FormatString(Language.LanguageString.NotifyForm_HideNow); settingsButton.Text = Language.FormatString(Language.LanguageString.NotifyForm_Configuration); }
private void savePictureButton_Click(object sender, EventArgs e) { takePictureSaveDialog.Title = Language.FormatString(Language.LanguageString.MainForm_TakePicture_SaveDialogTitle); takePictureSaveDialog.FileName = Path.Combine(confFolder.Text, Common.GenerateFilename(confFilename.Text)); if (takePictureSaveDialog.ShowDialog(this) == DialogResult.OK) { Common.SaveJPEG(takePicturePicture.DisplayBitmap, takePictureSaveDialog.FileName); } }
private void EnumerateCams() { int currentTick = System.Environment.TickCount; if ((currentTick - m_lastEnumTick > 5000) || (m_lastEnumTick == 0)) { m_lastEnumTick = currentTick; confWebcam.Items.Clear(); confWebcam.Items.AddRange(WebcamManager.Enumerate()); confWebcam.Items.Add(Language.FormatString(Language.LanguageString.MainForm_Configuration_RefreshWebcamList)); confWebcam.SelectedIndex = 0; } }
private void animatePanelIn_Click(object sender, EventArgs ev) { // animate in :) if ((confWebcam.SelectedItem is Webcam) || (sender != confTakePictureButton)) { if (!m_animator.IsAnimating) { Control panelIn = (sender == confTakePictureButton ? takePicturePanel : infoPanel); takePictureSaveButton.Enabled = false; panelIn.Location = new Point(ClientRectangle.Width, 0); panelIn.Visible = true; panelIn.Focus(); if (panelIn == takePicturePanel) { takePictureDisplacement.Visible = false; if (confWebcam.SelectedItem is WebcamWithPreview) { takePictureDisplacement.Visible = true; takePictureDisplacement.ResetPosition(); } } m_animator.Run((EventHandler <AnimationEventArgs>) delegate(object sendr, AnimationEventArgs e) { Invoke((MethodInvoker) delegate() { int newLeft = (int)(Math.Min(e.PercentRemaining * e.PercentRemaining * e.PercentRemaining, 1) * ClientRectangle.Width); panelIn.Left = newLeft; confPanel.Left = -(ClientRectangle.Width - newLeft); if (e.IsLastCall) { if (panelIn == takePicturePanel) { Text = Application.ProductName + " - " + Language.FormatString(Language.LanguageString.MainForm_TakePicture_Title); TakePicture(null, null); } else { Text = Application.ProductName + " - " + Language.FormatString(Language.LanguageString.MainForm_Information_Title); } confPanel.Visible = false; } }); }); } } }
internal Kernel(string[] args) { m_notifyIcon = new NotifyIcon(); m_notifyIcon.Icon = new System.Drawing.Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CamTimer.Graphics.mainIcon.ico")); m_notifyIcon.DoubleClick += new EventHandler(m_notifyIcon_Show); m_notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("&" + Application.ProductName, m_notifyIcon_Show), new MenuItem(Language.FormatString(Language.LanguageString.NotifyMenu_TakePicture), m_notifyIcon_TakePicture), new MenuItem("-"), new MenuItem(Language.FormatString(Language.LanguageString.NotifyMenu_Exit), new EventHandler(m_notifyIcon_Exit)) }); m_notifyIcon.ContextMenu.MenuItems[0].DefaultItem = true; m_notifyIcon.Text = Application.ProductName; m_notifyIcon.Visible = true; if (Settings.FirstRun == DateTime.MinValue) { Settings.FirstRun = DateTime.Now; m_notifyIcon.ShowBalloonTip(5000, Language.FormatString(Language.LanguageString.NotifyMenu_FirstRunBalloonTitle), Language.FormatString(Language.LanguageString.NotifyMenu_FirstRunBalloonText), ToolTipIcon.Info); } bool showInterface = true; for (int x = 0; x < args.Length; x++) { if ((args[x].Trim().Equals("/autostart", StringComparison.OrdinalIgnoreCase)) || (args[x].Trim().Equals("-autostart", StringComparison.OrdinalIgnoreCase))) { showInterface = false; break; } } if (showInterface) { MainForm.ShowInstance(0); } m_scheduleThread = new System.Windows.Forms.Timer(); #if (DEBUG) m_scheduleThread.Interval = 10000; // start after 10 seconds #else m_scheduleThread.Interval = 60000 * 2; // start after 2 minutes (to prevent annoying user at system startup). #endif m_scheduleThread.Tick += (EventHandler) delegate(object sender, EventArgs e) { if (m_scheduleThread.Interval != 1000) { m_scheduleThread.Interval = 1000; } // check if we should take a picture if (Settings.ScheduleEnabled) { DateTime now = DateTime.Now; if (RunToday(now.DayOfWeek)) { if ((now.TimeOfDay >= Settings.ScheduleTimeStart.TimeOfDay) && (now.TimeOfDay <= Settings.ScheduleTimeEnd.TimeOfDay)) { bool takePicture = false; for (TimeSpan x = Settings.ScheduleTimeStart.TimeOfDay; x <= Settings.ScheduleTimeEnd.TimeOfDay; x = x.Add(new TimeSpan(Settings.ScheduleInterval, 0, 0))) { DateTime calculatedRunAt = new DateTime(now.Year, now.Month, now.Day, x.Hours, x.Minutes, x.Seconds); if (now > calculatedRunAt) { if (calculatedRunAt > Settings.ScheduleLastRun) { takePicture = true; break; } } } // check screensaver if specified if ((takePicture) && (Settings.ScheduleDisabledOnScreensaver)) { bool screenSaverRunning = false; if (NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETSCREENSAVERRUNNING, 0, ref screenSaverRunning, 0)) { if (screenSaverRunning) { takePicture = false; } } } // check if fullscreen directX window (game or such) is running if (takePicture) { IntPtr fgHwnd = NativeMethods.GetForegroundWindow(); if ((fgHwnd != null) && (fgHwnd != IntPtr.Zero)) { if ((fgHwnd != NativeMethods.GetDesktopWindow()) && (fgHwnd != NativeMethods.GetShellWindow())) { NativeMethods.RECT appRect; if (NativeMethods.GetWindowRect(fgHwnd, out appRect) != 0) { System.Drawing.Rectangle screenRect = Screen.FromHandle(fgHwnd).Bounds; if (((appRect.Bottom - appRect.Top) == screenRect.Height) && ((appRect.Right - appRect.Left) == screenRect.Width)) { takePicture = false; } } } } } if (takePicture) { Settings.ScheduleLastRun = now; NotifyForm.ShowInstance(); } } } } }; m_scheduleThread.Start(); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #region create thumbnail option for (int x = 0; x < args.Length; x++) { if ((args[x].Trim().Equals("/displace", StringComparison.OrdinalIgnoreCase)) || (args[x].Trim().Equals("-displace", StringComparison.OrdinalIgnoreCase))) { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Title = "Select displacement map"; openDialog.Filter = "All files (*.*)|*.*"; openDialog.FilterIndex = 1; openDialog.CheckFileExists = true; openDialog.DereferenceLinks = true; openDialog.ShowReadOnly = false; openDialog.FileName = string.Empty; if (openDialog.ShowDialog() == DialogResult.OK) { // load displacement map string mapName = openDialog.FileName; Bitmap mapBitmap; try { mapBitmap = new Bitmap(mapName); } catch (Exception) { MessageBox.Show("Error loading displacement map. Application ended.", Application.ProductName, MessageBoxButtons.OK); return; } if ((mapBitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb) || (mapBitmap.Size.Width != 1024) || (mapBitmap.Size.Height != 768)) { MessageBox.Show("The displacement map must be 1024x768 and 24bpp. Application ended.", Application.ProductName, MessageBoxButtons.OK); return; } openDialog.Title = "Select image to displace"; openDialog.FileName = string.Empty; if (openDialog.ShowDialog() == DialogResult.OK) { // load source bitmap string sourceName = openDialog.FileName; Bitmap sourceBitmap; try { sourceBitmap = new Bitmap(sourceName); } catch (Exception) { MessageBox.Show("Error loading image. Application ended.", Application.ProductName, MessageBoxButtons.OK); return; } if ((sourceBitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format16bppRgb565) && (sourceBitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb) && (sourceBitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppRgb)) { MessageBox.Show("This image to displace must be 16bpp(565), 24bpp(888) or 32bpp. Application ended.", Application.ProductName, MessageBoxButtons.OK); return; } // create distorted bitmap Bitmap destBitmap = new Bitmap(sourceBitmap.Width, sourceBitmap.Height, sourceBitmap.PixelFormat); Bitmap destThumb = new Bitmap((int)(320 * 0.5), (int)(240 * 0.5), sourceBitmap.PixelFormat); unsafe { BitmapData sourceData = sourceBitmap.LockBits(new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, sourceBitmap.PixelFormat); byte * sourceScan0 = (byte *)sourceData.Scan0; WebcamWithPreview.DistortedDraw((byte *)sourceScan0, mapBitmap, destBitmap); sourceBitmap.UnlockBits(sourceData); } using (Graphics g = Graphics.FromImage(destThumb)) { g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.DrawImage(destBitmap, g.VisibleClipBounds); } // write distorted jpeg EncoderParameters eargs = new EncoderParameters(); eargs.Param = new EncoderParameter[] { new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 95L) }; ImageCodecInfo[] arrCodecs = ImageCodecInfo.GetImageEncoders(); foreach (ImageCodecInfo i in arrCodecs) { if (i.FormatID.Equals(ImageFormat.Jpeg.Guid)) { destThumb.Save(Path.Combine(Path.GetDirectoryName(mapName), Path.GetFileNameWithoutExtension(mapName)) + "-thumb.jpg", i, eargs); break; } } MessageBox.Show("Displaced bitmap created successfully! Application ended.", Application.ProductName, MessageBoxButtons.OK); } } return; } } #endregion // one instance limit IntPtr mutexPtr = NativeMethods.CreateMutexA(IntPtr.Zero, false, "FJRCamTimerMutex"); if (mutexPtr != IntPtr.Zero) { if (Marshal.GetLastWin32Error() == NativeMethods.ERROR_ALREADY_EXISTS) { NativeMethods.ReleaseMutex(mutexPtr); MessageBox.Show(Language.FormatString(Language.LanguageString.App_AlreadyRunning), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Kernel kernel = new Kernel(args); Application.Run(); kernel = null; if (mutexPtr != IntPtr.Zero) { NativeMethods.ReleaseMutex(mutexPtr); } }
private MainForm() { InitializeComponent(); Width = 560; confScheduleInterval.Items.Clear(); for (int x = 23; x > 0; x--) { confScheduleInterval.Items.Add(x); } EnumerateCams(); // query settings if (Settings.CamName.Length > 0) { confWebcam.SelectedIndex = confWebcam.FindStringExact(Settings.CamName); webCamList_SelectedIndexChanged(null, null); confResolution.FocusItem(Settings.CamConfigSize, Settings.CamConfigBPP); } else { webCamList_SelectedIndexChanged(null, null); } confFolder.Text = Settings.OutputFolder; confFilename.Text = Settings.OutputFilename; confScheduleEnabled.Checked = Settings.ScheduleEnabled; scheduleEnabled_CheckedChanged(null, null); confScheduleMaxRes.Checked = Settings.ScheduleMaxResultionAndQuality; confScheduleMon.Checked = Settings.ScheduleMon; confScheduleTue.Checked = Settings.ScheduleTue; confScheduleWed.Checked = Settings.ScheduleWed; confScheduleThu.Checked = Settings.ScheduleThu; confScheduleFri.Checked = Settings.ScheduleFri; confScheduleSat.Checked = Settings.ScheduleSat; confScheduleSun.Checked = Settings.ScheduleSun; confScheduleTimeStart.Value = Settings.ScheduleTimeStart; confScheduleTimeEnd.Value = Settings.ScheduleTimeEnd; confScheduleInterval.SelectedItem = Settings.ScheduleInterval; confScheduleDisableOnScreensaver.Checked = Settings.ScheduleDisabledOnScreensaver; confAutoStart.Checked = Settings.AutoStart; // bind help BindHelp(confTakePictureButton, Language.FormatString(Language.LanguageString.MainForm_Help_TakePictureButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_TakePictureButtonText)); BindHelp(confAcceptButton, Language.FormatString(Language.LanguageString.MainForm_Help_AcceptConfigurationButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_AcceptConfigurationButtonText)); BindHelp(confRejectButton, Language.FormatString(Language.LanguageString.MainForm_Help_CancelConfigurationButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_CancelConfigurationButtonText)); BindHelp(confInfoButton, Language.FormatString(Language.LanguageString.MainForm_Help_InformationButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_InformationButtonText)); BindHelp(confWebcamPanel, Language.FormatString(Language.LanguageString.MainForm_Help_PickWebCamTitle), Language.FormatString(Language.LanguageString.MainForm_Help_PickWebCamText)); BindHelp(confFolderPanel, Language.FormatString(Language.LanguageString.MainForm_Help_FoldernameTitle), Language.FormatString(Language.LanguageString.MainForm_Help_FoldernameText)); BindHelp(confFilenamePanel, Language.FormatString(Language.LanguageString.MainForm_Help_FilenameTitle), Language.FormatString(Language.LanguageString.MainForm_Help_FilenameText, "webcam " + DateTime.Now.ToString("yyyy-MM-dd HH.mm", CultureInfo.CurrentCulture) + ".jpg")); BindHelp(confResolution, Language.FormatString(Language.LanguageString.MainForm_Help_ChangeResolutionTitle), Language.FormatString(Language.LanguageString.MainForm_Help_ChangeResolutionText)); BindHelp(confSchedulePanel, Language.FormatString(Language.LanguageString.MainForm_Help_ScheduleTitle), Language.FormatString(Language.LanguageString.MainForm_Help_ScheduleText)); BindHelp(confAutoStart, Language.FormatString(Language.LanguageString.MainForm_Help_AutoStartTitle), Language.FormatString(Language.LanguageString.MainForm_Help_AutoStartText)); BindHelp(takePictureBackButton, Language.FormatString(Language.LanguageString.MainForm_Help_TakePictureBackButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_TakePictureBackButtonText)); BindHelp(takePictureSaveButton, Language.FormatString(Language.LanguageString.MainForm_Help_SavePictureButtonTitle), Language.FormatString(Language.LanguageString.MainForm_Help_SavePictureButtonText)); BindHelp(infoBackButton, Language.FormatString(Language.LanguageString.MainForm_Help_InformationButtonBackTitle), Language.FormatString(Language.LanguageString.MainForm_Help_InformationButtonBackText)); // set texts confWebcamLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_PickWebCam); confFoldernameLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Foldername); confFilenameLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Filename); confScheduleEnabled.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_ScheduleEnabled); confScheduleMaxRes.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_ScheduleMaxRes); confScheduleDisableOnScreensaver.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_ScheduleDisableOnScreensaver); confScheduleDaysLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Days); confScheduleMon.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Mon); confScheduleTue.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Tue); confScheduleWed.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Wed); confScheduleThu.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Thu); confScheduleFri.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Fri); confScheduleSat.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Sat); confScheduleSun.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Sun); confScheduleBetweenLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Between); confScheduleBetweenAnd.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_BetweenAnd); confScheduleIntervalLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_Every); confScheduleIntervalHoursLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_EveryHours); confAutoStart.Text = Language.FormatString(Language.LanguageString.MainForm_Configuration_AutoStart); infoWebsiteLabel.Text = Language.FormatString(Language.LanguageString.MainForm_Information_VisitWebSite); infoCopyright1Label.Text = Language.FormatString(Language.LanguageString.MainForm_Information_About); infoCopyright2Label.Text = Application.ProductName + " Copyright © 2008 by Fredrik Johansson Robotics AB. Please refer to LICENSE.txt in the installation folder.\r\n\r\n" + "This application uses (links) to DirectShowLib, which is licensed under LGPL (Lesser General Public License). Copyright © http://directshownet.sourceforge.net. Please refer to LGPL.txt in the installation folder."; // load displacement filters takePictureDisplacement.Items.Add(new PictureAndThumbnailPair(string.Empty, string.Empty)); string filterPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Filters"); if (Directory.Exists(filterPath)) { string[] filterThumbs = Directory.GetFiles(filterPath, "*-thumb.*"); for (int x = 0; x < filterThumbs.Length; x++) { string filterFile = Path.Combine(filterPath, Path.GetFileNameWithoutExtension(filterThumbs[x]).Replace("-thumb", string.Empty) + ".png"); if (File.Exists(filterFile)) { takePictureDisplacement.Items.Add(new PictureAndThumbnailPair(filterFile, filterThumbs[x])); } } } }
// 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); } } }