private void favoriteItemToolStripMenuItem_Click(object sender, EventArgs e) { if (ActiveForm.Name == "MarketAbuse") { Item item = GetItem(selectedListbox.SelectedItem.ToString()); if (cm.Items[1].Text == "Favorite") { FavoriteItemList.Add(item); } else if (cm.Items[1].Text == "Unfavorite") { int itemIndex = 0; for (int o = 0; o < FavoriteItemList.Count(); o++) { if (FavoriteItemList[o].id == item.id) { itemIndex = o; } } FavoriteItemList.RemoveAt(itemIndex); } } else if (ActiveForm.Name == "CreationForm") { CreationProcess item = (selectedListbox.SelectedItem as CreationProcess); if (cm.Items[1].Text == "Favorite") { FavoriteProcessList.Add(item); } else if (cm.Items[1].Text == "Unfavorite") { int itemIndex = 0; for (int o = 0; o < FavoriteProcessList.Count(); o++) { foreach (Item i in FavoriteProcessList[o].itemsNeeded) { foreach (Item it in item.itemsNeeded) { if (i.id == it.id) { itemIndex = o; } } } } FavoriteProcessList.RemoveAt(itemIndex); } } }
public void CreateLabel(string text, ref Point location, ref List <object> objectArray, GroupBox container, CreationProcess process, Item i = null) { Label temp = new Label(); container.Controls.Add(temp); temp.Location = location; temp.AutoSize = true; temp.Text = text; if (i != null) { temp.Tag = i.id; temp.DoubleClick += new EventHandler(updateitem); } if (text.Contains("Name: ")) { PictureBox image = new PictureBox(); container.Controls.Add(image); Point loc = new Point(location.X + 175, location.Y); image.Location = loc; image.Tag = i.id; if (i != null) { image.Load("http://cdn.rsbuddy.com/items/" + i.id + ".png"); } image.DoubleClick += new EventHandler(updateitem); image.Size = image.Image.Size; objectArray.Add(image); } if (process.margin != "null" && text.Contains("Margin: ")) { if (int.Parse(process.margin) > 0) { temp.ForeColor = Color.Green; } else if (int.Parse(process.margin) == 0) { temp.ForeColor = SystemColors.ControlText; } else if (int.Parse(process.margin) < 0) { temp.ForeColor = Color.Red; } } location.Y += temp.Height + 7; objectArray.Add(temp); }
private void itemCombinations_DoubleClick(object sender, EventArgs e) { if (sender == null || ((ListBox)sender) == null || ((ListBox)sender).SelectedItem == null || ((ListBox)sender).SelectedItem.ToString() == null) { return; } MarketAbuse.UpdateGEInformation(); for (int i = 0; i < creationList.Count(); i++) { creationList[i].completedItems = UpdateList(creationList[i].completedItems); creationList[i].itemsNeeded = UpdateList(creationList[i].itemsNeeded); } this.Size = new Size(594, 320); CreationProcess process = ((ListBox)sender).SelectedItem as CreationProcess; if (process != null) { Point objectPosition = new Point(6, 16); foreach (object o in createdObjects) { if (o.GetType() == typeof(PictureBox)) { ((PictureBox)o).Dispose(); } else if (o.GetType() == typeof(Label)) { ((Label)o).Dispose(); } else if (o.GetType() == typeof(Panel)) { ((Panel)o).Dispose(); } } createdObjects.Clear(); foreach (Item i in process.itemsNeeded) { i.UpdateItemData(); string nameAmount = (i.quantity == 1) ? "Name: " + i.name : "Name: " + i.name + " x" + i.quantity; string buyamount = (i.quantity == 1) ? "Buy Price: " + (i.buyPrice).ToString("#,##0") : "Buy Price: " + (i.buyPrice * i.quantity).ToString("#,##0") + " (" + i.buyPrice + " ea)"; CreateLabel(nameAmount, ref objectPosition, ref createdObjects, groupBox3, process, i); Panel tempPanel = new Panel(); tempPanel.Location = ((Label)createdObjects[createdObjects.Count() - 1]).Location; CreateLabel(buyamount, ref objectPosition, ref createdObjects, groupBox3, process, i); Label label = ((Label)createdObjects[createdObjects.Count() - 1]); Size s = new Size(tempPanel.Width, label.Location.Y - tempPanel.Location.Y + label.Height); tempPanel.Size = s; tempPanel.DoubleClick += new EventHandler(updateitem); tempPanel.BorderStyle = BorderStyle.None; tempPanel.Parent = groupBox3; tempPanel.Tag = i.id; createdObjects.Add(tempPanel); } foreach (Item i in process.completedItems) { string nameAmount = (i.quantity == 1)? "Name: " + i.name: "Name: " + i.name + " x" + i.quantity; string sellamount = (i.quantity == 1) ? "Sell Price: " + (i.sellPrice).ToString("#,##0") : "Sell Price: " + (i.sellPrice * i.quantity).ToString("#,##0") + " (" + i.sellPrice + " ea)"; CreateLabel(nameAmount, ref objectPosition, ref createdObjects, groupBox3, process, i); Panel tempPanel = new Panel(); tempPanel.Location = ((Label)createdObjects[createdObjects.Count() - 1]).Location; CreateLabel(sellamount, ref objectPosition, ref createdObjects, groupBox3, process, i); Label label = ((Label)createdObjects[createdObjects.Count() - 1]); Size s = new Size(tempPanel.Width, label.Location.Y - tempPanel.Location.Y + label.Height); tempPanel.Size = s; tempPanel.DoubleClick += new EventHandler(updateitem); tempPanel.BorderStyle = BorderStyle.None; tempPanel.Parent = groupBox3; tempPanel.Tag = i.id; createdObjects.Add(tempPanel); } string margin = (process.margin == "null") ? "Margin: " + process.margin : "Margin: " + int.Parse(process.margin).ToString("#,##0"); CreateLabel(margin, ref objectPosition, ref createdObjects, groupBox3, process); } else { MessageBox.Show("This item has not been configured yet."); } }
public void listBoxSnap_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } selectedListbox = ((ListBox)sender); selectedListbox.SelectedIndex = selectedListbox.IndexFromPoint(e.Location); if (selectedListbox.SelectedIndex == -1) { return; } Rectangle r = selectedListbox.GetItemRectangle(selectedListbox.SelectedIndex); if (r.Contains(e.Location)) { cm.Items[1].Text = "Favorite"; if (ActiveForm.Name == "MarketAbuse") { foreach (Item i in FavoriteItemList) { if (i.id == GetItem(selectedListbox.SelectedItem.ToString()).id) { cm.Items[1].Text = "Unfavorite"; } } } else if (ActiveForm.Name == "CreationForm") { CreationProcess item = (selectedListbox.SelectedItem as CreationProcess); for (int o = 0; o < FavoriteProcessList.Count(); o++) { string itemIDList = ""; string itemIDList2 = ""; foreach (Item i in FavoriteProcessList[o].itemsNeeded) { itemIDList += i.id + ","; } foreach (Item i in item.itemsNeeded) { itemIDList2 += i.id + ","; } string completedItemList = ""; string completedItemList2 = ""; foreach (Item i in FavoriteProcessList[o].completedItems) { completedItemList += i.id + ","; } foreach (Item i in item.completedItems) { completedItemList2 += i.id + ","; } if (itemIDList == itemIDList2 && completedItemList == completedItemList2) { cm.Items[1].Text = "Unfavorite"; break; } } } cm.Show(selectedListbox, e.Location); } }