public TooltipSection MinablesTooltip(Player player) { var myHardness = this.Tier.GetCurrentValue(player.User); var minableBlockTypes = Block.BlockTypesWithAttribute(typeof(Minable)).Select(x => new KeyValuePair <Type, float>(x, Block.Get <Minable>(x).Hardness)).ToList(); if (!minableBlockTypes.Any()) { return(null); } var allBlocks = AllItems.OfType <BlockItem>(); var resList = new List <LocString>(); minableBlockTypes.OrderBy(item => item.Value).ForEach(x => { var targetItem = allBlocks.FirstOrDefault(item => item.OriginType == x.Key); var hitCount = (int)Math.Ceiling(x.Value / myHardness); if (targetItem != null) { resList.Add(new LocString(string.Format("{0}: {1} {2}", targetItem.UILink(), hitCount, "hit".Pluralize(hitCount)))); } }); return(new TooltipSection(Localizer.DoStr("Can mine"), resList.FoldoutListLoc("item"))); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { Items = AllItems.OfType <object>(). Select(i => new ListPickerBoxItem { Item = i, IsChecked = OriginalSelectedItems.Contains(i) }). ToList(); UpdateSelectedItems(); UpdateSelectAllButton(); list.ItemsSource = Items; }
public void Add(BaseItem item) { AllItems.Add(item); if (item is ItemGroup) { ItemList.Add(item); } else { AllItems.OfType <ItemGroup>().Single(i => i.GroupId == item.GroupId).Notify(); } }