示例#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);
            }
        }
示例#2
0
        // 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();
        }
示例#3
0
        // Sets the current selection. No feedback is provided as to whether the selection
        // is valid; if invalid, the selection will simply be cleared when it is retrieved.
        private void SetSelection(SelectionKind selectionKind, Id<CourseControl> courseControlId, Id<CourseControl> courseControlId2, LegInsertionLoc legInsertionLoc, 
                                  Id<ControlPoint> controlId, Id<Special> specialId, Symbol keySymbol, DescriptionLine.TextLineKind textLineKind)
        {
            if (this.selectionKind != selectionKind || this.selectedCourseControl != courseControlId ||
                this.selectedCourseControl2 != courseControlId2 || this.selectedControl != controlId || this.selectedSpecial != specialId) 
            {
                controller.ScrollHighlightIntoView = true;     // scroll the newly selection item into view.
            }

            ++selectionChangeNum;
            this.selectionKind = selectionKind;
            this.selectedCourseControl = courseControlId;
            this.selectedCourseControl2 = courseControlId2;
            this.legInsertionLoc = legInsertionLoc;
            this.selectedControl = controlId;
            this.selectedSpecial = specialId;
            this.selectedKeySymbol = keySymbol;
            this.selectedTextLineKind = textLineKind;
        }
示例#4
0
 // Select a leg in the current course view.
 public void SelectLeg(Id<CourseControl> courseControlId, Id<CourseControl> courseControlId2, LegInsertionLoc legInsertionLoc)
 {
     eventDB.CheckCourseControlId(courseControlId);
     eventDB.CheckCourseControlId(courseControlId2);
     SetSelection(SelectionKind.Leg, courseControlId, courseControlId2, legInsertionLoc, eventDB.GetCourseControl(courseControlId).control, Id<Special>.None, null, DescriptionLine.TextLineKind.None);
 }
示例#5
0
 public DropTarget(float abstractX, float abstractY, LegInsertionLoc insertionLoc)
 {
     this.abstractX    = abstractX;
     this.abstractY    = abstractY;
     this.insertionLoc = insertionLoc;
 }