// 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); } }
// Udate the selected course objects in the course. void UpdateSelectedTopologyObjects() { if (selectionKind == SelectionKind.None || activeTopologyCourseLayout == null) { selectedTopologyObjects = null; return; } List<CourseObj> list = new List<CourseObj>(); // Get through each object in the active course and find which ones match. Ignore stuff in the All Controls layer. foreach (CourseObj courseobj in activeTopologyCourseLayout) { if (courseobj.layer != CourseLayer.AllControls) { if (selectionKind == SelectionKind.Control && !(courseobj is VariationCodeCourseObj) && // don't select legs !(courseobj is LineCourseObj) && // don't select legs !(courseobj is TopologyDropTargetCourseObj) && // don't select drop targets courseobj.controlId == selectedControl && courseobj.courseControlId == selectedCourseControl) { list.Add(courseobj); } else if (selectionKind == SelectionKind.Control && courseobj is TopologyDropTargetCourseObj && courseobj.controlId == selectedControl && courseobj.courseControlId == selectedCourseControl) { // Possible drop target. Check find if it's the one we would insert at. Id<CourseControl> cc1 = selectedCourseControl, cc2 = Id<CourseControl>.None; LegInsertionLoc loc = LegInsertionLoc.Normal; QueryEvent.FindControlInsertionPoint(eventDB, activeCourseDesignator, ref cc1, ref cc2, ref loc); if (((TopologyDropTargetCourseObj)courseobj).courseControlId2 == cc2 && ((TopologyDropTargetCourseObj)courseobj).InsertionLoc == loc) { list.Add(courseobj); } } else if (selectionKind == SelectionKind.Leg && courseobj is LineCourseObj && courseobj.courseControlId == selectedCourseControl && ((LineCourseObj)courseobj).courseControlId2 == selectedCourseControl2) { list.Add(courseobj); } else if (selectionKind == SelectionKind.Leg && courseobj is TopologyDropTargetCourseObj && courseobj.courseControlId == selectedCourseControl && ((TopologyDropTargetCourseObj)courseobj).courseControlId2 == selectedCourseControl2 && ((TopologyDropTargetCourseObj)courseobj).InsertionLoc == legInsertionLoc) { list.Add(courseobj); } } } selectedTopologyObjects = list.ToArray(); }