Ejemplo n.º 1
0
        public static List <Icon> GetMetadataIcons(string Type, IEnumerable <string> Tags)
        {
            // Build a list of invariant tags
            List <string> RemainingTags = new List <string>(Tags.Select(x => x.ToLowerInvariant()).Distinct());

            // Get the icons for this type
            MetadataIcon[] MetadataIcons = GetMetadataIconsForType(Type);

            // Build a list of tags for each icon
            string[] TagList = new string[MetadataIcons.Length];
            for (int Idx = 0; Idx < MetadataIcons.Length; Idx++)
            {
                MetadataIcon Icon = MetadataIcons[Idx];
                for (int TagIdx = 0; TagIdx < Icon.InvariantTags.Length; TagIdx++)
                {
                    int RemainingIdx = RemainingTags.IndexOf(Icon.InvariantTags[TagIdx]);
                    if (RemainingIdx != -1)
                    {
                        TagList[Idx] = ((TagList[Idx] == null)? "" : TagList[Idx] + ", ") + Icon.Tags[TagIdx];
                        RemainingTags.RemoveAt(RemainingIdx);
                    }
                }
            }

            // Append all the remaining tags to the list
            if (RemainingTags.Count > 0)
            {
                RemainingTags.Sort((x, y) => String.Compare(x, y));

                string OtherTagList = TagList[TagList.Length - 1];
                if (OtherTagList != null)
                {
                    OtherTagList += ", ";
                }
                TagList[TagList.Length - 1] = OtherTagList + String.Join(", ", RemainingTags);
            }

            // Build a list of icons which have tags
            List <Icon> Icons = new List <Icon>();

            for (int Idx = 0; Idx < MetadataIcons.Length; Idx++)
            {
                if (TagList[Idx] != null)
                {
                    Icons.Add(new Icon(MetadataIcons[Idx].Icon.Path, TagList[Idx]));
                }
            }
            return(Icons);
        }
Ejemplo n.º 2
0
        public static Icon GetMetadataIcon(MetadataIcon[] MetadataIcons, string Tag)
        {
            int Idx = 0;
            while(Idx + 1 < MetadataIcons.Length && !MetadataIcons[Idx].InvariantTags.Contains(Tag.ToLowerInvariant())) Idx++;

            return MetadataIcons[Idx].Icon;
        }
Ejemplo n.º 3
0
        public static void CreateListItems(List<MetadataNode> Nodes, MetadataIcon[] TypeIcons, Dictionary<string, string> Descriptions, bool bMetaPrefix, List<MetadataListItem> ListItems)
        {
            foreach (MetadataNode Node in Nodes)
            {
                string TagName = Node.TagText;
                if (String.Compare(TagName, "Meta", true) == 0 && Node.ListValue != null)
                {
                    CreateListItems(Node.ListValue, APIDocTool.Icons.MetaMetadataIcons, MetadataLookup.MetaTags, true, ListItems);
                }
                else
                {
                    // Get the list name
                    string ListName = bMetaPrefix ? ("Meta=(" + TagName + ")") : TagName;

                    // Find or create a list item
                    MetadataListItem ListItem = ListItems.FirstOrDefault(x => x.Name == ListName);
                    if (ListItem == null)
                    {
                        ListItem = new MetadataListItem();
                        ListItem.Icon = APIDocTool.Icons.GetMetadataIcon(TypeIcons, Node.TagText);
                        ListItem.Name = ListName;
                        Descriptions.TryGetValue(Node.TagText, out ListItem.Description);
                        ListItems.Add(ListItem);
                    }

                    // Add all the values
                    if(Node.TokenValue.HasValue)
                    {
                        ListItem.Values.Add(MetadataLookup.GetReferenceName(Node.TokenValue.ToString()));
                    }
                    if(Node.ListValue != null)
                    {
                        ListItem.Values.AddRange(Node.ListValue.Select(x => x.ToString()));
                    }
                }
            }
        }