Exemplo n.º 1
0
        public ShapeManager(RectangleRegionForm form)
        {
            this.form = form;
            Config = form.Config;

            ResizeManager = new ResizeManager(form, this);

            form.LostFocus += form_LostFocus;
            form.MouseDown += form_MouseDown;
            form.MouseUp += form_MouseUp;
            form.MouseDoubleClick += form_MouseDoubleClick;
            form.MouseWheel += form_MouseWheel;
            form.KeyDown += form_KeyDown;
            form.KeyUp += form_KeyUp;

            if (form.Mode == RectangleRegionMode.Annotation)
            {
                CreateContextMenu();
            }

            CurrentShape = null;

            if (form.Mode == RectangleRegionMode.Annotation)
            {
                CurrentShapeType = Config.LastRegionTool;
            }
            else
            {
                CurrentShapeType = ShapeType.RegionRectangle;
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BaseRegionForm form;
            TaskSettings   taskSettings = TaskSettings.GetDefaultTaskSettings();

            RectangleRegionMode mode = RectangleRegionMode.Annotation;

            form = new RectangleRegionForm(mode);

            var cap = new Cap();

            cap.DoCapture(() =>
            {
                Image img = null;

                try
                {
                    form.Config = taskSettings.CaptureSettingsReference.SurfaceOptions;
                    form.Prepare();
                    form.ShowDialog();

                    img = form.GetResultImage();

                    if (img != null)
                    {
                        if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
                        {
                            WindowInfo windowInfo = form.GetWindowInfo();

                            if (windowInfo != null)
                            {
                                img.Tag = new ImageTag
                                {
                                    WindowTitle = windowInfo.Text,
                                    ProcessName = windowInfo.ProcessName
                                };
                            }
                        }

                        lastRegionCaptureType = LastRegionCaptureType.Default;
                    }
                }
                finally
                {
                    if (form != null)
                    {
                        form.Dispose();
                    }
                }

                return(img);
            }, captureType, taskSettings, autoHideForm);


            Application.Run(new ());
        }
Exemplo n.º 3
0
        public static void ShowScreenRuler()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Ruler))
            {
                form.Config.QuickCrop = false;
                form.Config.ShowTips  = false;

                form.Prepare();
                form.ShowDialog();
            }
        }
Exemplo n.º 4
0
        public static Image GetRegionImage()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Default))
            {
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();

                return form.GetResultImage();
            }
        }
Exemplo n.º 5
0
        public static Image GetRegionImage()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Default))
            {
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();

                return(form.GetResultImage());
            }
        }
Exemplo n.º 6
0
        public static bool GetRectangleRegion(out Rectangle rect, RegionCaptureOptions options)
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Default))
            {
                form.Config          = GetRegionCaptureOptions(options);
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    if (form.ShapeManager.IsCurrentShapeValid)
                    {
                        rect = CaptureHelpers.ClientToScreen(form.ShapeManager.CurrentRectangle);
                        return(true);
                    }
                }
                else if (form.Result == RegionResult.Fullscreen)
                {
                    rect = CaptureHelpers.GetScreenBounds();
                    return(true);
                }
                else if (form.Result == RegionResult.Monitor)
                {
                    Screen[] screens = Screen.AllScreens;

                    if (form.MonitorIndex < screens.Length)
                    {
                        Screen screen = screens[form.MonitorIndex];
                        rect = screen.Bounds;
                        return(true);
                    }
                }
                else if (form.Result == RegionResult.ActiveMonitor)
                {
                    rect = CaptureHelpers.GetActiveScreenBounds();
                    return(true);
                }
            }

            rect = Rectangle.Empty;
            return(false);
        }
Exemplo n.º 7
0
        public static SimpleWindowInfo GetWindowInfo()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.OneClick))
            {
                form.Config.UseDimming    = false;
                form.Config.ShowMagnifier = false;
                form.Config.ShowTips      = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    return(form.SelectedWindow);
                }
            }

            return(null);
        }
Exemplo n.º 8
0
        public static bool GetRectangleRegion(out Rectangle rect)
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Default))
            {
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    if (form.ShapeManager.IsCurrentRectangleValid)
                    {
                        rect = CaptureHelpers.ClientToScreen(form.ShapeManager.CurrentRectangle);
                        return true;
                    }
                }
                else if (form.Result == RegionResult.Fullscreen)
                {
                    rect = CaptureHelpers.GetScreenBounds();
                    return true;
                }
                else if (form.Result == RegionResult.Monitor)
                {
                    Screen[] screens = Screen.AllScreens;

                    if (form.MonitorIndex < screens.Length)
                    {
                        Screen screen = screens[form.MonitorIndex];
                        rect = screen.Bounds;
                        return true;
                    }
                }
                else if (form.Result == RegionResult.ActiveMonitor)
                {
                    rect = CaptureHelpers.GetActiveScreenBounds();
                    return true;
                }
            }

            rect = Rectangle.Empty;
            return false;
        }
