private void DoScreenCapture()
        {
            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);
        }
        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);
        }