comparison FrmMain.cs @ 221:c47094612bac

Re #355: Add XML export format that can be transformed with an XSL * Merge Clutch's WinForms code into main branch * Fix targetting of project * Add .hgignore
author IBBoard <dev@ibboard.co.uk>
date Thu, 25 Aug 2011 20:43:51 +0100
parents 83685ed69c69
children 5233147ca7e4
comparison
equal deleted inserted replaced
206:314d90a059d8 221:c47094612bac
38 /// </summary> 38 /// </summary>
39 public class FrmMain : System.Windows.Forms.Form 39 public class FrmMain : System.Windows.Forms.Form
40 { 40 {
41 private static readonly string AppTitle = "WarFoundry"; 41 private static readonly string AppTitle = "WarFoundry";
42 internal static readonly string VERSION = "0.1"; 42 internal static readonly string VERSION = "0.1";
43 const string DefaultDataDir = "data"; 43 const string DefaultDataDir = "data";
44 /* public static string pointsAbbrevSingle;
45 public static string pointsAbbrevPlural;
46 public static string pointsAbbreviation;
47 public static string pointsNameSingle;
48 public static string pointsNamePlural;
49 public static string pointsName;*/
50 44
51 private Preferences preferences; 45 private Preferences preferences;
52 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain)); 46 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain));
53 47
54 private CommandStack commandStack; 48 private CommandStack commandStack;
55 49
56 public ObjectAddDelegate UnitAddedMethod; 50 public ObjectAddDelegate UnitAddedMethod;
57 public ObjectRemoveDelegate UnitRemovedMethod; 51 public ObjectRemoveDelegate UnitRemovedMethod;
58 public DoubleValChangedDelegate PointsValueChangedMethod; 52 public DoubleValChangedDelegate PointsValueChangedMethod;
59 //public FailedUnitRequirementDelegate FailedUnitRequirementMethod;
60 53
61 private FrmArmyTree armyTree; 54 private FrmArmyTree armyTree;
62 private string loadedFilePath; 55 private string loadedFilePath;
63 private Dictionary<string, FrmUnit> unitWindows; 56 private Dictionary<string, FrmUnit> unitWindows;
64 57
69 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbMainPanel; 62 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbMainPanel;
70 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbErrorPanel; 63 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbErrorPanel;
71 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbPointsPanel; 64 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbPointsPanel;
72 private System.Windows.Forms.ContextMenu undoMenu; 65 private System.Windows.Forms.ContextMenu undoMenu;
73 private System.Windows.Forms.ContextMenu redoMenu; 66 private System.Windows.Forms.ContextMenu redoMenu;
74 private IBBoard.Windows.Forms.ColorableStatusBar statusBar; 67 private IBBoard.Windows.Forms.ColorableStatusBar statusBar;
75 private MenuStrip menuStrip; 68 private MenuStrip menuStrip;
76 private IBBToolStripMenuItem menuFile; 69 private IBBToolStripMenuItem menuFile;
77 private IBBToolStripMenuItem miNewArmy; 70 private IBBToolStripMenuItem miNewArmy;
78 private IBBToolStripMenuItem miOpenArmy; 71 private IBBToolStripMenuItem miOpenArmy;
79 private IBBToolStripMenuItem miSaveArmy; 72 private IBBToolStripMenuItem miSaveArmy;
98 private IBBToolStripSplitButton bttnRedo; 91 private IBBToolStripSplitButton bttnRedo;
99 private ToolStrip catToolStrip; 92 private ToolStrip catToolStrip;
100 private ToolStripPanel toolStripPanel; 93 private ToolStripPanel toolStripPanel;
101 private ToolStripSeparator toolStripSeparator4; 94 private ToolStripSeparator toolStripSeparator4;
102 private IBBToolStripMenuItem miPreferences; 95 private IBBToolStripMenuItem miPreferences;
96 private IBBToolStripMenuItem miExportArmyAsBasicXml;
103 private IBBToolStripMenuItem miAbout; 97 private IBBToolStripMenuItem miAbout;
104 98
105 99
106 /// <summary> 100 /// <summary>
107 /// The main entry point for the application. 101 /// The main entry point for the application.
151 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged); 145 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged);
152 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged); 146 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged);
153 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod); 147 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
154 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod); 148 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
155 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); 149 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
156 //FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(FrmMain_FailedUnitRequirement); 150
157
158
159 sbErrorPanel.Color = Color.Red; 151 sbErrorPanel.Color = Color.Red;
160 SetPointsPanelToolTipText(); 152 SetPointsPanelToolTipText();
161 153
162 // hack to load default files 154 // hack to load default files
163 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir)); 155 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir));
264 this.miOpenArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 256 this.miOpenArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
265 this.miSaveArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 257 this.miSaveArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
266 this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 258 this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
267 this.miExportArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 259 this.miExportArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
268 this.miExportArmyAsBasicHTML = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 260 this.miExportArmyAsBasicHTML = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
261 this.miExportArmyAsBasicXml = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
269 this.miCloseArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 262 this.miCloseArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
270 this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); 263 this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
271 this.miReloadFiles = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 264 this.miReloadFiles = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
272 this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); 265 this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
273 this.miExit = new IBBoard.Windows.Forms.IBBToolStripMenuItem(); 266 this.miExit = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
326 this.toolStripSeparator1, 319 this.toolStripSeparator1,
327 this.miReloadFiles, 320 this.miReloadFiles,
328 this.toolStripSeparator2, 321 this.toolStripSeparator2,
329 this.miExit}); 322 this.miExit});
330 this.menuFile.Name = "menuFile"; 323 this.menuFile.Name = "menuFile";
331 this.menuFile.Size = new System.Drawing.Size(33, 20); 324 this.menuFile.Size = new System.Drawing.Size(35, 20);
332 this.menuFile.Text = "&file"; 325 this.menuFile.Text = "&file";
333 // 326 //
334 // miNewArmy 327 // miNewArmy
335 // 328 //
336 this.miNewArmy.Name = "miNewArmy"; 329 this.miNewArmy.Name = "miNewArmy";
337 this.miNewArmy.Size = new System.Drawing.Size(164, 22); 330 this.miNewArmy.Size = new System.Drawing.Size(160, 22);
338 this.miNewArmy.Text = "&new army"; 331 this.miNewArmy.Text = "&new army";
339 this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click); 332 this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click);
340 // 333 //
341 // miOpenArmy 334 // miOpenArmy
342 // 335 //
343 this.miOpenArmy.Name = "miOpenArmy"; 336 this.miOpenArmy.Name = "miOpenArmy";
344 this.miOpenArmy.Size = new System.Drawing.Size(164, 22); 337 this.miOpenArmy.Size = new System.Drawing.Size(160, 22);
345 this.miOpenArmy.Text = "&open army"; 338 this.miOpenArmy.Text = "&open army";
346 this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click); 339 this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click);
347 // 340 //
348 // miSaveArmy 341 // miSaveArmy
349 // 342 //
350 this.miSaveArmy.Enabled = false; 343 this.miSaveArmy.Enabled = false;
351 this.miSaveArmy.Name = "miSaveArmy"; 344 this.miSaveArmy.Name = "miSaveArmy";
352 this.miSaveArmy.Size = new System.Drawing.Size(164, 22); 345 this.miSaveArmy.Size = new System.Drawing.Size(160, 22);
353 this.miSaveArmy.Text = "&save army"; 346 this.miSaveArmy.Text = "&save army";
354 this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click); 347 this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click);
355 // 348 //
356 // miSaveArmyAs 349 // miSaveArmyAs
357 // 350 //
358 this.miSaveArmyAs.Enabled = false; 351 this.miSaveArmyAs.Enabled = false;
359 this.miSaveArmyAs.Name = "miSaveArmyAs"; 352 this.miSaveArmyAs.Name = "miSaveArmyAs";
360 this.miSaveArmyAs.Size = new System.Drawing.Size(164, 22); 353 this.miSaveArmyAs.Size = new System.Drawing.Size(160, 22);
361 this.miSaveArmyAs.Text = "save army &as..."; 354 this.miSaveArmyAs.Text = "save army &as...";
362 this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click); 355 this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click);
363 // 356 //
364 // miExportArmyAs 357 // miExportArmyAs
365 // 358 //
366 this.miExportArmyAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 359 this.miExportArmyAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
367 this.miExportArmyAsBasicHTML}); 360 this.miExportArmyAsBasicHTML,
361 this.miExportArmyAsBasicXml});
368 this.miExportArmyAs.Enabled = false; 362 this.miExportArmyAs.Enabled = false;
369 this.miExportArmyAs.Name = "miExportArmyAs"; 363 this.miExportArmyAs.Name = "miExportArmyAs";
370 this.miExportArmyAs.Size = new System.Drawing.Size(164, 22); 364 this.miExportArmyAs.Size = new System.Drawing.Size(160, 22);
371 this.miExportArmyAs.Text = "export army as..."; 365 this.miExportArmyAs.Text = "export army as...";
372 // 366 //
373 // miExportArmyAsBasicHTML 367 // miExportArmyAsBasicHTML
374 // 368 //
375 this.miExportArmyAsBasicHTML.Name = "miExportArmyAsBasicHTML"; 369 this.miExportArmyAsBasicHTML.Name = "miExportArmyAsBasicHTML";
376 this.miExportArmyAsBasicHTML.Size = new System.Drawing.Size(130, 22); 370 this.miExportArmyAsBasicHTML.Size = new System.Drawing.Size(152, 22);
377 this.miExportArmyAsBasicHTML.Text = "&basic html"; 371 this.miExportArmyAsBasicHTML.Text = "&basic html";
378 this.miExportArmyAsBasicHTML.Click += new System.EventHandler(this.miExportArmyAsBasicHTML_Click); 372 this.miExportArmyAsBasicHTML.Click += new System.EventHandler(this.miExportArmyAsBasicHTML_Click);
379 // 373 //
374 // miExportArmyAsBasicXml
375 //
376 this.miExportArmyAsBasicXml.Name = "miExportArmyAsBasicXml";
377 this.miExportArmyAsBasicXml.Size = new System.Drawing.Size(152, 22);
378 this.miExportArmyAsBasicXml.Text = "basic xml";
379 this.miExportArmyAsBasicXml.Click += new System.EventHandler(this.miExportArmyAsBasicXml_Click);
380 //
380 // miCloseArmy 381 // miCloseArmy
381 // 382 //
382 this.miCloseArmy.Enabled = false; 383 this.miCloseArmy.Enabled = false;
383 this.miCloseArmy.Name = "miCloseArmy"; 384 this.miCloseArmy.Name = "miCloseArmy";
384 this.miCloseArmy.Size = new System.Drawing.Size(164, 22); 385 this.miCloseArmy.Size = new System.Drawing.Size(160, 22);
385 this.miCloseArmy.Text = "&close army"; 386 this.miCloseArmy.Text = "&close army";
386 this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click); 387 this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click);
387 // 388 //
388 // toolStripSeparator1 389 // toolStripSeparator1
389 // 390 //
390 this.toolStripSeparator1.Name = "toolStripSeparator1"; 391 this.toolStripSeparator1.Name = "toolStripSeparator1";
391 this.toolStripSeparator1.Size = new System.Drawing.Size(161, 6); 392 this.toolStripSeparator1.Size = new System.Drawing.Size(157, 6);
392 // 393 //
393 // miReloadFiles 394 // miReloadFiles
394 // 395 //
395 this.miReloadFiles.Name = "miReloadFiles"; 396 this.miReloadFiles.Name = "miReloadFiles";
396 this.miReloadFiles.Size = new System.Drawing.Size(164, 22); 397 this.miReloadFiles.Size = new System.Drawing.Size(160, 22);
397 this.miReloadFiles.Text = "&reload files"; 398 this.miReloadFiles.Text = "&reload files";
398 this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click); 399 this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click);
399 // 400 //
400 // toolStripSeparator2 401 // toolStripSeparator2
401 // 402 //
402 this.toolStripSeparator2.Name = "toolStripSeparator2"; 403 this.toolStripSeparator2.Name = "toolStripSeparator2";
403 this.toolStripSeparator2.Size = new System.Drawing.Size(161, 6); 404 this.toolStripSeparator2.Size = new System.Drawing.Size(157, 6);
404 // 405 //
405 // miExit 406 // miExit
406 // 407 //
407 this.miExit.Name = "miExit"; 408 this.miExit.Name = "miExit";
408 this.miExit.Size = new System.Drawing.Size(164, 22); 409 this.miExit.Size = new System.Drawing.Size(160, 22);
409 this.miExit.Text = "e&xit"; 410 this.miExit.Text = "e&xit";
410 this.miExit.Click += new System.EventHandler(this.miExit_Click); 411 this.miExit.Click += new System.EventHandler(this.miExit_Click);
411 // 412 //
412 // menuEdit 413 // menuEdit
413 // 414 //
415 this.miUndo, 416 this.miUndo,
416 this.miRedo, 417 this.miRedo,
417 this.toolStripSeparator4, 418 this.toolStripSeparator4,
418 this.miPreferences}); 419 this.miPreferences});
419 this.menuEdit.Name = "menuEdit"; 420 this.menuEdit.Name = "menuEdit";
420 this.menuEdit.Size = new System.Drawing.Size(36, 20); 421 this.menuEdit.Size = new System.Drawing.Size(39, 20);
421 this.menuEdit.Text = "&edit"; 422 this.menuEdit.Text = "&edit";
422 // 423 //
423 // miUndo 424 // miUndo
424 // 425 //
425 this.miUndo.Enabled = false; 426 this.miUndo.Enabled = false;
426 this.miUndo.Name = "miUndo"; 427 this.miUndo.Name = "miUndo";
427 this.miUndo.Size = new System.Drawing.Size(142, 22); 428 this.miUndo.Size = new System.Drawing.Size(135, 22);
428 this.miUndo.Text = "&undo"; 429 this.miUndo.Text = "&undo";
429 this.miUndo.Click += new System.EventHandler(this.miUndo_Click); 430 this.miUndo.Click += new System.EventHandler(this.miUndo_Click);
430 // 431 //
431 // miRedo 432 // miRedo
432 // 433 //
433 this.miRedo.Enabled = false; 434 this.miRedo.Enabled = false;
434 this.miRedo.Name = "miRedo"; 435 this.miRedo.Name = "miRedo";
435 this.miRedo.Size = new System.Drawing.Size(142, 22); 436 this.miRedo.Size = new System.Drawing.Size(135, 22);
436 this.miRedo.Text = "&redo"; 437 this.miRedo.Text = "&redo";
437 this.miRedo.Click += new System.EventHandler(this.miRedo_Click); 438 this.miRedo.Click += new System.EventHandler(this.miRedo_Click);
438 // 439 //
439 // toolStripSeparator4 440 // toolStripSeparator4
440 // 441 //
441 this.toolStripSeparator4.Name = "toolStripSeparator4"; 442 this.toolStripSeparator4.Name = "toolStripSeparator4";
442 this.toolStripSeparator4.Size = new System.Drawing.Size(139, 6); 443 this.toolStripSeparator4.Size = new System.Drawing.Size(132, 6);
443 // 444 //
444 // miPreferences 445 // miPreferences
445 // 446 //
446 this.miPreferences.Name = "miPreferences"; 447 this.miPreferences.Name = "miPreferences";
447 this.miPreferences.Size = new System.Drawing.Size(142, 22); 448 this.miPreferences.Size = new System.Drawing.Size(135, 22);
448 this.miPreferences.Text = "&preferences"; 449 this.miPreferences.Text = "&preferences";
449 this.miPreferences.Click += new System.EventHandler(this.miPreferences_Click); 450 this.miPreferences.Click += new System.EventHandler(this.miPreferences_Click);
450 // 451 //
451 // menuHelp 452 // menuHelp
452 // 453 //
453 this.menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 454 this.menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
454 this.miAbout}); 455 this.miAbout});
455 this.menuHelp.Name = "menuHelp"; 456 this.menuHelp.Name = "menuHelp";
456 this.menuHelp.Size = new System.Drawing.Size(39, 20); 457 this.menuHelp.Size = new System.Drawing.Size(42, 20);
457 this.menuHelp.Text = "&help"; 458 this.menuHelp.Text = "&help";
458 // 459 //
459 // miAbout 460 // miAbout
460 // 461 //
461 this.miAbout.Name = "miAbout"; 462 this.miAbout.Name = "miAbout";
462 this.miAbout.Size = new System.Drawing.Size(109, 22); 463 this.miAbout.Size = new System.Drawing.Size(105, 22);
463 this.miAbout.Text = "&about"; 464 this.miAbout.Text = "&about";
464 this.miAbout.Click += new System.EventHandler(this.miAbout_Click); 465 this.miAbout.Click += new System.EventHandler(this.miAbout_Click);
465 // 466 //
466 // mainToolStrip 467 // mainToolStrip
467 // 468 //
473 this.toolStripSeparator3, 474 this.toolStripSeparator3,
474 this.bttnUndo, 475 this.bttnUndo,
475 this.bttnRedo}); 476 this.bttnRedo});
476 this.mainToolStrip.Location = new System.Drawing.Point(0, 24); 477 this.mainToolStrip.Location = new System.Drawing.Point(0, 24);
477 this.mainToolStrip.Name = "mainToolStrip"; 478 this.mainToolStrip.Name = "mainToolStrip";
478 this.mainToolStrip.Size = new System.Drawing.Size(182, 25); 479 this.mainToolStrip.Size = new System.Drawing.Size(151, 25);
479 this.mainToolStrip.TabIndex = 8; 480 this.mainToolStrip.TabIndex = 8;
480 // 481 //
481 // bttnNewArmy 482 // bttnNewArmy
482 // 483 //
483 this.bttnNewArmy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 484 this.bttnNewArmy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
554 this.sbErrorPanel, 555 this.sbErrorPanel,
555 this.sbPointsPanel}); 556 this.sbPointsPanel});
556 this.statusBar.ShowPanels = true; 557 this.statusBar.ShowPanels = true;
557 this.statusBar.Size = new System.Drawing.Size(790, 22); 558 this.statusBar.Size = new System.Drawing.Size(790, 22);
558 this.statusBar.TabIndex = 1; 559 this.statusBar.TabIndex = 1;
560 this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem);
559 this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick); 561 this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick);
560 this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem);
561 // 562 //
562 // sbMainPanel 563 // sbMainPanel
563 // 564 //
564 this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; 565 this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
565 this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText; 566 this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText;
1419 private void miPreferences_Click(object sender, EventArgs e) 1420 private void miPreferences_Click(object sender, EventArgs e)
1420 { 1421 {
1421 FrmPreferences prefsForm = new FrmPreferences(Preferences); 1422 FrmPreferences prefsForm = new FrmPreferences(Preferences);
1422 prefsForm.Show(this); 1423 prefsForm.Show(this);
1423 } 1424 }
1425
1426 private void miExportArmyAsBasicXml_Click(object sender, EventArgs e)
1427 {
1428 Form xmlOutput = new FrmXmlExport(CurrentArmy);
1429 xmlOutput.ShowDialog(this);
1430 }
1424 } 1431 }
1425 } 1432 }