From 10cc629ba1470be02f8be72a898337bd2014faf1 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 23 Sep 2020 01:41:52 -0400 Subject: [PATCH] try to do better with merging command items --- .../Common/Reflection.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs b/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs index 0575f1fd..2b191a04 100644 --- a/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs +++ b/Libraries/UniversalEditor.UserInterface/Common/Reflection.cs @@ -172,7 +172,13 @@ namespace UniversalEditor.UserInterface.Common string id = tagCommand.Attributes["ID"]?.Value; string title = tagCommand.Attributes["Title"]?.Value; - Command cmd = new Command(id, title != null ? title : id); + Command cmd = er.Commands[id]; + if (cmd == null) + { + cmd = new Command(id, title != null ? title : id); + er.Commands.Add(cmd); + } + MarkupTagElement tagItems = tagCommand.Elements["Items"] as MarkupTagElement; if (tagItems != null) { @@ -182,11 +188,9 @@ namespace UniversalEditor.UserInterface.Common if (tagItem == null) continue; CommandItem ci = CommandItem.FromMarkup(tagItem); - if (ci != null) - cmd.Items.Add(ci); + CommandItem.AddToCommandBar(ci, cmd, null); } } - er.Commands.Add(cmd); } } }