public void ReloadCreation() { if (!(itemList.SelectedItem == null || TablePanel.Controls == null)) { foreach (Control control in TablePanel.Controls) { if (control.Name.Contains("BuyPrice")) { Item item = (Item)control.Tag; int num = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? item.sellPrice : item.BuyPrice; string text = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? "Sell Price: " : "Buy Price: "; text += (num * item.quantity).ToString("N0"); text += ((item.quantity == 1) ? "" : (" (" + num.ToString("N0") + " each)")); control.Text = text; } else if (control.Name.Contains("SellPrice")) { Item item2 = (Item)control.Tag; int num2 = (sortBox.Text == "Insta-sell" || sortBox.Text == "Insta-transaction") ? item2.BuyPrice : item2.sellPrice; string text2 = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? "Buy Price: " : "Sell Price: "; text2 += (num2 * item2.quantity).ToString("N0"); text2 += ((item2.quantity == 1) ? "" : (" (" + num2.ToString("N0") + " each)")); control.Text = text2; } else if (control.Name.Contains("Margin")) { int num3; if (formType == Creation.CreationFormType.Shop) { ShopItem shopItem = (ShopItem)itemList.SelectedItem; num3 = shopItem.margin(); } else { Creation creation = (Creation)itemList.SelectedItem; if (sortBox.Text == "Insta-buy") { num3 = creation.instaBuyMargin(); } else if (sortBox.Text == "Insta-sell") { num3 = creation.instaSellMargin(); } else if (sortBox.Text == "Insta-transaction") { num3 = creation.instaTransactionMargin(); } else { num3 = creation.margin(); } } control.Text = "Profit: " + num3.ToString("N0"); control.ForeColor = ((num3 >= 0) ? Color.Green : ((num3 == 0) ? SystemColors.Control : Color.Red)); } } } }
private void LoadCreation(Creation c, int row = 0) { if (formType != Creation.CreationFormType.Shop) { TablePanel.Controls.Clear(); TablePanel.ColumnCount = 2; TablePanel.RowCount = c.Input.Count * 2 + c.Output.Count * 2 + 1; TablePanel.Size = new Size(254, TablePanel.RowCount * 16); } foreach (Item current in c.Input) { string text = "Name: " + current.name; text += ((current.quantity == 1) ? "" : (" x" + current.quantity)); Label label = new Label { Text = text, AutoSize = true, Tag = current, Name = "Name" + current.name }; label.Click += new EventHandler(TableItemSelected); TablePanel.Controls.Add(label, 0, row); PictureBox pictureBox = new PictureBox(); //pictureBox.Load("http://cdn.rsbuddy.com/items/" + current.id + ".png"); pictureBox.Click += new EventHandler(TableItemSelected); pictureBox.Tag = current; pictureBox.Image = null; TablePanel.Controls.Add(pictureBox, 1, row); TablePanel.SetRowSpan(pictureBox, 2); int num = row; row = num + 1; int num2 = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? current.sellPrice : current.BuyPrice; string str = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? "Sell Price: " : "Buy Price: "; text = str + (num2 * current.quantity).ToString("N0"); text += ((current.quantity == 1) ? "" : (" (" + num2.ToString("N0") + " each)")); Label label2 = new Label { Text = text, AutoSize = true, Tag = current, Name = "BuyPrice" + current.name }; label2.Click += new EventHandler(TableItemSelected); TablePanel.Controls.Add(label2, 0, row); num = row; row = num + 1; } foreach (Item current2 in c.Output) { string text2 = "Name: " + current2.name; text2 += ((current2.quantity == 1) ? "" : (" x" + current2.quantity)); Label label3 = new Label { Text = text2, AutoSize = true, Tag = current2, Name = "Name" + current2.name }; label3.Click += new EventHandler(TableItemSelected); TablePanel.Controls.Add(label3, 0, row); PictureBox pictureBox2 = new PictureBox(); //pictureBox2.Load("http://cdn.rsbuddy.com/items/" + current2.id + ".png"); pictureBox2.Click += new EventHandler(TableItemSelected); TablePanel.Controls.Add(pictureBox2, 1, row); pictureBox2.Tag = current2; TablePanel.SetRowSpan(pictureBox2, 2); int num = row; row = num + 1; int num3 = (sortBox.Text == "Insta-sell" || sortBox.Text == "Insta-transaction") ? current2.BuyPrice : current2.sellPrice; string str2 = (sortBox.Text == "Insta-buy" || sortBox.Text == "Insta-transaction") ? "Buy Price: " : "Sell Price: "; text2 = str2 + (num3 * current2.quantity).ToString("N0"); text2 += ((current2.quantity == 1) ? "" : (" (" + num3.ToString("N0") + " each)")); Label label4 = new Label { Text = text2, AutoSize = true, Tag = current2, Name = "SellPrice" + current2.name }; label4.Click += new EventHandler(TableItemSelected); TablePanel.Controls.Add(label4, 0, row); num = row; row = num + 1; } int num4; if (sortBox.Text == "Insta-buy") { num4 = c.instaBuyMargin(); } else if (sortBox.Text == "Insta-sell") { num4 = c.instaSellMargin(); } else if (sortBox.Text == "Insta-transaction") { num4 = c.instaTransactionMargin(); } else { num4 = c.margin(); } Label control = new Label { Text = "Profit: " + num4.ToString("N0"), AutoSize = true, Name = "Margin", ForeColor = ((num4 >= 0) ? Color.Green : ((num4 == 0) ? SystemColors.Control : Color.Red)) }; TablePanel.Controls.Add(control, 0, row); }