Beispiel #1
0
        public void Update()
        {
            if (IsMoving)
            {
                Rectangle rect = CurrentArea;
                rect.X     += InputManager.MouseVelocity.X;
                rect.Y     += InputManager.MouseVelocity.Y;
                CurrentArea = rect;
            }

            if (IsCreating && !CurrentArea.IsEmpty)
            {
                currentPosition = InputManager.MousePosition0Based;

                Point newPosition = currentPosition;

                if (proportionalResizing)
                {
                    newPosition = CaptureHelpers.ProportionalPosition(positionOnClick, currentPosition);
                }

                CurrentArea = CaptureHelpers.CreateRectangle(positionOnClick, newPosition);
            }

            CheckHover();

            ResizeManager.Update();
        }
Beispiel #2
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;
            }
        }
Beispiel #3
0
        private void surface_MouseDown(object sender, MouseEventArgs e)
        {
            int areaIndex = AreaIntersect(InputManager.MousePosition0Based);

            if (e.Button == MouseButtons.Left && !ResizeManager.IsCursorOnNode())
            {
                positionOnClick = InputManager.MousePosition0Based;

                if (areaIndex > -1) // Select area
                {
                    IsMoving          = true;
                    SelectedAreaIndex = areaIndex;
                    SelectArea();
                }
                else if (!IsCreating) // Create new area
                {
                    DeselectArea();

                    Rectangle rect;

                    if (surface.Config.IsFixedSize)
                    {
                        IsMoving = true;
                        rect     = new Rectangle(new Point(e.X - surface.Config.FixedSize.Width / 2, e.Y - surface.Config.FixedSize.Height / 2), surface.Config.FixedSize);
                    }
                    else
                    {
                        IsCreating = true;
                        rect       = new Rectangle(e.Location, new Size(1, 1));
                    }

                    AddRegionInfo(rect);
                }
            }
        }
Beispiel #4
0
 private void SelectShape()
 {
     if (!CurrentRectangle.IsEmpty && !Config.IsFixedSize)
     {
         ResizeManager.Show();
     }
 }
Beispiel #5
0
 private void SelectArea()
 {
     if (!CurrentArea.IsEmpty && !surface.Config.IsFixedSize)
     {
         ResizeManager.Show();
     }
 }
Beispiel #6
0
        public void Update()
        {
            BaseShape shape = CurrentShape;

            if (shape != null)
            {
                if (IsMoving)
                {
                    ResizeManager.MoveCurrentArea(InputManager.MouseVelocity.X, InputManager.MouseVelocity.Y);
                }
                else if (IsCreating && !CurrentRectangle.IsEmpty)
                {
                    CurrentPosition = InputManager.MousePosition0Based;

                    Point newPosition = CurrentPosition;

                    if (IsProportionalResizing)
                    {
                        newPosition = CaptureHelpers.ProportionalPosition(PositionOnClick, CurrentPosition);
                    }

                    if (IsSnapResizing)
                    {
                        newPosition = SnapPosition(PositionOnClick, newPosition);
                    }

                    shape.EndPosition = newPosition;
                }
            }

            CheckHover();

            ResizeManager.Update();
        }
Beispiel #7
0
        private void SelectShape()
        {
            BaseShape shape = CurrentShape;

            if (shape != null && !CurrentRectangle.IsEmpty && shape.NodeType != NodeType.Point)
            {
                ResizeManager.Show();
            }
        }
Beispiel #8
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;
        }
Beispiel #9
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;
        }
Beispiel #10
0
        public AreaManager(RectangleRegion surface)
        {
            this.surface = surface;
            ResizeManager = new ResizeManager(surface, this);

            Areas = new List<RegionInfo>();
            SelectedAreaIndex = -1;
            RoundedRectangleRadius = 25;
            RoundedRectangleRadiusIncrement = 3;
            TriangleAngle = TriangleAngle.Top;
            MinimumSize = 10;

            surface.MouseDown += surface_MouseDown;
            surface.MouseUp += surface_MouseUp;
            surface.KeyDown += surface_KeyDown;
            surface.KeyUp += surface_KeyUp;
        }
Beispiel #11
0
        public AreaManager(RectangleRegion surface)
        {
            this.surface  = surface;
            ResizeManager = new ResizeManager(surface, this);

            Areas                           = new List <RegionInfo>();
            SelectedAreaIndex               = -1;
            RoundedRectangleRadius          = 25;
            RoundedRectangleRadiusIncrement = 3;
            TriangleAngle                   = TriangleAngle.Top;
            MinimumSize                     = 10;

            surface.MouseDown += surface_MouseDown;
            surface.MouseUp   += surface_MouseUp;
            surface.KeyDown   += surface_KeyDown;
            surface.KeyUp     += surface_KeyUp;
        }
