Fixed cancel on exit not working
This commit is contained in:
parent
065e56e0a6
commit
290547cbba
|
@ -8,7 +8,7 @@ namespace Filtration.Interface
|
|||
{
|
||||
bool IsScript { get; }
|
||||
bool IsTheme { get; }
|
||||
Task Close();
|
||||
Task<bool> Close();
|
||||
RelayCommand CloseCommand { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -799,34 +799,37 @@ 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);
|
||||
|
||||
switch (result)
|
||||
var result = _messageBoxService.Show("Filtration",
|
||||
"Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
{
|
||||
await SaveAsync();
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
case MessageBoxResult.No:
|
||||
{
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
case MessageBoxResult.Cancel:
|
||||
{
|
||||
return;
|
||||
}
|
||||
await SaveAsync();
|
||||
CloseScript();
|
||||
return true;
|
||||
}
|
||||
case MessageBoxResult.No:
|
||||
{
|
||||
CloseScript();
|
||||
return true;
|
||||
}
|
||||
case MessageBoxResult.Cancel:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -768,7 +768,10 @@ namespace Filtration.ViewModels
|
|||
continue;
|
||||
}
|
||||
|
||||
await document.Close();
|
||||
if (!await document.Close())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace Filtration.Views
|
|||
if (!allDocumentsClosed)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue