From 20da72dc557a3c2a0b6db2cae91d9cae8afa43b8 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 16 Dec 2019 06:15:32 -0500 Subject: [PATCH] handle the case for confirm save before close when closing just one document --- .../MainWindow.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs index e081a56a..ad33f251 100644 --- a/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/CSharp/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -500,6 +500,7 @@ namespace UniversalEditor.UserInterface // no need to open and load file, it's already been done } Editor editor = editors[0].Create(); + EditorPage page = new EditorPage(); page.Document = doc; page.DocumentEdited += page_DocumentEdited; @@ -554,9 +555,19 @@ namespace UniversalEditor.UserInterface return true; } - public bool ConfirmExit() + public bool ConfirmExit(EditorPage page = null) { - EditorPage[] pages = GetEditorPages(); + EditorPage[] pages = null; + + if (page != null) + { + pages = new EditorPage[] { page }; + } + else + { + pages = GetEditorPages(); + } + if (pages.Length == 0) return true; @@ -1043,6 +1054,13 @@ namespace UniversalEditor.UserInterface { if (dckContainer.CurrentItem != null) { + if (dckContainer.CurrentItem.ChildControl is EditorPage) + { + if (!ConfirmExit(dckContainer.CurrentItem.ChildControl as EditorPage)) + { + return; + } + } dckContainer.Items.Remove(dckContainer.CurrentItem); documentWindowCount--; }