PurplePen.DescriptionFormatter.GetMarkedRouteLine C# (CSharp) Method

GetMarkedRouteLine() private method

private GetMarkedRouteLine ( CourseView controlViewFrom, CourseView controlViewTo, Id legId ) : DescriptionLine
controlViewFrom CourseView
controlViewTo CourseView
legId Id
return DescriptionLine
        private DescriptionLine GetMarkedRouteLine(CourseView.ControlView controlViewFrom, CourseView.ControlView controlViewTo, Id<Leg> legId)
        {
            Leg leg = eventDB.GetLeg(legId);

            Debug.Assert(leg.flagging != FlaggingKind.None && leg.flagging != FlaggingKind.End);

            DescriptionLine line = new DescriptionLine();
            line.kind = DescriptionLineKind.Directive;
            line.boxes = new object[2];

            // Figure out the distance in the directive, rounded to nearest 10m.
            string distanceText;
            float distance = QueryEvent.ComputeFlaggedLegLength(eventDB, leg.controlId1, leg.controlId2, legId);
            distance = (float) (Math.Round(distance / 10.0) * 10.0);      // round to nearest 10 m.
            distanceText = string.Format("{0} m", distance);

            // Box 1: directive graphics.
            string symbolId = (leg.flagging == FlaggingKind.Begin) ? "13.1" : "13.2";
            line.boxes[0] = symbolDB[symbolId];

            // Box 2: distance of the flagging
            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(symbolId, distanceText);

            // The course control IDs, for use in coordinating the selection
            line.isLeg = true;
            line.controlId = controlViewFrom.controlId;
            line.courseControlId = controlViewFrom.courseControlIds[0];
            line.courseControlId2 = controlViewTo.courseControlIds[0];

            return line;
        }