コード例 #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();
        }
コード例 #2
0
 private void SelectArea()
 {
     if (!CurrentArea.IsEmpty && !surface.Config.IsFixedSize)
     {
         ResizeManager.Show();
     }
 }
コード例 #3
0
        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 += new MouseEventHandler(surface_MouseDown);
            surface.MouseUp += new MouseEventHandler(surface_MouseUp);
        }
コード例 #5
0
ファイル: AreaManager.cs プロジェクト: kurozael/ShareX
        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;
        }
コード例 #6
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;
        }
コード例 #7
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));
                    }

                    Areas.Add(rect);
                    SelectedAreaIndex = Areas.Count - 1;
                }
            }
        }
コード例 #8
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.FixScreenCoordinates(hoverArea);
                        CurrentHoverArea = Rectangle.Intersect(surface.ScreenRectangle0Based, hoverArea);
                    }
                }
            }
        }
コード例 #9
0
 private void DeselectArea()
 {
     SelectedAreaIndex = -1;
     ResizeManager.Hide();
 }