private void lb_choice_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string item = lb_choice.SelectedItem.ToString();

            if (lb_choice.SelectedIndex == -1)
            {
                return;
            }

            string id = item.Split('(')[1].Replace(")", string.Empty);

            if (!_cardsToOffer.ContainsKey(Convert.ToInt32(id)))
            {
                return;
            }
            else
            {
                if (_cardsToOffer[Convert.ToInt32(id)].Quantity > 1)
                {
                    _cardsToOffer[Convert.ToInt32(id)].Quantity--;
                }
                else
                {
                    _cardsToOffer.Remove(Convert.ToInt32(id));
                }
            }



            PlayerCard card = CollectionJ1.AddCard(Convert.ToInt32(id));

            lb_choice.Items.RemoveAt(lb_choice.SelectedIndex);
        }
        public Trade(TradeAdministrator admin)
        {
            InitializeComponent();
            this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
            _admin         = admin;

            Closed         += Trade_Closed;
            this.MouseDown += Window_MouseDown;


            _admin.InitTrade          += _admin_InitTrade;
            _admin.GetMessage         += _admin_GetMessage;
            _admin.UpdateCardsToOffer += _admin_UpdateCardsToOffer;
            _admin.TradeExit          += _admin_TradeExit;
            _admin.TradeEnd           += _admin_TradeEnd;

            CollectionJ1.GetListview().SelectionChanged += lvPlayer1_SelectionChanged;
            CollectionJ2.GetListview().SelectionChanged += lvPlayer2_SelectionChanged;

            LoadStyle();

            img_card.MouseEnter        += Img_card_MouseEnter;
            img_card.MouseLeave        += Img_card_MouseLeave;
            img_card.PreviewMouseWheel += Img_card_PreviewMouseWheel;
        }
        private void BCA_ColorButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (CollectionJ1.SelectedIndex() == -1)
            {
                return;
            }

            PlayerCard card = ((PlayerCard)CollectionJ1.SelectedItem());

            if (!CollectionJ1.RemoveCard(card))
            {
                return;
            }

            lb_choice.Items.Add(card.Name + "(" + card.Id + ")");

            PlayerCard offerCard = new PlayerCard();

            offerCard.Id       = card.Id;
            offerCard.Name     = card.Name;
            offerCard.Quantity = 1;

            if (!_cardsToOffer.ContainsKey(offerCard.Id))
            {
                _cardsToOffer.Add(offerCard.Id, offerCard);
            }
            else
            {
                _cardsToOffer[offerCard.Id].Quantity++;
            }
        }
 private void lvPlayer1_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (CollectionJ1.SelectedItem() == null)
     {
         return;
     }
     _idCardShow     = ((PlayerCard)CollectionJ1.SelectedItem()).Id;
     img_card.Source = FormExecution.AssetsManager.GetPics(new string[] { "BattleCityAlpha", "pics", ((PlayerCard)CollectionJ1.SelectedItem()).Id + ".jpg" });
 }
        private void _admin_InitTrade(int id, PlayerInfo[] players, Dictionary <int, BCA.Common.PlayerCard>[] Collections)
        {
            _id              = id;
            _players         = players;
            this.Title       = _players[0].Username + " & " + _players[1].Username;
            this.nameJ1.Text = "Collection de " + _players[0].Username;
            this.nameJ2.Text = "Collection de " + _players[1].Username;

            CollectionJ1.UpdateCollection(Collections[0]);
            CollectionJ2.UpdateCollection(Collections[1]);

            btnValidate.IsEnabled = true;
        }
        private void _admin_UpdateCardsToOffer(List <PlayerCard> cards)
        {
            CollectionJ1.Clear();
            foreach (var card in _cardsToOffer)
            {
                CollectionJ1.Add(card.Value);
            }
            CollectionJ2.Clear();
            foreach (PlayerCard card in cards)
            {
                CollectionJ2.Add(card);
            }

            btnValidate.IsEnabled = true;
        }
        private void Trade_Closed(object sender, EventArgs e)
        {
            if (!endTrade)
            {
                _admin.SendTradeExit(_id);
            }

            Closed -= Trade_Closed;


            _admin.InitTrade          -= _admin_InitTrade;
            _admin.GetMessage         -= _admin_GetMessage;
            _admin.UpdateCardsToOffer -= _admin_UpdateCardsToOffer;
            _admin.TradeExit          -= _admin_TradeExit;
            _admin.TradeEnd           -= _admin_TradeEnd;

            CollectionJ1.GetListview().SelectionChanged -= lvPlayer1_SelectionChanged;
            CollectionJ2.GetListview().SelectionChanged -= lvPlayer2_SelectionChanged;
        }