Пример #1
0
        private void updateMarketValuesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var loadForm = new LoadingForm(Market);

            loadForm.ShowDialog(this);
            if (loadForm.DiscardOres)
            {
                // Get rid of them
                List <ulong> toRemove = new List <ulong>();
                foreach (var order in Market.MarketOrders)
                {
                    var recipe = Manager._recipes.Values.Where(r => r.NqId == order.Value.ItemType).FirstOrDefault();
                    if (recipe != null && recipe.ParentGroupName == "Ore")
                    {
                        toRemove.Add(order.Key);
                    }
                }
                foreach (var key in toRemove)
                {
                    Market.MarketOrders.Remove(key);
                }
                Market.SaveData();
            }
            else
            {
                // Process them and leave them so they show in exports
                foreach (var order in Market.MarketOrders)
                {
                    var recipe = Manager._recipes.Values.Where(r => r.NqId == order.Value.ItemType).FirstOrDefault();
                    if (recipe != null && recipe.ParentGroupName == "Ore")
                    {
                        var ore = Manager.Ores.Where(o => o.Key.ToLower() == recipe.Key.ToLower()).FirstOrDefault();
                        if (ore != null)
                        {
                            var orders = Market.MarketOrders.Values.Where(o => o.ItemType == recipe.NqId && o.BuyQuantity < 0 && DateTime.Now < o.ExpirationDate && o.Price > 0);

                            var bestOrder = orders.OrderBy(o => o.Price).FirstOrDefault();
                            if (bestOrder != null)
                            {
                                ore.Value = bestOrder.Price;
                            }
                        }
                    }
                }
                Manager.SaveOreValues();
            }

            loadForm.Dispose();
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (var values in oreGrid.Rows)
     {
         var row            = values as DataGridViewRow;
         var oreName        = row.Cells[0].Value as string;
         var oreValueString = row.Cells[1].Value as string;
         if (double.TryParse(oreValueString, out double oreValue))
         {
             var oreRecipe = Manager.Ores.Where(o => o.Name.ToLower() == oreName.ToLower()).FirstOrDefault();
             if (oreRecipe != null)
             {
                 oreRecipe.Value = oreValue;
             }
         }
     }
     Manager.SaveOreValues();
     this.Close();
 }