private void cardsFormCLick(object sender, EventArgs e) { if (count != 15) { CardsForm card = (CardsForm)sender; if (card.ISPRESSED == false) { card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА; foreach (CardHeroes a in allcards) { if (card.NameCards == a.Name) { koloda.Add(a); count++; card.ISPRESSED = true; } } } else { card.BackgroundImage = Resource1.ФОН_ЛИСТА; foreach (CardHeroes a in allcards) { if (card.NameCards == a.Name) { count--; card.ISPRESSED = false; koloda.Remove(a); } } } if (count < 15) { if (Ready.InvokeRequired) { Ready.Invoke((MethodInvoker)(() => Ready.Visible = false)); } else { Ready.Visible = false; } } else if (count == 15) { if (Ready.InvokeRequired) { Ready.Invoke((MethodInvoker)(() => Ready.Visible = true)); } else { Ready.Visible = true; } } } }
private void cardsForm1_Click(object sender, EventArgs e) { CardsForm card = (CardsForm)sender; if (pEnemy.Contains((CardsForm)sender)) { // lNamePlayer2.Enabled = true; if (card.ISPRESSED == false) { choosenEnemyCard = (CardsForm)sender; choosenEnemyCard.ISPRESSED = true; choosenEnemyCard.Index = card.Index; card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА; if (choosenEnemyCard != null && choosenEnemyCard != null) { Step.Visible = true; } } else { choosenEnemyCard.ISPRESSED = false; choosenEnemyCard = null; card.BackgroundImage = Resource1.ФОН_ЛИСТА; Step.Visible = false; } } else if (pMyArena.Contains((CardsForm)sender)) { lNamePlayer2.Enabled = true; if (card.ISPRESSED == false) { choosenCard = (CardsForm)sender; choosenCard.ISPRESSED = true; choosenCard.Index = card.Index; card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА; if (choosenCard != null && choosenEnemyCard != null) { Step.Visible = true; } foreach (CardsForm a in pEnemy.Controls) { if (this.InvokeRequired) { a.Invoke((MethodInvoker)(() => a.Enabled = true)); } else { a.Enabled = true; } } ENSt.Invoke((MethodInvoker)(() => ENSt.Enabled = true)); } else { choosenCard.ISPRESSED = false; choosenCard = null; card.BackgroundImage = Resource1.ФОН_ЛИСТА; Step.Visible = false; foreach (CardsForm a in pEnemy.Controls) { a.Invoke((MethodInvoker)(() => a.Enabled = false)); } ENSt.Invoke((MethodInvoker)(() => ENSt.Enabled = false)); } } else { if (choosenCard != sender && choosenCard != null) { chooseFace = false; choosenCard.BackgroundImage = Resource1.ФОН_ЛИСТА; choosenCard.ISPRESSED = false; choosenCard = (CardsForm)sender; if (!pMyArena.Contains((CardsForm)sender)) { bArena.Visible = true; } } if (card.ISPRESSED == false) { card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА; card.ISPRESSED = true; choosenCard = card; choosenCard.Index = card.Index; if (!pMyArena.Contains((CardsForm)sender)) { bArena.Visible = true; } } else { card.BackgroundImage = Resource1.ФОН_ЛИСТА; card.ISPRESSED = false; choosenCard = null; bArena.Visible = false; } } }