private void MenuFileOpen_Click(object sender, EventArgs e) { OpenFileDialog opf = new OpenFileDialog(); String fileName; opf.Filter = "Fen files (*.fen)| *.fen; | All files (*.*)|*.*"; if (opf.ShowDialog() == DialogResult.OK) { fileName = opf.FileName; } else { return; } ChessUtils ut = new ChessUtils(); Position pos; if (fileName.EndsWith("txt")) { pos = ut.ReadPositionFromFile(opf.FileName); } else if (fileName.EndsWith("fen")) { pos = ut.ReadPositionFromFenFile(opf.FileName); } else { return; } ClearBoard(); FillBoard(pos); }
private void saveAsFenFileToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog spf = new SaveFileDialog(); spf.Filter = "Fen files (*.fen)|*.fen"; if (spf.ShowDialog() == DialogResult.OK) { Position pos = readPostionFromBoard(); ChessUtils ut = new ChessUtils(); ut.WritePositionToFenFile(spf.FileName, pos); } else { return; } }
private void MenuFileSave_Click(object sender, EventArgs e) { SaveFileDialog spf = new SaveFileDialog(); spf.Filter = "Text files (*.txt)|*.txt"; if (spf.ShowDialog() == DialogResult.OK) { Position pos = readPostionFromBoard(); ChessUtils ut = new ChessUtils(); ut.WritePositionToFile(spf.FileName, pos); } else { return; } }
private void loadGamePGNToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog opf = new OpenFileDialog(); String fileName; opf.Filter = "Pgn files (*.pgn)| *.pgn; | All files (*.*)|*.*"; if (opf.ShowDialog() == DialogResult.OK) { fileName = opf.FileName; } else { return; } ChessUtils ut = new ChessUtils(); Game game = ut.ReadGameFromPgnFile(fileName); }