Esempio n. 1
0
        // Describe a special.
        private static TextPart[] DescribeSpecial(EventDB eventDB, Id <Special> specialId, float scaleRatio, DescKind descKind)
        {
            Debug.Assert(descKind == DescKind.Tooltip || descKind == DescKind.DescPane);

            List <TextPart> list    = new List <TextPart>();
            Special         special = eventDB.GetSpecial(specialId);

            // Name of the special.
            list.Add(new TextPart(TextFormat.Title, SpecialName(eventDB, specialId)));

            if (descKind == DescKind.DescPane)
            {
                // Special location.
                if (special.kind == SpecialKind.FirstAid || special.kind == SpecialKind.Water || special.kind == SpecialKind.Forbidden ||
                    special.kind == SpecialKind.OptCrossing || special.kind == SpecialKind.RegMark || special.kind == SpecialKind.Descriptions)
                {
                    list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Location + "  "));
                    list.Add(new TextPart(TextFormat.SameLine, string.Format("({0:##0.0}, {1:##0.0})", special.locations[0].X, special.locations[0].Y)));
                }
            }

            if (special.kind == SpecialKind.Image)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.FileName + "  "));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", special.text)));
            }

            if (special.kind == SpecialKind.Boundary || special.kind == SpecialKind.Line)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Length));
                list.Add(new TextPart(TextFormat.SameLine,
                                      string.Format("{0:#,###} m", QueryEvent.ComputeSpecialLength(eventDB, specialId))));
            }

            // Line height for descriptions.
            if (special.kind == SpecialKind.Descriptions)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.LineHeight + "  "));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("{0:#0.0} mm", Geometry.Distance(special.locations[0], special.locations[1]) / scaleRatio)));
            }

            // Which courses is it used in?
            list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
            if (special.allCourses)
            {
                list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, SelectionDescriptionText.CourseList_AllCourses));
            }
            else
            {
                list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, special.courses)));
            }

            return(list.ToArray());
        }