+2007-09-11 Jonathan Pobst <monkey@jpobst.com>
+
+ * ToolStripManager.cs: When we have added MDI buttons onto a MenuStrip, we
+ can't let them count as real items when calculating where to merge in the
+ user's items. [Fixed bug #82786]
+
2007-09-10 Jonathan Pobst <monkey@jpobst.com>
* ToolStripMenuItem.cs: Add a parent type check so we don't crash on people
if (tsi.MergeIndex == -1)
continue;
- else if (tsi.MergeIndex >= targetToolStrip.Items.Count)
+ else if (tsi.MergeIndex >= CountRealToolStripItems (targetToolStrip))
targetToolStrip.Items.AddNoOwnerOrLayout (tsi);
else
- targetToolStrip.Items.InsertNoOwnerOrLayout (tsi.MergeIndex, tsi);
+ targetToolStrip.Items.InsertNoOwnerOrLayout (AdjustItemMergeIndex (targetToolStrip, tsi), tsi);
tsi.Parent = targetToolStrip;
toolstrips.Add (ts);
}
+ // When we have merged in MDI items like the min/max/close buttons, we
+ // can't count them for the sake of menu merging or it will mess up
+ // where people are trying to put them
+ private static int AdjustItemMergeIndex (ToolStrip ts, ToolStripItem tsi)
+ {
+ if (ts.Items[0] is MdiControlStrip.SystemMenuItem)
+ return tsi.MergeIndex + 1;
+
+ return tsi.MergeIndex;
+ }
+
+ private static int CountRealToolStripItems (ToolStrip ts)
+ {
+ int count = 0;
+
+ foreach (ToolStripItem tsi in ts.Items)
+ if (!(tsi is MdiControlStrip.ControlBoxMenuItem) && !(tsi is MdiControlStrip.SystemMenuItem))
+ count++;
+
+ return count;
+ }
+
internal static ToolStrip GetNextToolStrip (ToolStrip ts, bool forward)
{
lock (toolstrips) {