private void geraCoresAleatorias() { for (int i = 0; i < NumeroDeBotoes; i++) { VetorCores[i] = new JogoBotoes(); } ClassEnumCores Conver = new ClassEnumCores(); int quantidadeDeCores = (NumeroDeBotoes / 2) + 1; for (int i = 1; i < quantidadeDeCores; i++) { Random rndPosicao = new Random(); int posicaoEsolhida = 0; while (posicaoEsolhida < 2) { int novaPosicao = rndPosicao.Next(0, NumeroDeBotoes); if (VetorCores[novaPosicao].GetCor() == Cores.Vazio) { VetorCores[novaPosicao].SetCor(Conver.ParseIntToString(i)); posicaoEsolhida++; } } } }
private async Task CleanCor(bool automatic) { if (automatic) { await Task.Delay(500); } duasCores[0] = -1; duasCores[1] = -1; var cor2 = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFDDDDDD")); ClassEnumCores cec = new ClassEnumCores(); Button_0.Background = VetorCores[0].GetFezPar() == true?pegaCor(VetorCores[0].GetCor()) : cor2; Button_1.Background = VetorCores[1].GetFezPar() == true?pegaCor(VetorCores[1].GetCor()) : cor2; Button_2.Background = VetorCores[2].GetFezPar() == true?pegaCor(VetorCores[2].GetCor()) : cor2; Button_3.Background = VetorCores[3].GetFezPar() == true?pegaCor(VetorCores[3].GetCor()) : cor2; Button_4.Background = VetorCores[4].GetFezPar() == true?pegaCor(VetorCores[4].GetCor()) : cor2; Button_5.Background = VetorCores[5].GetFezPar() == true?pegaCor(VetorCores[5].GetCor()) : cor2; Button_6.Background = VetorCores[6].GetFezPar() == true?pegaCor(VetorCores[6].GetCor()) : cor2; Button_7.Background = VetorCores[7].GetFezPar() == true?pegaCor(VetorCores[7].GetCor()) : cor2; Button_8.Background = VetorCores[8].GetFezPar() == true?pegaCor(VetorCores[8].GetCor()) : cor2; Button_9.Background = VetorCores[9].GetFezPar() == true?pegaCor(VetorCores[9].GetCor()) : cor2; Button_10.Background = VetorCores[10].GetFezPar() == true?pegaCor(VetorCores[10].GetCor()) : cor2; Button_11.Background = VetorCores[11].GetFezPar() == true?pegaCor(VetorCores[11].GetCor()) : cor2; Button_12.Background = VetorCores[12].GetFezPar() == true?pegaCor(VetorCores[12].GetCor()) : cor2; Button_13.Background = VetorCores[13].GetFezPar() == true?pegaCor(VetorCores[13].GetCor()) : cor2; Button_14.Background = VetorCores[14].GetFezPar() == true?pegaCor(VetorCores[14].GetCor()) : cor2; Button_15.Background = VetorCores[15].GetFezPar() == true?pegaCor(VetorCores[15].GetCor()) : cor2; botoesAbertos = 0; }
private SolidColorBrush pegaCor(Cores valor) { ClassEnumCores Cec = new ClassEnumCores(); int valorInt = Cec.ParseStringToInt(valor); SolidColorBrush cor; switch (valorInt) { case 1: cor = Brushes.Red; break; case 2: cor = Brushes.Blue; break; case 3: cor = Brushes.Green; break; case 4: cor = Brushes.Yellow; break; case 5: cor = Brushes.Aqua; break; case 6: cor = Brushes.Black; break; case 7: cor = Brushes.Brown; break; case 8: cor = Brushes.Magenta; break; default: cor = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFDDDDDD")); break; } return(cor); }