SelectCourseControl() public method

public SelectCourseControl ( Id courseControlId ) : void
courseControlId Id
return void
Example #1
0
        public override void LeftButtonClick(Pane pane, PointF location, float pixelSize, ref bool displayUpdateNeeded)
        {
            if (pane != Pane.Map)
            {
                return;
            }

            // Create the new control!

            // Are we creating a new control point, or using existing one?
            PointF            highlightLocation;
            Id <ControlPoint> controlId = HitTestPoint(location, pixelSize, out highlightLocation);
            bool   createNewControl     = controlId.IsNone;
            string commandString;

            switch (controlKind)
            {
            case ControlPointKind.MapIssue: commandString = CommandNameText.AddMapIssue; break;

            case ControlPointKind.Start: commandString = CommandNameText.AddStart; break;

            case ControlPointKind.Finish: commandString = CommandNameText.AddFinish; break;

            case ControlPointKind.CrossingPoint: commandString = CommandNameText.AddCrossingPoint; break;

            case ControlPointKind.MapExchange: commandString = CommandNameText.AddMapExchange; break;

            default:
                if (exchangeAtControl)
                {
                    commandString = CommandNameText.AddMapExchange;
                }
                else
                {
                    commandString = CommandNameText.AddControl;
                }
                break;
            }

            undoMgr.BeginCommand(1321, commandString);

            if (createNewControl)
            {
                // Creating a new control point.
                string newCode = null;
                if (controlKind == ControlPointKind.Normal)
                {
                    newCode = QueryEvent.NextUnusedControlCode(eventDB);
                }
                controlId = ChangeEvent.AddControlPoint(eventDB, controlKind, newCode, highlightLocation, 0, mapIssueKind);
                if (controlKind == ControlPointKind.Finish)
                {
                    ChangeEvent.ChangeDescriptionSymbol(eventDB, controlId, 0, "14.3");   // set finish to "navigate to finish".
                }
                else if (controlKind == ControlPointKind.CrossingPoint)
                {
                    ChangeEvent.ChangeDescriptionSymbol(eventDB, controlId, 0, "13.3");   // set to mandatory crossing point.
                }
                else if (controlKind == ControlPointKind.MapIssue)
                {
                    ChangeEvent.ChangeDescriptionSymbol(eventDB, controlId, 0, "13.6");   // Map issue point.
                }
            }

            if (allControls)
            {
                // select the new control.
                selectionMgr.SelectControl(controlId);
            }
            else
            {
                // Add the control to the current course.

                // Get where to add the control.
                CourseDesignator   courseDesignator;
                Id <CourseControl> courseControl1, courseControl2;
                LegInsertionLoc    legInsertionLoc;

                GetControlInsertionPoint(highlightLocation, out courseDesignator, out courseControl1, out courseControl2, out legInsertionLoc);

                // And add it.
                Id <CourseControl> courseControlId;
                if (controlKind == ControlPointKind.Start)
                {
                    courseControlId = ChangeEvent.AddStartOrMapIssueToCourse(eventDB, controlId, courseDesignator.CourseId, true);
                }
                else if (controlKind == ControlPointKind.MapIssue)
                {
                    courseControlId = ChangeEvent.AddStartOrMapIssueToCourse(eventDB, controlId, courseDesignator.CourseId, true);
                }
                else if (controlKind == ControlPointKind.Finish)
                {
                    courseControlId = ChangeEvent.AddFinishToCourse(eventDB, controlId, courseDesignator.CourseId, true);
                }
                else if (controlKind == ControlPointKind.MapExchange)
                {
                    courseControlId = ChangeEvent.AddCourseControl(eventDB, controlId, courseDesignator.CourseId, courseControl1, courseControl2, legInsertionLoc);
                    ChangeEvent.ChangeControlExchange(eventDB, courseControlId, true);
                }
                else if (exchangeAtControl && QueryEvent.CourseUsesControl(eventDB, courseDesignator, controlId))
                {
                    // Selected control already on course, just add map exchange at that courseControl(s)).
                    courseControlId = Id <CourseControl> .None;
                    foreach (Id <CourseControl> courseControlBecomesExchange in QueryEvent.GetCourseControlsInCourse(eventDB, courseDesignator, controlId))
                    {
                        ChangeEvent.ChangeControlExchange(eventDB, courseControlBecomesExchange, true);
                        courseControlId = courseControlBecomesExchange;
                    }
                }
                else
                {
                    courseControlId = ChangeEvent.AddCourseControl(eventDB, controlId, courseDesignator.CourseId, courseControl1, courseControl2, legInsertionLoc);
                    if (exchangeAtControl)
                    {
                        ChangeEvent.ChangeControlExchange(eventDB, courseControlId, true);
                    }
                }

                // select the new control.
                selectionMgr.SelectCourseControl(courseControlId);
            }

            undoMgr.EndCommand(1321);

            controller.DefaultCommandMode();
        }