Ejemplo n.º 1
0
        private void gameFromFENToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Check that 2 different players are selected
            if (cmbPlayer1.SelectedIndex == -1 || cmbPlayer2.SelectedIndex == -1 || cmbPlayer1.SelectedIndex == cmbPlayer2.SelectedIndex)
            {
                MessageBox.Show("Please select 2 unique players!");
            }
            else
            {
                FENSpecifier fenRetriever = new FENSpecifier(SerializationModes.Input);

                // Open dialog to enter FEN string
                if (fenRetriever.ShowDialog() == DialogResult.OK && !String.IsNullOrEmpty(fenRetriever.Result))
                {
                    Game g = new Game((Player)cmbPlayer1.SelectedItem, (Player)cmbPlayer2.SelectedItem);
                    Board2 b = new Board2(g, fenRetriever.Result);
                    b.Show();
                }
            }
        }
Ejemplo n.º 2
0
        private void fromFENSpecifiedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FENSpecifier fenRetriever = new FENSpecifier(SerializationModes.Input, this.game.Layout);
            DialogResult result = fenRetriever.ShowDialog();

            if (result == DialogResult.OK)
                SetPositionFromFEN(fenRetriever.Result);
        }
Ejemplo n.º 3
0
        private void toFENToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            /*saveDiag.Filter = Main.FILETYPE_FEN;

            // Prompt for where to save file
            if (saveDiag.ShowDialog() == DialogResult.OK)
            {
                // Open stream and serializer
                StreamWriter stream = new StreamWriter(new FileStream(saveDiag.FileName, FileMode.OpenOrCreate, FileAccess.Write));
                GameSerializer s = new GameSerializer();

                try
                {
                    // Generate string and write to file
                    stream.WriteLine(s.ToFEN(this.game));
                    stream.Flush();
                    s.ToStream(new FENSerializer(), this.game.Layout, stream);
                }
                catch (FENException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception ex) // May be FENException
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    stream.Close();
                    stream.Dispose();
                }
            }*/

            FENSpecifier fenRetriever = new FENSpecifier(SerializationModes.Output, this.game.Layout);
            DialogResult result = fenRetriever.ShowDialog();
        }
Ejemplo n.º 4
0
        private void fromFENFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*string fenString = String.Empty;

            openDiag.Filter = Main.FILETYPE_FEN;

            // Prompt for where to save file
            if (openDiag.ShowDialog() == DialogResult.OK)
            {
                // Open stream and serializer
                StreamReader stream = new StreamReader(new FileStream(openDiag.FileName, FileMode.Open, FileAccess.Read));

                try
                {
                    // Generate string and write to file
                    fenString = stream.ReadLine();
                }
                catch (FENException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    stream.Close();
                    stream.Dispose();
                }
            }

            if (String.IsNullOrEmpty(fenString))
                MessageBox.Show("Could not read any data from file");
            else
                SetPositionFromFEN(fenString);*/

            FENSpecifier fenRetriever = new FENSpecifier(SerializationModes.Input, this.game.Layout);
            DialogResult result = fenRetriever.ShowDialog();

            if (result == DialogResult.OK)
                SetPositionFromFEN(fenRetriever.Result);
        }