Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
annotate FrmMain.cs @ 9:ffb49ec86df7
Closes #42 - Update translations file to use Schema (WinForms)
* Update WinForms GUI translations to use namespace for schema instead of DTD
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 19 May 2009 11:10:07 +0000 |
parents | 9828ba4f3f36 |
children | 19bdbb80999c |
rev | line source |
---|---|
3
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
1 // This file (FrmMain.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
2 // |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
8935971e307c
Fixes #1 - Correctly license code
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
4 |
0 | 5 using System; |
6 using System.Drawing; | |
7 using System.Drawing.Drawing2D; | |
8 using System.Collections; | |
9 using System.ComponentModel; | |
10 using System.Windows.Forms; | |
11 using System.Data; | |
5
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
12 using System.IO; |
0 | 13 using System.Threading; |
5
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
14 using log4net; |
0 | 15 using IBBoard; |
16 using IBBoard.CustomMath; | |
17 using IBBoard.Commands; | |
18 using IBBoard.IO; | |
5
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
19 using IBBoard.Lang; |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
20 using IBBoard.Log4Net; |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
21 using IBBoard.Windows.Forms; |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
22 using IBBoard.Windows.Forms.I18N; |
0 | 23 using IBBoard.Xml; |
5
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
24 using IBBoard.WarFoundry.API; |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
25 using IBBoard.WarFoundry.API.Commands; |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
26 using IBBoard.WarFoundry.API.Objects; |
7 | 27 using IBBoard.WarFoundry.API.Savers; |
28 using IBBoard.WarFoundry.API.Factories; | |
29 using IBBoard.WarFoundry.API.Factories.Xml; | |
0 | 30 |
31 namespace IBBoard.WarFoundry | |
32 { | |
33 /// <summary> | |
34 /// Summary description for Form1. | |
35 /// </summary> | |
36 public class FrmMain : System.Windows.Forms.Form | |
37 { | |
38 private static readonly string AppTitle = "WarFoundry"; | |
7 | 39 const string DefaultDataDir = "data"; |
0 | 40 |
41 private Preferences preferences; | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
42 protected readonly ILog logger = LogManager.GetLogger(typeof(FrmMain)); |
0 | 43 |
44 private CommandStack commandStack; | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
45 private ToolBarButton[] categoryButtons; |
0 | 46 |
47 public ObjectAddDelegate UnitAddedMethod; | |
48 public ObjectRemoveDelegate UnitRemovedMethod; | |
49 public DoubleValChangedDelegate PointsValueChangedMethod; | |
50 //public FailedUnitRequirementDelegate FailedUnitRequirementMethod; | |
51 | |
52 private FrmArmyTree armyTree; | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
53 private FrmDebugOutput debugWindow; |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
54 private string loadedFilePath; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
55 |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
56 private System.ComponentModel.IContainer components; |
0 | 57 private System.Windows.Forms.ToolBar toolBar; |
58 private IBBoard.Windows.Forms.IBBToolBarButton bttnNewArmy; | |
59 private System.Windows.Forms.ImageList buttonIcons; | |
60 private IBBoard.Windows.Forms.IBBToolBarButton bttnSaveArmy; | |
61 private System.Windows.Forms.OpenFileDialog openArmyDialog; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
62 private System.Windows.Forms.SaveFileDialog saveArmyDialog; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
63 private IBBoard.Windows.Forms.IBBToolBarButton bttnOpenArmy; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
64 private IBBoard.Windows.Forms.IBBToolBarButton bttnSep1; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
65 private IBBoard.Windows.Forms.IBBToolBarButton bttnUndo; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
66 private IBBoard.Windows.Forms.IBBToolBarButton bttnRedo; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
67 private System.Windows.Forms.MainMenu mainMenu; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
68 private IBBoard.Windows.Forms.IBBMenuItem menuFile; |
0 | 69 private IBBoard.Windows.Forms.IBBMenuItem miNewArmy; |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
70 private IBBoard.Windows.Forms.IBBMenuItem miOpenArmy; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
71 private IBBoard.Windows.Forms.IBBMenuItem miCloseArmy; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
72 private IBBoard.Windows.Forms.IBBMenuItem miSaveArmy; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
73 private IBBoard.Windows.Forms.IBBMenuItem miSaveArmyAs; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
74 private System.Windows.Forms.MenuItem miSep2; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
75 private IBBoard.Windows.Forms.IBBMenuItem miChangeSystem; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
76 private System.Windows.Forms.MenuItem miSep1; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
77 private IBBoard.Windows.Forms.IBBMenuItem miReloadFiles; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
78 private System.Windows.Forms.MenuItem miSep3; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
79 private IBBoard.Windows.Forms.IBBMenuItem miExit; |
0 | 80 private IBBoard.Windows.Forms.IBBMenuItem menuEdit; |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
81 private IBBoard.Windows.Forms.IBBMenuItem miUndo; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
82 private IBBoard.Windows.Forms.IBBMenuItem miRedo; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
83 private IBBoard.Windows.Forms.IBBMenuItem menuHelp; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
84 private IBBoard.Windows.Forms.IBBMenuItem miDebugWindow; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
85 private IBBoard.Windows.Forms.IBBMenuItem miAbout; |
0 | 86 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbMainPanel; |
87 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbErrorPanel; | |
88 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbPointsPanel; | |
89 private System.Windows.Forms.ContextMenu undoMenu; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
90 private System.Windows.Forms.ContextMenu redoMenu; |
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
91 private IBBoard.Windows.Forms.ColorableStatusBar statusBar; |
0 | 92 private System.Windows.Forms.Timer statusBarTimer; |
93 private System.Windows.Forms.Panel pnlRight; | |
94 | |
95 public FrmMain(string[] args) | |
96 { | |
5
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
97 this.Closing+=new CancelEventHandler(FrmMain_Closing); |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
98 CommandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); |
26fc79eeda37
Fixes #31 - Add log4net logging to WinForms interface
IBBoard <dev@ibboard.co.uk>
parents:
3
diff
changeset
|
99 LogNotifierHandler.RegisterNotifierHandler(); |
0 | 100 |
101 InitializeComponent(); | |
102 | |
103 Preferences = new Preferences("WarFoundry"); | |
104 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); | |
105 | |
106 //pnlRight.Left = ClientSize.Width - pnlRight.Width - 2; | |
107 //pnlRight.Top = toolBar.Height + 5; | |
108 //pnlRight.Height = ClientRectangle.Bottom - statusBar.Height - pnlRight.Top - 3; | |
109 | |
110 foreach (Control ctrl in Controls) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
111 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
112 ControlTranslator.TranslateControl(ctrl); |
0 | 113 } |
114 | |
115 foreach(Component comp in components.Components) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
116 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
117 ControlTranslator.TranslateComponent(comp); |
0 | 118 } |
119 | |
120 foreach (IBBMenuItem mi in Menu.MenuItems) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
121 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
122 ControlTranslator.TranslateComponent(mi); |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
123 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
124 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
125 ControlTranslator.TranslateComponent(openArmyDialog); |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
126 ControlTranslator.TranslateComponent(saveArmyDialog); |
0 | 127 |
128 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged); | |
129 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged); | |
130 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod); | |
131 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod); | |
132 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); | |
133 //FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(FrmMain_FailedUnitRequirement); | |
134 | |
135 sbErrorPanel.Color = Color.Red; | |
136 | |
137 armyTree = new FrmArmyTree(CommandStack); | |
138 armyTree.MdiParent = this; | |
139 armyTree.Show(); | |
140 armyTree.StartPosition = FormStartPosition.Manual; | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
141 armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10); |
7 | 142 ControlTranslator.TranslateControl(armyTree); |
143 | |
144 // hack to load default files | |
145 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir)); | |
146 | |
147 IWarFoundryFactory factory = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(WarFoundryXmlFactory)); | |
148 | |
149 if (factory != null && factory is WarFoundryXmlFactory) | |
150 { | |
151 WarFoundryLoader.GetDefault().RegisterFactory((WarFoundryXmlFactory)factory); | |
152 } | |
0 | 153 |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
154 /* |
0 | 155 if (args.Length == 1) |
156 { | |
157 logger.Debug("Attempting to load from file"); | |
158 FileInfo file = new FileInfo(args[0]); | |
159 | |
160 try | |
161 { | |
162 if (file.Extension.Equals("."+Factory.GetArmyFileExtension())) | |
163 { | |
164 WarFoundryCore.CurrentArmy = Factory.CreateArmyFromFile(file); | |
165 logger.InfoFormat("Loaded army from {0}", file.FullName); | |
166 } | |
167 else if (file.Extension.Equals("."+Factory.GetSystemFileExtension())) | |
168 { | |
169 WarFoundryCore.CurrentGameSystem = Factory.CreateGameSystemFromFile(file); | |
170 logger.InfoFormat("Loaded game system from {0}", file.FullName); | |
171 } | |
172 } | |
173 catch (InvalidFileException ex) | |
174 { | |
175 MessageBox.Show(Translation.GetTranslation("InvalidFileLoadError", "The file loaded ({0}) was not a valid WarFoundry file", file.FullName), Translation.GetTranslation("InvalidFileLoadTitle", "Invalid data file", null), MessageBoxButtons.OK, MessageBoxIcon.Error); | |
176 logger.Error(ex); | |
177 } | |
178 } | |
179 else | |
180 { | |
181 string gameSystemID = Preferences.GetStringProperty("currSystem"); | |
182 | |
183 if (gameSystemID!=null && !"".Equals(gameSystemID)) | |
184 { | |
185 logger.Debug("Attempting to load current game system from properties"); | |
186 GameSystem sys = Factory.GetGameSystem(gameSystemID); | |
187 | |
188 if (sys!=null) | |
189 { | |
190 WarFoundryCore.CurrentGameSystem = sys; | |
191 logger.InfoFormat("Loaded game system {0} from properties", gameSystemID); | |
192 } | |
193 } | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
194 }*/ |
0 | 195 } |
196 | |
197 public static string DataPath | |
198 { | |
199 get { return Constants.ExecutablePath+Constants.DirectoryChar+"data"; } | |
200 } | |
201 | |
202 public static String ArmiesPath | |
203 { | |
204 get { return Constants.UserDataPath+Constants.DirectoryChar+"armies"; } | |
205 } | |
206 | |
207 public Preferences Preferences | |
208 { | |
209 get { return preferences; } | |
210 set { preferences = value; } | |
211 } | |
212 | |
213 public CommandStack CommandStack | |
214 { | |
215 get | |
216 { | |
217 if (commandStack == null) | |
218 { | |
219 commandStack = new CommandStack(); | |
220 } | |
221 | |
222 return commandStack; | |
223 } | |
224 } | |
225 | |
226 /// <summary> | |
227 /// Clean up any resources being used. | |
228 /// </summary> | |
229 protected override void Dispose( bool disposing ) | |
230 { | |
231 if( disposing ) | |
232 { | |
233 if (components != null) | |
234 { | |
235 components.Dispose(); | |
236 } | |
237 } | |
238 base.Dispose( disposing ); | |
239 } | |
240 | |
241 #region Windows Form Designer generated code | |
242 /// <summary> | |
243 /// Required method for Designer support - do not modify | |
244 /// the contents of this method with the code editor. | |
245 /// </summary> | |
246 private void InitializeComponent() | |
247 { | |
248 this.components = new System.ComponentModel.Container(); | |
249 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); | |
250 this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); | |
251 this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | |
252 this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | |
253 this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); | |
254 this.toolBar = new System.Windows.Forms.ToolBar(); | |
255 this.bttnNewArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
256 this.bttnOpenArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
257 this.bttnSaveArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
258 this.bttnSep1 = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
259 this.bttnUndo = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
260 this.undoMenu = new System.Windows.Forms.ContextMenu(); | |
261 this.bttnRedo = new IBBoard.Windows.Forms.IBBToolBarButton(); | |
262 this.redoMenu = new System.Windows.Forms.ContextMenu(); | |
263 this.buttonIcons = new System.Windows.Forms.ImageList(this.components); | |
264 this.mainMenu = new System.Windows.Forms.MainMenu(this.components); | |
265 this.menuFile = new IBBoard.Windows.Forms.IBBMenuItem(); | |
266 this.miNewArmy = new IBBoard.Windows.Forms.IBBMenuItem(); | |
267 this.miOpenArmy = new IBBoard.Windows.Forms.IBBMenuItem(); | |
268 this.miSaveArmy = new IBBoard.Windows.Forms.IBBMenuItem(); | |
269 this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBMenuItem(); | |
270 this.miCloseArmy = new IBBoard.Windows.Forms.IBBMenuItem(); | |
271 this.miSep1 = new System.Windows.Forms.MenuItem(); | |
272 this.miChangeSystem = new IBBoard.Windows.Forms.IBBMenuItem(); | |
273 this.miSep2 = new System.Windows.Forms.MenuItem(); | |
274 this.miReloadFiles = new IBBoard.Windows.Forms.IBBMenuItem(); | |
275 this.miSep3 = new System.Windows.Forms.MenuItem(); | |
276 this.miExit = new IBBoard.Windows.Forms.IBBMenuItem(); | |
277 this.menuEdit = new IBBoard.Windows.Forms.IBBMenuItem(); | |
278 this.miUndo = new IBBoard.Windows.Forms.IBBMenuItem(); | |
279 this.miRedo = new IBBoard.Windows.Forms.IBBMenuItem(); | |
280 this.menuHelp = new IBBoard.Windows.Forms.IBBMenuItem(); | |
281 this.miAbout = new IBBoard.Windows.Forms.IBBMenuItem(); | |
282 this.miDebugWindow = new IBBoard.Windows.Forms.IBBMenuItem(); | |
283 this.openArmyDialog = new System.Windows.Forms.OpenFileDialog(); | |
284 this.saveArmyDialog = new System.Windows.Forms.SaveFileDialog(); | |
285 this.pnlRight = new System.Windows.Forms.Panel(); | |
286 this.statusBarTimer = new System.Windows.Forms.Timer(this.components); | |
287 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit(); | |
288 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit(); | |
289 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit(); | |
290 this.SuspendLayout(); | |
291 // | |
292 // statusBar | |
293 // | |
294 this.statusBar.Location = new System.Drawing.Point(0, 548); | |
295 this.statusBar.Name = "statusBar"; | |
296 this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { | |
297 this.sbMainPanel, | |
298 this.sbErrorPanel, | |
299 this.sbPointsPanel}); | |
300 this.statusBar.ShowPanels = true; | |
301 this.statusBar.Size = new System.Drawing.Size(792, 22); | |
302 this.statusBar.TabIndex = 1; | |
303 this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick); | |
304 this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem); | |
305 // | |
306 // sbMainPanel | |
307 // | |
308 this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; | |
309 this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText; | |
310 this.sbMainPanel.Name = "sbMainPanel"; | |
311 this.sbMainPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; | |
312 this.sbMainPanel.Width = 475; | |
313 // | |
314 // sbErrorPanel | |
315 // | |
316 this.sbErrorPanel.Color = System.Drawing.SystemColors.WindowText; | |
317 this.sbErrorPanel.Name = "sbErrorPanel"; | |
318 this.sbErrorPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; | |
319 this.sbErrorPanel.Width = 150; | |
320 // | |
321 // sbPointsPanel | |
322 // | |
323 this.sbPointsPanel.Color = System.Drawing.SystemColors.WindowText; | |
324 this.sbPointsPanel.Name = "sbPointsPanel"; | |
325 this.sbPointsPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; | |
326 this.sbPointsPanel.ToolTipText = "Current Points Total"; | |
327 this.sbPointsPanel.Width = 150; | |
328 // | |
329 // toolBar | |
330 // | |
331 this.toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat; | |
332 this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { | |
333 this.bttnNewArmy, | |
334 this.bttnOpenArmy, | |
335 this.bttnSaveArmy, | |
336 this.bttnSep1, | |
337 this.bttnUndo, | |
338 this.bttnRedo}); | |
339 this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); | |
340 this.toolBar.DropDownArrows = true; | |
341 this.toolBar.ImageList = this.buttonIcons; | |
342 this.toolBar.Location = new System.Drawing.Point(0, 0); | |
343 this.toolBar.Name = "toolBar"; | |
344 this.toolBar.ShowToolTips = true; | |
345 this.toolBar.Size = new System.Drawing.Size(792, 28); | |
346 this.toolBar.TabIndex = 2; | |
347 this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick); | |
348 // | |
349 // bttnNewArmy | |
350 // | |
351 this.bttnNewArmy.Enabled = false; | |
352 this.bttnNewArmy.ImageIndex = 0; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
353 this.bttnNewArmy.Name = "bttnNewArmy"; |
0 | 354 // |
355 // bttnOpenArmy | |
356 // | |
357 this.bttnOpenArmy.ImageIndex = 2; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
358 this.bttnOpenArmy.Name = "bttnOpenArmy"; |
0 | 359 // |
360 // bttnSaveArmy | |
361 // | |
362 this.bttnSaveArmy.Enabled = false; | |
363 this.bttnSaveArmy.ImageIndex = 1; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
364 this.bttnSaveArmy.Name = "bttnSaveArmy"; |
0 | 365 // |
366 // bttnSep1 | |
367 // | |
368 this.bttnSep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; | |
369 // | |
370 // bttnUndo | |
371 // | |
372 this.bttnUndo.DropDownMenu = this.undoMenu; | |
373 this.bttnUndo.Enabled = false; | |
374 this.bttnUndo.ImageIndex = 3; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
375 this.bttnUndo.Name = "bttnUndo"; |
0 | 376 this.bttnUndo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; |
377 // | |
378 // bttnRedo | |
379 // | |
380 this.bttnRedo.DropDownMenu = this.redoMenu; | |
381 this.bttnRedo.Enabled = false; | |
382 this.bttnRedo.ImageIndex = 4; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
383 this.bttnRedo.Name = "bttnRedo"; |
0 | 384 this.bttnRedo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; |
385 // | |
386 // buttonIcons | |
387 // | |
388 this.buttonIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("buttonIcons.ImageStream"))); | |
389 this.buttonIcons.TransparentColor = System.Drawing.Color.Transparent; | |
390 this.buttonIcons.Images.SetKeyName(0, ""); | |
391 this.buttonIcons.Images.SetKeyName(1, ""); | |
392 this.buttonIcons.Images.SetKeyName(2, ""); | |
393 this.buttonIcons.Images.SetKeyName(3, ""); | |
394 this.buttonIcons.Images.SetKeyName(4, ""); | |
395 this.buttonIcons.Images.SetKeyName(5, ""); | |
396 this.buttonIcons.Images.SetKeyName(6, ""); | |
397 // | |
398 // mainMenu | |
399 // | |
400 this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |
401 this.menuFile, | |
402 this.menuEdit, | |
403 this.menuHelp}); | |
404 // | |
405 // menuFile | |
406 // | |
407 this.menuFile.Index = 0; | |
408 this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |
409 this.miNewArmy, | |
410 this.miOpenArmy, | |
411 this.miSaveArmy, | |
412 this.miSaveArmyAs, | |
413 this.miCloseArmy, | |
414 this.miSep1, | |
415 this.miChangeSystem, | |
416 this.miSep2, | |
417 this.miReloadFiles, | |
418 this.miSep3, | |
419 this.miExit}); | |
420 this.menuFile.Text = "&file"; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
421 this.menuFile.Name = "menuFile"; |
0 | 422 // |
423 // miNewArmy | |
424 // | |
425 this.miNewArmy.Index = 0; | |
426 this.miNewArmy.Text = "&new army"; | |
427 this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
428 this.miNewArmy.Name = "miNewArmy"; |
0 | 429 // |
430 // miOpenArmy | |
431 // | |
432 this.miOpenArmy.Index = 1; | |
433 this.miOpenArmy.Text = "&open army"; | |
434 this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
435 this.miOpenArmy.Name = "miOpenArmy"; |
0 | 436 // |
437 // miSaveArmy | |
438 // | |
439 this.miSaveArmy.Enabled = false; | |
440 this.miSaveArmy.Index = 2; | |
441 this.miSaveArmy.Text = "&save army"; | |
442 this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
443 this.miSaveArmy.Name = "miSaveArmy"; |
0 | 444 // |
445 // miSaveArmyAs | |
446 // | |
447 this.miSaveArmyAs.Enabled = false; | |
448 this.miSaveArmyAs.Index = 3; | |
449 this.miSaveArmyAs.Text = "save army &as..."; | |
450 this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
451 this.miSaveArmyAs.Name = "miSaveArmyAs"; |
0 | 452 // |
453 // miCloseArmy | |
454 // | |
455 this.miCloseArmy.Enabled = false; | |
456 this.miCloseArmy.Index = 4; | |
457 this.miCloseArmy.Text = "&close army"; | |
458 this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
459 this.miCloseArmy.Name = "miCloseArmy"; |
0 | 460 // |
461 // miSep1 | |
462 // | |
463 this.miSep1.Index = 5; | |
464 this.miSep1.Text = "-"; | |
465 // | |
466 // miChangeSystem | |
467 // | |
468 this.miChangeSystem.Index = 6; | |
469 this.miChangeSystem.Text = "change &game system"; | |
470 this.miChangeSystem.Click += new System.EventHandler(this.miChangeSystem_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
471 this.miChangeSystem.Name = "miChangeSystem"; |
0 | 472 // |
473 // miSep2 | |
474 // | |
475 this.miSep2.Index = 7; | |
476 this.miSep2.Text = "-"; | |
477 // | |
478 // miReloadFiles | |
479 // | |
480 this.miReloadFiles.Index = 8; | |
481 this.miReloadFiles.Text = "&reload files"; | |
482 this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
483 this.miReloadFiles.Name = "miReloadFiles"; |
0 | 484 // |
485 // miSep3 | |
486 // | |
487 this.miSep3.Index = 9; | |
488 this.miSep3.Text = "-"; | |
489 // | |
490 // miExit | |
491 // | |
492 this.miExit.Index = 10; | |
493 this.miExit.Text = "e&xit"; | |
494 this.miExit.Click += new System.EventHandler(this.miExit_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
495 this.miExit.Name = "miExit"; |
0 | 496 // |
497 // menuEdit | |
498 // | |
499 this.menuEdit.Index = 1; | |
500 this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |
501 this.miUndo, | |
502 this.miRedo}); | |
503 this.menuEdit.Text = "&edit"; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
504 this.menuEdit.Name = "menuEdit"; |
0 | 505 // |
506 // miUndo | |
507 // | |
508 this.miUndo.Enabled = false; | |
509 this.miUndo.Index = 0; | |
510 this.miUndo.Text = "&undo"; | |
511 this.miUndo.Click += new System.EventHandler(this.miUndo_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
512 this.miUndo.Name = "miUndo"; |
0 | 513 // |
514 // miRedo | |
515 // | |
516 this.miRedo.Enabled = false; | |
517 this.miRedo.Index = 1; | |
518 this.miRedo.Text = "&redo"; | |
519 this.miRedo.Click += new System.EventHandler(this.miRedo_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
520 this.miRedo.Name = "miRedo"; |
0 | 521 // |
522 // menuHelp | |
523 // | |
524 this.menuHelp.Index = 2; | |
525 this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | |
526 this.miAbout, | |
527 this.miDebugWindow}); | |
528 this.menuHelp.Text = "&help"; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
529 this.menuHelp.Name = "menuHelp"; |
0 | 530 // |
531 // miAbout | |
532 // | |
533 this.miAbout.Enabled = false; | |
534 this.miAbout.Index = 0; | |
535 this.miAbout.Text = "&about"; | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
536 this.miAbout.Name = "miAbout"; |
0 | 537 // |
538 // miDebugWindow | |
539 // | |
540 this.miDebugWindow.Index = 1; | |
541 this.miDebugWindow.Text = "&debug"; | |
542 this.miDebugWindow.Click += new System.EventHandler(this.miDebugWindow_Click); | |
2
74df258710fe
Fixes #8 - Update SWF version of WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
1
diff
changeset
|
543 this.miDebugWindow.Name = "miDebugWindow"; |
0 | 544 // |
545 // saveArmyDialog | |
546 // | |
547 this.saveArmyDialog.Title = "Translatable:saveArmyDialog"; | |
548 // | |
549 // pnlRight | |
550 // | |
551 this.pnlRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | |
552 | System.Windows.Forms.AnchorStyles.Right))); | |
553 this.pnlRight.BackColor = System.Drawing.SystemColors.AppWorkspace; | |
554 this.pnlRight.Location = new System.Drawing.Point(726, 30); | |
555 this.pnlRight.Name = "pnlRight"; | |
556 this.pnlRight.Size = new System.Drawing.Size(64, 516); | |
557 this.pnlRight.TabIndex = 4; | |
558 this.pnlRight.Visible = false; | |
559 this.pnlRight.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlRight_Paint); | |
560 // | |
561 // statusBarTimer | |
562 // | |
563 this.statusBarTimer.Interval = 5000; | |
564 this.statusBarTimer.Tick += new System.EventHandler(this.statusBarTimer_Tick); | |
565 // | |
566 // FrmMain | |
567 // | |
568 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); | |
569 this.ClientSize = new System.Drawing.Size(792, 570); | |
570 this.Controls.Add(this.pnlRight); | |
571 this.Controls.Add(this.toolBar); | |
572 this.Controls.Add(this.statusBar); | |
573 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); | |
574 this.IsMdiContainer = true; | |
575 this.Menu = this.mainMenu; | |
576 this.Name = "FrmMain"; | |
577 this.Text = "WarFoundry"; | |
578 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit(); | |
579 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit(); | |
580 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit(); | |
581 this.ResumeLayout(false); | |
582 this.PerformLayout(); | |
583 | |
584 } | |
585 #endregion | |
586 | |
587 /// <summary> | |
588 /// The main entry point for the application. | |
589 /// </summary> | |
590 [STAThread] | |
591 static void Main(string[] args) | |
592 { | |
593 try | |
594 { | |
595 ///TODO: Work out how to auto-embed the Manifest file so that we can have visual styles without having a .manifest file floating around | |
596 //and without using the line below, which causes the toolbar buttons to lose their icons | |
597 //Application.EnableVisualStyles(); | |
598 Application.Run(new FrmMain(args)); | |
599 } | |
600 catch(Exception ex) | |
601 { | |
602 LogManager.GetLogger(typeof(FrmMain)).Fatal(ex); | |
603 MessageBox.Show(null, "A major, unexpected and fatal error ocurred while starting the application: \r\n\r\n"+ex.Message+"\r\n\r\n"+ex.StackTrace, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error); | |
604 } | |
605 } | |
606 | |
607 private void miExit_Click(object sender, System.EventArgs e) | |
608 { | |
609 Application.Exit(); | |
610 } | |
611 | |
612 private void miNewArmy_Click(object sender, System.EventArgs e) | |
613 { | |
614 createNewArmy(); | |
615 } | |
616 | |
617 private void createNewArmy() | |
618 { | |
619 if (closeCurrentArmy()) | |
620 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
621 FrmNewArmy newArmy = new FrmNewArmy(CurrentGameSystem); |
0 | 622 DialogResult dr = newArmy.ShowDialog(); |
623 | |
624 if (dr == DialogResult.OK) | |
625 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
626 CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize); |
0 | 627 } |
628 } | |
629 } | |
630 | |
631 private bool openArmy() | |
632 { | |
633 if (closeCurrentArmy()) | |
634 { | |
635 if (openArmyDialog.Filter=="") | |
636 { | |
637 string savePath = ArmiesPath; | |
638 | |
639 if (!Directory.Exists(savePath)) | |
640 { | |
641 Directory.CreateDirectory(savePath); | |
642 } | |
643 | |
644 openArmyDialog.InitialDirectory = savePath; | |
645 openArmyDialog.Filter = Translation.GetTranslation("armyFileFilter")+"|*.army"; | |
646 openArmyDialog.Title = Translation.GetTranslation("openArmyDialog"); | |
647 | |
648 } | |
649 | |
650 DialogResult dr = openArmyDialog.ShowDialog(this); | |
651 | |
652 if (dr == DialogResult.OK) | |
653 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
654 /* |
0 | 655 try |
656 { | |
657 CurrentArmy = Factory.LoadArmy(openArmyDialog.FileName); | |
658 return true; | |
659 } | |
660 catch (InvalidFileException ex) | |
661 { | |
662 logger.Error(ex); | |
663 MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidFileBoxTitle", "Invalid data file"), MessageBoxButtons.OK, MessageBoxIcon.Error); | |
664 return false; | |
665 } | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
666 * */ |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
667 return false; |
0 | 668 } |
669 else | |
670 { | |
671 return false; | |
672 } | |
673 } | |
674 else | |
675 { | |
676 return false; | |
677 } | |
678 } | |
679 | |
680 private bool closeCurrentArmy() | |
681 { | |
682 if (CurrentArmy!=null) | |
683 { | |
684 bool canClose = false; | |
685 | |
686 if (CommandStack.IsDirty()) | |
687 { | |
688 DialogResult dr = MessageBox.Show(this, "The army \""+CurrentArmy.Name+"\" has been modified.\r\nSave changes before closing army?", "Unsaved changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3); | |
689 | |
690 if (dr == DialogResult.Yes) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
691 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
692 canClose = SaveCurrentArmy(); |
0 | 693 } |
694 else if (dr == DialogResult.No) | |
695 { | |
696 canClose = true; | |
697 } | |
698 //else they said cancel and we default to "canClose = false" so do nothing | |
699 } | |
700 else | |
701 { | |
702 canClose = true; | |
703 } | |
704 | |
705 if (canClose) | |
706 { | |
707 //do close | |
708 disableCategoryButtons(); | |
709 CurrentArmy = null; | |
710 return true; | |
711 } | |
712 else | |
713 { | |
714 return false; | |
715 } | |
716 } | |
717 else | |
718 { | |
719 disableCategoryButtons(); | |
720 //pretend we succeeded | |
721 return true; | |
722 } | |
723 } | |
724 | |
725 private void undoLastAction() | |
726 { | |
727 if (commandStack.CanUndo()) | |
728 { | |
729 commandStack.Undo(); | |
730 } | |
731 } | |
732 | |
733 private void redoAction() | |
734 { | |
735 if (commandStack.CanRedo()) | |
736 { | |
737 commandStack.Redo(); | |
738 } | |
739 } | |
740 | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
741 private bool SaveCurrentArmy() |
0 | 742 { |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
743 bool saved = false; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
744 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
745 if (loadedFilePath != null || PromptForFilePath()) |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
746 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
747 saved = SaveCurrentArmyToFile(); |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
748 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
749 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
750 return saved; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
751 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
752 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
753 private bool SaveCurrentArmyAs() |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
754 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
755 bool saved = false; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
756 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
757 if (PromptForFilePath()) |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
758 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
759 saved = SaveCurrentArmyToFile(); |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
760 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
761 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
762 return saved; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
763 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
764 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
765 private bool SaveCurrentArmyToFile() |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
766 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
767 if (WarFoundrySaver.GetSaver().Save(CurrentArmy, loadedFilePath)) |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
768 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
769 miSaveArmy.Enabled = false; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
770 bttnSaveArmy.Enabled = false; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
771 CommandStack.setCleanMark(); |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
772 return true; |
0 | 773 } |
774 else | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
775 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
776 loadedFilePath = null; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
777 MessageBox.Show(this, Translation.GetTranslation("SaveFailed"), Translation.GetTranslation("SaveFailedTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); |
0 | 778 return false; |
779 } | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
780 } |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
781 |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
782 private bool PromptForFilePath() |
0 | 783 { |
784 if (saveArmyDialog.Filter == "") | |
785 { | |
786 string savePath = ArmiesPath; | |
787 | |
788 if (!Directory.Exists(savePath)) | |
789 { | |
790 Directory.CreateDirectory(savePath); | |
791 } | |
792 | |
793 saveArmyDialog.InitialDirectory = savePath; | |
794 saveArmyDialog.Filter = Translation.GetTranslation("armyFileFilter")+"|*.army"; | |
795 saveArmyDialog.Title = Translation.GetTranslation("saveArmyDialog"); | |
796 } | |
797 | |
798 DialogResult dr = saveArmyDialog.ShowDialog(this); | |
799 | |
800 if (dr == DialogResult.OK) | |
801 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
802 loadedFilePath = saveArmyDialog.FileName; |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
803 return true; |
0 | 804 } |
805 else | |
806 { | |
807 return false; | |
808 } | |
809 } | |
810 | |
811 private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) | |
812 { | |
813 if (e.Button == bttnUndo) | |
814 { | |
815 undoLastAction(); | |
816 } | |
817 else if (e.Button == bttnRedo) | |
818 { | |
819 redoAction(); | |
820 } | |
821 else if (e.Button == bttnNewArmy) | |
822 { | |
823 createNewArmy(); | |
824 } | |
825 else if (e.Button == bttnOpenArmy) | |
826 { | |
827 openArmy(); | |
828 } | |
829 else if (e.Button == bttnSaveArmy) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
830 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
831 SaveCurrentArmy(); |
0 | 832 } |
833 else | |
834 { | |
835 //it must be one of our extra buttons for the categories | |
836 addUnitFromCategory((Category)e.Button.Tag); | |
837 } | |
838 } | |
839 | |
840 private GameSystem CurrentGameSystem | |
841 { | |
842 get { return WarFoundryCore.CurrentGameSystem; } | |
843 set { WarFoundryCore.CurrentGameSystem = value; } | |
844 } | |
845 | |
846 private static Army CurrentArmy | |
847 { | |
848 get { return WarFoundryCore.CurrentArmy; } | |
849 set { WarFoundryCore.CurrentArmy = value; } | |
850 } | |
851 | |
852 private void SelectGameSystem() | |
853 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
854 FrmSelectSystem selectSystem = new FrmSelectSystem(); |
0 | 855 DialogResult dr = selectSystem.ShowDialog(this); |
856 | |
857 if (dr==DialogResult.OK) | |
858 { | |
859 closeCurrentArmy(); | |
860 CurrentGameSystem = selectSystem.GameSystem; | |
861 } | |
862 } | |
863 | |
864 private void miChangeSystem_Click(object sender, System.EventArgs e) | |
865 { | |
866 SelectGameSystem(); | |
867 } | |
868 | |
869 private void FrmMain_GameSystemChanged(GameSystem oldSystem, GameSystem newSystem) | |
870 { | |
871 miNewArmy.Enabled = newSystem != null; | |
872 bttnNewArmy.Enabled = newSystem != null; | |
873 setAppTitle(); | |
874 removeCategoryButtons(); | |
875 addCategoryButtons(); | |
876 } | |
877 | |
878 private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy) | |
879 { | |
880 setAppTitle(); | |
881 | |
882 if (oldArmy != null) | |
883 { | |
884 oldArmy.UnitAdded += UnitAddedMethod; | |
885 oldArmy.UnitRemoved += UnitRemovedMethod; | |
886 oldArmy.PointsValueChanged += PointsValueChangedMethod; | |
887 } | |
888 | |
889 if (CurrentArmy==null) | |
890 { | |
891 miSaveArmyAs.Enabled = false; | |
892 miCloseArmy.Enabled = false; | |
893 disableCategoryButtons(); | |
894 } | |
895 else | |
896 { | |
897 newArmy.UnitAdded += UnitAddedMethod; | |
898 newArmy.UnitRemoved += UnitRemovedMethod; | |
899 newArmy.PointsValueChanged += PointsValueChangedMethod; | |
900 //TODO: Clear all buttons | |
901 miSaveArmyAs.Enabled = true; | |
902 miCloseArmy.Enabled = true; | |
903 enableCategoryButtons(); | |
904 | |
905 if (newArmy.Race.HasCategoryOverrides()) | |
906 { | |
907 removeCategoryButtons(); | |
908 addCategoryButtons(newArmy.Race.Categories); | |
909 } | |
910 } | |
911 | |
912 CommandStack.Reset(); | |
913 | |
914 miSaveArmy.Enabled = false; | |
915 bttnSaveArmy.Enabled = false; | |
916 | |
917 setPointsPanelText(); | |
918 } | |
919 | |
920 private void addCategoryButtons() | |
921 { | |
922 if (CurrentGameSystem!=null) | |
923 { | |
924 addCategoryButtons(CurrentGameSystem.Categories); | |
925 } | |
926 } | |
927 | |
928 private void addCategoryButtons(Category[] cats) | |
929 { | |
930 int catCount = cats.Length; | |
931 Category cat; | |
932 categoryButtons = new ToolBarButton[catCount+1]; | |
933 | |
934 ToolBarButton sep = new ToolBarButton(); | |
935 sep.Style = ToolBarButtonStyle.Separator; | |
936 categoryButtons[0] = sep; | |
937 | |
938 IBBToolBarButton button; | |
939 | |
940 for (int i = 0; i<catCount; i++) | |
941 { | |
942 cat = cats[i]; | |
943 button = new IBBToolBarButton(); | |
944 ///button.Name = "bttnAddCategory" + cat.Name[0].ToString(); | |
945 button.Text = cat.Name.ToString();//String.Format(Translation.GetTranslation("bttnAddCategory"), cat.Name); | |
946 button.Tag = cat; | |
947 button.ImageIndex = 6; | |
948 button.Enabled = false; | |
949 categoryButtons[i+1] = button; | |
950 } | |
951 | |
952 this.Invoke(new ToolBarButtonRangeDelegate(toolBar.Buttons.AddRange), new object[]{categoryButtons}); | |
953 } | |
954 | |
955 private void removeCategoryButtons() | |
956 { | |
957 if (categoryButtons!=null) | |
958 { | |
959 for (int i = 0; i<categoryButtons.Length; i++) | |
960 { | |
961 this.Invoke(new ToolBarButtonDelegate(toolBar.Buttons.Remove), new object[]{categoryButtons[i]}); | |
962 } | |
963 } | |
964 } | |
965 | |
966 private void enableCategoryButtons() | |
967 { | |
968 setCategoryButtonState(true); | |
969 } | |
970 | |
971 private void disableCategoryButtons() | |
972 { | |
973 setCategoryButtonState(false); | |
974 } | |
975 | |
976 private void setCategoryButtonState(bool state) | |
977 { | |
978 if (categoryButtons!=null) | |
979 { | |
980 for (int i = 0; i<categoryButtons.Length; i++) | |
981 { | |
982 categoryButtons[i].Enabled = state; | |
983 } | |
984 } | |
985 } | |
986 | |
987 private void miSaveArmyAs_Click(object sender, System.EventArgs e) | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
988 { |
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
989 SaveCurrentArmyAs(); |
0 | 990 } |
991 | |
992 private void commandStack_CommandStackUpdated() | |
993 { | |
994 bttnUndo.Enabled = commandStack.CanUndo(); | |
995 miUndo.Enabled = bttnUndo.Enabled; | |
996 bttnRedo.Enabled = commandStack.CanRedo(); | |
997 miRedo.Enabled = bttnRedo.Enabled; | |
998 MenuItem[] menuItems = null; | |
999 int redoLength = commandStack.RedoLength; | |
1000 int maxRedo = Math.Min(10, redoLength); | |
1001 | |
1002 if (redoLength > 0) | |
1003 { | |
1004 menuItems = new MenuItem[maxRedo]; | |
1005 Command com; | |
1006 MenuItem mi; | |
1007 | |
1008 for (int i = 0; i < maxRedo; i++) | |
1009 { | |
1010 com = commandStack.PeekRedoCommand(i+1); | |
1011 | |
1012 if (com == null) | |
1013 { | |
1014 break; | |
1015 } | |
1016 | |
1017 mi = new MenuItem(com.Description); | |
1018 mi.Click+=new EventHandler(redoMenu_Click); | |
1019 menuItems[i] = mi; | |
1020 } | |
1021 } | |
1022 | |
1023 redoMenu.MenuItems.Clear(); | |
1024 | |
1025 if (menuItems!=null && menuItems[0]!=null) | |
1026 { | |
1027 bttnRedo.ToolTipText = menuItems[0].Text; | |
1028 redoMenu.MenuItems.AddRange(menuItems); | |
1029 } | |
1030 | |
1031 int undoLength = commandStack.UndoLength; | |
1032 int maxUndo = Math.Min(10, undoLength); | |
1033 MenuItem[] menuItemsUndo = null; | |
1034 | |
1035 if (undoLength > 0) | |
1036 { | |
1037 menuItemsUndo = new MenuItem[maxUndo]; | |
1038 Command com; | |
1039 MenuItem mi; | |
1040 | |
1041 for (int i = 0; i < maxUndo; i++) | |
1042 { | |
1043 com = commandStack.PeekUndoCommand(i+1); | |
1044 | |
1045 if (com == null) | |
1046 { | |
1047 break; | |
1048 } | |
1049 | |
1050 mi = new MenuItem(com.UndoDescription); | |
1051 mi.Click+=new EventHandler(undoMenu_Click); | |
1052 menuItemsUndo[i] = mi; | |
1053 } | |
1054 } | |
1055 | |
1056 undoMenu.MenuItems.Clear(); | |
1057 | |
1058 if (menuItemsUndo!=null && menuItemsUndo[0]!=null) | |
1059 { | |
1060 bttnUndo.ToolTipText = menuItemsUndo[0].Text; | |
1061 undoMenu.MenuItems.AddRange(menuItemsUndo); | |
1062 } | |
1063 | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1064 bool canSave = loadedFilePath != null; |
0 | 1065 bttnSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null && canSave; |
1066 miSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null && canSave; | |
1067 } | |
1068 | |
1069 private void miSaveArmy_Click(object sender, System.EventArgs e) | |
1070 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1071 SaveCurrentArmy(); |
0 | 1072 } |
1073 | |
1074 private void setAppTitle() | |
1075 { | |
1076 string str = AppTitle; | |
1077 | |
1078 if (CurrentGameSystem!=null) | |
1079 { | |
1080 str+= " - "+CurrentGameSystem.Name; | |
1081 } | |
1082 | |
1083 if (CurrentArmy!=null) | |
1084 { | |
1085 str+= " - "+CurrentArmy.Name; | |
1086 } | |
1087 | |
1088 this.Text = str; | |
1089 } | |
1090 | |
1091 private void addUnitFromCategory(Category cat) | |
1092 { | |
1093 FrmNewUnit newUnit = new FrmNewUnit(CurrentArmy.Race, cat, CurrentArmy); | |
1094 DialogResult dr = newUnit.ShowDialog(this); | |
1095 | |
1096 if (dr == DialogResult.OK) | |
1097 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1098 CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, cat, CurrentArmy); |
0 | 1099 commandStack.Execute(cmd); |
1100 } | |
1101 } | |
1102 | |
1103 private void FrmMain_UnitAddedMethod(object unitObj) | |
1104 { | |
1105 if (unitObj is Unit) | |
1106 { | |
1107 Unit unit = (Unit)unitObj; | |
1108 sbErrorPanel.Text = ""; | |
1109 } | |
1110 } | |
1111 | |
1112 private void FrmMain_UnitRemovedMethod(object unitObj) | |
1113 { | |
1114 if (unitObj is Unit) | |
1115 { | |
1116 Unit unit = (Unit)unitObj; | |
1117 sbErrorPanel.Text = ""; | |
1118 | |
1119 //check if window is open, and close it if it is | |
1120 foreach (Form frm in this.MdiChildren) | |
1121 { | |
1122 if (frm is FrmUnit) | |
1123 { | |
1124 if (((FrmUnit)frm).Unit == unit) | |
1125 { | |
1126 frm.Close(); | |
1127 break; | |
1128 } | |
1129 } | |
1130 } | |
1131 } | |
1132 } | |
1133 | |
1134 /*private void FrmMain_FailedUnitRequirement(FailedUnitRequirement failedRequirement) | |
1135 { | |
1136 sbErrorPanel.Text = Translation.GetTranslation("UnitRequirementFailed", "Unit Requirement Failed"); | |
1137 sbErrorPanel.Tag = failedRequirement.Description; | |
1138 }*/ | |
1139 | |
1140 /*public void MdiChildMoved() | |
1141 { | |
1142 Point mouseAt = PointToClient(ActiveMdiChild.Location); | |
1143 | |
1144 if (Comparisons.ValueWithinAmount(pnlRight.Right, ActiveMdiChild.Right, 10)) | |
1145 { | |
1146 pnlRight.Visible = true; | |
1147 //pnlRight.Container.Add(ActiveMdiChild); | |
1148 } | |
1149 else | |
1150 { | |
1151 pnlRight.Visible = false; | |
1152 } | |
1153 }*/ | |
1154 | |
1155 public void pnlRight_Paint(object sender, System.Windows.Forms.PaintEventArgs e) | |
1156 { | |
1157 HatchBrush dockCueBrush = new HatchBrush(HatchStyle.LightDownwardDiagonal, Color.White, Color.Gray); | |
1158 Pen dockCuePen = new Pen(dockCueBrush, 10); | |
1159 e.Graphics.DrawRectangle(dockCuePen, new Rectangle(pnlRight.Left, pnlRight.Top, pnlRight.Width, pnlRight.Height)); | |
1160 } | |
1161 | |
1162 private void miUndo_Click(object sender, System.EventArgs e) | |
1163 { | |
1164 undoLastAction(); | |
1165 } | |
1166 | |
1167 private void miRedo_Click(object sender, System.EventArgs e) | |
1168 { | |
1169 redoAction(); | |
1170 } | |
1171 | |
1172 private void miCloseArmy_Click(object sender, EventArgs e) | |
1173 { | |
1174 closeCurrentArmy(); | |
1175 } | |
1176 | |
1177 private void miOpenArmy_Click(object sender, EventArgs e) | |
1178 { | |
1179 openArmy(); | |
1180 } | |
1181 | |
1182 private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal) | |
1183 { | |
1184 if (obj is Army) | |
1185 { | |
1186 setPointsPanelText(); | |
1187 } | |
1188 } | |
1189 | |
1190 private void setPointsPanelText() | |
1191 { | |
1192 if (CurrentArmy==null) | |
1193 { | |
1194 sbPointsPanel.Text = ""; | |
1195 sbPointsPanel.ResetColor(); | |
1196 } | |
1197 else | |
1198 { | |
1199 sbPointsPanel.Text = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.PointsTotal, CurrentArmy.MaxPoints); | |
1200 | |
1201 if (CurrentArmy.PointsTotal>CurrentArmy.MaxPoints) | |
1202 { | |
1203 sbPointsPanel.Color = Color.Red; | |
1204 } | |
1205 else | |
1206 { | |
1207 sbPointsPanel.ResetColor(); | |
1208 } | |
1209 } | |
1210 } | |
1211 | |
1212 private void redoMenu_Click(object sender, EventArgs e) | |
1213 { | |
1214 if (sender is MenuItem) | |
1215 { | |
1216 MenuItem mi = (MenuItem)sender; | |
1217 | |
1218 if (mi.Parent == redoMenu) | |
1219 { | |
1220 //we know it's an redo menu item so find it's index and redo everything | |
1221 int max = mi.Index; | |
1222 | |
1223 for (int i = 0; i <= max; i++) | |
1224 { | |
1225 commandStack.Redo(); | |
1226 } | |
1227 } | |
1228 } | |
1229 } | |
1230 | |
1231 private void undoMenu_Click(object sender, EventArgs e) | |
1232 { | |
1233 if (sender is MenuItem) | |
1234 { | |
1235 MenuItem mi = (MenuItem)sender; | |
1236 | |
1237 if (mi.Parent == undoMenu) | |
1238 { | |
1239 //we know it's an undo menu item so find it's index and undo everything | |
1240 int max = mi.Index; | |
1241 for (int i = 0; i <= max; i++) | |
1242 { | |
1243 commandStack.Undo(); | |
1244 } | |
1245 } | |
1246 } | |
1247 } | |
1248 | |
1249 private void statusBar_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent) | |
1250 { | |
1251 statusBar.ColorableStatusBarDrawItem(sender, sbdevent); | |
1252 } | |
1253 | |
1254 private void miDebugWindow_Click(object sender, EventArgs e) | |
1255 { | |
1256 if (debugWindow == null || debugWindow.IsDisposed) | |
1257 { | |
1258 debugWindow = new FrmDebugOutput(); | |
1259 } | |
1260 | |
1261 debugWindow.Show(); | |
1262 debugWindow.Focus(); | |
1263 } | |
1264 | |
1265 private void FrmMain_Closing(object sender, CancelEventArgs e) | |
1266 { | |
1267 if (!closeCurrentArmy()) | |
1268 { | |
1269 e.Cancel = true; | |
1270 } | |
1271 } | |
1272 | |
1273 private void miReloadFiles_Click(object sender, System.EventArgs e) | |
1274 { | |
1
42cf06b8f897
Re #8 - Get a working Windows WarFoundry
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1275 WarFoundryLoader.GetDefault().LoadFiles(); |
0 | 1276 sbMainPanel.Text = Translation.GetTranslation("GameSystemFilesReloaded", "Game system and race files reloaded"); |
1277 statusBarTimer.Enabled = true; | |
1278 } | |
1279 | |
1280 private void statusBarTimer_Tick(object sender, System.EventArgs e) | |
1281 { | |
1282 sbMainPanel.Text = ""; | |
1283 statusBarTimer.Enabled = false; | |
1284 } | |
1285 | |
1286 private void statusBar_PanelClick(object sender, StatusBarPanelClickEventArgs e) | |
1287 { | |
1288 if (e.StatusBarPanel == sbErrorPanel && sbErrorPanel.Text!="") | |
1289 { | |
1290 MessageBox.Show(this, sbErrorPanel.TagString, Translation.GetTranslation("FailedRequirementMessage"), MessageBoxButtons.OK, MessageBoxIcon.Warning); | |
1291 } | |
1292 } | |
1293 } | |
1294 } |