private void listBoxOffers_MouseDoubleClick(object sender, MouseEventArgs e) { if (listBoxOffers.SelectedItem == null) { return; } // open offer Offer offer = (Offer)listBoxOffers.SelectedItem; var fo = new FormOffer(offer); var result = fo.ShowDialog(); if (result == DialogResult.Yes) { foreach (var item in from item in offer.Send where _users[offer.SenderID].removeItem(item) select item) { _users[offer.ReceaverID].addItem(item); } foreach (var item in from item in offer.Receave where _users[offer.ReceaverID].removeItem(item) select item) { _users[offer.SenderID].addItem(item); } _offers.Remove(offer); } else // offer declined (Dialogbox.No) { _offers.Remove(offer); } }
private void listBoxFriends_DoubleClick(object sender, EventArgs e) { if (listBoxFriends.SelectedItem == null) { return; } FriendRequest fr = (FriendRequest)listBoxFriends.SelectedItem; if (fr.getStatus() == 0) { if (MessageBox.Show( "Do you want to accept?", "Confirm accept", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { MessageBox.Show("Accepted!"); fr.accept(); // Add friend to the sender FriendRequest senderRequest = new FriendRequest( fr.getReceaver(), fr.getSender(), _users[fr.getReceaver()].Name); senderRequest.accept(); _users[fr.getSender()].Friends.Add(senderRequest); showFriends(false); } else { MessageBox.Show("Deleted!"); _friends.Remove(fr); } } else { // Already a friend User receaver = _users[fr.getReceaver()]; var fo = new FormOffer(receaver.Inventory, _users[fr.getSender()].Inventory); var result = fo.ShowDialog(); if (result == DialogResult.Yes) { // send trade offer List <Item> tmp = new List <Item>(); _users[fr.getSender()].Offers.Add( new Offer(fr.getSender(), fr.getReceaver(), fo.getReceave(), fo.getSend())); /* * receaver.Offers.Add( * new Offer( * fr.getReceaver(), * fr.getSender(), * fo.getSend(), * fo.getReceave()));*/ } else if (result == DialogResult.No) { // remove friend } } }