private void GetControlInsertionPoint(PointF pt, out CourseDesignator courseDesignator, out Id<CourseControl> courseControlId1, out Id<CourseControl> courseControlId2)
{
SelectionMgr.SelectionInfo selection = selectionMgr.Selection;
courseDesignator = selection.ActiveCourseDesignator;
courseControlId1 = Id<CourseControl>.None;
courseControlId2 = Id<CourseControl>.None;
if (selection.SelectionKind == SelectionMgr.SelectionKind.Control &&
(courseDesignator.IsAllControls || QueryEvent.IsCourseControlInPart(eventDB, courseDesignator, selection.SelectedCourseControl)))
courseControlId1 = selection.SelectedCourseControl;
else if (selection.SelectionKind == SelectionMgr.SelectionKind.Leg) {
courseControlId1 = selection.SelectedCourseControl;
courseControlId2 = selection.SelectedCourseControl2;
}
else if (courseDesignator.IsNotAllControls) {
// Not all control, and neight control or leg is selected. Use the closest leg.
QueryEvent.LegInfo leg = QueryEvent.FindClosestLeg(eventDB, courseDesignator, pt);
courseControlId1 = leg.courseControlId1;
courseControlId2 = leg.courseControlId2;
}
if (courseDesignator.IsNotAllControls)
QueryEvent.FindControlInsertionPoint(eventDB, courseDesignator, ref courseControlId1, ref courseControlId2);
}