Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
diff FrmMain.cs @ 10:19bdbb80999c
Closes #47 - Remove magic numbers
* Replace "magic number" -1s in WinForms with WarFoundryCore.INFINITY
Also:
* Code cleanup to remove warnings
* Code cleanup to replace space indentation with tabs
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 19 May 2009 18:51:32 +0000 |
parents | 9828ba4f3f36 |
children | f7f65d80951e |
line wrap: on
line diff
--- a/FrmMain.cs Tue May 19 11:10:07 2009 +0000 +++ b/FrmMain.cs Tue May 19 18:51:32 2009 +0000 @@ -1,7 +1,7 @@ -// This file (FrmMain.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. -// -// 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. - +// This file (FrmMain.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. +// +// 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. + using System; using System.Drawing; using System.Drawing.Drawing2D; @@ -9,23 +9,23 @@ using System.ComponentModel; using System.Windows.Forms; using System.Data; -using System.IO; -using System.Threading; -using log4net; -using IBBoard; +using System.IO; +using System.Threading; +using log4net; +using IBBoard; using IBBoard.CustomMath; -using IBBoard.Commands; -using IBBoard.IO; -using IBBoard.Lang; -using IBBoard.Log4Net; -using IBBoard.Windows.Forms; -using IBBoard.Windows.Forms.I18N; -using IBBoard.Xml; -using IBBoard.WarFoundry.API; -using IBBoard.WarFoundry.API.Commands; -using IBBoard.WarFoundry.API.Objects; -using IBBoard.WarFoundry.API.Savers; -using IBBoard.WarFoundry.API.Factories; +using IBBoard.Commands; +using IBBoard.IO; +using IBBoard.Lang; +using IBBoard.Log4Net; +using IBBoard.Windows.Forms; +using IBBoard.Windows.Forms.I18N; +using IBBoard.Xml; +using IBBoard.WarFoundry.API; +using IBBoard.WarFoundry.API.Commands; +using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.API.Savers; +using IBBoard.WarFoundry.API.Factories; using IBBoard.WarFoundry.API.Factories.Xml; namespace IBBoard.WarFoundry @@ -35,11 +35,11 @@ /// </summary> public class FrmMain : System.Windows.Forms.Form { - private static readonly string AppTitle = "WarFoundry"; - const string DefaultDataDir = "data"; - - private Preferences preferences; - protected readonly ILog logger = LogManager.GetLogger(typeof(FrmMain)); + private static readonly string AppTitle = "WarFoundry"; + const string DefaultDataDir = "data"; + + private Preferences preferences; + protected readonly ILog logger = LogManager.GetLogger(typeof(FrmMain)); private CommandStack commandStack; private ToolBarButton[] categoryButtons; @@ -50,83 +50,83 @@ //public FailedUnitRequirementDelegate FailedUnitRequirementMethod; private FrmArmyTree armyTree; - private FrmDebugOutput debugWindow; - private string loadedFilePath; - - private System.ComponentModel.IContainer components; + private FrmDebugOutput debugWindow; + private string loadedFilePath; + + private System.ComponentModel.IContainer components; private System.Windows.Forms.ToolBar toolBar; private IBBoard.Windows.Forms.IBBToolBarButton bttnNewArmy; private System.Windows.Forms.ImageList buttonIcons; private IBBoard.Windows.Forms.IBBToolBarButton bttnSaveArmy; private System.Windows.Forms.OpenFileDialog openArmyDialog; - private System.Windows.Forms.SaveFileDialog saveArmyDialog; - private IBBoard.Windows.Forms.IBBToolBarButton bttnOpenArmy; - private IBBoard.Windows.Forms.IBBToolBarButton bttnSep1; - private IBBoard.Windows.Forms.IBBToolBarButton bttnUndo; - private IBBoard.Windows.Forms.IBBToolBarButton bttnRedo; - private System.Windows.Forms.MainMenu mainMenu; - private IBBoard.Windows.Forms.IBBMenuItem menuFile; + private System.Windows.Forms.SaveFileDialog saveArmyDialog; + private IBBoard.Windows.Forms.IBBToolBarButton bttnOpenArmy; + private IBBoard.Windows.Forms.IBBToolBarButton bttnSep1; + private IBBoard.Windows.Forms.IBBToolBarButton bttnUndo; + private IBBoard.Windows.Forms.IBBToolBarButton bttnRedo; + private System.Windows.Forms.MainMenu mainMenu; + private IBBoard.Windows.Forms.IBBMenuItem menuFile; private IBBoard.Windows.Forms.IBBMenuItem miNewArmy; - private IBBoard.Windows.Forms.IBBMenuItem miOpenArmy; - private IBBoard.Windows.Forms.IBBMenuItem miCloseArmy; - private IBBoard.Windows.Forms.IBBMenuItem miSaveArmy; - private IBBoard.Windows.Forms.IBBMenuItem miSaveArmyAs; - private System.Windows.Forms.MenuItem miSep2; - private IBBoard.Windows.Forms.IBBMenuItem miChangeSystem; - private System.Windows.Forms.MenuItem miSep1; - private IBBoard.Windows.Forms.IBBMenuItem miReloadFiles; - private System.Windows.Forms.MenuItem miSep3; - private IBBoard.Windows.Forms.IBBMenuItem miExit; + private IBBoard.Windows.Forms.IBBMenuItem miOpenArmy; + private IBBoard.Windows.Forms.IBBMenuItem miCloseArmy; + private IBBoard.Windows.Forms.IBBMenuItem miSaveArmy; + private IBBoard.Windows.Forms.IBBMenuItem miSaveArmyAs; + private System.Windows.Forms.MenuItem miSep2; + private IBBoard.Windows.Forms.IBBMenuItem miChangeSystem; + private System.Windows.Forms.MenuItem miSep1; + private IBBoard.Windows.Forms.IBBMenuItem miReloadFiles; + private System.Windows.Forms.MenuItem miSep3; + private IBBoard.Windows.Forms.IBBMenuItem miExit; private IBBoard.Windows.Forms.IBBMenuItem menuEdit; - private IBBoard.Windows.Forms.IBBMenuItem miUndo; - private IBBoard.Windows.Forms.IBBMenuItem miRedo; - private IBBoard.Windows.Forms.IBBMenuItem menuHelp; - private IBBoard.Windows.Forms.IBBMenuItem miDebugWindow; - private IBBoard.Windows.Forms.IBBMenuItem miAbout; + private IBBoard.Windows.Forms.IBBMenuItem miUndo; + private IBBoard.Windows.Forms.IBBMenuItem miRedo; + private IBBoard.Windows.Forms.IBBMenuItem menuHelp; + private IBBoard.Windows.Forms.IBBMenuItem miDebugWindow; + private IBBoard.Windows.Forms.IBBMenuItem miAbout; private IBBoard.Windows.Forms.ColorableStatusBarPanel sbMainPanel; private IBBoard.Windows.Forms.ColorableStatusBarPanel sbErrorPanel; private IBBoard.Windows.Forms.ColorableStatusBarPanel sbPointsPanel; private System.Windows.Forms.ContextMenu undoMenu; - private System.Windows.Forms.ContextMenu redoMenu; - private IBBoard.Windows.Forms.ColorableStatusBar statusBar; + private System.Windows.Forms.ContextMenu redoMenu; + private IBBoard.Windows.Forms.ColorableStatusBar statusBar; private System.Windows.Forms.Timer statusBarTimer; private System.Windows.Forms.Panel pnlRight; public FrmMain(string[] args) { - this.Closing+=new CancelEventHandler(FrmMain_Closing); - CommandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); - LogNotifierHandler.RegisterNotifierHandler(); + this.Closing+=new CancelEventHandler(FrmMain_Closing); + CommandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); + LogNotifierHandler.RegisterNotifierHandler(); - InitializeComponent(); - - Preferences = new Preferences("WarFoundry"); - Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); + InitializeComponent(); + + Preferences = new Preferences("WarFoundry"); + Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); //pnlRight.Left = ClientSize.Width - pnlRight.Width - 2; //pnlRight.Top = toolBar.Height + 5; //pnlRight.Height = ClientRectangle.Bottom - statusBar.Height - pnlRight.Top - 3; foreach (Control ctrl in Controls) - { - ControlTranslator.TranslateControl(ctrl); + { + ControlTranslator.TranslateControl(ctrl); } foreach(Component comp in components.Components) - { - ControlTranslator.TranslateComponent(comp); + { + ControlTranslator.TranslateComponent(comp); } foreach (IBBMenuItem mi in Menu.MenuItems) - { - ControlTranslator.TranslateComponent(mi); - } - - ControlTranslator.TranslateComponent(openArmyDialog); - ControlTranslator.TranslateComponent(saveArmyDialog); + { + ControlTranslator.TranslateComponent(mi); + } - WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged); - WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged); + ControlTranslator.TranslateComponent(openArmyDialog); + ControlTranslator.TranslateComponent(saveArmyDialog); + + WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged); + WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged); UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod); UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod); PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); @@ -138,59 +138,59 @@ armyTree.MdiParent = this; armyTree.Show(); armyTree.StartPosition = FormStartPosition.Manual; - armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10); - ControlTranslator.TranslateControl(armyTree); - - // hack to load default files - WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir)); - - IWarFoundryFactory factory = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(WarFoundryXmlFactory)); - - if (factory != null && factory is WarFoundryXmlFactory) - { - WarFoundryLoader.GetDefault().RegisterFactory((WarFoundryXmlFactory)factory); - } + armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10); + ControlTranslator.TranslateControl(armyTree); + + // hack to load default files + WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir)); + + IWarFoundryFactory factory = WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(typeof(WarFoundryXmlFactory)); + + if (factory != null && factory is WarFoundryXmlFactory) + { + WarFoundryLoader.GetDefault().RegisterFactory((WarFoundryXmlFactory)factory); + } - /* - if (args.Length == 1) - { - logger.Debug("Attempting to load from file"); - FileInfo file = new FileInfo(args[0]); - - try - { - if (file.Extension.Equals("."+Factory.GetArmyFileExtension())) - { - WarFoundryCore.CurrentArmy = Factory.CreateArmyFromFile(file); - logger.InfoFormat("Loaded army from {0}", file.FullName); - } - else if (file.Extension.Equals("."+Factory.GetSystemFileExtension())) - { - WarFoundryCore.CurrentGameSystem = Factory.CreateGameSystemFromFile(file); - logger.InfoFormat("Loaded game system from {0}", file.FullName); - } - } - catch (InvalidFileException ex) - { - 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); - logger.Error(ex); - } - } - else - { - string gameSystemID = Preferences.GetStringProperty("currSystem"); - - if (gameSystemID!=null && !"".Equals(gameSystemID)) - { - logger.Debug("Attempting to load current game system from properties"); - GameSystem sys = Factory.GetGameSystem(gameSystemID); - - if (sys!=null) - { - WarFoundryCore.CurrentGameSystem = sys; - logger.InfoFormat("Loaded game system {0} from properties", gameSystemID); - } - } + /* + if (args.Length == 1) + { + logger.Debug("Attempting to load from file"); + FileInfo file = new FileInfo(args[0]); + + try + { + if (file.Extension.Equals("."+Factory.GetArmyFileExtension())) + { + WarFoundryCore.CurrentArmy = Factory.CreateArmyFromFile(file); + logger.InfoFormat("Loaded army from {0}", file.FullName); + } + else if (file.Extension.Equals("."+Factory.GetSystemFileExtension())) + { + WarFoundryCore.CurrentGameSystem = Factory.CreateGameSystemFromFile(file); + logger.InfoFormat("Loaded game system from {0}", file.FullName); + } + } + catch (InvalidFileException ex) + { + 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); + logger.Error(ex); + } + } + else + { + string gameSystemID = Preferences.GetStringProperty("currSystem"); + + if (gameSystemID!=null && !"".Equals(gameSystemID)) + { + logger.Debug("Attempting to load current game system from properties"); + GameSystem sys = Factory.GetGameSystem(gameSystemID); + + if (sys!=null) + { + WarFoundryCore.CurrentGameSystem = sys; + logger.InfoFormat("Loaded game system {0} from properties", gameSystemID); + } + } }*/ } @@ -201,14 +201,14 @@ public static String ArmiesPath { - get { return Constants.UserDataPath+Constants.DirectoryChar+"armies"; } - } - - public Preferences Preferences - { - get { return preferences; } - set { preferences = value; } - } + get { return Constants.UserDataPath+Constants.DirectoryChar+"armies"; } + } + + public Preferences Preferences + { + get { return preferences; } + set { preferences = value; } + } public CommandStack CommandStack { @@ -244,343 +244,343 @@ /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); - this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); - this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); - this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); - this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); - this.toolBar = new System.Windows.Forms.ToolBar(); - this.bttnNewArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.bttnOpenArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.bttnSaveArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.bttnSep1 = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.bttnUndo = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.undoMenu = new System.Windows.Forms.ContextMenu(); - this.bttnRedo = new IBBoard.Windows.Forms.IBBToolBarButton(); - this.redoMenu = new System.Windows.Forms.ContextMenu(); - this.buttonIcons = new System.Windows.Forms.ImageList(this.components); - this.mainMenu = new System.Windows.Forms.MainMenu(this.components); - this.menuFile = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miNewArmy = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miOpenArmy = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miSaveArmy = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miCloseArmy = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miSep1 = new System.Windows.Forms.MenuItem(); - this.miChangeSystem = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miSep2 = new System.Windows.Forms.MenuItem(); - this.miReloadFiles = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miSep3 = new System.Windows.Forms.MenuItem(); - this.miExit = new IBBoard.Windows.Forms.IBBMenuItem(); - this.menuEdit = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miUndo = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miRedo = new IBBoard.Windows.Forms.IBBMenuItem(); - this.menuHelp = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miAbout = new IBBoard.Windows.Forms.IBBMenuItem(); - this.miDebugWindow = new IBBoard.Windows.Forms.IBBMenuItem(); - this.openArmyDialog = new System.Windows.Forms.OpenFileDialog(); - this.saveArmyDialog = new System.Windows.Forms.SaveFileDialog(); - this.pnlRight = new System.Windows.Forms.Panel(); - this.statusBarTimer = new System.Windows.Forms.Timer(this.components); - ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit(); - this.SuspendLayout(); - // - // statusBar - // - this.statusBar.Location = new System.Drawing.Point(0, 548); - this.statusBar.Name = "statusBar"; - this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { - this.sbMainPanel, - this.sbErrorPanel, - this.sbPointsPanel}); - this.statusBar.ShowPanels = true; - this.statusBar.Size = new System.Drawing.Size(792, 22); - this.statusBar.TabIndex = 1; - this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick); - this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem); - // - // sbMainPanel - // - this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; - this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText; - this.sbMainPanel.Name = "sbMainPanel"; - this.sbMainPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; - this.sbMainPanel.Width = 475; - // - // sbErrorPanel - // - this.sbErrorPanel.Color = System.Drawing.SystemColors.WindowText; - this.sbErrorPanel.Name = "sbErrorPanel"; - this.sbErrorPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; - this.sbErrorPanel.Width = 150; - // - // sbPointsPanel - // - this.sbPointsPanel.Color = System.Drawing.SystemColors.WindowText; - this.sbPointsPanel.Name = "sbPointsPanel"; - this.sbPointsPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; - this.sbPointsPanel.ToolTipText = "Current Points Total"; - this.sbPointsPanel.Width = 150; - // - // toolBar - // - this.toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat; - this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { - this.bttnNewArmy, - this.bttnOpenArmy, - this.bttnSaveArmy, - this.bttnSep1, - this.bttnUndo, - this.bttnRedo}); - this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); - this.toolBar.DropDownArrows = true; - this.toolBar.ImageList = this.buttonIcons; - this.toolBar.Location = new System.Drawing.Point(0, 0); - this.toolBar.Name = "toolBar"; - this.toolBar.ShowToolTips = true; - this.toolBar.Size = new System.Drawing.Size(792, 28); - this.toolBar.TabIndex = 2; - this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick); - // - // bttnNewArmy - // - this.bttnNewArmy.Enabled = false; - this.bttnNewArmy.ImageIndex = 0; - this.bttnNewArmy.Name = "bttnNewArmy"; - // - // bttnOpenArmy - // - this.bttnOpenArmy.ImageIndex = 2; - this.bttnOpenArmy.Name = "bttnOpenArmy"; - // - // bttnSaveArmy - // - this.bttnSaveArmy.Enabled = false; - this.bttnSaveArmy.ImageIndex = 1; - this.bttnSaveArmy.Name = "bttnSaveArmy"; - // - // bttnSep1 - // - this.bttnSep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; - // - // bttnUndo - // - this.bttnUndo.DropDownMenu = this.undoMenu; - this.bttnUndo.Enabled = false; - this.bttnUndo.ImageIndex = 3; - this.bttnUndo.Name = "bttnUndo"; - this.bttnUndo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; - // - // bttnRedo - // - this.bttnRedo.DropDownMenu = this.redoMenu; - this.bttnRedo.Enabled = false; - this.bttnRedo.ImageIndex = 4; - this.bttnRedo.Name = "bttnRedo"; - this.bttnRedo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; - // - // buttonIcons - // - this.buttonIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("buttonIcons.ImageStream"))); - this.buttonIcons.TransparentColor = System.Drawing.Color.Transparent; - this.buttonIcons.Images.SetKeyName(0, ""); - this.buttonIcons.Images.SetKeyName(1, ""); - this.buttonIcons.Images.SetKeyName(2, ""); - this.buttonIcons.Images.SetKeyName(3, ""); - this.buttonIcons.Images.SetKeyName(4, ""); - this.buttonIcons.Images.SetKeyName(5, ""); - this.buttonIcons.Images.SetKeyName(6, ""); - // - // mainMenu - // - this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuFile, - this.menuEdit, - this.menuHelp}); - // - // menuFile - // - this.menuFile.Index = 0; - this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.miNewArmy, - this.miOpenArmy, - this.miSaveArmy, - this.miSaveArmyAs, - this.miCloseArmy, - this.miSep1, - this.miChangeSystem, - this.miSep2, - this.miReloadFiles, - this.miSep3, - this.miExit}); - this.menuFile.Text = "&file"; - this.menuFile.Name = "menuFile"; - // - // miNewArmy - // - this.miNewArmy.Index = 0; - this.miNewArmy.Text = "&new army"; - this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click); - this.miNewArmy.Name = "miNewArmy"; - // - // miOpenArmy - // - this.miOpenArmy.Index = 1; - this.miOpenArmy.Text = "&open army"; - this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click); - this.miOpenArmy.Name = "miOpenArmy"; - // - // miSaveArmy - // - this.miSaveArmy.Enabled = false; - this.miSaveArmy.Index = 2; - this.miSaveArmy.Text = "&save army"; - this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click); - this.miSaveArmy.Name = "miSaveArmy"; - // - // miSaveArmyAs - // - this.miSaveArmyAs.Enabled = false; - this.miSaveArmyAs.Index = 3; - this.miSaveArmyAs.Text = "save army &as..."; - this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click); - this.miSaveArmyAs.Name = "miSaveArmyAs"; - // - // miCloseArmy - // - this.miCloseArmy.Enabled = false; - this.miCloseArmy.Index = 4; - this.miCloseArmy.Text = "&close army"; - this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click); - this.miCloseArmy.Name = "miCloseArmy"; - // - // miSep1 - // - this.miSep1.Index = 5; - this.miSep1.Text = "-"; - // - // miChangeSystem - // - this.miChangeSystem.Index = 6; - this.miChangeSystem.Text = "change &game system"; - this.miChangeSystem.Click += new System.EventHandler(this.miChangeSystem_Click); - this.miChangeSystem.Name = "miChangeSystem"; - // - // miSep2 - // - this.miSep2.Index = 7; - this.miSep2.Text = "-"; - // - // miReloadFiles - // - this.miReloadFiles.Index = 8; - this.miReloadFiles.Text = "&reload files"; - this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click); - this.miReloadFiles.Name = "miReloadFiles"; - // - // miSep3 - // - this.miSep3.Index = 9; - this.miSep3.Text = "-"; - // - // miExit - // - this.miExit.Index = 10; - this.miExit.Text = "e&xit"; - this.miExit.Click += new System.EventHandler(this.miExit_Click); - this.miExit.Name = "miExit"; - // - // menuEdit - // - this.menuEdit.Index = 1; - this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.miUndo, - this.miRedo}); - this.menuEdit.Text = "&edit"; - this.menuEdit.Name = "menuEdit"; - // - // miUndo - // - this.miUndo.Enabled = false; - this.miUndo.Index = 0; - this.miUndo.Text = "&undo"; - this.miUndo.Click += new System.EventHandler(this.miUndo_Click); - this.miUndo.Name = "miUndo"; - // - // miRedo - // - this.miRedo.Enabled = false; - this.miRedo.Index = 1; - this.miRedo.Text = "&redo"; - this.miRedo.Click += new System.EventHandler(this.miRedo_Click); - this.miRedo.Name = "miRedo"; - // - // menuHelp - // - this.menuHelp.Index = 2; - this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.miAbout, - this.miDebugWindow}); - this.menuHelp.Text = "&help"; - this.menuHelp.Name = "menuHelp"; - // - // miAbout - // - this.miAbout.Enabled = false; - this.miAbout.Index = 0; - this.miAbout.Text = "&about"; - this.miAbout.Name = "miAbout"; - // - // miDebugWindow - // - this.miDebugWindow.Index = 1; - this.miDebugWindow.Text = "&debug"; - this.miDebugWindow.Click += new System.EventHandler(this.miDebugWindow_Click); - this.miDebugWindow.Name = "miDebugWindow"; - // - // saveArmyDialog - // - this.saveArmyDialog.Title = "Translatable:saveArmyDialog"; - // - // pnlRight - // - this.pnlRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.pnlRight.BackColor = System.Drawing.SystemColors.AppWorkspace; - this.pnlRight.Location = new System.Drawing.Point(726, 30); - this.pnlRight.Name = "pnlRight"; - this.pnlRight.Size = new System.Drawing.Size(64, 516); - this.pnlRight.TabIndex = 4; - this.pnlRight.Visible = false; - this.pnlRight.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlRight_Paint); - // - // statusBarTimer - // - this.statusBarTimer.Interval = 5000; - this.statusBarTimer.Tick += new System.EventHandler(this.statusBarTimer_Tick); - // - // FrmMain - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(792, 570); - this.Controls.Add(this.pnlRight); - this.Controls.Add(this.toolBar); - this.Controls.Add(this.statusBar); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.IsMdiContainer = true; - this.Menu = this.mainMenu; - this.Name = "FrmMain"; - this.Text = "WarFoundry"; - ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); + this.statusBar = new IBBoard.Windows.Forms.ColorableStatusBar(); + this.sbMainPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); + this.sbErrorPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); + this.sbPointsPanel = new IBBoard.Windows.Forms.ColorableStatusBarPanel(); + this.toolBar = new System.Windows.Forms.ToolBar(); + this.bttnNewArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.bttnOpenArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.bttnSaveArmy = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.bttnSep1 = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.bttnUndo = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.undoMenu = new System.Windows.Forms.ContextMenu(); + this.bttnRedo = new IBBoard.Windows.Forms.IBBToolBarButton(); + this.redoMenu = new System.Windows.Forms.ContextMenu(); + this.buttonIcons = new System.Windows.Forms.ImageList(this.components); + this.mainMenu = new System.Windows.Forms.MainMenu(this.components); + this.menuFile = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miNewArmy = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miOpenArmy = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miSaveArmy = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miSaveArmyAs = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miCloseArmy = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miSep1 = new System.Windows.Forms.MenuItem(); + this.miChangeSystem = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miSep2 = new System.Windows.Forms.MenuItem(); + this.miReloadFiles = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miSep3 = new System.Windows.Forms.MenuItem(); + this.miExit = new IBBoard.Windows.Forms.IBBMenuItem(); + this.menuEdit = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miUndo = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miRedo = new IBBoard.Windows.Forms.IBBMenuItem(); + this.menuHelp = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miAbout = new IBBoard.Windows.Forms.IBBMenuItem(); + this.miDebugWindow = new IBBoard.Windows.Forms.IBBMenuItem(); + this.openArmyDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveArmyDialog = new System.Windows.Forms.SaveFileDialog(); + this.pnlRight = new System.Windows.Forms.Panel(); + this.statusBarTimer = new System.Windows.Forms.Timer(this.components); + ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).BeginInit(); + this.SuspendLayout(); + // + // statusBar + // + this.statusBar.Location = new System.Drawing.Point(0, 548); + this.statusBar.Name = "statusBar"; + this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { + this.sbMainPanel, + this.sbErrorPanel, + this.sbPointsPanel}); + this.statusBar.ShowPanels = true; + this.statusBar.Size = new System.Drawing.Size(792, 22); + this.statusBar.TabIndex = 1; + this.statusBar.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar_PanelClick); + this.statusBar.DrawItem += new System.Windows.Forms.StatusBarDrawItemEventHandler(this.statusBar_DrawItem); + // + // sbMainPanel + // + this.sbMainPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring; + this.sbMainPanel.Color = System.Drawing.SystemColors.WindowText; + this.sbMainPanel.Name = "sbMainPanel"; + this.sbMainPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; + this.sbMainPanel.Width = 475; + // + // sbErrorPanel + // + this.sbErrorPanel.Color = System.Drawing.SystemColors.WindowText; + this.sbErrorPanel.Name = "sbErrorPanel"; + this.sbErrorPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; + this.sbErrorPanel.Width = 150; + // + // sbPointsPanel + // + this.sbPointsPanel.Color = System.Drawing.SystemColors.WindowText; + this.sbPointsPanel.Name = "sbPointsPanel"; + this.sbPointsPanel.Style = System.Windows.Forms.StatusBarPanelStyle.OwnerDraw; + this.sbPointsPanel.ToolTipText = "Current Points Total"; + this.sbPointsPanel.Width = 150; + // + // toolBar + // + this.toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat; + this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { + this.bttnNewArmy, + this.bttnOpenArmy, + this.bttnSaveArmy, + this.bttnSep1, + this.bttnUndo, + this.bttnRedo}); + this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); + this.toolBar.DropDownArrows = true; + this.toolBar.ImageList = this.buttonIcons; + this.toolBar.Location = new System.Drawing.Point(0, 0); + this.toolBar.Name = "toolBar"; + this.toolBar.ShowToolTips = true; + this.toolBar.Size = new System.Drawing.Size(792, 28); + this.toolBar.TabIndex = 2; + this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick); + // + // bttnNewArmy + // + this.bttnNewArmy.Enabled = false; + this.bttnNewArmy.ImageIndex = 0; + this.bttnNewArmy.Name = "bttnNewArmy"; + // + // bttnOpenArmy + // + this.bttnOpenArmy.ImageIndex = 2; + this.bttnOpenArmy.Name = "bttnOpenArmy"; + // + // bttnSaveArmy + // + this.bttnSaveArmy.Enabled = false; + this.bttnSaveArmy.ImageIndex = 1; + this.bttnSaveArmy.Name = "bttnSaveArmy"; + // + // bttnSep1 + // + this.bttnSep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator; + // + // bttnUndo + // + this.bttnUndo.DropDownMenu = this.undoMenu; + this.bttnUndo.Enabled = false; + this.bttnUndo.ImageIndex = 3; + this.bttnUndo.Name = "bttnUndo"; + this.bttnUndo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; + // + // bttnRedo + // + this.bttnRedo.DropDownMenu = this.redoMenu; + this.bttnRedo.Enabled = false; + this.bttnRedo.ImageIndex = 4; + this.bttnRedo.Name = "bttnRedo"; + this.bttnRedo.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton; + // + // buttonIcons + // + this.buttonIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("buttonIcons.ImageStream"))); + this.buttonIcons.TransparentColor = System.Drawing.Color.Transparent; + this.buttonIcons.Images.SetKeyName(0, ""); + this.buttonIcons.Images.SetKeyName(1, ""); + this.buttonIcons.Images.SetKeyName(2, ""); + this.buttonIcons.Images.SetKeyName(3, ""); + this.buttonIcons.Images.SetKeyName(4, ""); + this.buttonIcons.Images.SetKeyName(5, ""); + this.buttonIcons.Images.SetKeyName(6, ""); + // + // mainMenu + // + this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuFile, + this.menuEdit, + this.menuHelp}); + // + // menuFile + // + this.menuFile.Index = 0; + this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.miNewArmy, + this.miOpenArmy, + this.miSaveArmy, + this.miSaveArmyAs, + this.miCloseArmy, + this.miSep1, + this.miChangeSystem, + this.miSep2, + this.miReloadFiles, + this.miSep3, + this.miExit}); + this.menuFile.Text = "&file"; + this.menuFile.Name = "menuFile"; + // + // miNewArmy + // + this.miNewArmy.Index = 0; + this.miNewArmy.Text = "&new army"; + this.miNewArmy.Click += new System.EventHandler(this.miNewArmy_Click); + this.miNewArmy.Name = "miNewArmy"; + // + // miOpenArmy + // + this.miOpenArmy.Index = 1; + this.miOpenArmy.Text = "&open army"; + this.miOpenArmy.Click += new System.EventHandler(this.miOpenArmy_Click); + this.miOpenArmy.Name = "miOpenArmy"; + // + // miSaveArmy + // + this.miSaveArmy.Enabled = false; + this.miSaveArmy.Index = 2; + this.miSaveArmy.Text = "&save army"; + this.miSaveArmy.Click += new System.EventHandler(this.miSaveArmy_Click); + this.miSaveArmy.Name = "miSaveArmy"; + // + // miSaveArmyAs + // + this.miSaveArmyAs.Enabled = false; + this.miSaveArmyAs.Index = 3; + this.miSaveArmyAs.Text = "save army &as..."; + this.miSaveArmyAs.Click += new System.EventHandler(this.miSaveArmyAs_Click); + this.miSaveArmyAs.Name = "miSaveArmyAs"; + // + // miCloseArmy + // + this.miCloseArmy.Enabled = false; + this.miCloseArmy.Index = 4; + this.miCloseArmy.Text = "&close army"; + this.miCloseArmy.Click += new System.EventHandler(this.miCloseArmy_Click); + this.miCloseArmy.Name = "miCloseArmy"; + // + // miSep1 + // + this.miSep1.Index = 5; + this.miSep1.Text = "-"; + // + // miChangeSystem + // + this.miChangeSystem.Index = 6; + this.miChangeSystem.Text = "change &game system"; + this.miChangeSystem.Click += new System.EventHandler(this.miChangeSystem_Click); + this.miChangeSystem.Name = "miChangeSystem"; + // + // miSep2 + // + this.miSep2.Index = 7; + this.miSep2.Text = "-"; + // + // miReloadFiles + // + this.miReloadFiles.Index = 8; + this.miReloadFiles.Text = "&reload files"; + this.miReloadFiles.Click += new System.EventHandler(this.miReloadFiles_Click); + this.miReloadFiles.Name = "miReloadFiles"; + // + // miSep3 + // + this.miSep3.Index = 9; + this.miSep3.Text = "-"; + // + // miExit + // + this.miExit.Index = 10; + this.miExit.Text = "e&xit"; + this.miExit.Click += new System.EventHandler(this.miExit_Click); + this.miExit.Name = "miExit"; + // + // menuEdit + // + this.menuEdit.Index = 1; + this.menuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.miUndo, + this.miRedo}); + this.menuEdit.Text = "&edit"; + this.menuEdit.Name = "menuEdit"; + // + // miUndo + // + this.miUndo.Enabled = false; + this.miUndo.Index = 0; + this.miUndo.Text = "&undo"; + this.miUndo.Click += new System.EventHandler(this.miUndo_Click); + this.miUndo.Name = "miUndo"; + // + // miRedo + // + this.miRedo.Enabled = false; + this.miRedo.Index = 1; + this.miRedo.Text = "&redo"; + this.miRedo.Click += new System.EventHandler(this.miRedo_Click); + this.miRedo.Name = "miRedo"; + // + // menuHelp + // + this.menuHelp.Index = 2; + this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.miAbout, + this.miDebugWindow}); + this.menuHelp.Text = "&help"; + this.menuHelp.Name = "menuHelp"; + // + // miAbout + // + this.miAbout.Enabled = false; + this.miAbout.Index = 0; + this.miAbout.Text = "&about"; + this.miAbout.Name = "miAbout"; + // + // miDebugWindow + // + this.miDebugWindow.Index = 1; + this.miDebugWindow.Text = "&debug"; + this.miDebugWindow.Click += new System.EventHandler(this.miDebugWindow_Click); + this.miDebugWindow.Name = "miDebugWindow"; + // + // saveArmyDialog + // + this.saveArmyDialog.Title = "Translatable:saveArmyDialog"; + // + // pnlRight + // + this.pnlRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlRight.BackColor = System.Drawing.SystemColors.AppWorkspace; + this.pnlRight.Location = new System.Drawing.Point(726, 30); + this.pnlRight.Name = "pnlRight"; + this.pnlRight.Size = new System.Drawing.Size(64, 516); + this.pnlRight.TabIndex = 4; + this.pnlRight.Visible = false; + this.pnlRight.Paint += new System.Windows.Forms.PaintEventHandler(this.pnlRight_Paint); + // + // statusBarTimer + // + this.statusBarTimer.Interval = 5000; + this.statusBarTimer.Tick += new System.EventHandler(this.statusBarTimer_Tick); + // + // FrmMain + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(792, 570); + this.Controls.Add(this.pnlRight); + this.Controls.Add(this.toolBar); + this.Controls.Add(this.statusBar); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.IsMdiContainer = true; + this.Menu = this.mainMenu; + this.Name = "FrmMain"; + this.Text = "WarFoundry"; + ((System.ComponentModel.ISupportInitialize)(this.sbMainPanel)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.sbErrorPanel)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.sbPointsPanel)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion @@ -598,11 +598,11 @@ Application.Run(new FrmMain(args)); } catch(Exception ex) - { - LogManager.GetLogger(typeof(FrmMain)).Fatal(ex); + { + LogManager.GetLogger(typeof(FrmMain)).Fatal(ex); 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); } - } + } private void miExit_Click(object sender, System.EventArgs e) { @@ -622,8 +622,8 @@ DialogResult dr = newArmy.ShowDialog(); if (dr == DialogResult.OK) - { - CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize); + { + CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize); } } } @@ -651,7 +651,7 @@ if (dr == DialogResult.OK) { - /* + /* try { CurrentArmy = Factory.LoadArmy(openArmyDialog.FileName); @@ -663,8 +663,8 @@ MessageBox.Show(this, ex.Message, Translation.GetTranslation("InvalidFileBoxTitle", "Invalid data file"), MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } - * */ - return false; + * */ + return false; } else { @@ -688,8 +688,8 @@ 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); if (dr == DialogResult.Yes) - { - canClose = SaveCurrentArmy(); + { + canClose = SaveCurrentArmy(); } else if (dr == DialogResult.No) { @@ -739,32 +739,32 @@ } private bool SaveCurrentArmy() - { - bool saved = false; - - if (loadedFilePath != null || PromptForFilePath()) - { - saved = SaveCurrentArmyToFile(); - } - - return saved; - } - - private bool SaveCurrentArmyAs() - { - bool saved = false; - - if (PromptForFilePath()) - { - saved = SaveCurrentArmyToFile(); - } + { + bool saved = false; + + if (loadedFilePath != null || PromptForFilePath()) + { + saved = SaveCurrentArmyToFile(); + } + + return saved; + } + + private bool SaveCurrentArmyAs() + { + bool saved = false; + + if (PromptForFilePath()) + { + saved = SaveCurrentArmyToFile(); + } - return saved; - } - - private bool SaveCurrentArmyToFile() - { - if (WarFoundrySaver.GetSaver().Save(CurrentArmy, loadedFilePath)) + return saved; + } + + private bool SaveCurrentArmyToFile() + { + if (WarFoundrySaver.GetSaver().Save(CurrentArmy, loadedFilePath)) { miSaveArmy.Enabled = false; bttnSaveArmy.Enabled = false; @@ -772,14 +772,14 @@ return true; } else - { - loadedFilePath = null; + { + loadedFilePath = null; MessageBox.Show(this, Translation.GetTranslation("SaveFailed"), Translation.GetTranslation("SaveFailedTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } - } - - private bool PromptForFilePath() + } + + private bool PromptForFilePath() { if (saveArmyDialog.Filter == "") { @@ -827,8 +827,8 @@ openArmy(); } else if (e.Button == bttnSaveArmy) - { - SaveCurrentArmy(); + { + SaveCurrentArmy(); } else { @@ -839,8 +839,8 @@ private GameSystem CurrentGameSystem { - get { return WarFoundryCore.CurrentGameSystem; } - set { WarFoundryCore.CurrentGameSystem = value; } + get { return WarFoundryCore.CurrentGameSystem; } + set { WarFoundryCore.CurrentGameSystem = value; } } private static Army CurrentArmy @@ -867,9 +867,9 @@ } private void FrmMain_GameSystemChanged(GameSystem oldSystem, GameSystem newSystem) - { - miNewArmy.Enabled = newSystem != null; - bttnNewArmy.Enabled = newSystem != null; + { + miNewArmy.Enabled = newSystem != null; + bttnNewArmy.Enabled = newSystem != null; setAppTitle(); removeCategoryButtons(); addCategoryButtons(); @@ -877,14 +877,14 @@ private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy) { - setAppTitle(); - - if (oldArmy != null) - { - oldArmy.UnitAdded += UnitAddedMethod; - oldArmy.UnitRemoved += UnitRemovedMethod; - oldArmy.PointsValueChanged += PointsValueChangedMethod; - } + setAppTitle(); + + if (oldArmy != null) + { + oldArmy.UnitAdded += UnitAddedMethod; + oldArmy.UnitRemoved += UnitRemovedMethod; + oldArmy.PointsValueChanged += PointsValueChangedMethod; + } if (CurrentArmy==null) { @@ -893,19 +893,19 @@ disableCategoryButtons(); } else - { - newArmy.UnitAdded += UnitAddedMethod; - newArmy.UnitRemoved += UnitRemovedMethod; - newArmy.PointsValueChanged += PointsValueChangedMethod; + { + newArmy.UnitAdded += UnitAddedMethod; + newArmy.UnitRemoved += UnitRemovedMethod; + newArmy.PointsValueChanged += PointsValueChangedMethod; //TODO: Clear all buttons miSaveArmyAs.Enabled = true; miCloseArmy.Enabled = true; - enableCategoryButtons(); - - if (newArmy.Race.HasCategoryOverrides()) + enableCategoryButtons(); + + if (newArmy.Race.HasCategoryOverrides()) { - removeCategoryButtons(); - addCategoryButtons(newArmy.Race.Categories); + removeCategoryButtons(); + addCategoryButtons(newArmy.Race.Categories); } } @@ -985,8 +985,8 @@ } private void miSaveArmyAs_Click(object sender, System.EventArgs e) - { - SaveCurrentArmyAs(); + { + SaveCurrentArmyAs(); } private void commandStack_CommandStackUpdated() @@ -1059,9 +1059,9 @@ { bttnUndo.ToolTipText = menuItemsUndo[0].Text; undoMenu.MenuItems.AddRange(menuItemsUndo); - } - - bool canSave = loadedFilePath != null; + } + + bool canSave = loadedFilePath != null; bttnSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null && canSave; miSaveArmy.Enabled = commandStack.IsDirty() && CurrentArmy!=null && canSave; } @@ -1094,8 +1094,8 @@ DialogResult dr = newUnit.ShowDialog(this); if (dr == DialogResult.OK) - { - CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, cat, CurrentArmy); + { + CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, CurrentArmy); commandStack.Execute(cmd); } }