Ejemplo n.º 1
0
        // Get the controls the define where to insert the new control point.
        private void GetControlInsertionPoint(PointF pt, out CourseDesignator courseDesignator,
                                              out Id <CourseControl> courseControlId1, out Id <CourseControl> courseControlId2,
                                              out LegInsertionLoc legInsertionLoc)
        {
            SelectionMgr.SelectionInfo selection = selectionMgr.Selection;
            courseDesignator = selection.ActiveCourseDesignator;
            courseControlId1 = Id <CourseControl> .None;
            courseControlId2 = Id <CourseControl> .None;
            legInsertionLoc  = LegInsertionLoc.Normal;

            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;
                legInsertionLoc  = selection.LegInsertionLoc;
            }
            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, ref legInsertionLoc);
            }
        }