예제 #1
0
 /// <summary>
 /// Updates the Board with the values in the text boxes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SetBoardButton_Click(object sender, RoutedEventArgs e)
 {
     int[] newBoard = new int[9];
     foreach (TextBox element in GridSetter.Children.OfType <TextBox>())
     {
         TextBox temp = (TextBox)element;
         if ((int)Char.GetNumericValue(temp.Name[temp.Name.Length - 1]) == 0)
         {
             if (temp.Text != "")
             {
                 newBoard[8] = (int)Char.GetNumericValue(temp.Text[0]);
             }
         }
         else if (temp.Text != "")
         {
             newBoard[(int)Char.GetNumericValue(temp.Name[temp.Name.Length - 1]) - 1] = (int)Char.GetNumericValue(temp.Text[0]);
         }
         else
         {
             break;
         }
     }
     game.SetBoard(newBoard);
     UpdateBoard(game.GetBoard());
 }