void StartCapture() { Hide(); ExternalWindow?.Hide(); StatusImageSize.Text = ""; // make sure windows actually hides before we wait WindowUtilities.DoEvents(); // Display counter IsPreviewCapturing = true; Cancelled = false; ScreenOverlayCounter counterForm = null; if (CaptureDelaySeconds > 0) { counterForm = new ScreenOverlayCounter(); counterForm.Show(); counterForm.Topmost = true; counterForm.SetWindowText("1"); } else { DoScreenCapture(); return; } var secs = 1; var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += (p, a) => { Dispatcher.Invoke(() => { secs++; if (secs > CaptureDelaySeconds) { dispatcherTimer.Stop(); counterForm?.Close(); DoScreenCapture(); } counterForm?.SetWindowText(secs.ToString()); }); }; if (CaptureDelaySeconds == 0) { dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1); } else { dispatcherTimer.Interval = new TimeSpan(0, 0, 1); } dispatcherTimer.Start(); }
void StartCapture() { Hide(); ExternalWindow?.Hide(); StatusImageSize.Text = ""; // make sure windows actually hides before we wait WindowUtilities.DoEvents(); // Display counter if (CaptureDelaySeconds > 0) { IsPreviewCapturing = true; Cancelled = false; var counterForm = new ScreenOverlayCounter(); try { counterForm.Show(); counterForm.Topmost = true; counterForm.SetWindowText("1"); for (int i = CaptureDelaySeconds; i > 0; i--) { counterForm.SetWindowText(i.ToString()); WindowUtilities.DoEvents(); for (int j = 0; j < 100; j++) { Thread.Sleep(10); WindowUtilities.DoEvents(); } if (Cancelled) { CancelCapture(true); return; } } } finally { counterForm.Close(); IsPreviewCapturing = false; Cancelled = true; } } IsMouseClickCapturing = true; Desktop = new ScreenOverlayDesktop(this); Desktop.SetDesktop(IncludeCursor); Desktop.Show(); WindowUtilities.DoEvents(); Overlay = new ScreenClickOverlay(this) { Width = 0, Height = 0 }; Overlay.Show(); LastWindow = null; CaptureTimer = new Timer(Capture, null, 0, 200); }