예제 #1
0
        private void SelectRectangle()
        {
            WindowState = FormWindowState.Minimized;

            try
            {
                Thread.Sleep(250);

                Rectangle rect;

                if (RegionCaptureHelpers.GetRectangleRegion(out rect))
                {
                    selectedRectangle         = rect;
                    lblSelectedRectangle.Text = selectedRectangle.ToString();
                }
            }
            finally
            {
                this.ForceActivate();
            }
        }
예제 #2
0
        public virtual Image GetResultImage()
        {
            if (Result == RegionResult.Region)
            {
                using (Image img = GetOutputImage())
                {
                    return(RegionCaptureHelpers.ApplyRegionPathToImage(img, regionFillPath));
                }
            }
            else if (Result == RegionResult.Fullscreen)
            {
                return(GetOutputImage());
            }
            else if (Result == RegionResult.Monitor)
            {
                Screen[] screens = Screen.AllScreens;

                if (MonitorIndex < screens.Length)
                {
                    Screen    screen     = screens[MonitorIndex];
                    Rectangle screenRect = CaptureHelpers.ScreenToClient(screen.Bounds);

                    using (Image img = GetOutputImage())
                    {
                        return(ImageHelpers.CropImage(img, screenRect));
                    }
                }
            }
            else if (Result == RegionResult.ActiveMonitor)
            {
                Rectangle activeScreenRect = CaptureHelpers.GetActiveScreenBounds0Based();

                using (Image img = GetOutputImage())
                {
                    return(ImageHelpers.CropImage(img, activeScreenRect));
                }
            }

            return(null);
        }
예제 #3
0
        private void SelectHandle()
        {
            WindowState = FormWindowState.Minimized;

            bool capturing = false;

            try
            {
                Thread.Sleep(250);

                SimpleWindowInfo simpleWindowInfo = RegionCaptureHelpers.GetWindowInfo();

                if (simpleWindowInfo != null)
                {
                    selectedWindow             = new WindowInfo(simpleWindowInfo.Handle);
                    lblControlText.Text        = selectedWindow.ClassName ?? "";
                    selectedRectangle          = simpleWindowInfo.Rectangle;
                    lblSelectedRectangle.Text  = selectedRectangle.ToString();
                    btnSelectRectangle.Enabled = btnCapture.Enabled = true;

                    if (Options.StartCaptureAutomatically)
                    {
                        capturing = true;
                        StartCapture();
                    }
                }
                else
                {
                    btnCapture.Enabled = false;
                }
            }
            finally
            {
                if (!capturing)
                {
                    this.ForceActivate();
                }
            }
        }