private void button2_Click(object sender, EventArgs e) { string path = GetFileName(this.dateTime.Year.ToString()); if (path != null) { string text = GetCalendar(); if (radioButton1.Checked) { writeInFile = WriteToPDFDocument; } else if (radioButton2.Checked) { writeInFile = WriteToWordDocument; } else { writeInFile = WriteToTextFile; } if (writeInFile.Invoke(text, path)) { Process.Start(path); } } }
// Метод, определяющий победителя по фишке-символу игрока public bool IsWinner(char symbol) { // Определим выигрышные комбинации int[,] combWin = new int[8, 3] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 }, { 0, 4, 8 }, { 2, 4, 6 } }; int first = 0, second = 0, third = 0; for (int i = 0; i < combWin.GetLength(0); i++) { int j = 0; first = combWin[i, j++]; second = combWin[i, j++]; third = combWin[i, j++]; if (board[map[first]] == board[map[second]] && board[map[second]] == board[map[third]] && board[map[third]] == symbol) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n*************Congratulation!!!**************"); Console.WriteLine($"Winner is: {symbol}!\n"); if (symbol == ChipComp) { _countWinComp++; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("This is a computer victory! A shame!"); Console.ForegroundColor = ConsoleColor.Gray; } else { _countWinPlayer++; } Console.ForegroundColor = ConsoleColor.Gray; WriteToFile?.Invoke(this, new TicTacToeEventArgs("Recording completed!", _countWinComp, _countWinPlayer)); // если событие для обработки добавлено (т.е. не равно null) то обработаем его Console.WriteLine("**********************************************"); return(true); } } return(false); }