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);
 }
예제 #2
0
        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();
            }
        }
예제 #3
0
        public static void CaptureToFile(ScreenCaptureSource screenCaptureSource, String fileName, ImageFormat imageFormat)
        {
            var action = new Action <Bitmap>((bitmap) => bitmap.Save(fileName, imageFormat));

            Capture(screenCaptureSource, action);
        }
예제 #4
0
        public static void CaptureToClipboard(ScreenCaptureSource screenCaptureSource)
        {
            var action = new Action <Bitmap>((bitmap) => Clipboard.SetImage(bitmap));

            Capture(screenCaptureSource, action);
        }