Fixed cancel on exit not working

This commit is contained in:
Ben Wallis 2018-12-06 21:20:42 +00:00
parent 065e56e0a6
commit 290547cbba
8 changed files with 35 additions and 28 deletions

View File

@ -8,7 +8,7 @@ namespace Filtration.Interface
{
bool IsScript { get; }
bool IsTheme { get; }
Task Close();
Task<bool> Close();
RelayCommand CloseCommand { get; }
}
}

View File

@ -186,10 +186,11 @@ namespace Filtration.ThemeEditor.ViewModels
}
#pragma warning disable 1998
public async Task Close()
public async Task<bool> Close()
#pragma warning restore 1998
{
Messenger.Default.Send(new ThemeClosedMessage {ClosedViewModel = this});
return true;
}
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)

View File

@ -39,7 +39,7 @@ namespace Filtration.ViewModels.DesignTime
public bool IsScript { get; }
public bool IsTheme { get; }
public Task Close()
public Task<bool> Close()
{
throw new System.NotImplementedException();
}

View File

@ -799,14 +799,14 @@ namespace Filtration.ViewModels
await Close();
}
public async Task Close()
public async Task<bool> Close()
{
if (!IsDirty)
{
CloseScript();
return true;
}
else
{
var result = _messageBoxService.Show("Filtration",
"Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
@ -816,17 +816,20 @@ namespace Filtration.ViewModels
{
await SaveAsync();
CloseScript();
break;
return true;
}
case MessageBoxResult.No:
{
CloseScript();
break;
return true;
}
case MessageBoxResult.Cancel:
{
return;
return false;
}
default:
{
return false;
}
}
}

View File

@ -768,7 +768,10 @@ namespace Filtration.ViewModels
continue;
}
await document.Close();
if (!await document.Close())
{
return false;
}
}
return true;

View File

@ -25,7 +25,7 @@ namespace Filtration.ViewModels
public bool IsScript => false;
public bool IsTheme => false;
public Task Close()
public Task<bool> Close()
{
throw new System.NotImplementedException();
}

View File

@ -65,9 +65,10 @@ namespace Filtration.ViewModels
public bool IsInErrorState => UpdateStatus == UpdateStatus.Error;
public async Task Close()
public async Task<bool> Close()
{
await Task.FromResult(true);
return true;
}
public RelayCommand CloseCommand { get; }

View File

@ -44,7 +44,6 @@ namespace Filtration.Views
if (!allDocumentsClosed)
{
e.Cancel = true;
}
}