Пример #1
0
        private BaseShape CheckHover()
        {
            if (!IsCursorOnNode && !IsCreating && !IsMoving && !IsResizing)
            {
                BaseShape shape = GetIntersectShape();

                if (shape != null && shape.IsValidShape)
                {
                    return(shape);
                }
                else
                {
                    switch (CurrentTool)
                    {
                    case ShapeType.RegionFreehand:
                    case ShapeType.DrawingFreehand:
                    case ShapeType.DrawingLine:
                    case ShapeType.DrawingArrow:
                    case ShapeType.DrawingTextOutline:
                    case ShapeType.DrawingTextBackground:
                    case ShapeType.DrawingSpeechBalloon:
                    case ShapeType.DrawingStep:
                    case ShapeType.DrawingImage:
                    case ShapeType.DrawingCursor:
                        return(null);
                    }

                    if (Options.IsFixedSize && IsCurrentShapeTypeRegion)
                    {
                        Point location = InputManager.ClientMousePosition;

                        return(new RectangleRegionShape()
                        {
                            Rectangle = new Rectangle(new Point(location.X - Options.FixedSize.Width / 2, location.Y - Options.FixedSize.Height / 2), Options.FixedSize)
                        });
                    }
                    else
                    {
                        SimpleWindowInfo window = FindSelectedWindow();

                        if (window != null && !window.Rectangle.IsEmpty)
                        {
                            Rectangle hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle);

                            return(new RectangleRegionShape()
                            {
                                Rectangle = Rectangle.Intersect(Form.ClientArea, hoverArea)
                            });
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
        private void CheckHover()
        {
            CurrentHoverShape = null;

            if (!IsCursorOnNode && !IsCreating && !IsMoving && !IsResizing)
            {
                BaseShape shape = GetIntersectShape();

                if (shape != null && shape.IsValidShape)
                {
                    CurrentHoverShape = shape;
                }
                else
                {
                    switch (CurrentShapeType)
                    {
                    case ShapeType.RegionFreehand:
                    case ShapeType.DrawingFreehand:
                    case ShapeType.DrawingLine:
                    case ShapeType.DrawingArrow:
                    case ShapeType.DrawingTextOutline:
                    case ShapeType.DrawingTextBackground:
                    case ShapeType.DrawingSpeechBalloon:
                    case ShapeType.DrawingStep:
                    case ShapeType.DrawingImage:
                        return;
                    }

                    if (Config.IsFixedSize && IsCurrentShapeTypeRegion)
                    {
                        Point location = InputManager.MousePosition0Based;

                        CurrentHoverShape = new RectangleRegionShape()
                        {
                            Rectangle = new Rectangle(new Point(location.X - Config.FixedSize.Width / 2, location.Y - Config.FixedSize.Height / 2), Config.FixedSize)
                        };
                    }
                    else
                    {
                        SimpleWindowInfo window = FindSelectedWindow();

                        if (window != null && !window.Rectangle.IsEmpty)
                        {
                            Rectangle hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle);

                            CurrentHoverShape = new RectangleRegionShape()
                            {
                                Rectangle = Rectangle.Intersect(form.ScreenRectangle0Based, hoverArea)
                            };
                        }
                    }
                }
            }
        }
Пример #3
0
        public WindowInfo FindSelectedWindowInfo(Point position)
        {
            if (Windows != null)
            {
                SimpleWindowInfo windowInfo = Windows.FirstOrDefault(x => x.IsWindow && x.Rectangle.Contains(position));

                if (windowInfo != null)
                {
                    return(windowInfo.WindowInfo);
                }
            }

            return(null);
        }
Пример #4
0
        private void RectangleRegion_MouseDown(object sender, MouseEventArgs e)
        {
            if ((OneClickMode || ScreenColorPickerMode) && e.Button == MouseButtons.Left)
            {
                CurrentPosition = InputManager.MousePosition;

                if (OneClickMode)
                {
                    SelectedWindow = AreaManager.FindSelectedWindow();
                }

                Close(SurfaceResult.Region);
            }
        }
Пример #5
0
        private void RectangleRegion_MouseDown(object sender, MouseEventArgs e)
        {
            if ((Mode == RectangleRegionMode.OneClick || Mode == RectangleRegionMode.ScreenColorPicker) && e.Button == MouseButtons.Left)
            {
                CurrentPosition = InputManager.MousePosition;

                if (Mode == RectangleRegionMode.OneClick)
                {
                    SelectedWindow = ShapeManager.FindSelectedWindow();
                }

                Close(RegionResult.Region);
            }
        }
Пример #6
0
        private bool CheckHandle(IntPtr handle, bool isWindow)
        {
            if (handle == IgnoreHandle || !NativeMethods.IsWindowVisible(handle) || (isWindow && NativeMethods.IsWindowCloaked(handle)))
            {
                return(true);
            }

            SimpleWindowInfo windowInfo = new SimpleWindowInfo(handle);

            if (isWindow)
            {
                windowInfo.IsWindow  = true;
                windowInfo.Rectangle = CaptureHelpers.GetWindowRectangle(handle);
            }
            else
            {
                windowInfo.Rectangle = NativeMethods.GetWindowRect(handle);
            }

            if (!windowInfo.Rectangle.IsValid())
            {
                return(true);
            }

            if (IncludeChildWindows && !parentHandles.Contains(handle))
            {
                parentHandles.Add(handle);

                EnumWindowsProc ewp = EvalControl;
                NativeMethods.EnumChildWindows(handle, ewp, IntPtr.Zero);
            }

            if (isWindow)
            {
                Rectangle clientRect = NativeMethods.GetClientRect(handle);

                if (clientRect.IsValid() && clientRect != windowInfo.Rectangle)
                {
                    windows.Add(new SimpleWindowInfo(handle, clientRect));
                }
            }

            windows.Add(windowInfo);

            return(true);
        }
Пример #7
0
        private void CheckHover()
        {
            CurrentHoverRectangle = Rectangle.Empty;

            if (!ResizeManager.IsCursorOnNode() && !IsCreating && !IsMoving && !IsResizing)
            {
                BaseShape shape = GetShapeIntersect();

                if (shape != null && !shape.Rectangle.IsEmpty)
                {
                    CurrentHoverRectangle = shape.Rectangle;
                }
                else
                {
                    switch (CurrentShapeType)
                    {
                    case ShapeType.DrawingLine:
                    case ShapeType.DrawingArrow:
                    case ShapeType.DrawingStep:
                        return;
                    }

                    if (Config.IsFixedSize && IsCurrentShapeTypeRegion)
                    {
                        Point location = InputManager.MousePosition0Based;
                        CurrentHoverRectangle = new Rectangle(new Point(location.X - Config.FixedSize.Width / 2, location.Y - Config.FixedSize.Height / 2), Config.FixedSize);
                    }
                    else
                    {
                        SimpleWindowInfo window = FindSelectedWindow();

                        if (window != null && !window.Rectangle.IsEmpty)
                        {
                            Rectangle hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle);
                            CurrentHoverRectangle = Rectangle.Intersect(form.ScreenRectangle0Based, hoverArea);
                        }
                    }
                }
            }
        }
Пример #8
0
        private void SelectHandle()
        {
            WindowState = FormWindowState.Minimized;

            bool capturing = false;

            try
            {
                Thread.Sleep(250);

                SimpleWindowInfo simpleWindowInfo = RegionCaptureTasks.GetWindowInfo(RegionCaptureOptions);

                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();
                }
            }
        }
Пример #9
0
        private void CheckHover()
        {
            CurrentHoverArea = Rectangle.Empty;

            if (!ResizeManager.IsCursorOnNode() && !IsCreating && !IsMoving && !IsResizing)
            {
                Rectangle hoverArea = GetAreaIntersectWithMouse();

                if (!hoverArea.IsEmpty)
                {
                    CurrentHoverArea = hoverArea;
                }
                else
                {
                    SimpleWindowInfo window = FindSelectedWindow();

                    if (window != null && !window.Rectangle.IsEmpty)
                    {
                        hoverArea        = CaptureHelpers.ScreenToClient(window.Rectangle);
                        CurrentHoverArea = Rectangle.Intersect(surface.ScreenRectangle0Based, hoverArea);
                    }
                }
            }
        }
Пример #10
0
        private void RectangleRegion_MouseDown(object sender, MouseEventArgs e)
        {
            if ((OneClickMode || ScreenColorPickerMode) && e.Button == MouseButtons.Left)
            {
                CurrentPosition = InputManager.MousePosition;

                if (OneClickMode)
                {
                    SelectedWindow = AreaManager.FindSelectedWindow();
                }

                Close(SurfaceResult.Region);
            }
        }
Пример #11
0
        private bool CheckHandle(IntPtr handle, bool isWindow)
        {
            if (handle == IgnoreHandle || !NativeMethods.IsWindowVisible(handle) || (isWindow && NativeMethods.IsWindowCloaked(handle)))
            {
                return true;
            }

            SimpleWindowInfo windowInfo = new SimpleWindowInfo(handle);

            if (isWindow)
            {
                windowInfo.IsWindow = true;
                windowInfo.Rectangle = CaptureHelpers.GetWindowRectangle(handle);
            }
            else
            {
                windowInfo.Rectangle = NativeMethods.GetWindowRect(handle);
            }

            if (!windowInfo.Rectangle.IsValid())
            {
                return true;
            }

            if (IncludeChildWindows && !parentHandles.Contains(handle))
            {
                parentHandles.Add(handle);

                EnumWindowsProc ewp = EvalControl;
                NativeMethods.EnumChildWindows(handle, ewp, IntPtr.Zero);
            }

            if (isWindow)
            {
                Rectangle clientRect = NativeMethods.GetClientRect(handle);

                if (clientRect.IsValid() && clientRect != windowInfo.Rectangle)
                {
                    windows.Add(new SimpleWindowInfo(handle, clientRect));
                }
            }

            windows.Add(windowInfo);

            return true;
        }
Пример #12
0
        private void RectangleRegion_MouseDown(object sender, MouseEventArgs e)
        {
            if ((Mode == RectangleRegionMode.OneClick || Mode == RectangleRegionMode.ScreenColorPicker) && e.Button == MouseButtons.Left)
            {
                CurrentPosition = InputManager.MousePosition;

                if (Mode == RectangleRegionMode.OneClick)
                {
                    SelectedWindow = ShapeManager.FindSelectedWindow();
                }

                Close(RegionResult.Region);
            }
        }