private void CloseCaptureWindowCore() { if (this.captureWindow != null) { if (!this.captureWindow.IsClosed) { this.captureWindow.Close(); } this.captureWindow = null; this.Focus(); } }
private void CaptureFromScreenButton_Click(object sender, RoutedEventArgs e) { if ((this.captureWindow != null) && (this.captureWindow.IsClosed)) { this.captureWindow = null; } if (this.captureWindow == null) { using (var scopedHideShow = new Utils.ScopedHideShow(this)) { int delay = 1000 * int.Parse(((ComboBoxItem)this.DelayComboBox.SelectedItem)?.Tag?.ToString() ?? "0"); Thread.Sleep(500 + delay); // TODO This is both ugly and wrong. Wait for asynchronous "hidden" event instead. This will complicate scoped handling. using (var screenshot = new Utils.Movable <System.Drawing.Bitmap>(Utils.ScreenShooting.CaptureImageFromFullScreen())) { this.captureWindow = new Utils.CapturingImage(); this.captureWindow.Owner = this; this.captureWindow.SetImage(screenshot.Release()); this.captureWindow.Show(); } } } }