Ejemplo n.º 1
0
 public override int GetHashCode()
 {
     return(DescKind.GetHashCode()
            ^ TypeName.GetHashCode()
            ^ Namespace.GetHashCode()
            ^ MemberName.GetHashCode());
 }
Ejemplo n.º 2
0
        public string ToEcmaCref()
        {
            var sb = new StringBuilder();

            // Cref type
            sb.Append(DescKind.ToString()[0]);
            // Create the rest
            ConstructCRef(sb);

            return(sb.ToString());
        }
Ejemplo n.º 3
0
 public override string ToString()
 {
     return(string.Format("({8}) {0}::{1}{2}{3}{7} {4}{5}{6} {9}",
                          Namespace,
                          TypeName,
                          FormatGenericArgsFull(GenericTypeArguments),
                          NestedType != null ? "+" + NestedType.ToString() : string.Empty,
                          MemberName ?? string.Empty,
                          FormatGenericArgsFull(GenericMemberArguments),
                          MemberArguments != null ? "(" + string.Join(",", MemberArguments.Select(m => m.ToString())) + ")" : string.Empty,
                          ArrayDimensions != null && ArrayDimensions.Count > 0 ? ArrayDimensions.Select(dim => "[" + new string (',', dim - 1) + "]").Aggregate(string.Concat) : string.Empty,
                          DescKind.ToString()[0],
                          Etc != 0 ? '(' + Etc.ToString() + ')' : string.Empty));
 }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        // Describe a leg.
        private static TextPart[] DescribeLeg(EventDB eventDB, Id<CourseControl> courseControlId1, Id<CourseControl> courseControlId2, DescKind descKind)
        {
            Debug.Assert(descKind == DescKind.Tooltip || descKind == DescKind.DescPane);

            Id<ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
            Id<ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
            Id<Leg> legId = QueryEvent.FindLeg(eventDB, controlId1, controlId2);

            List<TextPart> list = new List<TextPart>();

            // Course name
            list.Add(new TextPart(TextFormat.Title, string.Format("{0} \u2013 {1}", Util.ControlPointName(eventDB, controlId1, NameStyle.Long), Util.ControlPointName(eventDB, controlId2, NameStyle.Long))));

            // Course length
            list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Length));
            list.Add(new TextPart(TextFormat.SameLine,
                string.Format("{0:#,###} m", QueryEvent.ComputeLegLength(eventDB, controlId1, controlId2, legId))));

            // Which courses
            list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
            Id<Course>[] coursesUsingControl = QueryEvent.CoursesUsingLeg(eventDB, controlId1, controlId2);
            list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, coursesUsingControl)));

            // What is the competitor load?
            int load = QueryEvent.GetLegLoad(eventDB, controlId1, controlId2);
            if (load >= 0) {
                list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.Load : SelectionDescriptionText.CompetitorLoad)));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", load)));
            }

            if (descKind == DescKind.DescPane) {
                // Flagging
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Flagging + "  "));
                list.Add(new TextPart(TextFormat.SameLine, FlaggingType(eventDB, controlId1, controlId2, legId)));
            }

            return list.ToArray();
        }
Ejemplo n.º 6
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);
            if (load >= 0) {
                list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.Load : SelectionDescriptionText.CompetitorLoad)));
                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();
        }
Ejemplo n.º 7
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());
        }
Ejemplo n.º 8
0
        // Describe a leg.
        private static TextPart[] DescribeLeg(EventDB eventDB, Id <CourseControl> courseControlId1, Id <CourseControl> courseControlId2, DescKind descKind)
        {
            Debug.Assert(descKind == DescKind.Tooltip || descKind == DescKind.DescPane);

            Id <ControlPoint> controlId1 = eventDB.GetCourseControl(courseControlId1).control;
            Id <ControlPoint> controlId2 = eventDB.GetCourseControl(courseControlId2).control;
            Id <Leg>          legId      = QueryEvent.FindLeg(eventDB, controlId1, controlId2);

            List <TextPart> list = new List <TextPart>();

            // Course name
            list.Add(new TextPart(TextFormat.Title, string.Format("{0} \u2013 {1}", Util.ControlPointName(eventDB, controlId1, NameStyle.Long), Util.ControlPointName(eventDB, controlId2, NameStyle.Long))));

            // Course length
            list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Length));
            list.Add(new TextPart(TextFormat.SameLine,
                                  string.Format("{0:#,###} m", QueryEvent.ComputeLegLength(eventDB, controlId1, controlId2, legId))));

            // Which courses
            list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
            Id <Course>[] coursesUsingControl = QueryEvent.CoursesUsingLeg(eventDB, controlId1, controlId2);
            list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, coursesUsingControl)));

            // What is the competitor load?
            int load = QueryEvent.GetLegLoad(eventDB, controlId1, controlId2);

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

            if (descKind == DescKind.DescPane)
            {
                // Flagging
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Flagging + "  "));
                list.Add(new TextPart(TextFormat.SameLine, FlaggingType(eventDB, controlId1, controlId2, legId)));
            }

            return(list.ToArray());
        }
Ejemplo n.º 9
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());
        }