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; } } }
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); } } } }