/// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> protected void AddNewObject(MkaDocument docArea, DrawObject o) { docArea.MokkanList.UnselectAll(); o.Selected = true; docArea.MokkanList.Add(o); docArea.MokkanList[0].MokkanInfo.RBangou = docArea.MokkanList.GetNextRBangou(docArea.MokkanList[0].MokkanInfo.RBangou, 1); MkaMokkanInfo.LastRBangou = docArea.MokkanList.GetNextRBangou(MkaMokkanInfo.LastRBangou + 1, 0); docArea.Capture = true; docArea.Refresh(); docArea.SetDirty(); }
/// <summary> /// Mouse is moved. /// None button is pressed, or left button is pressed. /// </summary> public override void OnMouseMove(MkaDocument docArea, MouseEventArgs e) { Point point = new Point(e.X, e.Y); Point oldPoint = lastPoint; wasMove = true; // set cursor when mouse button is not pressed if (e.Button == MouseButtons.None) { Cursor cursor = null; for (int i = 0; i < docArea.MokkanList.Count; i++) { int n = docArea.MokkanList[i].HitTest(point); if (n > 0) { cursor = docArea.MokkanList[i].GetHandleCursor(n); break; } } if (cursor == null) { cursor = Cursors.Default; } docArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } /// Left button is pressed // Find difference between previous and current position int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; // resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); docArea.SetDirty(); docArea.Refresh(); } } // move if (selectMode == SelectionMode.Move) { foreach (DrawObject o in docArea.MokkanList.Selection) { o.Move(dx, dy); } docArea.Cursor = Cursors.SizeAll; docArea.SetDirty(); docArea.Refresh(); } if (selectMode == SelectionMode.NetSelection) { // Remove old selection rectangle ControlPaint.DrawReversibleFrame( docArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)), Color.Black, FrameStyle.Dashed); // Draw new selection rectangle ControlPaint.DrawReversibleFrame( docArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, point)), Color.Black, FrameStyle.Dashed); return; } }