annotate FrmMain.cs @ 207:ac5f87626abd

Basic XML translations
author Dan.Kulinski@dank-laptop.Global.Local
date Sun, 14 Aug 2011 14:38:06 -0600
parents 10ba2c5340b2
children 256f2f2f6e8c
rev   line source
dev@142 1 // This file (FrmMain.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard.
dev@142 2 //
dev@142 3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
dev@142 4
dev@142 5 using System;
dev@142 6 using System.Collections.Generic;
dev@142 7 using System.Drawing;
dev@142 8 using System.Drawing.Drawing2D;
dev@142 9 using System.ComponentModel;
dev@142 10 using System.Windows.Forms;
dev@142 11 using System.Data;
dev@142 12 using System.IO;
dev@142 13 using System.Threading;
dev@142 14 using log4net;
dev@142 15 using IBBoard;
dev@142 16 using IBBoard.CustomMath;
dev@142 17 using IBBoard.Commands;
dev@142 18 using IBBoard.IO;
dev@142 19 using IBBoard.Lang;
dev@142 20 using IBBoard.Windows.Forms;
dev@142 21 using IBBoard.Windows.Forms.I18N;
dev@142 22 using IBBoard.Xml;
dev@142 23 using IBBoard.WarFoundry.API;
dev@142 24 using IBBoard.WarFoundry.API.Commands;
dev@142 25 using IBBoard.WarFoundry.API.Exporters;
dev@142 26 using IBBoard.WarFoundry.API.Objects;
dev@196 27 using IBBoard.WarFoundry.API.Objects.Requirement;
snowblizz@190 28 using IBBoard.WarFoundry.API.Util;
dev@142 29 using IBBoard.WarFoundry.API.Savers;
dev@193 30 using IBBoard.WarFoundry.API.Savers.Xml;
dev@142 31 using IBBoard.WarFoundry.API.Factories;
dev@142 32 using IBBoard.WarFoundry.API.Factories.Xml;
dev@142 33
dev@142 34 namespace IBBoard.WarFoundry.GUI.WinForms
dev@142 35 {
dev@142 36 /// <summary>
dev@142 37 /// Summary description for Form1.
dev@142 38 /// </summary>
dev@142 39 public class FrmMain : System.Windows.Forms.Form
dev@142 40 {
dev@142 41 private static readonly string AppTitle = "WarFoundry";
dev@183 42 internal static readonly string VERSION = "0.1";
dev@142 43 const string DefaultDataDir = "data";
snowblizz@190 44 /* public static string pointsAbbrevSingle;
snowblizz@190 45 public static string pointsAbbrevPlural;
snowblizz@190 46 public static string pointsAbbreviation;
snowblizz@190 47 public static string pointsNameSingle;
snowblizz@190 48 public static string pointsNamePlural;
snowblizz@190 49 public static string pointsName;*/
dev@142 50
dev@142 51 private Preferences preferences;
dev@142 52 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain));
dev@142 53
dev@142 54 private CommandStack commandStack;
dev@142 55
dev@142 56 public ObjectAddDelegate UnitAddedMethod;
dev@142 57 public ObjectRemoveDelegate UnitRemovedMethod;
dev@142 58 public DoubleValChangedDelegate PointsValueChangedMethod;
dev@142 59 //public FailedUnitRequirementDelegate FailedUnitRequirementMethod;
dev@142 60
dev@142 61 private FrmArmyTree armyTree;
dev@142 62 private string loadedFilePath;
dev@142 63 private Dictionary<string, FrmUnit> unitWindows;
dev@142 64
dev@142 65 private System.ComponentModel.IContainer components;
dev@142 66 private System.Windows.Forms.OpenFileDialog openArmyDialog;
dev@142 67 private System.Windows.Forms.SaveFileDialog saveArmyDialog;
dev@142 68 private System.Windows.Forms.MainMenu mainMenu;
dev@142 69 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbMainPanel;
dev@142 70 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbErrorPanel;
dev@142 71 private IBBoard.Windows.Forms.ColorableStatusBarPanel sbPointsPanel;
dev@142 72 private System.Windows.Forms.ContextMenu undoMenu;
dev@142 73 private System.Windows.Forms.ContextMenu redoMenu;
dev@196 74 private IBBoard.Windows.Forms.ColorableStatusBar statusBar;
dev@142 75 private MenuStrip menuStrip;
dev@142 76 private IBBToolStripMenuItem menuFile;
dev@142 77 private IBBToolStripMenuItem miNewArmy;
dev@142 78 private IBBToolStripMenuItem miOpenArmy;
dev@142 79 private IBBToolStripMenuItem miSaveArmy;
dev@142 80 private IBBToolStripMenuItem miSaveArmyAs;
dev@142 81 private IBBToolStripMenuItem miExportArmyAs;
dev@142 82 private IBBToolStripMenuItem miExportArmyAsBasicHTML;
dev@142 83 private IBBToolStripMenuItem miCloseArmy;
dev@142 84 private ToolStripSeparator toolStripSeparator1;
dev@142 85 private IBBToolStripMenuItem miReloadFiles;
dev@142 86 private ToolStripSeparator toolStripSeparator2;
dev@142 87 private IBBToolStripMenuItem miExit;
dev@142 88 private IBBToolStripMenuItem menuEdit;
dev@142 89 private IBBToolStripMenuItem miUndo;
dev@142 90 private IBBToolStripMenuItem miRedo;
dev@142 91 private IBBToolStripMenuItem menuHelp;
dev@142 92 private ToolStrip mainToolStrip;
dev@142 93 private IBBToolStripButton bttnNewArmy;
dev@142 94 private IBBToolStripButton bttnOpenArmy;
dev@142 95 private IBBToolStripButton bttnSaveArmy;
dev@142 96 private ToolStripSeparator toolStripSeparator3;
dev@142 97 private IBBToolStripSplitButton bttnUndo;
dev@142 98 private IBBToolStripSplitButton bttnRedo;
dev@142 99 private ToolStrip catToolStrip;
dev@140 100 private ToolStripPanel toolStripPanel;
dev@140 101 private ToolStripSeparator toolStripSeparator4;
dev@142 102 private IBBToolStripMenuItem miPreferences;
Dan@207 103 private ToolStripMenuItem miExportArmyAsBasicXml;
dev@142 104 private IBBToolStripMenuItem miAbout;
dev@142 105
snowblizz@190 106
dev@142 107 /// <summary>
dev@142 108 /// The main entry point for the application.
dev@142 109 /// </summary>
dev@142 110 [STAThread]
dev@142 111 static void Main(string[] args)
dev@142 112 {
dev@142 113 try
dev@142 114 {
dev@142 115 LogManager.GetLogger(typeof(FrmMain)).Info("Starting WarFoundry WinForms");
dev@142 116 Application.EnableVisualStyles();
dev@142 117 Application.Run(new FrmMain(args));
dev@142 118 LogManager.GetLogger(typeof(FrmMain)).Info("Closing WarFoundry WinForms");
dev@142 119 }
dev@142 120 catch (Exception ex)
dev@142 121 {
dev@142 122 LogManager.GetLogger(typeof(FrmMain)).Fatal(ex);
dev@142 123 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);
dev@142 124 }
dev@142 125 }
dev@142 126
dev@142 127 public FrmMain(string[] args)
dev@142 128 {
dev@142 129 this.Closing+=new CancelEventHandler(FrmMain_Closing);
dev@142 130 CommandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated);
dev@142 131
dev@142 132 InitializeComponent();
dev@142 133 toolStripPanel.Join(mainToolStrip, 0, 0);
dev@142 134 toolStripPanel.Join(catToolStrip, mainToolStrip.Right, 0);
dev@142 135
dev@142 136 Preferences = new Preferences("WarFoundry");
dev@142 137 try
dev@142 138 {
dev@142 139 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString());
dev@142 140 }
dev@142 141 catch (TranslationLoadException ex)
dev@142 142 {
dev@142 143 log.Error("Translation loading failed for language " + Preferences["language"].ToString(), ex);
dev@142 144 MessageBox.Show(this, "Translation loading failed for language " + Preferences["language"].ToString(), "Translation failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@140 145 }
dev@140 146
dev@140 147 Translation.TranslationChanged += new MethodInvoker(TranslationChanged);
dev@140 148
dev@142 149 TranslateControls();
dev@142 150 unitWindows = new Dictionary<string, FrmUnit>();
dev@142 151
dev@142 152 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged);
dev@142 153 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged);
dev@142 154 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
dev@142 155 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
dev@142 156 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
dev@142 157 //FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(FrmMain_FailedUnitRequirement);
dev@142 158
snowblizz@190 159
dev@142 160 sbErrorPanel.Color = Color.Red;
snowblizz@190 161 SetPointsPanelToolTipText();
dev@142 162
dev@144 163 // hack to load default files
dev@144 164 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir));
dev@144 165 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
dev@142 166 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
dev@193 167 WarFoundrySaver.SetFileSaver(new WarFoundryXmlFileSaver());
dev@140 168 }
dev@140 169
dev@159 170 private FrmArmyTree GetArmyTree()
dev@159 171 {
dev@159 172 if (armyTree == null || armyTree.IsDisposed)
dev@159 173 {
dev@159 174 CreateArmyTree();
dev@159 175 }
dev@159 176
dev@159 177 return armyTree;
dev@159 178 }
dev@159 179
dev@159 180 private void CreateArmyTree()
dev@159 181 {
dev@159 182 armyTree = new FrmArmyTree(CommandStack);
dev@159 183 armyTree.MdiParent = this;
dev@159 184 armyTree.StartPosition = FormStartPosition.Manual;
dev@159 185 armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10);
dev@159 186 }
dev@159 187
dev@140 188 private void TranslateControls()
dev@140 189 {
dev@140 190 ControlTranslator.TranslateControls(Controls);
dev@140 191 ControlTranslator.TranslateComponents(components.Components);
dev@140 192 ControlTranslator.TranslateComponent(openArmyDialog);
dev@140 193 ControlTranslator.TranslateComponent(saveArmyDialog);
snowblizz@190 194 //translate pointspanel and tooltip
snowblizz@190 195 SetPointsPanelToolTipText();
snowblizz@190 196 SetPointsPanelText();
snowblizz@190 197 }
dev@140 198
dev@140 199 void TranslationChanged()
dev@140 200 {
dev@140 201 TranslateControls();
dev@142 202 }
dev@142 203
dev@142 204 public static string DataPath
dev@142 205 {
dev@142 206 get { return Constants.ExecutablePath+Constants.DirectoryChar+"data"; }
dev@142 207 }
dev@142 208
dev@142 209 public static String ArmiesPath
dev@142 210 {
dev@142 211 get { return Environment.GetFolderPath(Environment.SpecialFolder.Personal); }
dev@142 212 }
dev@142 213
dev@142 214 public Preferences Preferences
dev@142 215 {
dev@142 216 get { return preferences; }
dev@142 217 set { preferences = value; }
dev@142 218 }
dev@142 219
dev@142 220 public CommandStack CommandStack
dev@142 221 {
dev@142 222 get
dev@142 223 {
dev@142 224 if (commandStack == null)
dev@142 225 {
dev@142 226 commandStack = new CommandStack();
dev@142 227 }
dev@142 228
dev@142 229 return commandStack;
dev@142 230 }
dev@142 231 }
dev@142 232
dev@142 233 /// <summary>
dev@142 234 /// Clean up any resources being used.
dev@142 235 /// </summary>
dev@142 236 protected override void Dispose( bool disposing )
dev@142 237 {
dev@142 238 if( disposing )
dev@142 239 {
dev@142 240 if (components != null)
dev@142 241 {
dev@142 242 components.Dispose();
dev@142 243 }
dev@142 244 }
dev@142 245 base.Dispose( disposing );
dev@142 246 }
dev@142 247
dev@142 248 #region Windows Form Designer generated code
dev@142 249 /// <summary>
dev@142 250 /// Required method for Designer support - do not modify
dev@142 251 /// the contents of this method with the code editor.
dev@142 252 /// </summary>
dev@142 253 private void InitializeComponent()
dev@140 254 {
dev@196 255 this.components = new System.ComponentModel.Container();
dev@196 256 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain));
dev@196 257 this.undoMenu = new System.Windows.Forms.ContextMenu();
dev@196 258 this.redoMenu = new System.Windows.Forms.ContextMenu();
dev@196 259 this.mainMenu = new System.Windows.Forms.MainMenu(this.components);
dev@196 260 this.openArmyDialog = new System.Windows.Forms.OpenFileDialog();
dev@196 261 this.saveArmyDialog = new System.Windows.Forms.SaveFileDialog();
dev@196 262 this.menuStrip = new System.Windows.Forms.MenuStrip();
dev@196 263 this.menuFile = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 264 this.miNewArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 265 this.miOpenArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 266 this.miSaveArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 267 this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 268 this.miExportArmyAs = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 269 this.miExportArmyAsBasicHTML = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 270 this.miCloseArmy = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 271 this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
dev@196 272 this.miReloadFiles = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 273 this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
dev@196 274 this.miExit = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 275 this.menuEdit = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 276 this.miUndo = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 277 this.miRedo = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 278 this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
dev@196 279 this.miPreferences = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 280 this.menuHelp = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 281 this.miAbout = new IBBoard.Windows.Forms.IBBToolStripMenuItem();
dev@196 282 this.mainToolStrip = new System.Windows.Forms.ToolStrip();
dev@196 283 this.bttnNewArmy = new IBBoard.Windows.Forms.IBBToolStripButton();
dev@196 284 this.bttnOpenArmy = new IBBoard.Windows.Forms.IBBToolStripButton();
dev@196 285 this.bttnSaveArmy = new IBBoard.Windows.Forms.IBBToolStripButton();
dev@196 286 this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
dev@196 287 this.bttnUndo = new IBBoard.Windows.Forms.IBBToolStripSplitButton();
dev@196 288 this.bttnRedo = new IBBoard.Windows.Forms.IBBToolStripSplitButton();
dev@196 289 this.catToolStrip = new System.Windows.Forms.ToolStrip();
dev@196 290 this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar();
dev@196 291 this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel();
dev@196 292 this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel();
dev@196 293 this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel();
dev@196 294 this.toolStripPanel = new System.Windows.Forms.ToolStripPanel();
Dan@207 295 this.miExportArmyAsBasicXml = new System.Windows.Forms.ToolStripMenuItem();
dev@196 296 this.menuStrip.SuspendLayout();
dev@196 297 this.mainToolStrip.SuspendLayout();
dev@196 298 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit();
dev@196 299 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit();
dev@196 300 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit();
dev@196 301 this.SuspendLayout();
dev@196 302 //
dev@196 303 // saveArmyDialog
dev@196 304 //
dev@196 305 this.saveArmyDialog.Title = "Translatable:saveArmyDialog";
dev@196 306 //
dev@196 307 // menuStrip
dev@196 308 //
dev@196 309 this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
dev@140 310 this.menuFile,
dev@140 311 this.menuEdit,
dev@140 312 this.menuHelp});
dev@196 313 this.menuStrip.Location = new System.Drawing.Point(0, 0);
dev@196 314 this.menuStrip.Name = "menuStrip";
dev@196 315 this.menuStrip.Size = new System.Drawing.Size(790, 24);
dev@196 316 this.menuStrip.TabIndex = 6;
dev@196 317 this.menuStrip.Text = "menuStrip1";
dev@196 318 //
dev@196 319 // menuFile
dev@196 320 //
dev@196 321 this.menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
dev@140 322 this.miNewArmy,
dev@140 323 this.miOpenArmy,
dev@140 324 this.miSaveArmy,
dev@140 325 this.miSaveArmyAs,
dev@140 326 this.miExportArmyAs,
dev@140 327 this.miCloseArmy,
dev@140 328 this.toolStripSeparator1,
dev@140 329 this.miReloadFiles,
dev@140 330 this.toolStripSeparator2,
dev@140 331 this.miExit});
dev@196 332 this.menuFile.Name = "menuFile";
Dan@207 333 this.menuFile.Size = new System.Drawing.Size(35, 20);
dev@196 334 this.menuFile.Text = "&file";
dev@196 335 //
dev@196 336 // miNewArmy
dev@196 337 //
dev@196 338 this.miNewArmy.Name = "miNewArmy";
Dan@207 339 this.miNewArmy.Size = new System.Drawing.Size(160, 22);
dev@196 340 this.miNewArmy.Text = "&new army";
dev@196 341 this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click);
dev@196 342 //
dev@196 343 // miOpenArmy
dev@196 344 //
dev@196 345 this.miOpenArmy.Name = "miOpenArmy";
Dan@207 346 this.miOpenArmy.Size = new System.Drawing.Size(160, 22);
dev@196 347 this.miOpenArmy.Text = "&open army";
dev@196 348 this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click);
dev@196 349 //
dev@196 350 // miSaveArmy
dev@196 351 //
dev@196 352 this.miSaveArmy.Enabled = false;
dev@196 353 this.miSaveArmy.Name = "miSaveArmy";
Dan@207 354 this.miSaveArmy.Size = new System.Drawing.Size(160, 22);
dev@196 355 this.miSaveArmy.Text = "&save army";
dev@196 356 this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click);
dev@196 357 //
dev@196 358 // miSaveArmyAs
dev@196 359 //
dev@196 360 this.miSaveArmyAs.Enabled = false;
dev@196 361 this.miSaveArmyAs.Name = "miSaveArmyAs";
Dan@207 362 this.miSaveArmyAs.Size = new System.Drawing.Size(160, 22);
dev@196 363 this.miSaveArmyAs.Text = "save army &as...";
dev@196 364 this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click);
dev@196 365 //
dev@196 366 // miExportArmyAs
dev@196 367 //
dev@196 368 this.miExportArmyAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
Dan@207 369 this.miExportArmyAsBasicHTML,
Dan@207 370 this.miExportArmyAsBasicXml});
dev@196 371 this.miExportArmyAs.Enabled = false;
dev@196 372 this.miExportArmyAs.Name = "miExportArmyAs";
Dan@207 373 this.miExportArmyAs.Size = new System.Drawing.Size(160, 22);
dev@196 374 this.miExportArmyAs.Text = "export army as...";
dev@196 375 //
dev@196 376 // miExportArmyAsBasicHTML
dev@196 377 //
dev@196 378 this.miExportArmyAsBasicHTML.Name = "miExportArmyAsBasicHTML";
Dan@207 379 this.miExportArmyAsBasicHTML.Size = new System.Drawing.Size(152, 22);
dev@196 380 this.miExportArmyAsBasicHTML.Text = "&basic html";
dev@196 381 this.miExportArmyAsBasicHTML.Click += new System.EventHandler(this.miExportArmyAsBasicHTML_Click);
dev@196 382 //
dev@196 383 // miCloseArmy
dev@196 384 //
dev@196 385 this.miCloseArmy.Enabled = false;
dev@196 386 this.miCloseArmy.Name = "miCloseArmy";
Dan@207 387 this.miCloseArmy.Size = new System.Drawing.Size(160, 22);
dev@196 388 this.miCloseArmy.Text = "&close army";
dev@196 389 this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click);
dev@196 390 //
dev@196 391 // toolStripSeparator1
dev@196 392 //
dev@196 393 this.toolStripSeparator1.Name = "toolStripSeparator1";
Dan@207 394 this.toolStripSeparator1.Size = new System.Drawing.Size(157, 6);
dev@196 395 //
dev@196 396 // miReloadFiles
dev@196 397 //
dev@196 398 this.miReloadFiles.Name = "miReloadFiles";
Dan@207 399 this.miReloadFiles.Size = new System.Drawing.Size(160, 22);
dev@196 400 this.miReloadFiles.Text = "&reload files";
dev@196 401 this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click);
dev@196 402 //
dev@196 403 // toolStripSeparator2
dev@196 404 //
dev@196 405 this.toolStripSeparator2.Name = "toolStripSeparator2";
Dan@207 406 this.toolStripSeparator2.Size = new System.Drawing.Size(157, 6);
dev@196 407 //
dev@196 408 // miExit
dev@196 409 //
dev@196 410 this.miExit.Name = "miExit";
Dan@207 411 this.miExit.Size = new System.Drawing.Size(160, 22);
dev@196 412 this.miExit.Text = "e&xit";
dev@196 413 this.miExit.Click += new System.EventHandler(this.miExit_Click);
dev@196 414 //
dev@196 415 // menuEdit
dev@196 416 //
dev@196 417 this.menuEdit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
dev@140 418 this.miUndo,
dev@140 419 this.miRedo,
dev@140 420 this.toolStripSeparator4,
dev@140 421 this.miPreferences});
dev@196 422 this.menuEdit.Name = "menuEdit";
Dan@207 423 this.menuEdit.Size = new System.Drawing.Size(39, 20);
dev@196 424 this.menuEdit.Text = "&edit";
dev@196 425 //
dev@196 426 // miUndo
dev@196 427 //
dev@196 428 this.miUndo.Enabled = false;
dev@196 429 this.miUndo.Name = "miUndo";
Dan@207 430 this.miUndo.Size = new System.Drawing.Size(135, 22);
dev@196 431 this.miUndo.Text = "&undo";
dev@196 432 this.miUndo.Click += new System.EventHandler(this.miUndo_Click);
dev@196 433 //
dev@196 434 // miRedo
dev@196 435 //
dev@196 436 this.miRedo.Enabled = false;
dev@196 437 this.miRedo.Name = "miRedo";
Dan@207 438 this.miRedo.Size = new System.Drawing.Size(135, 22);
dev@196 439 this.miRedo.Text = "&redo";
dev@196 440 this.miRedo.Click += new System.EventHandler(this.miRedo_Click);
dev@196 441 //
dev@196 442 // toolStripSeparator4
dev@196 443 //
dev@196 444 this.toolStripSeparator4.Name = "toolStripSeparator4";
Dan@207 445 this.toolStripSeparator4.Size = new System.Drawing.Size(132, 6);
dev@196 446 //
dev@196 447 // miPreferences
dev@196 448 //
dev@196 449 this.miPreferences.Name = "miPreferences";
Dan@207 450 this.miPreferences.Size = new System.Drawing.Size(135, 22);
dev@196 451 this.miPreferences.Text = "&preferences";
dev@196 452 this.miPreferences.Click += new System.EventHandler(this.miPreferences_Click);
dev@196 453 //
dev@196 454 // menuHelp
dev@196 455 //
dev@196 456 this.menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
dev@140 457 this.miAbout});
dev@196 458 this.menuHelp.Name = "menuHelp";
Dan@207 459 this.menuHelp.Size = new System.Drawing.Size(42, 20);
dev@196 460 this.menuHelp.Text = "&help";
dev@196 461 //
dev@196 462 // miAbout
dev@196 463 //
dev@196 464 this.miAbout.Name = "miAbout";
Dan@207 465 this.miAbout.Size = new System.Drawing.Size(105, 22);
dev@196 466 this.miAbout.Text = "&about";
dev@196 467 this.miAbout.Click += new System.EventHandler(this.miAbout_Click);
dev@196 468 //
dev@196 469 // mainToolStrip
dev@196 470 //
dev@196 471 this.mainToolStrip.Dock = System.Windows.Forms.DockStyle.None;
dev@196 472 this.mainToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
dev@140 473 this.bttnNewArmy,
dev@140 474 this.bttnOpenArmy,
dev@140 475 this.bttnSaveArmy,
dev@140 476 this.toolStripSeparator3,
dev@140 477 this.bttnUndo,
dev@140 478 this.bttnRedo});
dev@196 479 this.mainToolStrip.Location = new System.Drawing.Point(0, 24);
dev@196 480 this.mainToolStrip.Name = "mainToolStrip";
Dan@207 481 this.mainToolStrip.Size = new System.Drawing.Size(151, 25);
dev@196 482 this.mainToolStrip.TabIndex = 8;
dev@196 483 //
dev@196 484 // bttnNewArmy
dev@196 485 //
dev@196 486 this.bttnNewArmy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
dev@196 487 this.bttnNewArmy.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.document_new;
dev@196 488 this.bttnNewArmy.ImageTransparentColor = System.Drawing.Color.Magenta;
dev@196 489 this.bttnNewArmy.Name = "bttnNewArmy";
dev@196 490 this.bttnNewArmy.Size = new System.Drawing.Size(23, 22);
dev@196 491 this.bttnNewArmy.Text = "new army";
dev@196 492 this.bttnNewArmy.Click += new System.EventHandler(this.miNewArmy_Click);
dev@196 493 //
dev@196 494 // bttnOpenArmy
dev@196 495 //
dev@196 496 this.bttnOpenArmy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
dev@196 497 this.bttnOpenArmy.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.document_open;
dev@196 498 this.bttnOpenArmy.ImageTransparentColor = System.Drawing.Color.Magenta;
dev@196 499 this.bttnOpenArmy.Name = "bttnOpenArmy";
dev@196 500 this.bttnOpenArmy.Size = new System.Drawing.Size(23, 22);
dev@196 501 this.bttnOpenArmy.Text = "open army";
dev@196 502 this.bttnOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click);
dev@196 503 //
dev@196 504 // bttnSaveArmy
dev@196 505 //
dev@196 506 this.bttnSaveArmy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
dev@196 507 this.bttnSaveArmy.Enabled = false;
dev@196 508 this.bttnSaveArmy.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.document_save;
dev@196 509 this.bttnSaveArmy.ImageTransparentColor = System.Drawing.Color.Magenta;
dev@196 510 this.bttnSaveArmy.Name = "bttnSaveArmy";
dev@196 511 this.bttnSaveArmy.Size = new System.Drawing.Size(23, 22);
dev@196 512 this.bttnSaveArmy.Text = "save army";
dev@196 513 this.bttnSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click);
dev@196 514 //
dev@196 515 // toolStripSeparator3
dev@196 516 //
dev@196 517 this.toolStripSeparator3.Name = "toolStripSeparator3";
dev@196 518 this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
dev@196 519 //
dev@196 520 // bttnUndo
dev@196 521 //
dev@196 522 this.bttnUndo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
dev@196 523 this.bttnUndo.Enabled = false;
dev@196 524 this.bttnUndo.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.edit_undo;
dev@196 525 this.bttnUndo.ImageTransparentColor = System.Drawing.Color.Magenta;
dev@196 526 this.bttnUndo.Name = "bttnUndo";
dev@196 527 this.bttnUndo.Size = new System.Drawing.Size(32, 22);
dev@196 528 this.bttnUndo.Text = "undo";
dev@196 529 this.bttnUndo.ButtonClick += new System.EventHandler(this.miUndo_Click);
dev@196 530 //
dev@196 531 // bttnRedo
dev@196 532 //
dev@196 533 this.bttnRedo.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
dev@196 534 this.bttnRedo.Enabled = false;
dev@196 535 this.bttnRedo.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.edit_redo;
dev@196 536 this.bttnRedo.ImageTransparentColor = System.Drawing.Color.Magenta;
dev@196 537 this.bttnRedo.Name = "bttnRedo";
dev@196 538 this.bttnRedo.Size = new System.Drawing.Size(32, 22);
dev@196 539 this.bttnRedo.Text = "redo";
dev@196 540 this.bttnRedo.ButtonClick += new System.EventHandler(this.miRedo_Click);
dev@196 541 //
dev@196 542 // catToolStrip
dev@196 543 //
dev@196 544 this.catToolStrip.Dock = System.Windows.Forms.DockStyle.None;
dev@196 545 this.catToolStrip.Location = new System.Drawing.Point(161, 24);
dev@196 546 this.catToolStrip.Name = "catToolStrip";
dev@196 547 this.catToolStrip.Size = new System.Drawing.Size(111, 25);
dev@196 548 this.catToolStrip.TabIndex = 9;
dev@196 549 this.catToolStrip.Visible = false;
dev@196 550 //
dev@196 551 // statusBar
dev@196 552 //
dev@196 553 this.statusBar.Location = new System.Drawing.Point(0, 586);
dev@196 554 this.statusBar.Name = "statusBar";
dev@196 555 this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
dev@140 556 this.sbMainPanel,
dev@140 557 this.sbErrorPanel,
dev@140 558 this.sbPointsPanel});
dev@196 559 this.statusBar.ShowPanels = true;
dev@196 560 this.statusBar.Size = new System.Drawing.Size(790, 22);
dev@196 561 this.statusBar.TabIndex = 1;
Dan@207 562 this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem);
dev@196 563 this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick);
dev@196 564 //
dev@196 565 // sbMainPanel
dev@196 566 //
dev@196 567 this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
dev@196 568 this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText;
dev@196 569 this.sbMainPanel.Name = "sbMainPanel";
dev@196 570 this.sbMainPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw;
dev@196 571 this.sbMainPanel.Width = 473;
dev@196 572 //
dev@196 573 // sbErrorPanel
dev@196 574 //
dev@196 575 this.sbErrorPanel.Color = System.Drawing.SystemColors.WindowText;
dev@196 576 this.sbErrorPanel.Name = "sbErrorPanel";
dev@196 577 this.sbErrorPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw;
dev@196 578 this.sbErrorPanel.Width = 150;
dev@196 579 //
dev@196 580 // sbPointsPanel
dev@196 581 //
dev@196 582 this.sbPointsPanel.Color = System.Drawing.SystemColors.WindowText;
dev@196 583 this.sbPointsPanel.Name = "sbPointsPanel";
dev@196 584 this.sbPointsPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw;
dev@196 585 this.sbPointsPanel.ToolTipText = "current points total";
dev@196 586 this.sbPointsPanel.Width = 150;
dev@196 587 //
dev@196 588 // toolStripPanel
dev@196 589 //
dev@196 590 this.toolStripPanel.Dock = System.Windows.Forms.DockStyle.Top;
dev@196 591 this.toolStripPanel.Location = new System.Drawing.Point(0, 24);
dev@196 592 this.toolStripPanel.Name = "toolStripPanel";
dev@196 593 this.toolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
dev@196 594 this.toolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
dev@196 595 this.toolStripPanel.Size = new System.Drawing.Size(790, 0);
dev@196 596 //
Dan@207 597 // miExportArmyAsBasicXml
Dan@207 598 //
Dan@207 599 this.miExportArmyAsBasicXml.Name = "miExportArmyAsBasicXml";
Dan@207 600 this.miExportArmyAsBasicXml.Size = new System.Drawing.Size(152, 22);
Dan@207 601 this.miExportArmyAsBasicXml.Text = "basic xm&l";
Dan@207 602 this.miExportArmyAsBasicXml.Click += new System.EventHandler(this.miExportArmyAsBasicXml_Click);
Dan@207 603 //
dev@196 604 // FrmMain
dev@196 605 //
dev@196 606 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
dev@196 607 this.ClientSize = new System.Drawing.Size(790, 608);
dev@196 608 this.Controls.Add(this.mainToolStrip);
dev@196 609 this.Controls.Add(this.toolStripPanel);
dev@196 610 this.Controls.Add(this.statusBar);
dev@196 611 this.Controls.Add(this.catToolStrip);
dev@196 612 this.Controls.Add(this.menuStrip);
dev@196 613 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
dev@196 614 this.IsMdiContainer = true;
dev@196 615 this.MainMenuStrip = this.menuStrip;
dev@196 616 this.Menu = this.mainMenu;
dev@196 617 this.Name = "FrmMain";
dev@196 618 this.Text = "WarFoundry";
dev@196 619 this.Load += new System.EventHandler(this.FrmMain_Load);
dev@196 620 this.menuStrip.ResumeLayout(false);
dev@196 621 this.menuStrip.PerformLayout();
dev@196 622 this.mainToolStrip.ResumeLayout(false);
dev@196 623 this.mainToolStrip.PerformLayout();
dev@196 624 ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit();
dev@196 625 ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit();
dev@196 626 ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit();
dev@196 627 this.ResumeLayout(false);
dev@196 628 this.PerformLayout();
dev@140 629
dev@142 630 }
dev@142 631 #endregion
dev@142 632
dev@142 633 private void FileLoadingFinished(List<FileLoadFailure> failures)
dev@142 634 {
dev@142 635 foreach (FileLoadFailure failure in failures)
dev@142 636 {
dev@142 637 log.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
dev@142 638 }
dev@142 639 }
dev@142 640
dev@142 641 private void miExit_Click(object sender, System.EventArgs e)
dev@142 642 {
dev@142 643 Application.Exit();
dev@142 644 }
dev@142 645
dev@142 646 private void miNewArmy_Click(object sender, System.EventArgs e)
dev@142 647 {
dev@142 648 CreateNewArmy();
dev@142 649 }
dev@142 650
dev@142 651 private void CreateNewArmy()
dev@142 652 {
dev@142 653 if (CloseCurrentArmy())
dev@142 654 {
dev@142 655 FrmNewArmy newArmy = new FrmNewArmy(CurrentGameSystem);
dev@142 656 DialogResult dr = newArmy.ShowDialog();
dev@142 657
dev@142 658 if (dr == DialogResult.OK)
dev@142 659 {
dev@142 660 try
dev@142 661 {
dev@142 662 CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize);
dev@142 663 }
dev@142 664 catch (RequiredDataMissingException ex)
dev@142 665 {
dev@142 666 log.Error("Required data missing from race file", ex);
dev@142 667 MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidRaceFileBoxTitle", "invalid race file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@142 668 }
dev@142 669 catch (InvalidFileException ex)
dev@142 670 {
dev@142 671 log.Error("Race file was invalid", ex);
dev@142 672 MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidRaceFileBoxTitle", "invalid race file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@142 673 }
dev@142 674 }
dev@142 675 }
dev@142 676 }
dev@142 677
dev@142 678 private bool OpenArmy()
dev@142 679 {
dev@142 680 if (openArmyDialog.Filter=="")
dev@142 681 {
dev@142 682 string savePath = ArmiesPath;
dev@142 683
dev@142 684 if (!Directory.Exists(savePath))
dev@142 685 {
dev@142 686 Directory.CreateDirectory(savePath);
dev@142 687 }
dev@142 688
dev@142 689 openArmyDialog.InitialDirectory = savePath;
dev@142 690 openArmyDialog.Filter = Translation.GetTranslation("armyFileFilter")+"|*.army";
dev@142 691 openArmyDialog.Title = Translation.GetTranslation("openArmyDialog");
dev@142 692
dev@142 693 }
dev@142 694
dev@142 695 DialogResult dr = openArmyDialog.ShowDialog(this);
dev@142 696
dev@142 697 if (dr == DialogResult.OK)
dev@142 698 {
dev@142 699 if (CloseCurrentArmy())
dev@142 700 {
dev@142 701 try
dev@142 702 {
dev@142 703 string newFilePath = openArmyDialog.FileName;
dev@142 704 CurrentArmy = WarFoundryLoader.GetDefault().LoadArmy(new FileInfo(newFilePath));
dev@142 705 loadedFilePath = newFilePath;
dev@142 706 return true;
dev@142 707 }
dev@142 708 catch (RequiredDataMissingException ex)
dev@142 709 {
dev@142 710 log.Error(ex);
dev@142 711 MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidArmyFileBoxTitle", "invalid army file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@142 712 return false;
dev@142 713 }
dev@142 714 catch (InvalidFileException ex)
dev@142 715 {
dev@142 716 log.Error(ex);
dev@142 717 MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidArmyFileBoxTitle", "invalid army file"), MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@142 718 return false;
dev@142 719 }
dev@142 720 }
dev@142 721 else
dev@142 722 {
dev@142 723 return false;
dev@142 724 }
dev@142 725 }
dev@142 726 else
dev@142 727 {
dev@142 728 return false;
dev@142 729 }
dev@142 730 }
dev@142 731
dev@142 732 private bool CloseCurrentArmy()
dev@142 733 {
dev@142 734 if (CurrentArmy!=null)
dev@142 735 {
dev@142 736 bool canClose = false;
dev@142 737
dev@142 738 if (CommandStack.IsDirty())
dev@142 739 {
dev@142 740 string saveChanges = Translation.GetTranslation("SaveChangesQuestion", "the army \"{0}\" has been modified\r\nsave changes before closing army?", CurrentArmy.Name);
dev@142 741 string saveChangesTitle = Translation.GetTranslation("SaveChangesTitle", "unsaved changes");
dev@142 742 DialogResult dr = MessageBox.Show(this, saveChanges, saveChangesTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3);
dev@142 743
dev@142 744 if (dr == DialogResult.Yes)
dev@142 745 {
dev@142 746 canClose = SaveCurrentArmy();
dev@142 747 }
dev@142 748 else if (dr == DialogResult.No)
dev@142 749 {
dev@142 750 canClose = true;
dev@142 751 }
dev@142 752 //else they said cancel and we default to "canClose = false" so do nothing
dev@142 753 }
dev@142 754 else
dev@142 755 {
dev@142 756 canClose = true;
dev@142 757 }
dev@142 758
dev@142 759 if (canClose)
dev@142 760 {
dev@142 761 //do close
dev@142 762 DisableCategoryButtons();
dev@142 763 CurrentArmy = null;
dev@142 764 return true;
dev@142 765 }
dev@142 766 else
dev@142 767 {
dev@142 768 return false;
dev@142 769 }
dev@142 770 }
dev@142 771 else
dev@142 772 {
dev@142 773 DisableCategoryButtons();
dev@142 774 //pretend we succeeded
dev@142 775 return true;
dev@142 776 }
dev@142 777 }
dev@142 778
dev@142 779 private void UndoLastAction()
dev@142 780 {
dev@142 781 if (commandStack.CanUndo())
dev@142 782 {
dev@142 783 commandStack.Undo();
dev@142 784 }
dev@142 785 }
dev@142 786
dev@142 787 private void RedoAction()
dev@142 788 {
dev@142 789 if (commandStack.CanRedo())
dev@142 790 {
dev@142 791 commandStack.Redo();
dev@142 792 }
dev@142 793 }
dev@142 794
dev@142 795 private bool SaveCurrentArmy()
dev@142 796 {
dev@142 797 bool saved = false;
dev@142 798
dev@142 799 string filePath = loadedFilePath;
dev@142 800
dev@142 801 if (filePath == null)
dev@142 802 {
dev@142 803 filePath = PromptForArmyFilePath();
dev@142 804 }
dev@142 805
dev@142 806 if (filePath != null)
dev@142 807 {
dev@142 808 saved = SaveCurrentArmyToFile(filePath);
dev@142 809 }
dev@142 810
dev@142 811 return saved;
dev@142 812 }
dev@142 813
dev@142 814 private bool SaveCurrentArmyAs()
dev@142 815 {
dev@142 816 bool saved = false;
dev@142 817 string filePath = PromptForArmyFilePath();
dev@142 818
dev@142 819 if (filePath != null)
dev@142 820 {
dev@142 821 saved = SaveCurrentArmyToFile(filePath);
dev@142 822 }
dev@142 823
dev@142 824 return saved;
dev@142 825 }
dev@142 826
dev@142 827 private bool SaveCurrentArmyToFile(string filePath)
dev@142 828 {
dev@193 829 if (WarFoundrySaver.GetSaver().Save(filePath, CurrentArmy))
dev@142 830 {
dev@142 831 loadedFilePath = filePath;
dev@142 832 miSaveArmy.Enabled = false;
dev@142 833 bttnSaveArmy.Enabled = false;
dev@142 834 CommandStack.setCleanMark();
dev@142 835 return true;
dev@142 836 }
dev@142 837 else
dev@142 838 {
dev@142 839 MessageBox.Show(this, Translation.GetTranslation("SaveFailed", "file save failed - check log for details"), Translation.GetTranslation("SaveFailedTitle", "file save failed"), MessageBoxButtons.OK, MessageBoxIcon.Error);
dev@142 840 return false;
dev@142 841 }
dev@142 842 }
dev@142 843
dev@142 844 private string PromptForArmyFilePath()
dev@142 845 {
dev@142 846 if (saveArmyDialog.Filter == "")
dev@142 847 {
dev@142 848 string savePath = ArmiesPath;
dev@142 849
dev@142 850 if (!Directory.Exists(savePath))
dev@142 851 {
dev@142 852 Directory.CreateDirectory(savePath);
dev@142 853 }
dev@142 854
dev@142 855 saveArmyDialog.InitialDirectory = savePath;
dev@142 856 saveArmyDialog.Filter = Translation.GetTranslation("armyFileFilter")+"|*.army";
dev@142 857 saveArmyDialog.Title = Translation.GetTranslation("saveArmyDialog");
dev@142 858 }
dev@142 859
dev@142 860 DialogResult dr = saveArmyDialog.ShowDialog(this);
dev@142 861
dev@142 862 if (dr == DialogResult.OK)
dev@142 863 {
dev@142 864 return saveArmyDialog.FileName;
dev@142 865 }
dev@142 866 else
dev@142 867 {
dev@142 868 return null;
dev@142 869 }
dev@142 870 }
dev@142 871
dev@142 872 public GameSystem CurrentGameSystem
dev@142 873 {
dev@142 874 get { return WarFoundryCore.CurrentGameSystem; }
dev@142 875 set { WarFoundryCore.CurrentGameSystem = value; }
dev@142 876 }
dev@142 877
dev@142 878 public Army CurrentArmy
dev@142 879 {
dev@142 880 get { return WarFoundryCore.CurrentArmy; }
dev@142 881 set { SetArmy(value); }
dev@142 882 }
dev@142 883
dev@142 884 private void FrmMain_GameSystemChanged(GameSystem oldSystem, GameSystem newSystem)
dev@142 885 {
dev@142 886 SetAppTitle();
dev@195 887
dev@195 888 if (newSystem == null)
dev@195 889 {
dev@195 890 Preferences["currSystem"] = "";
dev@195 891 }
dev@195 892 else
dev@195 893 {
dev@195 894 Preferences["currSystem"] = newSystem.ID;
dev@195 895 }
dev@195 896
dev@195 897 Preferences.Save();
dev@142 898 RemoveCategoryButtons();
dev@142 899 }
dev@142 900
dev@142 901 private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy)
dev@142 902 {
dev@142 903 CommandStack.Reset();
dev@142 904 loadedFilePath = null;
dev@142 905 miSaveArmy.Enabled = false;
dev@142 906 bttnSaveArmy.Enabled = false;
dev@196 907 //TODO: Subscribe to an "army changed" event here
dev@142 908 SetPointsPanelText();
dev@142 909 SetAppTitle();
dev@142 910 }
dev@142 911
dev@142 912 private void SetArmy(Army newArmy)
dev@142 913 {
dev@142 914 IgnoreArmy(CurrentArmy);
dev@142 915 CloseAllUnitWindows();
dev@142 916
dev@142 917 if (newArmy == null)
dev@142 918 {
dev@142 919 SetNullArmyState();
dev@142 920 }
dev@142 921 else
dev@142 922 {
dev@142 923 WarFoundryCore.CurrentGameSystem = newArmy.GameSystem;
dev@142 924 ListenToArmy(newArmy);
dev@142 925 SetNonNullArmyState(newArmy);
dev@142 926 }
dev@142 927
dev@142 928 WarFoundryCore.CurrentArmy = newArmy;
dev@142 929 }
dev@142 930
dev@142 931 private void IgnoreArmy(Army oldArmy)
dev@142 932 {
dev@142 933 if (oldArmy != null)
dev@142 934 {
dev@142 935 oldArmy.UnitAdded -= UnitAddedMethod;
dev@142 936 oldArmy.UnitRemoved -= UnitRemovedMethod;
dev@142 937 oldArmy.PointsValueChanged -= PointsValueChangedMethod;
dev@142 938 }
dev@142 939 }
dev@142 940
dev@142 941 private void CloseAllUnitWindows()
dev@142 942 {
dev@142 943 FrmUnit[] unitForms = DictionaryUtils.ToArray(unitWindows);
dev@142 944
dev@142 945 foreach (FrmUnit window in unitForms)
dev@142 946 {
dev@142 947 window.Close();
dev@142 948 }
dev@142 949
dev@142 950 unitWindows.Clear();
dev@142 951 }
dev@142 952
dev@142 953 private void ListenToArmy(Army newArmy)
dev@142 954 {
dev@142 955 if (newArmy != null)
dev@142 956 {
dev@142 957 newArmy.UnitAdded += UnitAddedMethod;
dev@142 958 newArmy.UnitRemoved += UnitRemovedMethod;
dev@142 959 newArmy.PointsValueChanged += PointsValueChangedMethod;
dev@142 960 }
dev@142 961 }
dev@142 962
dev@142 963 private void SetNullArmyState()
dev@142 964 {
dev@142 965 miSaveArmyAs.Enabled = false;
dev@142 966 miCloseArmy.Enabled = false;
dev@142 967 miExportArmyAs.Enabled = false;
dev@142 968 DisableCategoryButtons();
dev@159 969 GetArmyTree().Hide();
dev@142 970 }
dev@142 971
dev@142 972 private void SetNonNullArmyState(Army newArmy)
dev@142 973 {
dev@142 974 SetCategoryButtons(newArmy.Race.Categories);
dev@142 975 EnableCategoryButtons();
dev@142 976 miSaveArmyAs.Enabled = true;
dev@142 977 miCloseArmy.Enabled = true;
dev@142 978 miExportArmyAs.Enabled = true;
dev@159 979 GetArmyTree().Show();
dev@142 980 }
dev@142 981
dev@142 982 private void SetCategoryButtons(Category[] cats)
dev@142 983 {
dev@142 984 if (CategoryButtonsHaveChanged(cats))
dev@142 985 {
dev@142 986 RemoveCategoryButtons();
dev@142 987 AddCategoryButtons(cats);
dev@142 988 }
dev@142 989 }
dev@142 990
dev@142 991 private bool CategoryButtonsHaveChanged(Category[] cats)
dev@142 992 {
dev@142 993 int catCount = cats.Length;
dev@142 994 ToolStripItemCollection items = catToolStrip.Items;
dev@142 995 bool haveChanged = (!catToolStrip.Visible || catCount != items.Count);
dev@142 996
dev@142 997 if (!haveChanged)
dev@142 998 {
dev@142 999 for (int i = 0; i < catCount; i++)
dev@142 1000 {
dev@142 1001 if (cats[i].Equals(items[i+1].Tag))
dev@142 1002 {
dev@142 1003 haveChanged = true;
dev@142 1004 break;
dev@142 1005 }
dev@142 1006 }
dev@142 1007 }
dev@142 1008
dev@142 1009 return haveChanged;
dev@142 1010 }
dev@142 1011
dev@142 1012 private void RemoveCategoryButtons()
dev@142 1013 {
dev@142 1014 this.Invoke(new MethodInvoker(catToolStrip.Items.Clear));
dev@142 1015 }
dev@142 1016
dev@142 1017 private void AddCategoryButtons(Category[] cats)
dev@142 1018 {
dev@142 1019 int catCount = cats.Length;
dev@142 1020 Category cat;
dev@142 1021 IBBToolStripButton[] categoryButtons = new IBBToolStripButton[catCount];
dev@142 1022
dev@142 1023 for (int i = 0; i < catCount; i++)
dev@142 1024 {
dev@142 1025 cat = cats[i];
dev@142 1026 IBBToolStripButton button = new IBBToolStripButton();
dev@142 1027 button.Text = cat.Name;
dev@142 1028 button.Tag = cat;
dev@142 1029 button.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.list_add;
dev@142 1030 button.Enabled = false;
dev@142 1031 button.Click += new EventHandler(CreateUnitForCategoryButtonClick);
dev@142 1032 categoryButtons[i] = button;
dev@146 1033 }
dev@146 1034
dev@146 1035 this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(AddCatToolStripButtons), new object[] { categoryButtons });
dev@146 1036 }
dev@146 1037
dev@146 1038 private void AddCatToolStripButtons(IBBToolStripButton[] buttons)
dev@146 1039 {
dev@146 1040 log.Debug("Toolstrip width: " + catToolStrip.Width);
dev@146 1041 catToolStrip.Items.AddRange(buttons);
dev@146 1042 catToolStrip.Refresh();
dev@146 1043 int buttonWidths = 0;
dev@146 1044
dev@146 1045 foreach (IBBToolStripButton button in buttons)
dev@146 1046 {
dev@142 1047 buttonWidths += button.Width;
dev@142 1048 }
dev@146 1049 catToolStrip.Width = buttonWidths;
dev@146 1050 log.Debug("Button widths: " + buttonWidths);
dev@142 1051 log.Debug("Toolstrip width: " + catToolStrip.Width);
dev@142 1052 }
dev@142 1053
dev@142 1054 private void CreateUnitForCategoryButtonClick(object sender, EventArgs e)
dev@142 1055 {
dev@142 1056 if (sender is IBBToolStripButton)
dev@142 1057 {
dev@142 1058 IBBToolStripButton button = (IBBToolStripButton)sender;
dev@142 1059 object tag = button.Tag;
dev@142 1060
dev@142 1061 if (tag is Category)
dev@142 1062 {
dev@142 1063 AddUnitFromCategory((Category)tag);
dev@142 1064 }
dev@142 1065 }
dev@142 1066 }
dev@142 1067
dev@142 1068 private void EnableCategoryButtons()
dev@142 1069 {
dev@142 1070 catToolStrip.Visible = true;
dev@142 1071 SetCategoryButtonState(true);
dev@142 1072 }
dev@142 1073
dev@142 1074 private void DisableCategoryButtons()
dev@142 1075 {
dev@142 1076 catToolStrip.Visible = false;
dev@142 1077 SetCategoryButtonState(false);
dev@142 1078 }
dev@142 1079
dev@142 1080 private void SetCategoryButtonState(bool state)
dev@142 1081 {
dev@142 1082 foreach (IBBToolStripButton button in catToolStrip.Items)
dev@142 1083 {
dev@142 1084 button.Enabled = state;
dev@142 1085 }
dev@142 1086 }
dev@142 1087
dev@142 1088 private void miSaveArmyAs_Click(object sender, System.EventArgs e)
dev@142 1089 {
dev@142 1090 SaveCurrentArmyAs();
dev@142 1091 }
dev@142 1092
dev@142 1093 private void commandStack_CommandStackUpdated()
dev@142 1094 {
dev@142 1095 bttnUndo.Enabled = commandStack.CanUndo();
dev@142 1096 miUndo.Enabled = bttnUndo.Enabled;
dev@142 1097 bttnRedo.Enabled = commandStack.CanRedo();
dev@142 1098 miRedo.Enabled = bttnRedo.Enabled;
dev@142 1099
dev@142 1100 PopulateRedoMenu();
dev@142 1101 PopulateUndoMenu();
dev@142 1102
dev@142 1103 bttnSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null;
dev@142 1104 miSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null;
dev@142 1105 }
dev@142 1106
dev@142 1107 private void PopulateRedoMenu()
dev@142 1108 {
dev@142 1109 int redoLength = commandStack.RedoLength;
dev@142 1110 int maxRedo = Math.Min(10, redoLength);
dev@142 1111 ToolStripItemCollection dropDownItems = bttnRedo.DropDownItems;
dev@142 1112 dropDownItems.Clear();
dev@142 1113
dev@142 1114 for (int i = 1; i <= maxRedo; i++)
dev@142 1115 {
dev@142 1116 Command cmd = commandStack.PeekRedoCommand(i);
dev@142 1117
dev@142 1118 if (cmd == null)
dev@142 1119 {
dev@142 1120 break;
dev@142 1121 }
dev@142 1122
dev@142 1123 dropDownItems.Add(cmd.Description, null, redoMenu_Click);
dev@142 1124 }
dev@142 1125
dev@142 1126 if (redoLength > 0)
dev@142 1127 {
dev@142 1128 bttnRedo.Text = commandStack.PeekRedoCommand(1).Description;
dev@142 1129 }
dev@142 1130 else
dev@142 1131 {
dev@142 1132 bttnRedo.Text = Translation.GetTranslation("bttnRedo");
dev@142 1133 }
dev@142 1134 }
dev@142 1135
dev@142 1136 private void PopulateUndoMenu()
dev@142 1137 {
dev@142 1138 int undoLength = commandStack.UndoLength;
dev@142 1139 int maxUndo = Math.Min(10, undoLength);
dev@142 1140 ToolStripItemCollection dropDownItems = bttnUndo.DropDownItems;
dev@142 1141 dropDownItems.Clear();
dev@142 1142
dev@142 1143 for (int i = 1; i <= maxUndo; i++)
dev@142 1144 {
dev@142 1145 Command cmd = commandStack.PeekUndoCommand(i);
dev@142 1146
dev@142 1147 if (cmd == null)
dev@142 1148 {
dev@142 1149 break;
dev@142 1150 }
dev@142 1151
dev@142 1152 dropDownItems.Add(cmd.UndoDescription, null, undoMenu_Click);
dev@142 1153 }
dev@142 1154
dev@142 1155 if (undoLength > 0)
dev@142 1156 {
dev@142 1157 bttnUndo.Text = commandStack.PeekUndoCommand(1).UndoDescription;
dev@142 1158 }
dev@142 1159 else
dev@142 1160 {
dev@142 1161 bttnUndo.Text = Translation.GetTranslation("bttnUndo");
dev@142 1162 }
dev@142 1163 }
dev@142 1164
dev@142 1165 private void miSaveArmy_Click(object sender, System.EventArgs e)
dev@142 1166 {
dev@142 1167 SaveCurrentArmy();
dev@142 1168 }
dev@142 1169
dev@142 1170 private void SetAppTitle()
dev@142 1171 {
dev@142 1172 string str = AppTitle;
dev@142 1173
dev@142 1174 if (CurrentGameSystem!=null)
dev@142 1175 {
dev@142 1176 str+= " - "+CurrentGameSystem.Name;
dev@142 1177 }
dev@142 1178
dev@142 1179 if (CurrentArmy!=null)
dev@142 1180 {
dev@142 1181 str+= " - "+CurrentArmy.Name;
dev@142 1182 }
dev@142 1183
dev@142 1184 this.Text = str;
dev@142 1185 }
dev@142 1186
dev@142 1187 private void AddUnitFromCategory(Category cat)
dev@142 1188 {
dev@142 1189 FrmNewUnit newUnit = new FrmNewUnit(CurrentArmy.Race, cat, CurrentArmy);
dev@142 1190 DialogResult dr = newUnit.ShowDialog(this);
dev@142 1191
dev@142 1192 if (dr == DialogResult.OK)
dev@142 1193 {
dev@142 1194 CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, CurrentArmy.GetCategory(cat));
dev@142 1195 commandStack.Execute(cmd);
dev@142 1196 OpenUnitDialog(cmd.Unit);
dev@142 1197 }
dev@142 1198 }
dev@142 1199
dev@142 1200 internal void OpenUnitDialog(Unit unit)
dev@142 1201 {
dev@142 1202 string unitID = unit.ID;
dev@142 1203
dev@142 1204 if (unitWindows.ContainsKey(unitID))
dev@142 1205 {
dev@142 1206 unitWindows[unitID].Focus();
dev@142 1207 }
dev@142 1208 else
dev@142 1209 {
dev@142 1210 FrmUnit unitForm = new FrmUnit(unit, commandStack);
dev@142 1211 unitWindows.Add(unitID, unitForm);
dev@142 1212 unitForm.MdiParent = this;
dev@142 1213 unitForm.Closing += new CancelEventHandler(unitForm_Closing);
dev@142 1214 unitForm.Show();
dev@142 1215 }
dev@142 1216 }
dev@142 1217
dev@142 1218 private void unitForm_Closing(object sender, CancelEventArgs e)
dev@142 1219 {
dev@142 1220 if (sender is FrmUnit)
dev@142 1221 {
dev@142 1222 FrmUnit unitForm = (FrmUnit) sender;
dev@142 1223 unitWindows.Remove(unitForm.Unit.ID);
dev@142 1224 }
dev@142 1225 }
dev@142 1226
dev@142 1227 private void FrmMain_UnitAddedMethod(object unitObj)
dev@142 1228 {
dev@196 1229 ValidateArmy();
dev@196 1230 }
dev@196 1231
dev@196 1232 private void ValidateArmy()
dev@196 1233 {
dev@197 1234 ICollection<string> failureMessages;
dev@197 1235 if (Validates.AsOkay(RequirementHandler.ValidateArmy(CurrentArmy, out failureMessages)))
dev@196 1236 {
dev@196 1237 sbErrorPanel.Text = "";
dev@196 1238 sbErrorPanel.Tag = "";
dev@196 1239 }
dev@196 1240 else
dev@196 1241 {
dev@197 1242 sbErrorPanel.Text = failureMessages.Count + " validation errors";
dev@197 1243 sbErrorPanel.Tag = String.Join("\n", new List<string>(failureMessages).ToArray());
dev@196 1244 }
dev@196 1245 }
dev@196 1246
dev@196 1247 private void FrmMain_UnitRemovedMethod(object unitObj)
dev@196 1248 {
dev@196 1249 ValidateArmy();
dev@196 1250
dev@142 1251 if (unitObj is Unit)
dev@142 1252 {
dev@142 1253 Unit unit = (Unit)unitObj;
dev@142 1254
dev@142 1255 //check if window is open, and close it if it is
dev@142 1256 foreach (Form frm in this.MdiChildren)
dev@142 1257 {
dev@142 1258 if (frm is FrmUnit)
dev@142 1259 {
dev@142 1260 if (((FrmUnit)frm).Unit == unit)
dev@142 1261 {
dev@142 1262 frm.Close();
dev@142 1263 break;
dev@142 1264 }
dev@142 1265 }
dev@142 1266 }
dev@142 1267 }
dev@142 1268 }
dev@142 1269
dev@142 1270 private void miUndo_Click(object sender, System.EventArgs e)
dev@142 1271 {
dev@142 1272 UndoLastAction();
dev@142 1273 }
dev@142 1274
dev@142 1275 private void miRedo_Click(object sender, System.EventArgs e)
dev@142 1276 {
dev@142 1277 RedoAction();
dev@142 1278 }
dev@142 1279
dev@142 1280 private void miCloseArmy_Click(object sender, EventArgs e)
dev@142 1281 {
dev@142 1282 CloseCurrentArmy();
dev@142 1283 }
dev@142 1284
dev@142 1285 private void miOpenArmy_Click(object sender, EventArgs e)
dev@142 1286 {
dev@142 1287 OpenArmy();
dev@142 1288 }
dev@142 1289
dev@142 1290 private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal)
dev@142 1291 {
dev@142 1292 if (obj is Army)
dev@142 1293 {
dev@142 1294 SetPointsPanelText();
dev@142 1295 }
dev@142 1296 }
dev@142 1297
snowblizz@190 1298 private void SetPointsPanelText()
dev@142 1299 {
dev@142 1300 if (CurrentArmy==null)
dev@142 1301 {
dev@142 1302 sbPointsPanel.Text = "";
dev@142 1303 sbPointsPanel.ResetColor();
dev@142 1304 }
dev@142 1305 else
dev@142 1306 {
dev@193 1307 string pointsPanelText = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.Points, CurrentGameSystem.GetPointsName(CurrentArmy.Points), CurrentArmy.MaxPoints, CurrentGameSystem.GetPointsName(CurrentArmy.MaxPoints));
snowblizz@190 1308 sbPointsPanel.Text = pointsPanelText;
dev@142 1309
dev@142 1310 if (CurrentArmy.Points>CurrentArmy.MaxPoints)
dev@142 1311 {
dev@142 1312 sbPointsPanel.Color = Color.Red;
dev@142 1313 }
dev@142 1314 else
dev@142 1315 {
dev@142 1316 sbPointsPanel.ResetColor();
dev@142 1317 }
dev@142 1318 }
dev@142 1319 }
dev@142 1320
snowblizz@190 1321 private void SetPointsPanelToolTipText()
snowblizz@190 1322 {
snowblizz@190 1323 sbPointsPanel.ToolTipText = Translation.GetTranslation("statusPanelPointsToolTip", "total points value");
snowblizz@190 1324 }
snowblizz@190 1325
dev@142 1326 private void redoMenu_Click(object sender, EventArgs e)
dev@142 1327 {
dev@142 1328 if (sender is ToolStripDropDownItem)
dev@142 1329 {
dev@142 1330 ToolStripDropDownItem item = (ToolStripDropDownItem)sender;
dev@142 1331 //we know it's an redo menu item so find it's index and redo everything
dev@142 1332 int max = bttnRedo.DropDownItems.IndexOf(item);
dev@142 1333
dev@142 1334 if (max >= 0)
dev@142 1335 {
dev@142 1336 for (int i = 0; i <= max; i++)
dev@142 1337 {
dev@142 1338 commandStack.Redo();
dev@142 1339 }
dev@142 1340 }
dev@142 1341 }
dev@142 1342 }
dev@142 1343
dev@142 1344 private void undoMenu_Click(object sender, EventArgs e)
dev@142 1345 {
dev@142 1346 if (sender is ToolStripDropDownItem)
dev@142 1347 {
dev@142 1348 ToolStripDropDownItem item = (ToolStripDropDownItem)sender;
dev@142 1349 //we know it's an redo menu item so find it's index and redo everything
dev@142 1350 int max = bttnUndo.DropDownItems.IndexOf(item);
dev@142 1351
dev@142 1352 if (max >= 0)
dev@142 1353 {
dev@142 1354 for (int i = 0; i <= max; i++)
dev@142 1355 {
dev@142 1356 commandStack.Undo();
dev@142 1357 }
dev@142 1358 }
dev@142 1359 }
dev@142 1360 }
dev@142 1361
dev@142 1362 private void statusBar_DrawItem(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
dev@142 1363 {
dev@142 1364 statusBar.ColorableStatusBarDrawItem(sender, sbdevent);
dev@142 1365 }
dev@142 1366
dev@142 1367 private void FrmMain_Closing(object sender, CancelEventArgs e)
dev@142 1368 {
dev@142 1369 if (!CloseCurrentArmy())
dev@142 1370 {
dev@142 1371 e.Cancel = true;
dev@142 1372 }
dev@142 1373 }
dev@142 1374
dev@142 1375 private void miReloadFiles_Click(object sender, System.EventArgs e)
dev@142 1376 {
dev@142 1377 WarFoundryLoader.GetDefault().LoadFiles();
dev@142 1378 sbMainPanel.Text = Translation.GetTranslation("GameSystemFilesReloaded", "Game system and race files reloaded");
dev@142 1379 }
dev@142 1380
dev@142 1381 private void statusBar_PanelClick(object sender, StatusBarPanelClickEventArgs e)
dev@142 1382 {
dev@142 1383 if (e.StatusBarPanel == sbErrorPanel && sbErrorPanel.Text!="")
dev@142 1384 {
dev@142 1385 MessageBox.Show(this, sbErrorPanel.TagString, Translation.GetTranslation("FailedRequirementMessage"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
dev@142 1386 }
dev@142 1387 }
dev@142 1388
dev@142 1389 private void miExportArmyAsBasicHTML_Click(object sender, EventArgs e)
dev@142 1390 {
dev@142 1391 SaveFileDialog dialog = new SaveFileDialog();
dev@142 1392 dialog.Filter = Translation.GetTranslation("armyExportBasicHtmlFilter", "HTML pages") + "|*.html";
dev@142 1393 dialog.Title = Translation.GetTranslation("exportArmyDialog", "Export army");
dev@142 1394
dev@142 1395 DialogResult dr = dialog.ShowDialog(this);
dev@142 1396
dev@142 1397 if (dr == DialogResult.OK)
dev@142 1398 {
dev@142 1399 Army army = CurrentArmy;
dev@142 1400 string filePath = dialog.FileName;
dev@142 1401 log.DebugFormat("Exporting {0} to {1} as basic HTML", army.Name, filePath);
dev@142 1402 WarFoundryHtmlExporter.GetDefault().ExportArmy(army, filePath);
dev@142 1403 }
dev@142 1404 }
dev@142 1405
dev@142 1406 private void FrmMain_Load(object sender, EventArgs e)
dev@142 1407 {
dev@142 1408 string gameSystemID = Preferences.GetStringProperty("currSystem");
dev@142 1409
dev@142 1410 if (gameSystemID != null && !"".Equals(gameSystemID))
dev@142 1411 {
dev@142 1412 log.Debug("Attempting to load current game system from properties");
dev@142 1413 GameSystem sys = WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID);
dev@142 1414
dev@142 1415 if (sys != null)
dev@142 1416 {
dev@142 1417 WarFoundryCore.CurrentGameSystem = sys;
dev@142 1418 log.InfoFormat("Loaded game system {0} from properties", gameSystemID);
dev@142 1419 }
dev@142 1420 }
dev@142 1421 }
dev@142 1422
dev@142 1423 private void miAbout_Click(object sender, EventArgs e)
dev@142 1424 {
dev@142 1425 FrmAbout about = new FrmAbout();
dev@142 1426 about.ShowDialog(this);
dev@140 1427 }
dev@140 1428
dev@140 1429 private void miPreferences_Click(object sender, EventArgs e)
dev@140 1430 {
dev@140 1431 FrmPreferences prefsForm = new FrmPreferences(Preferences);
dev@140 1432 prefsForm.Show(this);
dev@142 1433 }
Dan@207 1434
Dan@207 1435 private void miExportArmyAsBasicXml_Click(object sender, EventArgs e)
Dan@207 1436 {
Dan@207 1437 SaveFileDialog dialog = new SaveFileDialog();
Dan@207 1438 dialog.Filter = Translation.GetTranslation("armyExportBasicXmlFilter", "XML pages") + "|*.xml";
Dan@207 1439 dialog.Title = Translation.GetTranslation("exportArmyDialog", "Export army");
Dan@207 1440
Dan@207 1441 DialogResult dr = dialog.ShowDialog(this);
Dan@207 1442
Dan@207 1443 if (dr == DialogResult.OK)
Dan@207 1444 {
Dan@207 1445 Army army = CurrentArmy;
Dan@207 1446 string filePath = dialog.FileName;
Dan@207 1447 log.DebugFormat("Exporting {0} to {1} as basic XML", army.Name, filePath);
Dan@207 1448 WarFoundryXmlWithXslExporter.GetDefault().ExportArmy(army, filePath);
Dan@207 1449 }
Dan@207 1450 }
dev@142 1451 }
dev@142 1452 }