예제 #1
0
 // Create a description formatter to format the given courseView.
 // Currently, the language for the text descriptions is taken from the language set for the event. It would be easy to make this
 // a parameter to the constructor (e.g., to allow printing in a different language), but this currently isn't required.
 public DescriptionFormatter(CourseView courseView, SymbolDB symbolDB, Purpose purpose)
 {
     this.courseView = courseView;
     this.eventDB    = courseView.EventDB;
     this.symbolDB   = symbolDB;
     this.language   = QueryEvent.GetDescriptionLanguage(eventDB);
     this.purpose    = purpose;
 }
예제 #2
0
        // Describe a control point.
        private static TextPart[] DescribeControlPoint(SymbolDB symbolDB, EventDB eventDB, Id <ControlPoint> controlId, DescKind descKind)
        {
            Debug.Assert(descKind == DescKind.DescPane || descKind == DescKind.Tooltip);

            List <TextPart> list    = new List <TextPart>();
            ControlPoint    control = eventDB.GetControl(controlId);

            // Control name/code.
            list.Add(new TextPart(TextFormat.Title, Util.ControlPointName(eventDB, controlId, NameStyle.Long)));

            // Control location.
            if (descKind == DescKind.DescPane)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Location + "  "));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("({0:##0.0}, {1:##0.0})", control.location.X, control.location.Y)));
            }

            // Which courses is it used in?
            list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
            Id <Course>[] coursesUsingControl = QueryEvent.CoursesUsingControl(eventDB, controlId);
            list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, coursesUsingControl)));

            // What is the competitor load?
            int load   = QueryEvent.GetControlLoad(eventDB, controlId);
            int visits = QueryEvent.GetControlVisitLoad(eventDB, controlId);

            if (load >= 0)
            {
                list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.Load : SelectionDescriptionText.CompetitorLoad)));
                if (visits != load)
                {
                    list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}/{1}", load, visits)));
                }
                else
                {
                    list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", load)));
                }
            }

            // Text version of the descriptions
            if (descKind == DescKind.DescPane)
            {
                Textifier textifier = new Textifier(eventDB, symbolDB, QueryEvent.GetDescriptionLanguage(eventDB));
                string    descText  = textifier.CreateTextForControl(controlId, null);
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.TextDescription));
                list.Add(new TextPart(TextFormat.NewLine, descText));
            }

            return(list.ToArray());
        }