Added save check on close

This commit is contained in:
Ben
2015-07-15 19:36:42 +01:00
parent 92ebc51e7b
commit b0b912c676
5 changed files with 40 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
@@ -33,6 +34,7 @@ namespace Filtration.ViewModels
{
RelayCommand OpenScriptCommand { get; }
RelayCommand NewScriptCommand { get; }
bool CloseAllDocuments();
}
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
@@ -626,5 +628,22 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
}
public bool CloseAllDocuments()
{
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
foreach (var document in openDocuments)
{
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
document.Close();
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
{
return false;
}
}
return true;
}
}
}