// Determine the type of flagging private static string FlaggingType(EventDB eventDB, Id <ControlPoint> controlId1, Id <ControlPoint> controlId2, Id <Leg> legId) { string flaggingType = SelectionDescriptionText.None; FlaggingKind kind = QueryEvent.GetLegFlagging(eventDB, controlId1, controlId2, legId); switch (kind) { case FlaggingKind.All: flaggingType = SelectionDescriptionText.EntireLeg; break; case FlaggingKind.Begin: flaggingType = SelectionDescriptionText.AwayFromControl; break; case FlaggingKind.End: flaggingType = SelectionDescriptionText.IntoControl; break; } // We use slightly different wording based on the finish control. ControlPoint ending = eventDB.GetControl(controlId2); if (ending.kind == ControlPointKind.Finish) { // finish control can influence flagging! if (ending.symbolIds[0] == "14.2" && kind == FlaggingKind.None) { flaggingType = SelectionDescriptionText.FinishFunnel; } else if (ending.symbolIds[0] == "14.2" && kind == FlaggingKind.End) { flaggingType = SelectionDescriptionText.IntoFinishFunnel; } } return(flaggingType); }
// Get a directive line for a finish or crossingpoint. private DescriptionLine GetDirectiveLine(CourseView.CourseViewKind kind, CourseView.ControlView controlView, CourseView.ControlView controlViewPrev) { ControlPoint control = eventDB.GetControl(controlView.controlId); CourseControl courseControl; if (controlView.courseControlIds[0].IsNone) { courseControl = null; } else { courseControl = eventDB.GetCourseControl(controlView.courseControlIds[0]); } Debug.Assert(control.kind == ControlPointKind.Finish || control.kind == ControlPointKind.CrossingPoint || control.kind == ControlPointKind.MapIssue); DescriptionLine line = new DescriptionLine(); line.kind = DescriptionLineKind.Directive; line.boxes = new object[2]; // Figure out the distance in the directive, rounded to nearest 10m. float distance = float.NaN; string distanceText; if (control.kind == ControlPointKind.MapIssue) { if (controlView.legLength != null) { distance = controlView.legLength[0]; } } else { if (controlViewPrev != null && controlViewPrev.legLength != null) { distance = controlViewPrev.legLength[0]; } } if (!float.IsNaN(distance)) { distance = (float)(Math.Round(distance / 10.0) * 10.0); // round to nearest 10 m. distanceText = string.Format("{0} m", distance); } else { distanceText = ""; } // Box 1: directive graphics. string directiveId = control.symbolIds[0]; // Based on the leg flagging, we may modify the finish directive symbol. if (control.kind == ControlPointKind.Finish && (kind == CourseView.CourseViewKind.Normal || kind == CourseView.CourseViewKind.AllVariations)) { FlaggingKind flagging = FlaggingKind.None; if (controlView != null && controlViewPrev != null) { flagging = QueryEvent.GetLegFlagging(eventDB, controlViewPrev.controlId, controlView.controlId); } if (flagging == FlaggingKind.All) { directiveId = "14.1"; // If flagging is All, then finish id must be flagging to finish. } else if (flagging == FlaggingKind.End) { directiveId = "14.2"; // If flagging is Partial, then finish id must be flagging to funnel. } } line.boxes[0] = symbolDB[directiveId]; // Box 2: distance for the control, if any. if (control.kind == ControlPointKind.Finish || control.kind == ControlPointKind.MapIssue) { line.boxes[1] = distanceText; } // Get the text version of the control using the Textifier. Textifier textifier = new Textifier(eventDB, symbolDB, language); line.textual = textifier.CreateTextForDirective(directiveId, distanceText); // The course control ID, for use in coordinating the selection line.controlId = controlView.controlId; line.courseControlId = controlView.courseControlIds[0]; return(line); }