public override void LeftButtonEndDrag(Pane pane, PointF location, PointF locationStart, float pixelSize, ref bool displayUpdateNeeded)
{
Debug.Assert(pane == Pane.Map);
float deltaX = (location.X - startDrag.X);
float deltaY = (location.Y - startDrag.Y);
PointF newHandleLocation = new PointF(handleLocation.X + deltaX, handleLocation.Y + deltaY);
if (courseObjectStart.specialId.IsNotNone) {
// Moving a corner of a special
Id<Special> specialId = courseObjectStart.specialId;
if (courseObjectStart is DescriptionCourseObj) {
// Moving a description. Descriptions are rather special in the way their locations are used.
DescriptionCourseObj descObj = (DescriptionCourseObj) courseObjectStart.Clone();
descObj.MoveHandle(handleLocation, location);
controller.MoveSpecial(specialId, new PointF[2] { new PointF(descObj.rect.Left, descObj.rect.Bottom), new PointF(descObj.rect.Left + descObj.CellSize, descObj.rect.Bottom) }, descObj.NumberOfColumns);
}
else if (courseObjectStart is RectCourseObj) {
// Moving rectangle handles is sort of special too.
RectCourseObj rectObj = (RectCourseObj)courseObjectStart.Clone();
rectObj.MoveHandle(handleLocation, location);
RectangleF rect = rectObj.GetHighlightBounds();
controller.MoveSpecial(specialId, new PointF[2] { new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top) });
}
else if (courseObjectStart is BasicTextCourseObj) {
// Moving text handles is sort of special too.
BasicTextCourseObj textObj = (BasicTextCourseObj)courseObjectStart.Clone();
textObj.MoveHandle(handleLocation, location);
RectangleF rect = textObj.GetHighlightBounds();
controller.MoveSpecial(specialId, new PointF[2] { new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top) });
}
else {
controller.MoveSpecialPoint(specialId, handleLocation, newHandleLocation);
}
}
else if ((courseObjectStart is LegCourseObj) || (courseObjectStart is FlaggedLegCourseObj)) {
// Moving a leg bend.
LineCourseObj lineCourseObj = (LineCourseObj) courseObjectStart;
controller.MoveLegBendOrGap(lineCourseObj.courseControlId, lineCourseObj.courseControlId2, handleLocation, newHandleLocation);
}
else if ((courseObjectStart is ControlCourseObj) || (courseObjectStart is FinishCourseObj)) {
PointCourseObj pointObj = (PointCourseObj)courseObjectStart.Clone();
pointObj.MoveHandle(handleLocation, location);
controller.MoveControlGap(courseObjectStart.controlId, pointObj.movableGaps);
}
else {
Debug.Fail("unknown situation");
}
controller.DefaultCommandMode();
}