コード例 #1
0
 /// <summary>
 /// 重新开始
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     for (int i = 0; i < GameGrid.Children.Count; i++)
     {
         Button btn = GameGrid.Children[i] as Button;
         btn.Background = new SolidColorBrush(Colors.Transparent);
         btn.Content    = "";
     }
     mines = MineHelper.CreateMines(8, 8);
     CountTextBlock.Text = ":" + MineHelper._minesCount;
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             if (mines[i, j] == -1)
             {
                 visited[i, j] = true;
             }
             else
             {
                 visited[i, j] = false;
             }
         }
     }
     clickedPoints = 0;
     marks.Clear();
     GGGrid.Visibility = Visibility.Collapsed;
     WPGrid.Visibility = Visibility.Collapsed;
 }
コード例 #2
0
 public MainWindow()
 {
     InitializeComponent();
     mines = MineHelper.CreateMines(8, 8);
     CountTextBlock.Text = ":" + MineHelper._minesCount;
     //初始化visited数组用于后面的函数递归
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             if (mines[i, j] == -1)
             {
                 visited[i, j] = true;
             }
             else
             {
                 visited[i, j] = false;
             }
         }
     }
 }