예제 #1
0
        public RectangleRegionLightForm(Screenshot screenshot)
        {
            backgroundImage = screenshot.CaptureFullscreen();
            backgroundBrush = new TextureBrush(backgroundImage);
            borderDotPen = new Pen(Color.Black, 1);
            borderDotPen2 = new Pen(Color.White, 1);
            borderDotPen2.DashPattern = new float[] { 5, 5 };
            penTimer = Stopwatch.StartNew();
            ScreenRectangle = CaptureHelpers.GetScreenBounds();

            InitializeComponent();
            Icon = ShareXResources.Icon;
            Cursor = Helpers.CreateCursor(Resources.Crosshair);

            timer = new Timer { Interval = 10 };
            timer.Tick += timer_Tick;
            timer.Start();
        }
        public RegionCaptureSimpleAnnotateForm(Screenshot screenshot, RectangleAnnotateOptions options)
        {
            Options = options;

            backgroundImage = screenshot.CaptureFullscreen();
            borderDotPen = new Pen(Color.Black, 1);
            borderDotPen2 = new Pen(Color.White, 1);
            borderDotPen2.DashPattern = new float[] { 5, 5 };
            textBackgroundBrush = new SolidBrush(Color.FromArgb(75, Color.Black));
            textBackgroundPenWhite = new Pen(Color.FromArgb(50, Color.White));
            textBackgroundPenBlack = new Pen(Color.FromArgb(150, Color.Black));
            infoFont = new Font("Verdana", 9);
            penTimer = Stopwatch.StartNew();
            ScreenRectangle = CaptureHelpers.GetScreenBounds();

            InitializeComponent();
            Icon = ShareXResources.Icon;
            Cursor = Helpers.CreateCursor(Resources.Crosshair);

            timer = new Timer { Interval = 10 };
            timer.Tick += timer_Tick;
            timer.Start();
        }
예제 #3
0
        public ScreenRecorder(ScreenRecordOutput outputType, ScreencastOptions options, Screenshot screenshot, Rectangle captureRectangle)
        {
            if (string.IsNullOrEmpty(options.OutputPath))
            {
                throw new Exception("Screen recorder cache path is empty.");
            }

            FPS = outputType == ScreenRecordOutput.GIF ? options.GIFFPS : options.ScreenRecordFPS;
            DurationSeconds = options.Duration;
            CaptureRectangle = captureRectangle;
            CachePath = options.OutputPath;
            OutputType = outputType;

            Options = options;

            switch (OutputType)
            {
                default:
                case ScreenRecordOutput.FFmpeg:
                    ffmpegCli = new FFmpegHelper(Options);
                    ffmpegCli.RecordingStarted += OnRecordingStarted;
                    break;
                case ScreenRecordOutput.GIF:
                    imgCache = new HardDiskCache(Options);
                    break;
            }

            this.screenshot = screenshot;
        }
        public Image GetAreaImage(Screenshot screenshot)
        {
            Rectangle rect = SelectionRectangle0Based;

            if (rect.Width > 0 && rect.Height > 0)
            {
                return screenshot.CaptureRectangle(SelectionRectangle);
            }

            return null;
        }
예제 #5
0
        private void captureTimer_Tick(object sender, EventArgs e)
        {
            if (firstCapture)
            {
                firstCapture = false;
                captureTimer.Interval = Options.ScrollDelay;

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.KeyPressHome)
                {
                    InputHelpers.SendKeyPress(VirtualKeyCode.HOME);
                }

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.SendMessageTop)
                {
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_TOP, 0);
                }

                if (Options.ScrollTopMethodBeforeCapture != ScrollingCaptureScrollTopMethod.None)
                {
                    return;
                }
            }

            Screenshot screenshot = new Screenshot() { CaptureCursor = false };
            Image image = screenshot.CaptureRectangle(selectedRectangle);

            if (image != null)
            {
                images.Add(image);
            }

            if (Options.ScrollMethod == ScrollingCaptureScrollMethod.Automatic && detectingScrollMethod && images.Count > 1 && IsLastTwoImagesSame())
            {
                if (currentScrollMethod == ScrollingCaptureScrollMethod.SendMessageScroll)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.KeyPressPageDown;
                }
                else if (currentScrollMethod == ScrollingCaptureScrollMethod.KeyPressPageDown)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.MouseWheel;
                }
                else
                {
                    StopCapture();
                }
            }
            else if (currentScrollCount == Options.MaximumScrollCount || (Options.AutoDetectScrollEnd && IsScrollReachedBottom(selectedWindow.Handle)))
            {
                StopCapture();
            }
            else if (images.Count > 1)
            {
                detectingScrollMethod = false;
            }

            switch (currentScrollMethod)
            {
                case ScrollingCaptureScrollMethod.Automatic:
                case ScrollingCaptureScrollMethod.SendMessageScroll:
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
                    break;
                case ScrollingCaptureScrollMethod.KeyPressPageDown:
                    InputHelpers.SendKeyPress(VirtualKeyCode.NEXT);
                    break;
                case ScrollingCaptureScrollMethod.MouseWheel:
                    InputHelpers.SendMouseWheel(-120);
                    break;
            }

            currentScrollCount++;
        }
