Example #1
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Table table=new Table();
     ChildrenOpen++;
     table.MdiParent = this;
     table.Text= "Table " + ChildrenOpen;
     table.Show();
 }
Example #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Museum[] tigers;
                try
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    FileStream fs = File.Open(ofd.FileName, FileMode.OpenOrCreate);

                    tigers = (Museum[])formatter.Deserialize(fs);

                }
                catch (IOException)
                {
                    return;
                }
                catch (NullReferenceException)
                {
                    return;
                }
                catch (InvalidCastException)
                {
                    MessageBox.Show("Неверный тип файла", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Table table=new Table(tigers);
                ChildrenOpen++;
                table.MdiParent = this;
                table.Text = "Table " + ChildrenOpen;
                table.Show();
            }
        }