Exemplo n.º 9
0
        public static PointInfo GetPointInfo()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.ScreenColorPicker))
            {
                form.Config.DetectWindows = false;
                form.Config.ShowTips      = false;
                form.Config.UseDimming    = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    PointInfo pointInfo = new PointInfo();
                    pointInfo.Position = form.CurrentPosition;
                    pointInfo.Color    = form.CurrentColor;
                    return(pointInfo);
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        public ShapeManager(RectangleRegionForm form)
        {
            this.form = form;
            Config    = form.Config;

            ResizeManager = new ResizeManager(form, this);

            form.MouseDown        += form_MouseDown;
            form.MouseUp          += form_MouseUp;
            form.MouseDoubleClick += form_MouseDoubleClick;
            form.MouseWheel       += form_MouseWheel;
            form.KeyDown          += form_KeyDown;
            form.KeyUp            += form_KeyUp;

            if (form.Mode == RectangleRegionMode.Annotation)
            {
                CreateContextMenu();
            }

            CurrentShape     = null;
            CurrentShapeType = ShapeType.RegionRectangle;
        }
Exemplo n.º 11
0
        public static PointInfo GetPointInfo()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.ScreenColorPicker))
            {
                form.Config.DetectWindows = false;
                form.Config.ShowTips = false;
                form.Config.UseDimming = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    PointInfo pointInfo = new PointInfo();
                    pointInfo.Position = form.CurrentPosition;
                    pointInfo.Color = form.CurrentColor;
                    return pointInfo;
                }
            }

            return null;
        }
Exemplo n.º 12
0
        public static SimpleWindowInfo GetWindowInfo()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.OneClick))
            {
                form.Config.UseDimming = false;
                form.Config.ShowMagnifier = false;
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();

                if (form.Result == RegionResult.Region)
                {
                    return form.SelectedWindow;
                }
            }

            return null;
        }
Exemplo n.º 13
0
        public static bool SelectRegion(out Rectangle rect, SurfaceOptions options)
        {
            using (RectangleRegionForm surface = new RectangleRegionForm())
            {
                surface.Config = options;
                surface.Config.ShowTips = false;
                surface.Config.QuickCrop = true;
                surface.Config.DetectWindows = true;
                surface.Prepare();
                surface.ShowDialog();

                if (surface.Result == SurfaceResult.Region)
                {
                    if (surface.AreaManager.IsCurrentRegionValid)
                    {
                        rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentRectangle);
                        return true;
                    }
                }
                else if (surface.Result == SurfaceResult.Fullscreen)
                {
                    rect = CaptureHelpers.GetScreenBounds();
                    return true;
                }
                else if (surface.Result == SurfaceResult.Monitor)
                {
                    Screen[] screens = Screen.AllScreens;

                    if (surface.MonitorIndex < screens.Length)
                    {
                        Screen screen = screens[surface.MonitorIndex];
                        rect = screen.Bounds;
                        return true;
                    }
                }
                else if (surface.Result == SurfaceResult.ActiveMonitor)
                {
                    rect = CaptureHelpers.GetActiveScreenBounds();
                    return true;
                }
            }

            rect = Rectangle.Empty;
            return false;
        }
Exemplo n.º 14
0
        private SimpleWindowInfo GetWindowInfo()
        {
            using (RectangleRegionForm surface = new RectangleRegionForm())
            {
                surface.OneClickMode = true;
                surface.Config.DetectWindows = true;
                surface.Config.DetectControls = true;
                surface.Config.UseDimming = false;
                surface.Config.ShowInfo = true;
                surface.Config.ShowMagnifier = false;
                surface.Config.ShowTips = false;
                surface.Prepare();
                surface.ShowDialog();

                if (surface.Result == SurfaceResult.Region)
                {
                    return surface.SelectedWindow;
                }
            }

            return null;
        }
Exemplo n.º 15
0
        public static PointInfo SelectPointColor()
        {
            using (RectangleRegionForm surface = new RectangleRegionForm())
            {
                surface.ScreenColorPickerMode = true;
                surface.Config.DetectWindows = false;
                surface.Config.UseDimming = false;
                surface.Config.ShowInfo = true;
                surface.Config.ShowMagnifier = true;
                surface.Config.ShowTips = false;
                surface.Prepare();
                surface.ShowDialog();

                if (surface.Result == SurfaceResult.Region)
                {
                    PointInfo pointInfo = new PointInfo();
                    pointInfo.Position = surface.CurrentPosition;
                    pointInfo.Color = surface.CurrentColor;
                    return pointInfo;
                }
            }

            return null;
        }
Exemplo n.º 16
0
 public static void OpenRuler()
 {
     using (RectangleRegionForm surface = new RectangleRegionForm())
     {
         surface.RulerMode = true;
         surface.Config.ShowTips = false;
         surface.Config.QuickCrop = false;
         surface.Config.ShowInfo = true;
         surface.AreaManager.MinimumSize = 3;
         surface.Prepare();
         surface.ShowDialog();
     }
 }
Exemplo n.º 17
0
        public static void ShowScreenRuler()
        {
            using (RectangleRegionForm form = new RectangleRegionForm(RectangleRegionMode.Ruler))
            {
                form.Config.QuickCrop = false;
                form.Config.ShowTips = false;

                form.Prepare();
                form.ShowDialog();
            }
        }