/// <summary> /// Tries to save the current text to the current file, if possible /// </summary> private async Task TrySaveTextAsync() { if (Code.File == null) { await TrySaveTextAsAsync(); } else { Code.Content = Text.ToString(); await Code.TrySaveAsync(); _ = FilesHistoryService.LogOrUpdateActivityAsync(Code.File !); CodeSaved?.Invoke(this, EventArgs.Empty); ReportCodeSaved(); } }
/// <summary> /// Tries to save the current text to a new file /// </summary> private async Task TrySaveTextAsAsync() { if (!(await FilesService.TryPickSaveFileAsync(string.Empty, (string.Empty, ".bfs")) is IFile file)) { return; } if (FilesManagerService.TrySwitchTo(file)) { AnalyticsService.Log(EventNames.SwitchToFile); return; } Code.Content = Text.ToString(); await Code.TrySaveAsAsync(file); _ = FilesHistoryService.LogOrUpdateActivityAsync(Code.File !); CodeSaved?.Invoke(this, EventArgs.Empty); ReportCodeSaved(); }