private async Task <bool> OnSave() { if (ProblemSet == null || !ProblemSet.IsDirty) { return(true); } if (File.Exists(ProblemSet.Path)) { State = MainWindowStatus.Running; StateText = "Saving Problem Set"; var result = await ProblemSet.SaveAsync().ConfigureAwait(false); Dispatcher.BeginInvoke((Action)(() => { if (result) { State = MainWindowStatus.Ready; StateText = "Problem Set Saved"; } else { State = MainWindowStatus.Error; StateText = "Failed to Save Problem Set"; } })); return(result); } else { return(await OnSaveAs().ConfigureAwait(false)); } }
private async Task <bool> OnSaveAs() { if (ProblemSet == null) { return(true); } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Judge Sharp Problem Set (*.jsps)|*.jsps"; var r = sfd.ShowDialog(); if (r.HasValue && r.Value) { ProblemSet.Path = sfd.FileName; State = MainWindowStatus.Running; StateText = "Saving Problem Set"; var result = await ProblemSet.SaveAsync().ConfigureAwait(false); Dispatcher.BeginInvoke((Action)(() => { if (result) { State = MainWindowStatus.Ready; StateText = "Problem Set Saved"; } else { State = MainWindowStatus.Error; StateText = "Failed to Save Problem Set"; } })); return(result); } return(false); }