private int GetNextIndex() { if (!ItemPrototypes.Any()) { return(1); } return(ItemPrototypes.Max(x => x.Index) + 1); }
public DiscoveryRule(PerformanceCounterCategory pdhCategory) : this() { Name = String.Format("{0} discovery", pdhCategory.CategoryName); Description = String.Format(@"{0} * Note* This discovery rule requires the 'perf_counter.discovery[]' key to be configured on the remote agent to execute the 'Get-CounterSetInstances.ps1' PowerShell script. ", pdhCategory.CategoryHelp); Key = String.Format(@"perf_counter.discovery[""\{0}""]", pdhCategory.CategoryName); /* * If instances exist on the source machine, search counters on each instance. * Otherwise just call GetCounters() on an empty instance. */ var counters = new Dictionary <String, PerformanceCounter>(); var instances = pdhCategory.GetInstanceNames(); if (instances.Length > 0) { foreach (var instance in instances) { foreach (var pdhCounter in pdhCategory.GetCounters(instance)) { if (pdhCounter.IsValidForExport()) { counters[pdhCounter.CounterName] = pdhCounter; } } } } else { foreach (var pdhCounter in pdhCategory.GetCounters()) { if (pdhCounter.IsValidForExport()) { counters[pdhCounter.CounterName] = pdhCounter; } } } foreach (var pdhCounter in counters.Values) { ItemPrototypes.Add(new Item { Name = String.Format("{0} on {{#INSTANCE}}", pdhCounter.CounterName), Key = String.Format(@"perf_counter[""\{0} ({{#INSTANCE}})\{1}""]", pdhCategory.CategoryName, pdhCounter.CounterName), Description = pdhCounter.CounterHelp, }); } }
public void Initialize(List <Affix> affixes, ItemBase itemBase, BaseInfomation baseInfo) { if (_baseInfo == null || !_baseInfo.Equals(baseInfo)) { _itemBase = itemBase; _affixes = affixes; _baseInfo = baseInfo; SelectedItem = new ItemPrototypeModel(); ItemPrototypes.Clear(); ItemControl = null; AddItem(); SelectedItem = ItemPrototypes[0]; OnPropertyChanged(nameof(SelectedItem)); } }
public void AllowFolders(bool showFolders) { if (!showFolders) { FlatItemPrototypes.Remove(FlatItemPrototypes.Where(i => i.IsContainer).ToList()); foreach (var group in ItemPrototypes) { group.Remove(group.Where(i => i.IsContainer).ToList()); } ItemPrototypes.Remove(ItemPrototypes.Where(i => i.Count == 0).ToList()); if (ItemPrototypes.Count > 0 && ItemPrototypes[0].Count > 0) { SelectedPrototype = ItemPrototypes[0][0]; } } }
private void AddItem() { var index = GetNextIndex(); ItemPrototypeModel prototypeModel = new ItemPrototypeModel { Condition = new CraftingCondition(), ItemName = "Item " + index, Value = 0, Index = index }; ItemPrototypes.Add(prototypeModel); SelectedItem = prototypeModel; UpdateSelectedItem(); OnPropertyChanged(nameof(SelectedItem)); OnPropertyChanged(nameof(ItemControl)); OnPropertyChanged(nameof(ItemPrototypes)); }
private void DeleteOnClick(object sender, RoutedEventArgs e) { if (SelectedItem != null) { ItemPrototypes.Remove(SelectedItem); SelectedItem = null; ItemControl = null; if (!ItemPrototypes.Any()) { AddItem(); } SelectedItem = ItemPrototypes[0]; OnPropertyChanged(nameof(SelectedItem)); OnPropertyChanged(nameof(ItemControl)); } }
public void Initialize(Dictionary <ItemPrototypeModel, List <Equipment> > items, double currencySpent) { ItemResults = string.Empty; OnPropertyChanged(nameof(ItemResults)); ItemDictionary = items; ItemPrototypes.Clear(); var itemCount = items.Where(x => x.Key.Value > 0).Sum(x => x.Value.Count); var itemsValue = items.Sum(x => x.Key.Value * x.Value.Count); CurrencyResults = String.Format("You spent {0} chaos crafting {1} items worth a total of {2} chaos", currencySpent, itemCount, itemsValue); foreach (var itemPrototype in ItemDictionary) { ItemPrototypes.Add(itemPrototype.Key); } OnPropertyChanged(nameof(CurrencyResults)); OnPropertyChanged(nameof(ItemPrototypes)); }