private void save() { if (currentFile != null) { string animationName = Path.GetFileNameWithoutExtension(currentFile); AnimationXMLSerializer aniXML = new AnimationXMLSerializer( modelView.Scene.Model, animationName); aniXML.Save(currentFile); unsaved = false; this.Text = title + " - " + animationName + ".xml"; } else { saveAs(); } }
private void saveAs() { if (saveDialog.ShowDialog() == DialogResult.OK) { currentFile = saveDialog.FileName; string animationName = Path.GetFileNameWithoutExtension(currentFile); AnimationXMLSerializer aniXML = new AnimationXMLSerializer( modelView.Scene.Model, animationName); aniXML.Save(currentFile); unsaved = false; this.Text = title + " - " + animationName + ".xml"; } }
private void open() { if (unsaved) { if (MessageBox.Show("Unsaved changes will be lost.\n\n" + "Do you want to save these changes?", "Unsaved Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) save(); } if (openDialog.ShowDialog() == DialogResult.OK) { currentFile = openDialog.FileName; AnimationXMLSerializer aniXML = new AnimationXMLSerializer( modelView.Scene.Model, null); aniXML.Deserialize(File.ReadAllText(openDialog.FileName)); string animationName = Path.GetFileName(currentFile); this.Text = title + " - " + animationName; //Update the modelTreeView this.modelTreeView.Model = this.modelView.Scene.Model; //Update properties this.propsControl.Model = this.modelView.Scene.Model; //Update timeline this.timeline.Model = this.modelView.Scene.Model; modelView.Invalidate(); } }