// Left mouse button selects the object clicked on, or drag something already selected. public override MapViewer.DragAction LeftButtonDown(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded) { if (pane != Pane.Map) { return(MapViewer.DragAction.None); } PointF handleLocation; // Area we initiating a drag of a corner/side? if (HitTestHandle(location, pixelSize, out handleLocation, out cursorDrag)) { // being dragging the corner draggingHandle = true; startDrag = location; handleDrag = handleLocation; dragStartCourseObj = (SelectingRectangleCourseObj)selectingCourseObj.Clone(); displayUpdateNeeded = true; return(MapViewer.DragAction.ImmediateDrag); } // Are we initiating a drag of the whole object? if (HitTestDraggable(location, pixelSize)) { // Begin dragging the clicked object. draggingWhole = true; startDrag = location; dragStartCourseObj = (SelectingRectangleCourseObj)selectingCourseObj.Clone(); displayUpdateNeeded = true; return(MapViewer.DragAction.ImmediateDrag); } return(MapViewer.DragAction.None); }
public override void LeftButtonDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded) { Debug.Assert(pane == Pane.Map); if (draggingWhole) { // Update the rectangle being dragged. selectingCourseObj = (SelectingRectangleCourseObj)dragStartCourseObj.Clone(); selectingCourseObj.Offset(location.X - startDrag.X, location.Y - startDrag.Y); } else if (draggingHandle) { // Update the rectangle where the handle is being dragged. selectingCourseObj = (SelectingRectangleCourseObj)dragStartCourseObj.Clone(); PointF newHandleLocation = new PointF(handleDrag.X + location.X - startDrag.X, handleDrag.Y + location.Y - startDrag.Y); selectingCourseObj.MoveHandle(handleDrag, newHandleLocation); } displayUpdateNeeded = true; }