private void Export_Click(object sender, EventArgs e) { try { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Export game album"; saveFileDialog.Filter = "Files Xml (*.xml)|*.xml|All files (*.*)" + "|*.*"; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { GameXmlSerialized.Serialize(data, saveFileDialog.FileName); } } catch (Exception x) { MessageBox.Show("Error : " + x.Message); } }
//Import GameForm private void gameToolStripMenuItem_Click(object sender, EventArgs e) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Import game"; openFileDialog.Filter = "Files format Xml (*.xml)|*.xml" + "|All files (*.*)|*.*"; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { Game data = GameXmlSerialized.Deserialize(openFileDialog.FileName); GameForm gameForm = new GameForm(data); gameForm.MdiParent = this; gameForm.Show(); } } catch (Exception x) { MessageBox.Show("Error : " + x.Message); } }