Exemple #1
0
        public void ImportTxtAction(object sender)
        {
            var dialog = new OpenFileDialog();

            dialog.Title  = "Choose the TXT file to be imported";
            dialog.Filter = "Text|*.txt|All|*.*";

            if (dialog.ShowDialog().Value)
            {
                Board board = null;
                try
                {
                    board = Serializer.ImportFromTxt(dialog.FileName);
                    Chess.Reset(board);
                    PlayerModel1.Reset();
                    PlayerModel2.Reset();
                    SetTurnedPlayer();
                    Message.StartBox(Level.Info, "Your board has successfully been imported and is ready to use", "Export Successful");
                }
                catch (Exception e)
                {
                    Message.StartBox(Level.Error, e.Message, "Import Error");
                    return;
                }
            }
        }
Exemple #2
0
        public void ImportXmlAction(object sender)
        {
            var dialog = new OpenFileDialog();

            dialog.Title  = "Choose the XML file to be imported";
            dialog.Filter = "XML|*.xml|All|*.*";
            if (dialog.ShowDialog().Value)
            {
                try
                {
                    Board board = Serializer.FromXml <Board>(dialog.FileName);
                    board.Squares = board.Squares.Skip(64).ToObservableCollection();
                    Chess.Reset(board);
                    PlayerModel1.Reset();
                    PlayerModel2.Reset();
                    SetTurnedPlayer();
                    Message.StartBox(Level.Info, "Your board has successfully been imported and is ready to use", "Export Successful");
                }
                catch (Exception e)
                {
                    Message.StartBox(Level.Error, e.Message, "Import Error");
                    return;
                }
            }
        }
Exemple #3
0
 private void GameOverModel_OnRetry(object sender, EventArgs e)
 {
     GameOverModel = null;
     Chess.Reset();
     PlayerModel1.Reset();
     PlayerModel2.Reset();
     SetTurnedPlayer();
 }