protected override void Update() { base.Update(); if (InputManager.IsMousePressed(MouseButtons.Right)) { if (isAreaCreated) { isAreaCreated = false; regionFillPath.Reset(); HideNodes(); points.Clear(); } else { Close(SurfaceResult.Close); } } if (Config.QuickCrop && isAreaCreated && InputManager.IsMouseReleased(MouseButtons.Left)) { Close(SurfaceResult.Region); } if (!isAreaCreated && InputManager.IsMouseDown(MouseButtons.Left)) { lastNode.Visible = true; isAreaCreated = true; } if (lastNode.Visible && InputManager.IsMouseDown(MouseButtons.Left)) { if (points.Count == 0 || points.Last() != InputManager.MousePosition0Based) { points.Add(InputManager.MousePosition0Based); if (points.Count > 1) { regionFillPath.AddLine(points.Last(1), points.Last()); } lastNode.Position = InputManager.MousePosition0Based; } } if (points.Count > 2) { RectangleF rect = regionFillPath.GetBounds(); currentArea = new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width + 1, (int)rect.Height + 1); } }
private void UpdateNodes() { BaseShape shape = CurrentShape; if (shape != null && NodesVisible) { if (InputManager.IsMouseDown(MouseButtons.Left)) { shape.OnNodeUpdate(); } else { IsResizing = false; } shape.OnNodePositionUpdate(); } }
public void Update() { BaseShape shape = shapeManager.CurrentShape; if (shape != null && Visible && nodes != null) { if (InputManager.IsMouseDown(MouseButtons.Left)) { if (shape.NodeType == NodeType.Rectangle) { for (int i = 0; i < 8; i++) { if (nodes[i].IsDragging) { IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempRect = shape.Rectangle; } NodePosition nodePosition = (NodePosition)i; int x = InputManager.MouseVelocity.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: tempRect.X += x; tempRect.Width -= x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: tempRect.Width += x; break; } int y = InputManager.MouseVelocity.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: tempRect.Y += y; tempRect.Height -= y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: tempRect.Height += y; break; } shape.Rectangle = CaptureHelpers.FixRectangle(tempRect); break; } } } else if (shape.NodeType == NodeType.Line) { if (nodes[(int)NodePosition.TopLeft].IsDragging) { IsResizing = true; shape.StartPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y); } else if (nodes[(int)NodePosition.BottomRight].IsDragging) { IsResizing = true; shape.EndPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y); } } } else { IsResizing = false; } UpdateNodePositions(); } }
public void Update() { if (Visible && nodes != null) { if (InputManager.IsMouseDown(MouseButtons.Left)) { for (int i = 0; i < 8; i++) { if (nodes[i].IsDragging) { IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempRect = areaManager.CurrentArea; } NodePosition nodePosition = (NodePosition)i; int x = InputManager.MouseVelocity.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: tempRect.X += x; tempRect.Width -= x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: tempRect.Width += x; break; } int y = InputManager.MouseVelocity.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: tempRect.Y += y; tempRect.Height -= y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: tempRect.Height += y; break; } areaManager.CurrentArea = CaptureHelpers.FixRectangle(tempRect); break; } } } else { IsResizing = false; } UpdateNodePositions(); } }