From 90204ed937260a67357fc502a10a977e877e1291 Mon Sep 17 00:00:00 2001 From: alcexhim Date: Thu, 16 Oct 2014 12:46:45 -0400 Subject: [PATCH] Name ToolStripMenuItem after command ID (used in combining menus) and fix positioning for menus that try to combine outside parent boundaries --- .../MainWindow.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs index 628af719..425be379 100644 --- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs +++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/MainWindow.cs @@ -246,6 +246,7 @@ namespace UniversalEditor.UserInterface.WindowsForms } ToolStripMenuItem tsmi = new ToolStripMenuItem(); + tsmi.Name = cmd.ID; tsmi.Click += tsmiCommand_Click; tsmi.Tag = cmd; tsmi.Text = cmd.Title.Replace("_", "&"); @@ -512,7 +513,12 @@ namespace UniversalEditor.UserInterface.WindowsForms } else { - tsiParent.DropDownItems.Insert(ami.Position, tsmi); + int pos = ami.Position; + if (pos > tsiParent.DropDownItems.Count) + { + pos = tsiParent.DropDownItems.Count; + } + tsiParent.DropDownItems.Insert(pos, tsmi); } } mvarEditorSpecificMenuItems.Add(tsmi); @@ -531,7 +537,9 @@ namespace UniversalEditor.UserInterface.WindowsForms } else { - tsiParent.DropDownItems.Insert(smi.Position, tsmi); + int pos = smi.Position; + if (pos > tsiParent.DropDownItems.Count) pos = tsiParent.DropDownItems.Count; + tsiParent.DropDownItems.Insert(pos, tsmi); } mvarEditorSpecificMenuItems.Add(tsmi);