Exemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (MatchOpenFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var pgnFileText = File.ReadAllText(MatchOpenFileDialog.FileName);
                    var matches     = _matchFactory.Load(pgnFileText);

                    switch (matches.Count)
                    {
                    case 0:
                        MessageBox.Show("No games found", "Invalid or empty PGN file specified", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;

                    case 1:
                        NewGame(matches.First().Game);
                        break;

                    default:
                        NewGame(matches.First().Game);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToMessageBox();
            }
        }