private void tsbWindowRectangle_Click(object sender, EventArgs e)
        {
            RectangleRegion rectangleRegion = new RectangleRegion();

            rectangleRegion.AreaManager.WindowCaptureMode = true;
            CaptureRegion(rectangleRegion);
        }
        public AreaManager(RectangleRegion surface)
        {
            this.surface  = surface;
            ResizeManager = new ResizeManager(surface, this);

            MinimumSize = 10;

            Areas             = new List <Rectangle>();
            SelectedAreaIndex = -1;

            surface.MouseDown += new MouseEventHandler(surface_MouseDown);
            surface.MouseUp   += new MouseEventHandler(surface_MouseUp);
        }
        public AreaManager(RectangleRegion surface)
        {
            this.surface = surface;
            ResizeManager = new ResizeManager(surface, this);

            MinimumSize = 10;

            Areas = new List<Rectangle>();
            SelectedAreaIndex = -1;

            surface.MouseDown += new MouseEventHandler(surface_MouseDown);
            surface.MouseUp += new MouseEventHandler(surface_MouseUp);
        }
Пример #4
0
        public AreaManager(RectangleRegion surface)
        {
            this.surface = surface;
            ResizeManager = new ResizeManager(surface, this);

            MinimumSize = 10;

            Areas = new List<Rectangle>();
            SelectedAreaIndex = -1;

            surface.MouseDown += surface_MouseDown;
            surface.MouseUp += surface_MouseUp;
            surface.KeyDown += surface_KeyDown;
            surface.KeyUp += surface_KeyUp;
        }
Пример #5
0
        public AreaManager(RectangleRegion surface)
        {
            this.surface  = surface;
            ResizeManager = new ResizeManager(surface, this);

            MinimumSize = 10;

            Areas             = new List <Rectangle>();
            SelectedAreaIndex = -1;

            surface.MouseDown += surface_MouseDown;
            surface.MouseUp   += surface_MouseUp;
            surface.KeyDown   += surface_KeyDown;
            surface.KeyUp     += surface_KeyUp;
        }
        private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, bool autoHideForm = true)
        {
            Surface surface;

            switch (captureType)
            {
                default:
                case CaptureType.Rectangle:
                    if (taskSettings.AdvancedSettings.UseLightRectangleCrop)
                    {
                        CaptureLightRectangle(taskSettings, autoHideForm);
                        return;
                    }

                    surface = new RectangleRegion();
                    break;
                case CaptureType.RectangleWindow:
                    RectangleRegion rectangleRegion = new RectangleRegion();
                    rectangleRegion.AreaManager.WindowCaptureMode = true;
                    surface = rectangleRegion;
                    break;
                case CaptureType.RoundedRectangle:
                    surface = new RoundedRectangleRegion();
                    break;
                case CaptureType.Ellipse:
                    surface = new EllipseRegion();
                    break;
                case CaptureType.Triangle:
                    surface = new TriangleRegion();
                    break;
                case CaptureType.Diamond:
                    surface = new DiamondRegion();
                    break;
                case CaptureType.Polygon:
                    surface = new PolygonRegion();
                    break;
                case CaptureType.Freehand:
                    surface = new FreeHandRegion();
                    break;
            }

            DoCapture(() =>
            {
                Image img = null;
                Image screenshot = Screenshot.CaptureFullscreen();

                try
                {
                    surface.Config = taskSettings.CaptureSettings.SurfaceOptions;
                    surface.SurfaceImage = screenshot;
                    surface.Prepare();
                    surface.ShowDialog();

                    if (surface.Result == SurfaceResult.Region)
                    {
                        img = surface.GetRegionImage();
                        screenshot.Dispose();
                    }
                    else if (surface.Result == SurfaceResult.Fullscreen)
                    {
                        img = screenshot;
                    }
                }
                finally
                {
                    surface.Dispose();
                }

                return img;
            }, captureType, taskSettings, autoHideForm);
        }
 private void tsbWindowRectangle_Click(object sender, EventArgs e)
 {
     RectangleRegion rectangleRegion = new RectangleRegion();
     rectangleRegion.AreaManager.WindowCaptureMode = true;
     CaptureRegion(rectangleRegion);
 }
