private void newSpriteSheet_Click(object sender, EventArgs e) { Form childForm = new SpriteSheetForm(); childForm.MdiParent = this; childForm.Text = "Sprite Sheet" + childFormNumber++; childForm.Show(); }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { string FileName = openFileDialog.FileName; SpriteForm childForm = new SpriteForm(); // Use a BinaryFormatter or SoapFormatter IFormatter formatter = new SoapFormatter(); childForm.DeserializeItem(FileName, formatter); // normally we would validate that the form loaded (as in didn't throw an exception) // before making it visible so we can cleanly exit on error // Check if the spritesheet form is open containing the same spritesheet, if not then open one SpriteSheetForm form = childForm.FindSheet(); if (form == null) { Form spritesheetForm = new SpriteSheetForm(childForm.Spritesheet); spritesheetForm.MdiParent = this; spritesheetForm.Text = "Sprite Sheet" + childFormNumber++; spritesheetForm.Show(); } else { childForm.Spritesheet = form.Spritesheet; } // Finally, display thr SpriteForm childForm.MdiParent = this; childForm.Text = "Sprite " + childFormNumber++; childForm.Show(); } }