Remember all open scripts (#100)
This commit is contained in:
parent
124786dd0d
commit
05a994f562
|
@ -221,12 +221,12 @@ namespace Filtration.Properties {
|
|||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string LastActiveDocument {
|
||||
public string LastOpenScripts {
|
||||
get {
|
||||
return ((string)(this["LastActiveDocument"]));
|
||||
return ((string)(this["LastOpenScripts"]));
|
||||
}
|
||||
set {
|
||||
this["LastActiveDocument"] = value;
|
||||
this["LastOpenScripts"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ namespace Filtration.ViewModels
|
|||
if (value.IsScript)
|
||||
{
|
||||
_activeScriptViewModel = (IItemFilterScriptViewModel) value;
|
||||
Settings.Default.LastActiveDocument = _activeScriptViewModel.Script.FilePath;
|
||||
}
|
||||
else if (value.IsTheme)
|
||||
{
|
||||
|
|
|
@ -206,9 +206,9 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
});
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Settings.Default.LastActiveDocument) && File.Exists(Settings.Default.LastActiveDocument))
|
||||
if (!string.IsNullOrWhiteSpace(Settings.Default.LastOpenScripts))
|
||||
{
|
||||
LoadScriptAsync(Settings.Default.LastActiveDocument);
|
||||
LoadScriptsAsync(Settings.Default.LastOpenScripts.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,6 +435,17 @@ namespace Filtration.ViewModels
|
|||
await LoadScriptAsync(filePath); // TODO: fix crash
|
||||
}
|
||||
|
||||
private async Task LoadScriptsAsync(string[] files)
|
||||
{
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
await LoadScriptAsync(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadScriptAsync(string scriptFilename)
|
||||
{
|
||||
IItemFilterScriptViewModel loadedViewModel;
|
||||
|
@ -637,7 +648,6 @@ namespace Filtration.ViewModels
|
|||
|
||||
private void OnCloseDocumentCommand()
|
||||
{
|
||||
Settings.Default.LastActiveDocument = "";
|
||||
_avalonDockWorkspaceViewModel.ActiveDocument.Close();
|
||||
}
|
||||
|
||||
|
@ -784,6 +794,7 @@ namespace Filtration.ViewModels
|
|||
|
||||
public async Task<bool> CloseAllDocumentsAsync()
|
||||
{
|
||||
Settings.Default.LastOpenScripts = string.Join("|", _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IItemFilterScriptViewModel>().Select(sc => sc.Script.FilePath));
|
||||
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
|
||||
|
||||
foreach (var document in openDocuments)
|
||||
|
|
Loading…
Reference in New Issue