Beispiel #12
0
        public void Update()
        {
            BaseShape shape = CurrentShape;

            if (shape != null)
            {
                if (IsMoving)
                {
                    ResizeManager.MoveCurrentArea(InputManager.MouseVelocity.X, InputManager.MouseVelocity.Y);
                }
                else if (IsCreating && !CurrentRectangle.IsEmpty)
                {
                    Point currentPosition = InputManager.MousePosition0Based;

                    if (IsProportionalResizing)
                    {
                        if (shape.NodeType == NodeType.Rectangle)
                        {
                            currentPosition = CaptureHelpers.SnapPositionToDegree(shape.StartPosition, currentPosition, 90, 45);
                        }
                        else if (shape.NodeType == NodeType.Line)
                        {
                            currentPosition = CaptureHelpers.SnapPositionToDegree(shape.StartPosition, currentPosition, 45, 0);
                        }
                    }
                    else if (IsCornerMoving)
                    {
                        shape.StartPosition = shape.StartPosition.Add(InputManager.MouseVelocity.X, InputManager.MouseVelocity.Y);
                    }
                    else if (IsSnapResizing)
                    {
                        currentPosition = SnapPosition(shape.StartPosition, currentPosition);
                    }

                    shape.EndPosition = currentPosition;
                }
            }

            CheckHover();

            ResizeManager.Update();
        }
Beispiel #13
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);
                        }
                    }
                }
            }
        }
Beispiel #14
0
        private void RegionSelection(Point location)
        {
            if (ResizeManager.IsCursorOnNode())
            {
                return;
            }

            PositionOnClick = location;

            BaseShape shape = GetShapeIntersect(location);

            if (shape != null && shape.ShapeType == CurrentShapeType) // Select shape
            {
                IsMoving     = true;
                CurrentShape = shape;
                SelectShape();
            }
            else if (!IsCreating) // Create new shape
            {
                DeselectShape();

                shape = AddShape();

                if (shape.NodeType == NodeType.Point)
                {
                    IsMoving        = true;
                    shape.Rectangle = new Rectangle(new Point(location.X - shape.Rectangle.Width / 2, location.Y - shape.Rectangle.Height / 2), shape.Rectangle.Size);
                }
                else if (Config.IsFixedSize && IsCurrentShapeTypeRegion)
                {
                    IsMoving        = true;
                    shape.Rectangle = new Rectangle(new Point(location.X - Config.FixedSize.Width / 2, location.Y - Config.FixedSize.Height / 2), Config.FixedSize);
                }
                else
                {
                    IsCreating          = true;
                    shape.StartPosition = location;
                }
            }
        }
Beispiel #15
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;
        }
Beispiel #16
0
        private void RegionSelection(Point location)
        {
            if (ResizeManager.IsCursorOnNode())
            {
                return;
            }

            BaseShape shape = AreaIntersect(InputManager.MousePosition0Based);

            PositionOnClick = InputManager.MousePosition0Based;

            if (shape != null && shape.ShapeType == CurrentShapeType) // Select area
            {
                IsMoving     = true;
                CurrentShape = shape;
                SelectShape();
            }
            else if (!IsCreating) // Create new area
            {
                DeselectShape();

                Rectangle rect;

                if (Config.IsFixedSize)
                {
                    IsMoving = true;
                    rect     = new Rectangle(new Point(location.X - Config.FixedSize.Width / 2, location.Y - Config.FixedSize.Height / 2), Config.FixedSize);
                }
                else
                {
                    IsCreating = true;
                    rect       = new Rectangle(location, new Size(1, 1));
                }

                AddShape(rect);

                CurrentShape.StartPosition = PositionOnClick;
            }
        }
Beispiel #17
0
        private void RegionSelection(Point location)
        {
            if (ResizeManager.IsCursorOnNode())
            {
                return;
            }

            int areaIndex = AreaIntersect(InputManager.MousePosition0Based);

            PositionOnClick = InputManager.MousePosition0Based;

            if (areaIndex > -1) // Select area
            {
                IsMoving          = true;
                SelectedAreaIndex = areaIndex;
                SelectArea();
            }
            else if (!IsCreating) // Create new area
            {
                DeselectArea();

                Rectangle rect;

                if (surface.Config.IsFixedSize)
                {
                    IsMoving = true;
                    rect     = new Rectangle(new Point(location.X - surface.Config.FixedSize.Width / 2, location.Y - surface.Config.FixedSize.Height / 2), surface.Config.FixedSize);
                }
                else
                {
                    IsCreating = true;
                    rect       = new Rectangle(location, new Size(1, 1));
                }

                AddRegionInfo(rect);
            }
        }
Beispiel #18
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);
                    }
                }
            }
        }
Beispiel #19
0
        private void CheckHover()
        {
            CurrentHoverArea = Rectangle.Empty;

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

                if (!hoverArea.IsEmpty)
                {
                    CurrentHoverArea = hoverArea;
                }
                else if (WindowCaptureMode && Windows != null)
                {
                    hoverArea = Windows.FirstOrDefault(x => x.Contains(InputManager.MousePosition));

                    if (!hoverArea.IsEmpty)
                    {
                        hoverArea        = CaptureHelpers.ScreenToClient(hoverArea);
                        CurrentHoverArea = Rectangle.Intersect(surface.ScreenRectangle0Based, hoverArea);
                    }
                }
            }
        }
Beispiel #20
0
 private void DeselectArea()
 {
     SelectedAreaIndex = -1;
     ResizeManager.Hide();
 }
Beispiel #21
0
 private void DeselectShape()
 {
     CurrentShape = null;
     ResizeManager.Hide();
 }