/// <summary> /// Finalize and save the active file under the main root folder after executing /// the given action. If the unselect input is true, the active file is unselected /// after saving /// </summary> /// <param name="rootFolder"></param> /// <param name="action"></param> /// <param name="unselect"></param> /// <returns>True if saving file resulted in no errors</returns> public bool SaveActiveFile(string rootFolder, Action <TextFileComposer> action, bool unselect = true) { if (HasActiveFile == false) { return(false); } action?.Invoke(ActiveFileComposer); ActiveFileComposer.FinalizeText(); try { ActiveFileComposer.SaveToDisk(rootFolder, true, FilesEncoding); if (unselect) { UnselectActiveFile(); } } catch (Exception ex) { _log .AppendLineAtNewLine($"Error saving file <{ActiveFilePath}>") .AppendLineAtNewLine(ex.Message); return(false); } return(true); }
/// <summary> /// Finalize the text of the active file of this composer. If AutoSaveFinalizedFiles /// is true, this saves the file to disk under the main root folder /// </summary> /// <returns></returns> public FilesComposer FinalizeActiveFile() { if (HasActiveFile == false || ActiveFileComposer.IsFinalized) { return(this); } ActiveFileComposer.FinalizeText(); return(this); }
/// <summary> /// Finalize the text of the active file if not already finalized after executing /// the given action. If AutoSaveFinalizedFiles is true, this saves the file to /// disk under the main root folder /// </summary> /// <param name="action"></param> /// <returns></returns> public FilesComposer FinalizeActiveFile(Action <TextFileComposer> action) { if (HasActiveFile == false || ActiveFileComposer.IsFinalized) { return(this); } action?.Invoke(ActiveFileComposer); ActiveFileComposer.FinalizeText(); return(this); }