public virtual void OnNodeVisible() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; node.Visible = true; } }
public override void OnNodeVisible() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; node.Visible = false; } for (int i = 0; i < 2 + CenterPointCount; i++) { Manager.ResizeNodes[i].Visible = true; } }
public ShapeManager(RegionCaptureForm form) { Form = form; Options = form.Options; DrawableObjects = new List <DrawableObject>(); ResizeNodes = new ResizeNode[9]; for (int i = 0; i < ResizeNodes.Length; i++) { ResizeNode node = new ResizeNode(); node.SetCustomNode(form.CustomNodeImage); DrawableObjects.Add(node); ResizeNodes[i] = node; } ResizeNodes[(int)NodePosition.BottomRight].Order = 10; form.Shown += form_Shown; 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; CurrentShape = null; if (form.Mode == RegionCaptureMode.Annotation) { CurrentTool = Options.LastRegionTool; } else if (form.IsEditorMode) { CurrentTool = Options.LastEditorTool; } else { CurrentTool = ShapeType.RegionRectangle; } }
public ShapeManager(RegionCaptureForm form) { this.form = form; Config = form.Config; ResizeNodes = new List <ResizeNode>(); for (int i = 0; i < 9; i++) { ResizeNode node = new ResizeNode(); node.SetCustomNode(form.CustomNodeImage); form.DrawableObjects.Add(node); ResizeNodes.Add(node); } ResizeNodes[(int)NodePosition.BottomRight].Order = 10; form.Shown += form_Shown; 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; CurrentShape = null; if (form.Mode == RegionCaptureMode.Annotation) { CurrentShapeType = Config.LastRegionTool; } else if (form.IsEditorMode) { CurrentShapeType = Config.LastAnnotationTool; } else { CurrentShapeType = ShapeType.RegionRectangle; } }
public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempNodePos = node.Position; tempStartPos = Rectangle.Location; tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); } Point pos = InputManager.MousePosition0Based; Point startPos = tempStartPos; Point endPos = tempEndPos; NodePosition nodePosition = (NodePosition)i; int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: endPos.X += x; break; } int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: endPos.Y += y; break; } Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos); } } }
public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempNodePos = node.Position; tempStartPos = Rectangle.Location; tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); tempRectangle = Rectangle; OnResizing(); } if (Manager.IsCornerMoving || Manager.IsPanning) { tempStartPos.Offset(InputManager.MouseVelocity); tempEndPos.Offset(InputManager.MouseVelocity); tempNodePos.Offset(InputManager.MouseVelocity); tempRectangle.LocationOffset(InputManager.MouseVelocity); } Point pos = InputManager.ClientMousePosition; Point startPos = tempStartPos; Point endPos = tempEndPos; NodePosition nodePosition = (NodePosition)i; int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: endPos.X += x; break; } int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: endPos.Y += y; break; } StartPosition = startPos; EndPosition = endPos; if (Manager.IsProportionalResizing && !InitialSize.IsEmpty) { switch (nodePosition) { case NodePosition.Top: case NodePosition.Right: case NodePosition.Bottom: case NodePosition.Left: return; } double ratio = Math.Min(Rectangle.Width / (double)InitialSize.Width, Rectangle.Height / (double)InitialSize.Height); int newWidth = (int)Math.Round(InitialSize.Width * ratio); int newHeight = (int)Math.Round(InitialSize.Height * ratio); Point anchor = new Point(); switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: anchor.X = tempRectangle.Right - 1; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: anchor.X = tempRectangle.X; break; } switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: anchor.Y = tempRectangle.Bottom - 1; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: anchor.Y = tempRectangle.Y; break; } Rectangle newRect = Rectangle; if (pos.X < anchor.X) { newRect.X = newRect.Right - newWidth; } newRect.Width = newWidth; if (pos.Y < anchor.Y) { newRect.Y = newRect.Bottom - newHeight; } newRect.Height = newHeight; Rectangle = newRect; } if (LimitRectangleToInsideCanvas) { Rectangle = RectangleInsideCanvas; } } } }
public ShapeManager(RegionCaptureForm form) { this.form = form; Config = form.Config; ResizeNodes = new List<ResizeNode>(); for (int i = 0; i < 9; i++) { ResizeNode node = new ResizeNode(); form.DrawableObjects.Add(node); ResizeNodes.Add(node); } ResizeNodes[(int)NodePosition.BottomRight].Order = 10; form.Shown += form_Shown; 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; CurrentShape = null; if (form.Mode == RegionCaptureMode.Annotation) { CurrentShapeType = Config.LastRegionTool; } else if (form.Mode == RegionCaptureMode.Editor) { CurrentShapeType = Config.LastAnnotationTool; } else { CurrentShapeType = ShapeType.RegionRectangle; } }
public virtual void OnNodeUpdate() { for (int i = 0; i < 8; i++) { ResizeNode node = Manager.ResizeNodes[i]; if (node.IsDragging) { Manager.IsResizing = true; if (!InputManager.IsBeforeMouseDown(MouseButtons.Left)) { tempNodePos = node.Position; tempStartPos = Rectangle.Location; tempEndPos = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1); } if (Manager.IsCornerMoving || Manager.IsPanning) { tempStartPos.Offset(InputManager.MouseVelocity); tempEndPos.Offset(InputManager.MouseVelocity); tempNodePos.Offset(InputManager.MouseVelocity); } Point pos = InputManager.ClientMousePosition; Point startPos = tempStartPos; Point endPos = tempEndPos; NodePosition nodePosition = (NodePosition)i; int x = pos.X - tempNodePos.X; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Left: case NodePosition.BottomLeft: startPos.X += x; break; case NodePosition.TopRight: case NodePosition.Right: case NodePosition.BottomRight: endPos.X += x; break; } int y = pos.Y - tempNodePos.Y; switch (nodePosition) { case NodePosition.TopLeft: case NodePosition.Top: case NodePosition.TopRight: startPos.Y += y; break; case NodePosition.BottomLeft: case NodePosition.Bottom: case NodePosition.BottomRight: endPos.Y += y; break; } StartPosition = startPos; EndPosition = endPos; } } }