Пример #8
0
        public static bool SelectRegion(out Rectangle rect)
        {
            using (RectangleRegion surface = new RectangleRegion())
            {
                surface.AreaManager.WindowCaptureMode = true;
                surface.Prepare();
                surface.ShowDialog();

                if (surface.Result == SurfaceResult.Region)
                {
                    if (surface.AreaManager.IsCurrentAreaValid)
                    {
                        rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentArea);
                        return true;
                    }
                }
                else if (surface.Result == SurfaceResult.Fullscreen)
                {
                    rect = CaptureHelpers.GetScreenBounds();
                    return true;
                }
            }

            rect = Rectangle.Empty;
            return false;
        }
Пример #9
0
        public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null)
        {
            using (Image fullscreen = Screenshot.CaptureFullscreen())
            using (RectangleRegion surface = new RectangleRegion(fullscreen))
            {
                if (surfaceOptions != null)
                {
                    surface.Config = new SurfaceOptions
                    {
                        MagnifierPixelCount = surfaceOptions.MagnifierPixelCount,
                        MagnifierPixelSize = surfaceOptions.MagnifierPixelSize
                    };
                }

                surface.OneClickMode = true;
                surface.Prepare();
                surface.ShowDialog();

                if (surface.Result == SurfaceResult.Region)
                {
                    PointInfo pointInfo = new PointInfo();
                    pointInfo.Position = CaptureHelpers.ClientToScreen(surface.OneClickPosition);
                    pointInfo.Color = ((Bitmap)fullscreen).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y);
                    return pointInfo;
                }
            }

            return null;
        }
 private void WindowRectangleCapture(bool autoHideForm = true)
 {
     RectangleRegion rectangleRegion = new RectangleRegion();
     rectangleRegion.AreaManager.WindowCaptureMode = true;
     CaptureRegion(rectangleRegion, autoHideForm);
 }
Пример #11
0
        public bool CaptureRegionOrWindow()
        {
            if (!Engine.IsTakingScreenShot)
            {
                Engine.IsTakingScreenShot = true;

                bool windowMode = Job2 == JobLevel2.CaptureSelectedWindow;

                if (Engine.ConfigUI == null) Engine.ConfigUI = new XMLSettings();

                try
                {
                    Screenshot.DrawCursor = Engine.ConfigWorkflow.DrawCursor;

                    using (Image imgSS = Screenshot.CaptureFullscreen())
                    {
                        if (Job2 == JobLevel2.CaptureLastCroppedWindow && !Engine.ConfigUI.LastRegion.IsEmpty)
                        {
                            SetImage(CaptureHelpers.CropImage(imgSS, Engine.ConfigUI.LastRegion));
                        }

                        else if (Job2 == JobLevel2.CaptureSelectedWindow)
                        {
                            CaptureWindow(imgSS);
                        }

                        else
                        {
                            switch (Engine.ConfigUI.CropEngineMode)
                            {
                                case CropEngineType.CropLite:
                                    using (var crop = new CropLight(imgSS))
                                    {
                                        if (crop.ShowDialog() == DialogResult.OK)
                                        {
                                            SetImage(CaptureHelpers.CropImage(imgSS, crop.SelectionRectangle));
                                        }
                                    }
                                    break;
                                case CropEngineType.Cropv1:
                                    CaptureRectangle(imgSS);
                                    break;
                                case CropEngineType.Cropv2:
                                    using (var crop = new Crop2(imgSS))
                                    {
                                        if (crop.ShowDialog() == DialogResult.OK)
                                        {
                                            SetImage(crop.GetCroppedScreenshot());
                                        }
                                    }
                                    break;
                                case CropEngineType.Cropv3:
                                    Surface surface = new RectangleRegion(imgSS);
                                    surface.Config = Engine.ConfigUI.SurfaceConfig;
                                    if (surface.ShowDialog() == DialogResult.OK)
                                    {
                                        SetImage(surface.GetRegionImage());
                                    }
                                    break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    DebugHelper.WriteException(ex, "Error while capturing region");
                    Errors.Add(ex.Message);
                    if (Engine.ConfigOptions.CaptureEntireScreenOnError)
                    {
                        CaptureScreen();
                    }
                }
                finally
                {
                    MyWorker.ReportProgress((int)ProgressType.UpdateCropMode);
                    Engine.IsTakingScreenShot = false;
                }
            }

            return TempImage != null;
        }