From 425d7d62f1c60530d616da685902d0a8e60272ac Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Sat, 13 Sep 2014 11:17:24 +0300 Subject: [PATCH] Fixed bug where save and close document commands were enabled/disabled badly. --- .../UI/Controller/DocumentController.cs | 20 +++++++++---------- RainmeterStudio/UI/MainWindow.xaml | 12 +++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/RainmeterStudio/UI/Controller/DocumentController.cs b/RainmeterStudio/UI/Controller/DocumentController.cs index 05bb5d28..7ad12eb8 100644 --- a/RainmeterStudio/UI/Controller/DocumentController.cs +++ b/RainmeterStudio/UI/Controller/DocumentController.cs @@ -121,13 +121,13 @@ namespace RainmeterStudio.UI.Controller DocumentSaveAllCommand = new Command("DocumentSaveAll", SaveAll, () => ProjectManager.ActiveProject != null); DocumentCloseCommand = new Command("DocumentClose", () => Close(), HasActiveDocumentEditor); - ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) => + ProjectManager.ActiveProjectChanged += new EventHandler((sender, e) => { DocumentCreateCommand.NotifyCanExecuteChanged(); DocumentSaveAllCommand.NotifyCanExecuteChanged(); }); - ActiveDocumentEditorChanged += new EventHandler((obj, e) => + ActiveDocumentEditorChanged += new EventHandler((sender, e) => { DocumentSaveCommand.NotifyCanExecuteChanged(); DocumentSaveAsCommand.NotifyCanExecuteChanged(); @@ -135,7 +135,7 @@ namespace RainmeterStudio.UI.Controller DocumentCloseCommand.NotifyCanExecuteChanged(); }); } - + private bool HasActiveDocumentEditor() { return ActiveDocumentEditor != null; @@ -305,6 +305,11 @@ namespace RainmeterStudio.UI.Controller // Close DocumentManager.Close(editor); + + // Update ActiveDocument + if (editor == ActiveDocumentEditor) + ActiveDocumentEditor = null; + return true; } @@ -315,14 +320,7 @@ namespace RainmeterStudio.UI.Controller /// Shows the 'are you sure' prompt if there are unsaved edits. public bool Close() { - // Show the 'are you sure' prompt if necesary - if (Close(ActiveDocumentEditor)) - { - ActiveDocumentEditor = null; - return true; - } - - return false; + return Close(ActiveDocumentEditor); } /// diff --git a/RainmeterStudio/UI/MainWindow.xaml b/RainmeterStudio/UI/MainWindow.xaml index 1622bf72..e53d53bc 100644 --- a/RainmeterStudio/UI/MainWindow.xaml +++ b/RainmeterStudio/UI/MainWindow.xaml @@ -120,6 +120,18 @@ Style="{StaticResource CommandButtonStyle}"> + + +