public static void FileSave(IFormatHandler Handler, string filename) { if (TargetWindow == null) { throw new ArgumentNullException("Forgot to set TargetWindow befor call"); } if (Handler != null) { var NewContext = new ContextFile(); try { NewContext.CurrentFile = filename; Handler.Save(TargetWindow.mainWindowRichText, NewContext); } catch (IOException e) { MessageBox.Show(e.Message, "Error saving file"); NewContext = null; } if (NewContext != null) { TargetWindow.CurrentFile = NewContext; } return; } throw new ArgumentNullException("handler=null"); }
/// <summary> /// The internal callback fo the GetSaveDialogForHandler. Plugged into FileOk Event /// </summary> /// <param name="Handler"></param> /// <param name="sender"></param> /// <param name="e"></param> #pragma warning disable IDE0060 // Remove unused parameter private static void InternalFileOk_Write(IFormatHandler Handler, object sender, CancelEventArgs e) #pragma warning restore IDE0060 // Remove unused parameter { if (Handler != null) { if (TargetWindow.CurrentFile == null) { TargetWindow.CurrentFile = new ContextFile(); } if (string.IsNullOrEmpty(TargetWindow.CurrentFile.CurrentFile)) { TargetWindow.CurrentFile.CurrentFile = ((FileDialog)sender).FileName; } Handler.Save(TargetWindow.mainWindowRichText, TargetWindow.CurrentFile); TargetWindow.CurrentFile.UpdateContextTitle(TargetWindow); return; } throw new Exception("Handler=null"); }