private async void InitMods() { if (System.IO.File.Exists("mod_list.txt")) { String[] names = System.IO.File.ReadAllLines("mod_list.txt"); for (int i = 0; i < names.GetLength(0); ++i) { String name = names[i]; lblStatus.Text = "Getting " + name + " data"; lblStatus.Refresh(); String rarity = await dh.GetItemProperty(name, "rarity"); lblStatus.Text = "Getting " + name + " price"; lblStatus.Refresh(); float price = await dh.GetItemPrice(name, "avg_price"); float min = 0; float max = 0; if (price != 0) { min = await dh.GetItemPrice(name, "min_price"); max = await dh.GetItemPrice(name, "max_price"); } mods.Add(new Tuple <String, String, float, float, float>(name, rarity, price, min, max)); } } lblStatus.Text = ""; UpdatePanel(); }
private async void UpdateValue(String name, Label min, Label max, Label avg) { if (min == null || max == null || avg == null) { return; } min.Text = "Min: "; max.Text = "Max: "; avg.Text = "Average"; min.AccessibleName = name; Task <float> t; if (ongoing_tasks.Exists(x => (x.Item2 == name && x.Item3 == "avg_price"))) { t = ongoing_tasks.Find(x => (x.Item2 == name && x.Item3 == "avg_price")).Item1; } else { t = dh.GetItemPrice(name, "avg_price"); ongoing_tasks.Add(new Tuple <Task <float>, String, String>(t, name, "avg_price")); } String s = (await t).ToString("N2"); if (min.AccessibleName == name) { avg.Text = s; min.Text = "Min: " + (await dh.GetItemPrice(name, "min_price")).ToString("N2"); max.Text = "Max: " + (await dh.GetItemPrice(name, "max_price")).ToString("N2"); } }
private async void PopulateItemBox() { pnlInv.AutoScroll = false; pnlInv.VerticalScroll.Value = 0; float plat_total = 0; pnlInv.Controls.Clear(); for (int i = 0; i < Math.Ceiling((decimal)inventory.Count / (decimal)7.0); ++i) { for (int ii = 0; ii < Math.Min(7, (inventory.Count - i * 7)); ++ii) { String item_name = await dh.GetItemProperty(inventory[i * 7 + ii].Item1, "item_name"); float price = await dh.GetItemPrice(inventory[i * 7 + ii].Item1); if (item_name == "" || price == 0) { CreateNewItemDisplay(new Point(10 + ii * 150, 10 + i * 150), inventory[i * 7 + ii].Item1, 0, 0, true); continue; } CreateNewItemDisplay(new Point(10 + ii * 150, 10 + i * 150), item_name, (int)inventory[i * 7 + ii].Item2, price); plat_total += (int)inventory[i * 7 + ii].Item2 * price; } } lblPTotal.Text = "Plat Total: " + plat_total.ToString(); pnlInv.AutoScroll = true; }
private async Task InitPanels() { relics.Clear(); pnlRelics.Controls.Clear(); pnlRelics.AutoScroll = false; pnlRelics.VerticalScroll.Value = 0; Status("Initializing Relics"); String value_type = "avg_price"; switch (cmbPlatSource.SelectedIndex) { case 1: value_type = "min_price"; break; case 2: value_type = "max_price"; break; } for (int i = 0; i < dh.relics.Count; ++i) { Panel panel = new Panel(); panel.Size = new Size(1050, 50); panel.Location = new Point(0, 50 * i); Relic r = dh.relics[i]; Label name = new Label(); name.Text = r.GetName(); name.Location = new Point(10, 25); panel.Controls.Add(name); List <float> values = new List <float>(); for (int j = 0; j < 6; ++j) { String iname = r.GetItemName(j); Label liname = new Label(); liname.Text = iname; liname.Location = new Point(10 + 150 * (j + 1), 10); liname.AutoSize = true; panel.Controls.Add(liname); Label plat = new Label(); float value = await dh.GetItemPrice(iname, value_type); values.Add(value); plat.Text = value.ToString("N2") + " Plat"; plat.Location = new Point(10 + 150 * (j + 1), 35); plat.AutoSize = true; panel.Controls.Add(plat); } relics.Add(new Tuple <Panel, List <float> >(panel, values)); pnlRelics.Controls.Add(panel); } SortPanels(); }