public void LoadGearBySlot(Character.CharacterSlot slot) { Calculations.ClearCache(); List <ComparisonCalculationBase> itemCalculations = new List <ComparisonCalculationBase>(); if (Items != null && Character != null) { foreach (Item item in Items) { if (item.FitsInSlot(slot)) { itemCalculations.Add(Calculations.GetItemCalculations(item, Character, slot)); } } } comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; comparisonGraph1.ItemCalculations = itemCalculations.ToArray(); comparisonGraph1.EquipSlot = slot == Character.CharacterSlot.Gems || slot == Character.CharacterSlot.Metas ? Character.CharacterSlot.None : slot; }
public void LoadGearBySlot(CharacterSlot slot, ItemSlot gemColour) { Calculations.ClearCache(); //_itemCalculations = new List<ComparisonCalculationBase>(); _characterSlot = slot; bool useMultithreading = Calculations.SupportsMultithreading && Rawr.Properties.GeneralSettings.Default.UseMultithreading; bool presorted = false; if (Character != null) { if ((int)slot >= 0 && (int)slot <= 20) { //Normal Gear Slots presorted = true; bool seenEquippedItem = (Character[slot] == null); List <ItemInstance> relevantItemInstances = Character.GetRelevantItemInstances(slot); _itemCalculations = new ComparisonCalculationBase[relevantItemInstances.Count]; _calculationCount = 0; _autoResetEvent = new AutoResetEvent(!useMultithreading); DateTime before = DateTime.Now; if (relevantItemInstances.Count > 0) { foreach (ItemInstance item in relevantItemInstances) { if (!seenEquippedItem && Character[slot].Equals(item)) { seenEquippedItem = true; } //Trace.WriteLine("Queuing WorkItem for item: " + item.ToString()); //Queue each item into the ThreadPool if (useMultithreading) { ThreadPool.QueueUserWorkItem(GetItemInstanceCalculations, item); } else { GetItemInstanceCalculations(item); } } //Wait for all items to be processed _autoResetEvent.WaitOne(); //Trace.WriteLine(DateTime.Now.Subtract(before).Ticks); //Trace.WriteLine("Finished all Calculations"); } // add item List <ComparisonCalculationBase> listItemCalculations = new List <ComparisonCalculationBase>(_itemCalculations); if (!seenEquippedItem) { listItemCalculations.Add(Calculations.GetItemCalculations(Character[slot], Character, slot)); } _itemCalculations = FilterTopXGemmings(listItemCalculations); } else { //Gems/Metas Character.ClearRelevantGems(); // we need to reset relevant items for gems to allow colour selection List <Item> relevantItems = Character.GetRelevantItems(slot, gemColour); _itemCalculations = new ComparisonCalculationBase[relevantItems.Count]; _calculationCount = 0; if (relevantItems.Count > 0) { _autoResetEvent = new AutoResetEvent(!useMultithreading); //DateTime before = DateTime.Now; foreach (Item item in relevantItems) { if (useMultithreading) { ThreadPool.QueueUserWorkItem(GetItemCalculations, item); } else { GetItemCalculations(item); } } //Wait for all items to be processed _autoResetEvent.WaitOne(); //Trace.WriteLine(DateTime.Now.Subtract(before).Ticks); } } } comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; if (presorted) { comparisonGraph1.LoadItemCalculationsPreSorted(_itemCalculations); } else { comparisonGraph1.ItemCalculations = _itemCalculations; } comparisonGraph1.EquipSlot = slot == CharacterSlot.Gems || slot == CharacterSlot.Metas ? CharacterSlot.None : slot; }