Author: jpobst
Date: 2007-09-11 10:47:56 -0400 (Tue, 11 Sep 2007)
New Revision: 85639

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
Log:
2007-09-11  Jonathan Pobst  <[EMAIL PROTECTED]>

        * 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]

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-09-11 14:18:17 UTC (rev 85638)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-09-11 14:47:56 UTC (rev 85639)
@@ -1,3 +1,9 @@
+2007-09-11  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * ToolStripMenuItem.cs: Add a parent type check so we don't crash on 
people

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-09-11 14:18:17 UTC (rev 85638)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-09-11 14:47:56 UTC (rev 85639)
@@ -511,6 +511,8 @@
                                        throw new ArgumentException ("Form 
cannot be added to the Controls collection that has a valid MDI parent.", 
"value");
                                }
                                
+                               value.recalculate_distances = true;
+                               
                                if (Contains (value)) {
                                        owner.PerformLayout();
                                        return;

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs  
    2007-09-11 14:18:17 UTC (rev 85638)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripManager.cs  
    2007-09-11 14:47:56 UTC (rev 85639)
@@ -275,10 +275,10 @@
 
                                                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;
                                                
@@ -433,6 +433,28 @@
                                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) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to