public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); int al = drawArea.TheLayers.ActiveLayerIndex; wasMove = true; // Set con trỏ khi chưa nhấn chuột if (e.Button == MouseButtons.None) { Cursor cursor = null; if (drawArea.TheLayers[al].Graphics != null) { for (int i = 0; i < drawArea.TheLayers[al].Graphics.Count; i++) { int n = drawArea.TheLayers[al].Graphics[i].HitTest(point); if (n > 0) { cursor = drawArea.TheLayers[al].Graphics[i].GetHandleCursor(n); break; } } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } // Khi nhấn trái chuột // Tìm khoảng cách giữa hai điểm trước và sau int dx = point.X - lastPoint.X; int dy = point.Y - lastPoint.Y; lastPoint.X = point.X; lastPoint.Y = point.Y; // Resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); drawArea.Refresh(); } } // Move if (selectMode == SelectionMode.Move) { int n = drawArea.TheLayers[al].Graphics.SelectionCount; for (int i = 0; i < n; i++) { drawArea.TheLayers[al].Graphics.GetSelectedObject(i).Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.Refresh(); } // Group selection if (selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); return; } }