Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
comparison FrmMain.cs @ 130:9d5d885965f9
Fixes #258: New toolbar and menu bar need translations
* Update FrmMain to use new toolstrip buttons
* Update English translations to include a default "undo" and "redo" translation
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 09 Mar 2010 21:05:06 +0000 |
parents | 5f21ecd030d0 |
children | acb4456598ce |
comparison
equal
deleted
inserted
replaced
129:5f21ecd030d0 | 130:9d5d885965f9 |
---|---|
80 private IBBToolStripMenuItem menuEdit; | 80 private IBBToolStripMenuItem menuEdit; |
81 private IBBToolStripMenuItem miUndo; | 81 private IBBToolStripMenuItem miUndo; |
82 private IBBToolStripMenuItem miRedo; | 82 private IBBToolStripMenuItem miRedo; |
83 private IBBToolStripMenuItem menuHelp; | 83 private IBBToolStripMenuItem menuHelp; |
84 private ToolStrip mainToolStrip; | 84 private ToolStrip mainToolStrip; |
85 private ToolStripButton bttnNewArmy; | 85 private IBBToolStripButton bttnNewArmy; |
86 private ToolStripButton bttnOpenArmy; | 86 private IBBToolStripButton bttnOpenArmy; |
87 private ToolStripButton bttnSaveArmy; | 87 private IBBToolStripButton bttnSaveArmy; |
88 private ToolStripSeparator toolStripSeparator3; | 88 private ToolStripSeparator toolStripSeparator3; |
89 private ToolStripSplitButton bttnUndo; | 89 private IBBToolStripSplitButton bttnUndo; |
90 private ToolStripSplitButton bttnRedo; | 90 private IBBToolStripSplitButton bttnRedo; |
91 private ToolStrip catToolStrip; | 91 private ToolStrip catToolStrip; |
92 private ToolStripPanel toolStripPanel; | 92 private ToolStripPanel toolStripPanel; |
93 private IBBToolStripMenuItem miAbout; | 93 private IBBToolStripMenuItem miAbout; |
94 | 94 |
95 /// <summary> | 95 /// <summary> |
237 this.miUndo = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); | 237 this.miUndo = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); |
238 this.miRedo = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); | 238 this.miRedo = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); |
239 this.menuHelp = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); | 239 this.menuHelp = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); |
240 this.miAbout = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); | 240 this.miAbout = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); |
241 this.mainToolStrip = new System.Windows.Forms.ToolStrip(); | 241 this.mainToolStrip = new System.Windows.Forms.ToolStrip(); |
242 this.bttnNewArmy = new System.Windows.Forms.ToolStripButton(); | 242 this.bttnNewArmy = new IBBoard.Windows.Forms.IBBToolStripButton(); |
243 this.bttnOpenArmy = new System.Windows.Forms.ToolStripButton(); | 243 this.bttnOpenArmy = new IBBoard.Windows.Forms.IBBToolStripButton(); |
244 this.bttnSaveArmy = new System.Windows.Forms.ToolStripButton(); | 244 this.bttnSaveArmy = new IBBoard.Windows.Forms.IBBToolStripButton(); |
245 this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); | 245 this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); |
246 this.bttnUndo = new System.Windows.Forms.ToolStripSplitButton(); | 246 this.bttnUndo = new IBBoard.Windows.Forms.IBBToolStripSplitButton(); |
247 this.bttnRedo = new System.Windows.Forms.ToolStripSplitButton(); | 247 this.bttnRedo = new IBBoard.Windows.Forms.IBBToolStripSplitButton(); |
248 this.catToolStrip = new System.Windows.Forms.ToolStrip(); | 248 this.catToolStrip = new System.Windows.Forms.ToolStrip(); |
249 this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); | 249 this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); |
250 this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | 250 this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); |
251 this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | 251 this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); |
252 this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | 252 this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); |
253 this.toolStripPanel = new System.Windows.Forms.ToolStripPanel(); | 253 this.toolStripPanel = new System.Windows.Forms.ToolStripPanel(); |
254 this.menuStrip.SuspendLayout(); | 254 this.menuStrip.SuspendLayout(); |
255 this.mainToolStrip.SuspendLayout(); | 255 this.mainToolStrip.SuspendLayout(); |
256 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit(); | 256 ((System.ComponentModel.ISupportInitialize) (this.sbMainPanel)).BeginInit(); |
257 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit(); | 257 ((System.ComponentModel.ISupportInitialize) (this.sbErrorPanel)).BeginInit(); |
258 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit(); | 258 ((System.ComponentModel.ISupportInitialize) (this.sbPointsPanel)).BeginInit(); |
259 this.SuspendLayout(); | 259 this.SuspendLayout(); |
260 // | 260 // |
261 // saveArmyDialog | 261 // saveArmyDialog |
262 // | 262 // |
263 this.saveArmyDialog.Title = "Translatable:saveArmyDialog"; | 263 this.saveArmyDialog.Title = "Translatable:saveArmyDialog"; |
549 this.Controls.Add(this.mainToolStrip); | 549 this.Controls.Add(this.mainToolStrip); |
550 this.Controls.Add(this.toolStripPanel); | 550 this.Controls.Add(this.toolStripPanel); |
551 this.Controls.Add(this.statusBar); | 551 this.Controls.Add(this.statusBar); |
552 this.Controls.Add(this.catToolStrip); | 552 this.Controls.Add(this.catToolStrip); |
553 this.Controls.Add(this.menuStrip); | 553 this.Controls.Add(this.menuStrip); |
554 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); | 554 this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); |
555 this.IsMdiContainer = true; | 555 this.IsMdiContainer = true; |
556 this.MainMenuStrip = this.menuStrip; | 556 this.MainMenuStrip = this.menuStrip; |
557 this.Menu = this.mainMenu; | 557 this.Menu = this.mainMenu; |
558 this.Name = "FrmMain"; | 558 this.Name = "FrmMain"; |
559 this.Text = "WarFoundry"; | 559 this.Text = "WarFoundry"; |
560 this.Load += new System.EventHandler(this.FrmMain_Load); | 560 this.Load += new System.EventHandler(this.FrmMain_Load); |
561 this.menuStrip.ResumeLayout(false); | 561 this.menuStrip.ResumeLayout(false); |
562 this.menuStrip.PerformLayout(); | 562 this.menuStrip.PerformLayout(); |
563 this.mainToolStrip.ResumeLayout(false); | 563 this.mainToolStrip.ResumeLayout(false); |
564 this.mainToolStrip.PerformLayout(); | 564 this.mainToolStrip.PerformLayout(); |
565 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit(); | 565 ((System.ComponentModel.ISupportInitialize) (this.sbMainPanel)).EndInit(); |
566 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit(); | 566 ((System.ComponentModel.ISupportInitialize) (this.sbErrorPanel)).EndInit(); |
567 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit(); | 567 ((System.ComponentModel.ISupportInitialize) (this.sbPointsPanel)).EndInit(); |
568 this.ResumeLayout(false); | 568 this.ResumeLayout(false); |
569 this.PerformLayout(); | 569 this.PerformLayout(); |
570 | 570 |
571 } | 571 } |
572 #endregion | 572 #endregion |
945 | 945 |
946 private void AddCategoryButtons(Category[] cats) | 946 private void AddCategoryButtons(Category[] cats) |
947 { | 947 { |
948 int catCount = cats.Length; | 948 int catCount = cats.Length; |
949 Category cat; | 949 Category cat; |
950 ToolStripButton[] categoryButtons = new ToolStripButton[catCount]; | 950 IBBToolStripButton[] categoryButtons = new IBBToolStripButton[catCount]; |
951 | 951 |
952 for (int i = 0; i < catCount; i++) | 952 for (int i = 0; i < catCount; i++) |
953 { | 953 { |
954 cat = cats[i]; | 954 cat = cats[i]; |
955 ToolStripButton button = new ToolStripButton(); | 955 IBBToolStripButton button = new IBBToolStripButton(); |
956 button.Text = cat.Name; | 956 button.Text = cat.Name; |
957 button.Tag = cat; | 957 button.Tag = cat; |
958 button.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.list_add; | 958 button.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.list_add; |
959 button.Enabled = false; | 959 button.Enabled = false; |
960 button.Click += new EventHandler(CreateUnitForCategoryButtonClick); | 960 button.Click += new EventHandler(CreateUnitForCategoryButtonClick); |
961 categoryButtons[i] = button; | 961 categoryButtons[i] = button; |
962 } | 962 } |
963 | 963 |
964 this.Invoke(new ArrayMethodInvoker<ToolStripButton>(catToolStrip.Items.AddRange), new object[]{ categoryButtons }); | 964 this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(catToolStrip.Items.AddRange), new object[]{ categoryButtons }); |
965 } | 965 } |
966 | 966 |
967 private void CreateUnitForCategoryButtonClick(object sender, EventArgs e) | 967 private void CreateUnitForCategoryButtonClick(object sender, EventArgs e) |
968 { | 968 { |
969 if (sender is ToolStripButton) | 969 if (sender is IBBToolStripButton) |
970 { | 970 { |
971 ToolStripButton button = (ToolStripButton)sender; | 971 IBBToolStripButton button = (IBBToolStripButton)sender; |
972 object tag = button.Tag; | 972 object tag = button.Tag; |
973 | 973 |
974 if (tag is Category) | 974 if (tag is Category) |
975 { | 975 { |
976 AddUnitFromCategory((Category)tag); | 976 AddUnitFromCategory((Category)tag); |
990 SetCategoryButtonState(false); | 990 SetCategoryButtonState(false); |
991 } | 991 } |
992 | 992 |
993 private void SetCategoryButtonState(bool state) | 993 private void SetCategoryButtonState(bool state) |
994 { | 994 { |
995 foreach (ToolStripButton button in catToolStrip.Items) | 995 foreach (IBBToolStripButton button in catToolStrip.Items) |
996 { | 996 { |
997 button.Enabled = state; | 997 button.Enabled = state; |
998 } | 998 } |
999 } | 999 } |
1000 | 1000 |
1033 break; | 1033 break; |
1034 } | 1034 } |
1035 | 1035 |
1036 dropDownItems.Add(cmd.Description, null, redoMenu_Click); | 1036 dropDownItems.Add(cmd.Description, null, redoMenu_Click); |
1037 } | 1037 } |
1038 | |
1039 if (redoLength > 0) | |
1040 { | |
1041 bttnRedo.Text = commandStack.PeekRedoCommand(1).Description; | |
1042 } | |
1043 else | |
1044 { | |
1045 bttnRedo.Text = Translation.GetTranslation("bttnRedo"); | |
1046 } | |
1038 } | 1047 } |
1039 | 1048 |
1040 private void PopulateUndoMenu() | 1049 private void PopulateUndoMenu() |
1041 { | 1050 { |
1042 int undoLength = commandStack.UndoLength; | 1051 int undoLength = commandStack.UndoLength; |
1052 { | 1061 { |
1053 break; | 1062 break; |
1054 } | 1063 } |
1055 | 1064 |
1056 dropDownItems.Add(cmd.UndoDescription, null, undoMenu_Click); | 1065 dropDownItems.Add(cmd.UndoDescription, null, undoMenu_Click); |
1066 } | |
1067 | |
1068 if (undoLength > 0) | |
1069 { | |
1070 bttnUndo.Text = commandStack.PeekUndoCommand(1).UndoDescription; | |
1071 } | |
1072 else | |
1073 { | |
1074 bttnUndo.Text = Translation.GetTranslation("bttnUndo"); | |
1057 } | 1075 } |
1058 } | 1076 } |
1059 | 1077 |
1060 private void miSaveArmy_Click(object sender, System.EventArgs e) | 1078 private void miSaveArmy_Click(object sender, System.EventArgs e) |
1061 { | 1079 { |