private void loadToolStripMenuItem_Click(object sender, EventArgs e) { //here we load the file that was perviously saved back into the program using a dialog box for the user //to indicate what file to load and then to load it OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Please indicate a file to load"; string fileName = ""; if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; } if (fileName != "") { using (var stream = File.OpenRead(fileName)) { XmlSerializer deserializer = new XmlSerializer(typeof(List<Game>)); TextReader textReader = new StreamReader(stream); games = (List<Game>)deserializer.Deserialize(textReader); textReader.Close(); } foreach (Game g in games) { Checkers checkers = new Checkers(g); checkers.MdiParent = this; checkers.Show(); LayoutMdi(MdiLayout.Cascade); } } }
private void newGameToolStripMenuItem_Click(object sender, EventArgs e) { //when the user clicks new create a checkerboard Checkers checkers = new Checkers(); checkers.MdiParent = this; checkers.Show(); LayoutMdi(MdiLayout.Cascade); }