changeset 146:5d9d4c75305f

Fixes #250: New panels don't work perfectly in Linux through Mono * Manually size the panel based on the contents
author IBBoard <dev@ibboard.co.uk>
date Sun, 18 Apr 2010 14:25:32 +0000
parents 51463bc1fb21
children 1bcd7ea857c4
files FrmMain.cs
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/FrmMain.cs	Sun Apr 18 14:22:10 2010 +0000
+++ b/FrmMain.cs	Sun Apr 18 14:25:32 2010 +0000
@@ -977,7 +977,6 @@
 			int catCount = cats.Length;
 			Category cat;
 			IBBToolStripButton[] categoryButtons = new IBBToolStripButton[catCount];
-			int buttonWidths = 0;
 
 			for (int i = 0; i < catCount; i++)
 			{
@@ -989,13 +988,25 @@
 				button.Enabled = false;
 				button.Click += new EventHandler(CreateUnitForCategoryButtonClick);
 				categoryButtons[i] = button;
-				buttonWidths += button.Width;
 			}
 
+			this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(AddCatToolStripButtons), new object[] { categoryButtons });
+		}
+
+		private void AddCatToolStripButtons(IBBToolStripButton[] buttons)
+		{
 			log.Debug("Toolstrip width: " + catToolStrip.Width);
+			catToolStrip.Items.AddRange(buttons);
+			catToolStrip.Refresh();
+			int buttonWidths = 0;
+
+			foreach (IBBToolStripButton button in buttons)
+			{
+				buttonWidths += button.Width;
+			}
+			catToolStrip.Width = buttonWidths;
 			log.Debug("Button widths: " + buttonWidths);
-
-			this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(catToolStrip.Items.AddRange), new object[]{ categoryButtons });
+			log.Debug("Toolstrip width: " + catToolStrip.Width);
 		}
 
 		private void CreateUnitForCategoryButtonClick(object sender, EventArgs e)