/// <summary> /// The SaveAsApplicationFile /// </summary> /// <param name="filename">The filename<see cref="string"/></param> /// <param name="askFile">The askFile<see cref="bool"/></param> /// <returns>The <see cref="bool"/></returns> private bool SaveAsApplicationFile(string filename, bool askFile) { if (string.IsNullOrEmpty(filename) || askFile) { SaveFileDialog.FileName = filename; if (SaveFileDialog.ShowDialog().Equals(DialogResult.Cancel)) { return(false); } } var fileName = SaveFileDialog.FileName; var savingApplicationFileEventArgs = new SavingFileEventArgs(fileName); OnSavingFile(savingApplicationFileEventArgs); if (!savingApplicationFileEventArgs.Cancel) { var saveApplicationFileEventArgs = new SaveFileEventArgs(fileName); OnSaveFile(saveApplicationFileEventArgs); bool failed = saveApplicationFileEventArgs.Failed; var savedApplicationEventArgs = new SavedFileEventArgs(saveApplicationFileEventArgs.Filename, failed); OnSavedFile(savedApplicationEventArgs); FileName = saveApplicationFileEventArgs.Filename; if (!savedApplicationEventArgs.Failed) { ChangeDetector.Changed = false; } return(!savedApplicationEventArgs.Failed); } return(false); }
/// <summary> /// The OnSavingFile /// </summary> /// <param name="e">The e<see cref="SavingFileEventArgs"/></param> protected virtual void OnSavingFile(SavingFileEventArgs e) { SavingFile?.Invoke(this, e); }