예제 #1
0
 private void SelectArea()
 {
     if (!CurrentArea.IsEmpty && !surface.Config.IsFixedSize)
     {
         ResizeManager.Show();
     }
 }
예제 #2
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 (IsProportionalResizing)
                {
                    newPosition = CaptureHelpers.ProportionalPosition(PositionOnClick, CurrentPosition);
                }

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

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

            CheckHover();

            ResizeManager.Update();
        }
예제 #3
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;
        }
예제 #4
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;
        }
예제 #5
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);
            }
        }
예제 #6
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);
                    }
                }
            }
        }
예제 #7
0
 private void DeselectArea()
 {
     SelectedAreaIndex = -1;
     ResizeManager.Hide();
 }