/// <summary> /// Remove card from player's flowLayoutPanel /// </summary> /// <param name="player">Player's id</param> /// <param name="CardInd">Removed card index</param> public void flpRemove(int player, int[] CardInd) { switch (player) { case 0: foreach (Control c in flowLayoutPanel2.Controls) { CustomPictureBox cpb = (CustomPictureBox)c; if (cpb.index == CardInd) { flowLayoutPanel2.Controls.Remove(c); } } break; case 1: foreach (Control c in flowLayoutPanel1.Controls) { CustomPictureBox cpb = (CustomPictureBox)c; if (cpb.index == CardInd) { flowLayoutPanel1.Controls.Remove(c); } } break; } }
/// <summary> /// Action: take off mouse from player's card. /// </summary> private void Cpb_MouseLeave(object sender, EventArgs e) { CustomPictureBox cpb = (CustomPictureBox)sender; cpb.Paint += Cpb_PaintOff; cpb.Height = 75; cpb.Width = 60; cpb.BorderStyle = BorderStyle.None; }
/// <summary> /// Action: choose card for move. /// </summary> private void Cpb_MouseHover(object sender, EventArgs e) { CustomPictureBox cpb = (CustomPictureBox)sender; cpb.BorderStyle = BorderStyle.FixedSingle; cpb.Paint += Cpb_PaintOn; int i = 0; while (i < 6) { cpb.Height += i; cpb.Width += i; i += 2; } }
/// <summary> /// Action: click on player's card. /// </summary> private void Cpb_MouseClick(object sender, MouseEventArgs e) { CustomPictureBox cpb = (CustomPictureBox)sender; NewG.NullDeck(); Card used = (Card)NewG.UsedCards.ReturnCard(); Card c = (Card)cpb.card; int index1 = used.index[0]; int index2 = used.index[1]; string text = "You can't play this card in this situation.\nFor more information you can press button Rules"; if (c.index[0] == 7 || c.index[0] == index1 || c.index[1] == index2) { NewG.PlayingProcess(1, cpb.card); } else { MessageBox.Show(text, "Error"); } }
/// <summary> /// Add new card's image in player's flowLayoutPanel (deck) /// </summary> /// <param name="card">Object for adding</param> /// <param name="player">Player which get card</param> public void Add(object card, int player) { Card c = (Card)card; CustomPictureBox cpb = new CustomPictureBox(c.index, card); Image img1 = (player == 1 ? ((Card)card).CardImg : Resources.back); cpb.Image = img1; cpb.Height = 75; cpb.Width = 60; cpb.SizeMode = PictureBoxSizeMode.StretchImage; if (player == 1) { cpb.MouseHover += Cpb_MouseHover; cpb.MouseLeave += Cpb_MouseLeave; cpb.MouseClick += Cpb_MouseClick; flowLayoutPanel1.Controls.Add(cpb); } else { flowLayoutPanel2.Controls.Add(cpb); } }