void control_Duplicate(object sender, DuplicateEventArgs e) { string errorMessage; foreach (DuplicateEventArgsInfo record in e.DuplicateEventArgsInfos) { if (!record.FileInfo.Directory.Exists) { record.FileInfo.Directory.Create(); } if (!XmlSerializationHelper <BindingList <PListDefinition> > .SaveAsXmlFile(record.Definitions, record.FileInfo.FullName, out errorMessage)) { MessageBox.Show("Unable to save " + record.FileInfo.FullName); } else { this.LoadTabPage(record.FileInfo); } } }
public bool Save() { string errorMessage; if (_FileInfo == null) { using (SaveFileDialog saveFileDialog = new SaveFileDialog()) { DirectoryInfo directoryInfo = new DirectoryInfo(MagicStrings.DFAULT_PATH); if (!directoryInfo.Exists) { directoryInfo.Create(); } saveFileDialog.InitialDirectory = directoryInfo.FullName; saveFileDialog.AddExtension = true; saveFileDialog.DefaultExt = ".tpd"; saveFileDialog.Filter = "Texture Packer Definition (*.tpd)|*.tpd"; saveFileDialog.OverwritePrompt = true; switch (saveFileDialog.ShowDialog()) { case DialogResult.OK: FileInfo fileInfo = new FileInfo(saveFileDialog.FileName); if (!XmlSerializationHelper <BindingList <PListDefinition> > .SaveAsXmlFile(_PListDefinitions, fileInfo.FullName, out errorMessage)) { MessageBox.Show("Unable to save file. Error: " + errorMessage); } else { _FileInfo = fileInfo; this.IsDirty = false; if (Saved != null) { this.Saved(this, EventArgs.Empty); } return(true); } break; } } } else { if (!XmlSerializationHelper <BindingList <PListDefinition> > .SaveAsXmlFile(_PListDefinitions, _FileInfo.FullName, out errorMessage)) { MessageBox.Show("Unable to save file. Error: " + errorMessage); } else { if (Saved != null) { this.Saved(this, EventArgs.Empty); } return(true); } } return(false); }