Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
changeset 126:25c989ef2a8d
Re #88: Complete initial WinForms UI
* Swap ToolStripContainer for ToolStripPanel to work with MDI
* Populate category/unit creation tool strip
Still needs work to make sure that cat/unit strip ends up after the main strip
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 06 Mar 2010 16:33:28 +0000 |
parents | 581a72dcb549 |
children | c89d0cb4b893 |
files | FrmMain.cs FrmMain.resx |
diffstat | 2 files changed, 65 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmMain.cs Fri Mar 05 20:58:15 2010 +0000 +++ b/FrmMain.cs Sat Mar 06 16:33:28 2010 +0000 @@ -66,7 +66,7 @@ private System.Windows.Forms.ContextMenu redoMenu; private IBBoard.Windows.Forms.ColorableStatusBar statusBar; private System.Windows.Forms.Timer statusBarTimer; - private MenuStrip menuStrip1; + private MenuStrip menuStrip; private ToolStripMenuItem menuFile; private ToolStripMenuItem miNewArmy; private ToolStripMenuItem miOpenArmy; @@ -90,7 +90,8 @@ private ToolStripSeparator toolStripSeparator3; private ToolStripSplitButton bttnUndo; private ToolStripSplitButton bttnRedo; - private ToolStripContainer toolStripContainer; + private ToolStrip catToolStrip; + private ToolStripPanel toolStripPanel; private ToolStripMenuItem miAbout; /// <summary> @@ -119,6 +120,8 @@ CommandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); InitializeComponent(); + toolStripPanel.Join(mainToolStrip, 0, 0); + toolStripPanel.Join(catToolStrip, 1, 0); Preferences = new Preferences("WarFoundry"); try @@ -131,10 +134,6 @@ MessageBox.Show(this, "Translation loading failed for language " + Preferences["language"].ToString(), "Translation failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } - //pnlRight.Left = ClientSize.Width - pnlRight.Width - 2; - //pnlRight.Top = toolBar.Height + 5; - //pnlRight.Height = ClientRectangle.Bottom - statusBar.Height - pnlRight.Top - 3; - ControlTranslator.TranslateControls(Controls); ControlTranslator.TranslateComponents(components.Components); ControlTranslator.TranslateComponent(openArmyDialog); @@ -224,7 +223,7 @@ this.openArmyDialog = new System.Windows.Forms.OpenFileDialog(); this.saveArmyDialog = new System.Windows.Forms.SaveFileDialog(); this.statusBarTimer = new System.Windows.Forms.Timer(this.components); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.menuStrip = new System.Windows.Forms.MenuStrip(); this.menuFile = new System.Windows.Forms.ToolStripMenuItem(); this.miNewArmy = new System.Windows.Forms.ToolStripMenuItem(); this.miOpenArmy = new System.Windows.Forms.ToolStripMenuItem(); @@ -249,23 +248,22 @@ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.bttnUndo = new System.Windows.Forms.ToolStripSplitButton(); this.bttnRedo = new System.Windows.Forms.ToolStripSplitButton(); - this.toolStripContainer = new System.Windows.Forms.ToolStripContainer(); + this.catToolStrip = new System.Windows.Forms.ToolStrip(); this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); - this.menuStrip1.SuspendLayout(); + this.toolStripPanel = new System.Windows.Forms.ToolStripPanel(); + this.menuStrip.SuspendLayout(); this.mainToolStrip.SuspendLayout(); - this.toolStripContainer.TopToolStripPanel.SuspendLayout(); - this.toolStripContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbMainPanel)).BeginInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbErrorPanel)).BeginInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbPointsPanel)).BeginInit(); this.SuspendLayout(); // // buttonIcons // - this.buttonIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("buttonIcons.ImageStream"))); + this.buttonIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("buttonIcons.ImageStream"))); this.buttonIcons.TransparentColor = System.Drawing.Color.Transparent; this.buttonIcons.Images.SetKeyName(0, ""); this.buttonIcons.Images.SetKeyName(1, ""); @@ -284,17 +282,17 @@ this.statusBarTimer.Interval = 5000; this.statusBarTimer.Tick += new System.EventHandler(this.statusBarTimer_Tick); // - // menuStrip1 + // menuStrip // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuFile, this.menuEdit, this.menuHelp}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(790, 24); - this.menuStrip1.TabIndex = 6; - this.menuStrip1.Text = "menuStrip1"; + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(790, 24); + this.menuStrip.TabIndex = 6; + this.menuStrip.Text = "menuStrip1"; // // menuFile // @@ -441,9 +439,9 @@ this.toolStripSeparator3, this.bttnUndo, this.bttnRedo}); - this.mainToolStrip.Location = new System.Drawing.Point(3, 0); + this.mainToolStrip.Location = new System.Drawing.Point(0, 24); this.mainToolStrip.Name = "mainToolStrip"; - this.mainToolStrip.Size = new System.Drawing.Size(151, 25); + this.mainToolStrip.Size = new System.Drawing.Size(182, 25); this.mainToolStrip.TabIndex = 8; // // bttnNewArmy @@ -453,7 +451,7 @@ this.bttnNewArmy.ImageTransparentColor = System.Drawing.Color.Magenta; this.bttnNewArmy.Name = "bttnNewArmy"; this.bttnNewArmy.Size = new System.Drawing.Size(23, 22); - this.bttnNewArmy.Text = "toolStripButton1"; + this.bttnNewArmy.Text = "new army"; this.bttnNewArmy.Click += new System.EventHandler(this.miNewArmy_Click); // // bttnOpenArmy @@ -463,7 +461,7 @@ this.bttnOpenArmy.ImageTransparentColor = System.Drawing.Color.Magenta; this.bttnOpenArmy.Name = "bttnOpenArmy"; this.bttnOpenArmy.Size = new System.Drawing.Size(23, 22); - this.bttnOpenArmy.Text = "toolStripButton2"; + this.bttnOpenArmy.Text = "open army"; this.bttnOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click); // // bttnSaveArmy @@ -474,13 +472,13 @@ this.bttnSaveArmy.ImageTransparentColor = System.Drawing.Color.Magenta; this.bttnSaveArmy.Name = "bttnSaveArmy"; this.bttnSaveArmy.Size = new System.Drawing.Size(23, 22); - this.bttnSaveArmy.Text = "toolStripButton3"; + this.bttnSaveArmy.Text = "save army"; this.bttnSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); + this.toolStripSeparator3.Size = new System.Drawing.Size(6, 23); // // bttnUndo // @@ -490,7 +488,7 @@ this.bttnUndo.ImageTransparentColor = System.Drawing.Color.Magenta; this.bttnUndo.Name = "bttnUndo"; this.bttnUndo.Size = new System.Drawing.Size(32, 22); - this.bttnUndo.Text = "toolStripSplitButton1"; + this.bttnUndo.Text = "undo"; this.bttnUndo.Click += new System.EventHandler(this.miUndo_Click); // // bttnRedo @@ -501,28 +499,17 @@ this.bttnRedo.ImageTransparentColor = System.Drawing.Color.Magenta; this.bttnRedo.Name = "bttnRedo"; this.bttnRedo.Size = new System.Drawing.Size(32, 22); - this.bttnRedo.Text = "toolStripSplitButton2"; + this.bttnRedo.Text = "redo"; this.bttnRedo.Click += new System.EventHandler(this.miRedo_Click); // - // toolStripContainer - // - this.toolStripContainer.BottomToolStripPanelVisible = false; - // - // toolStripContainer.ContentPanel + // catToolStrip // - this.toolStripContainer.ContentPanel.Enabled = false; - this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(790, 1); - this.toolStripContainer.ContentPanel.Visible = false; - this.toolStripContainer.LeftToolStripPanelVisible = false; - this.toolStripContainer.Location = new System.Drawing.Point(0, 24); - this.toolStripContainer.Name = "toolStripContainer"; - this.toolStripContainer.RightToolStripPanelVisible = false; - this.toolStripContainer.Size = new System.Drawing.Size(790, 26); - this.toolStripContainer.TabIndex = 11; - // - // toolStripContainer.TopToolStripPanel - // - this.toolStripContainer.TopToolStripPanel.Controls.Add(this.mainToolStrip); + this.catToolStrip.Dock = System.Windows.Forms.DockStyle.None; + this.catToolStrip.Location = new System.Drawing.Point(161, 24); + this.catToolStrip.Name = "catToolStrip"; + this.catToolStrip.Size = new System.Drawing.Size(111, 25); + this.catToolStrip.TabIndex = 9; + this.catToolStrip.Visible = false; // // statusBar // @@ -561,31 +548,38 @@ this.sbPointsPanel.ToolTipText = "current points total"; this.sbPointsPanel.Width = 150; // + // toolStripPanel + // + this.toolStripPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.toolStripPanel.Location = new System.Drawing.Point(0, 24); + this.toolStripPanel.Name = "toolStripPanel"; + this.toolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal; + this.toolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0); + this.toolStripPanel.Size = new System.Drawing.Size(790, 0); + // // FrmMain // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(790, 568); - this.Controls.Add(this.toolStripContainer); + this.Controls.Add(this.mainToolStrip); + this.Controls.Add(this.toolStripPanel); + this.Controls.Add(this.catToolStrip); this.Controls.Add(this.statusBar); - this.Controls.Add(this.menuStrip1); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Controls.Add(this.menuStrip); + this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); this.IsMdiContainer = true; - this.MainMenuStrip = this.menuStrip1; + this.MainMenuStrip = this.menuStrip; this.Menu = this.mainMenu; this.Name = "FrmMain"; this.Text = "WarFoundry"; this.Load += new System.EventHandler(this.FrmMain_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.mainToolStrip.ResumeLayout(false); this.mainToolStrip.PerformLayout(); - this.toolStripContainer.TopToolStripPanel.ResumeLayout(false); - this.toolStripContainer.TopToolStripPanel.PerformLayout(); - this.toolStripContainer.ResumeLayout(false); - this.toolStripContainer.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbMainPanel)).EndInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbErrorPanel)).EndInit(); + ((System.ComponentModel.ISupportInitialize) (this.sbPointsPanel)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -962,10 +956,7 @@ { if (categoryButtons!=null) { - for (int i = 0; i<categoryButtons.Length; i++) - { - //this.Invoke(new ToolBarButtonDelegate(toolBar.Buttons.Remove), new object[]{categoryButtons[i]}); - } + this.Invoke(new MethodInvoker(catToolStrip.Items.Clear)); } } @@ -973,7 +964,7 @@ { int catCount = cats.Length; Category cat; - categoryButtons = new ToolStripButton[catCount + 1]; + categoryButtons = new ToolStripButton[catCount]; ToolStripButton button; @@ -983,22 +974,23 @@ button = new ToolStripButton(); button.Text = cat.Name; button.Tag = cat; - //button.ImageIndex = 6; + button.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.list_add; button.Enabled = false; categoryButtons[i] = button; } - //TODO: add buttons to ToolStrip in toolStripContainer.TopToolStrip - //this.Invoke(new ToolBarButtonRangeDelegate(toolBar.Buttons.AddRange), new object[] { categoryButtons }); + this.Invoke(new ArrayMethodInvoker<ToolStripButton>(catToolStrip.Items.AddRange), new object[]{ categoryButtons }); } private void EnableCategoryButtons() { + catToolStrip.Visible = true; SetCategoryButtonState(true); } private void DisableCategoryButtons() { + catToolStrip.Visible = false; SetCategoryButtonState(false); }
--- a/FrmMain.resx Fri Mar 05 20:58:15 2010 +0000 +++ b/FrmMain.resx Sat Mar 06 16:33:28 2010 +0000 @@ -252,12 +252,15 @@ <metadata name="statusBarTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>707, 17</value> </metadata> - <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>835, 17</value> </metadata> <metadata name="mainToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 54</value> </metadata> + <metadata name="catToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>138, 54</value> + </metadata> <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>