Example #1
0
        private void CreateItemTypes()
        {
            if (_itemTypes == null)
            {
                _itemTypes = new FullyObservableCollection <LItem>();
            }

            var itemTypes = new List <TrinityItemType>((TrinityItemType[])Enum.GetValues(typeof(TrinityItemType)));

            var itemTypeImages = itemTypes.ToDictionary(k => k, v => string.Empty);

            foreach (var item in _TrinityItems)
            {
                itemTypeImages[item.TrinityItemType] = item.IconUrl;
            }

            var existingItemTypes = ItemTypes.ToDictionary(k => k.Id, v => v);

            foreach (var itemType in AllowedTrinityItemTypes)
            {
                LItem item;

                if (!existingItemTypes.TryGetValue((int)itemType, out item))
                {
                    item = new LItem
                    {
                        Name              = itemType.ToString(),
                        Id                = (int)itemType,
                        Type              = LItem.ILType.Slot,
                        TrinityItemType   = itemType,
                        ItemSelectionType = itemType.ToItemSelectionType(),
                        IconUrl           = itemTypeImages[itemType]
                    };
                    item.LoadCommands();
                    ItemTypes.Add(item);
                    continue;
                }

                item.Name              = itemType.ToString();
                item.Type              = LItem.ILType.Slot;
                item.TrinityItemType   = itemType;
                item.ItemSelectionType = itemType.ToItemSelectionType();
                item.IconUrl           = itemTypeImages[itemType];
                item.LoadCommands();
            }

            ItemTypes.Sort(itr => itr.Name);
        }