public PictureWithLabel(ScreenCaptureSource src) { this.Width = 160; this.Height = 140; label.Text = src.title; pictureBox.Image = src.snapshot; pictureBox.SetBounds(0, 0, 160, 120); label.SetBounds(0, 120, 160, 20); Controls.Add(label); Controls.Add(pictureBox); }
private static void Capture(ScreenCaptureSource screenCaptureSource, Action <Bitmap> action) { switch (screenCaptureSource) { case ScreenCaptureSource.ActiveWindow: CaptureActiveWindow(action); break; case ScreenCaptureSource.ActiveScreen: CaptureScreen(Screen.FromHandle(WinApi.GetForegroundWindow()), action); break; case ScreenCaptureSource.PrimaryScreen: CaptureScreen(Screen.PrimaryScreen, action); break; case ScreenCaptureSource.AllScreens: CaptureAllScreens(action); break; default: throw new NotImplementedException(); } }
public static void CaptureToFile(ScreenCaptureSource screenCaptureSource, String fileName, ImageFormat imageFormat) { var action = new Action <Bitmap>((bitmap) => bitmap.Save(fileName, imageFormat)); Capture(screenCaptureSource, action); }
public static void CaptureToClipboard(ScreenCaptureSource screenCaptureSource) { var action = new Action <Bitmap>((bitmap) => Clipboard.SetImage(bitmap)); Capture(screenCaptureSource, action); }