internal void StopCapture(bool cancelCapture = false) { Debug.WriteLine("StopCapture: " + cancelCapture); if (!IsMouseClickCapturing) { return; } CaptureTimer.Dispose(); IsMouseClickCapturing = false; Overlay?.Close(); //WindowUtilities.DoEvents(); //Point pt = GetMousePosition(); //CurWindow = new WindowInfo(ScreenCapture.WindowFromPoint(new System.Drawing.Point((int)pt.X, (int)pt.Y))); Desktop.Topmost = true; Desktop.Activate(); WindowUtilities.DoEvents(); if (LastWindow != null && !cancelCapture) { var img = ScreenCapture.CaptureWindow(CurWindow.Rect); CapturedBitmap = new Bitmap(img); //CapturedBitmap = ScreenCapture.CaptureWindowBitmap(CurWindow.Handle) as Bitmap; Desktop.Close(); if (CapturedBitmap != null) { ImageCaptured.Source = ScreenCapture.BitmapToBitmapSource(CapturedBitmap); StatusText.Text = "Image capture from Screen: " + $"{CapturedBitmap.Width}x{CapturedBitmap.Height}"; ScreenCaptureForm_SizeChanged(this, null); } else { StatusText.Text = "Image capture failed."; } } //Desktop.Topmost = false; Desktop?.Close(); //if (ExternalWindow != null) //{ // ExternalWindow.Show(); // ExternalWindow.Activate(); //} if (cancelCapture) { CancelCapture(true); } else { Show(); Activate(); } }
private void tbPasteImage_Click(object sender, RoutedEventArgs e) { if (System.Windows.Clipboard.ContainsImage()) { CapturedBitmap?.Dispose(); CapturedBitmap = new Bitmap(System.Windows.Forms.Clipboard.GetImage()); ImageCaptured.Source = ScreenCapture.BitmapToBitmapSource(CapturedBitmap); StatusText.Text = $"Pasted Image from Clipboard: {CapturedBitmap.Width}x{CapturedBitmap.Height}"; ScreenCaptureForm_SizeChanged(this, null); } }
internal void StopCapture(bool cancelCapture = false) { if (!IsMouseClickCapturing) { return; } IsMouseClickCapturing = false; Overlay?.Close(); WindowUtilities.DoEvents(); Desktop.Topmost = true; Desktop.Activate(); WindowUtilities.DoEvents(); if (LastWindow != null) { var img = ScreenCapture.CaptureWindow(CurWindow.Rect); CapturedBitmap = new Bitmap(img); //ScreenCapture.CaptureWindowBitmap(CurWindow.Handle) as Bitmap; Desktop.Close(); if (CapturedBitmap != null) { ImageCaptured.Source = ScreenCapture.BitmapToBitmapSource(CapturedBitmap); StatusText.Text = "Image capture from Screen: " + $"{CapturedBitmap.Width}x{CapturedBitmap.Height}"; ScreenCaptureForm_SizeChanged(this, null); } else { StatusText.Text = "Image capture failed."; } } //Desktop.Topmost = false; Desktop?.Close(); if (ExternalWindow != null) { ExternalWindow.Show(); ExternalWindow.Activate(); } if (cancelCapture) { CancelCapture(); } else { Show(); Activate(); } }
public void SetDesktop(bool includeCursor = false) { var handle = ScreenCapture.GetDesktopWindow(); Bitmap = ScreenCapture.CaptureWindowBitmap(handle); if (includeCursor) { var MousePointerInfo = ScreenCapture.GetMousePointerInfo(); ScreenCapture.DrawMousePointer(MousePointerInfo, Bitmap); } Left = 0; Top = 0; Width = Bitmap.Width; Height = Bitmap.Height; DesktopImage.Source = ScreenCapture.BitmapToBitmapSource(Bitmap); }
private void tbPasteImage_Click(object sender, RoutedEventArgs e) { if (ClipboardHelper.ContainsImage()) { CapturedBitmap?.Dispose(); var image = ClipboardHelper.GetImage(); if (image == null) { StatusBar.ShowStatusError("Couldn't retrieve image from clipboard."); return; } CapturedBitmap = new Bitmap(image); ImageCaptured.Source = ScreenCapture.BitmapToBitmapSource(CapturedBitmap); StatusText.Text = $"Pasted Image from Clipboard: {CapturedBitmap.Width}x{CapturedBitmap.Height}"; ScreenCaptureForm_SizeChanged(this, null); } }