private void NewGame(object sender, RoutedEventArgs e)
        {
            Pause();

            if (ChoiceGame())
            {
                Delete_n_Chess(times);
                iswin  = false;
                player = GoBang_Lib.Type.Black;
                pb_client.ResetTime();
            }
            Continue();
        }
        public void Timer1_Tick(object sender, EventArgs e)
        {
            if (iswin || pb_client.IsStop)
            {
                Pause();
            }
            else
            {
                Continue();
            }

            if (pb_client.Time <= 0 && !iswin)
            {
                RandomPutChess();
                if (isAgainstcomputer && !iswin)
                {
                    Computer();
                }
            }



            if (first && times == 0 && isAgainstcomputer)
            {
                PutChess(7, 7);
            }

            GoBang_Lib.Type type_computer = first == true ? GoBang_Lib.Type.Black : GoBang_Lib.Type.White;

            if (isAgainstcomputer == true && iswin == false && player == type_computer)
            {
                System.DateTime current = new System.DateTime();
                current = System.DateTime.Now;

                Computer();

                double timeSpan = (System.DateTime.Now - current).TotalSeconds;
                label1.Content = "搜索节点个数:" + GoBang_Lib.Tools.count + "\n剪枝节点个数:" + GoBang_Lib.Tools.cut + "\n思考时间:" + timeSpan + "秒";
            }
        }
        private void Recover_button_Click(object sender, RoutedEventArgs e)
        {
            Window recoverwindow = new Recover();

            recoverwindow.ShowDialog();

            GameSave savegame;


            if (File.Exists("GameSave.xml"))
            {
                using (var stream = File.OpenRead("GameSave.xml"))
                {
                    var serializer = new XmlSerializer(typeof(GameSave));
                    savegame = serializer.Deserialize(stream) as GameSave;
                }
            }
            else
            {
                savegame = new GameSave();
            }

            if (savegame.SelectedGames == null || savegame.SelectedGames.Chesses == null)
            {
                return;
            }

            Game game = savegame.SelectedGames;

            Chess[] chesses = game.Chesses;

            //清空棋盘
            Delete_n_Chess(times);
            iswin  = false;
            player = GoBang_Lib.Type.Black;
            pb_client.ResetTime();

            //复盘
            if (chesses.Length > 0)
            {
                player = chesses[chesses.Length - 1].type;

                for (int i = chesses.Length - 1; i >= 0; i--)
                {
                    PutChess(chesses[i].x, chesses[i].y);
                }
            }

            //清空选中状态
            savegame.SelectedGames = null;

            using (var stream = File.Open("GameSave.xml", FileMode.Create))
            {
                var serializer = new XmlSerializer(typeof(GameSave));
                serializer.Serialize(stream, savegame);
            }



            //显示
            this.bgmplayer.mediaElement.Play();
            this.BeginGrid.Opacity          = 0;
            this.BeginGrid.IsEnabled        = false;
            this.BeginGrid.IsHitTestVisible = false;

            this.gameClient.Opacity   = 1;
            this.gameClient.IsEnabled = true;

            this.pb_client.Start();

            if (this.gameClient.Opacity == 1)
            {
                beginlabel.Content = "返回游戏";
            }
        }
 private void SwitchPlayer()
 {
     player = player == GoBang_Lib.Type.Black ? GoBang_Lib.Type.White : GoBang_Lib.Type.Black;
 }