예제 #6
0
        /// <summary>Must be called before show form</summary>
        public virtual void Prepare(Screenshot screenshot)
        {
            backgroundImage = screenshot.CaptureFullscreen();

            if (Config.UseDimming)
            {
                using (Bitmap darkBackground = (Bitmap)backgroundImage.Clone())
                using (Graphics g = Graphics.FromImage(darkBackground))
                {
                    using (Brush brush = new SolidBrush(Color.FromArgb(30, Color.Black)))
                    {
                        g.FillRectangle(brush, 0, 0, darkBackground.Width, darkBackground.Height);
                    }

                    darkBackgroundBrush = new TextureBrush(darkBackground) { WrapMode = WrapMode.Clamp };
                    lightBackgroundBrush = new TextureBrush(backgroundImage) { WrapMode = WrapMode.Clamp };
                }
            }
            else
            {
                darkBackgroundBrush = new TextureBrush(backgroundImage) { WrapMode = WrapMode.Clamp };
            }
        }
예제 #7
0
        public override void Prepare(Screenshot screenshot)
        {
            base.Prepare(screenshot);

            if (Config != null)
            {
                ShapeManager = new ShapeManager(this);
                ShapeManager.WindowCaptureMode = Config.DetectWindows;
                ShapeManager.IncludeControls = Config.DetectControls;

                if (Mode == RectangleRegionMode.Annotation)
                {
                    ShapeManager.CurrentShapeTypeChanged += ShapeManager_CurrentShapeTypeChanged;
                }

                if (Mode == RectangleRegionMode.OneClick || ShapeManager.WindowCaptureMode)
                {
                    IntPtr handle = Handle;

                    TaskEx.Run(() =>
                    {
                        WindowsRectangleList wla = new WindowsRectangleList();
                        wla.IgnoreHandle = handle;
                        wla.IncludeChildWindows = ShapeManager.IncludeControls;
                        ShapeManager.Windows = wla.GetWindowInfoListAsync(5000);
                    });
                }

                if (Config.UseCustomInfoText || Mode == RectangleRegionMode.ScreenColorPicker)
                {
                    bmpBackgroundImage = new Bitmap(backgroundImage);
                }
            }
        }
예제 #8
0
        public ScreenRecorder(ScreenRecordOutput outputType, ScreencastOptions options, Screenshot screenshot, Rectangle captureRectangle)
        {
            if (string.IsNullOrEmpty(options.OutputPath))
            {
                throw new Exception("Screen recorder cache path is empty.");
            }

            FPS              = options.FPS;
            DurationSeconds  = options.Duration;
            CaptureRectangle = captureRectangle;
            CachePath        = options.OutputPath;
            OutputType       = outputType;

            Options = options;

            switch (OutputType)
            {
            default:
            case ScreenRecordOutput.FFmpeg:
                ffmpegCli = new FFmpegHelper(Options);
                ffmpegCli.RecordingStarted += OnRecordingStarted;
                break;

            case ScreenRecordOutput.GIF:
                imgCache = new HardDiskCache(Options);
                break;
            }

            this.screenshot = screenshot;
        }
예제 #9
0
        private void captureTimer_Tick(object sender, EventArgs e)
        {
            if (firstCapture)
            {
                firstCapture          = false;
                captureTimer.Interval = Options.ScrollDelay;

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.KeyPressHome)
                {
                    InputHelpers.SendKeyPress(VirtualKeyCode.HOME);
                }

                if (Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.All || Options.ScrollTopMethodBeforeCapture == ScrollingCaptureScrollTopMethod.SendMessageTop)
                {
                    NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_TOP, 0);
                }

                if (Options.ScrollTopMethodBeforeCapture != ScrollingCaptureScrollTopMethod.None)
                {
                    return;
                }
            }

            Screenshot screenshot = new Screenshot()
            {
                CaptureCursor = false
            };
            Image image = screenshot.CaptureRectangle(selectedRectangle);

            if (image != null)
            {
                images.Add(image);
            }

            if (Options.ScrollMethod == ScrollingCaptureScrollMethod.Automatic && detectingScrollMethod && images.Count > 1 && IsLastTwoImagesSame())
            {
                if (currentScrollMethod == ScrollingCaptureScrollMethod.SendMessageScroll)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.KeyPressPageDown;
                }
                else if (currentScrollMethod == ScrollingCaptureScrollMethod.KeyPressPageDown)
                {
                    currentScrollMethod = ScrollingCaptureScrollMethod.MouseWheel;
                }
                else
                {
                    StopCapture();
                }
            }
            else if (currentScrollCount == Options.MaximumScrollCount || (Options.AutoDetectScrollEnd && IsScrollReachedBottom(selectedWindow.Handle)))
            {
                StopCapture();
            }
            else if (images.Count > 1)
            {
                detectingScrollMethod = false;
            }

            switch (currentScrollMethod)
            {
            case ScrollingCaptureScrollMethod.Automatic:
            case ScrollingCaptureScrollMethod.SendMessageScroll:
                NativeMethods.SendMessage(selectedWindow.Handle, (int)WindowsMessages.VSCROLL, (int)ScrollBarCommands.SB_PAGEDOWN, 0);
                break;

            case ScrollingCaptureScrollMethod.KeyPressPageDown:
                InputHelpers.SendKeyPress(VirtualKeyCode.NEXT);
                break;

            case ScrollingCaptureScrollMethod.MouseWheel:
                InputHelpers.SendMouseWheel(-120);
                break;
            }

            currentScrollCount++;
        }