# HG changeset patch # User IBBoard # Date 1252961032 0 # Node ID 93b3d23147ba90b7305cca90acf143dde99a5847 # Parent cf644b2c65e608dc8848f05966bcbb7dfece040b Fixes #160: Army tree is visible when no army is available * Show/hide Army Tree depending on whether we have an army or not Also: * Tidy up FrmArmyTree code to remove "ht" prefix on dictionaries and to fix some mistmatches of naming conventions diff -r cf644b2c65e6 -r 93b3d23147ba FrmArmyTree.cs --- a/FrmArmyTree.cs Sun Sep 13 19:03:37 2009 +0000 +++ b/FrmArmyTree.cs Mon Sep 14 20:43:52 2009 +0000 @@ -25,11 +25,11 @@ /// Required designer variable. /// private System.ComponentModel.Container components = null; - private Dictionary htNodes; + private Dictionary nodes; private System.Windows.Forms.ContextMenu contextMenu; private System.Windows.Forms.MenuItem miDelete; private System.Windows.Forms.MenuItem miEdit; - private Dictionary htUnitWindows; + private Dictionary unitWindows; private ObjectAddDelegate UnitAddedMethod; private ObjectRemoveDelegate UnitRemovedMethod; @@ -45,8 +45,8 @@ UnitNameChangedMethod = new StringValChangedDelegate(UpdateUnitName); ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName); TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged); - htNodes = new Dictionary(); - htUnitWindows = new Dictionary(); + nodes = new Dictionary(); + unitWindows = new Dictionary(); this.Name = "ArmyTree"; WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(FrmArmyTree_ArmyChanged); } @@ -137,16 +137,16 @@ private void ClearArmy() { - htNodes.Clear(); + nodes.Clear(); treeView.Nodes.Clear(); - FrmUnit[] unitForms = DictionaryUtils.ToArray(htUnitWindows); + FrmUnit[] unitForms = DictionaryUtils.ToArray(unitWindows); foreach (FrmUnit window in unitForms) { window.Close(); } - htUnitWindows.Clear(); + unitWindows.Clear(); } private void SetArmy(Army army) @@ -174,7 +174,7 @@ temp = new TreeNode(cats[i].Name, unitNodes); temp.Tag = cats[i]; catNodes[i] = temp; - htNodes[cats[i].ID] = temp; + nodes[cats[i].ID] = temp; } TreeNode root = new TreeNode(army.Name, catNodes); @@ -189,7 +189,7 @@ TreeNode temp = new TreeNode(unit.Name); temp.Tag = unit; unit.NameChanged+= UnitNameChangedMethod; - htNodes[unit.ID] = temp; + nodes[unit.ID] = temp; return temp; } @@ -225,7 +225,7 @@ { Unit unit = (Unit)obj; ArmyCategory cat = unit.Category; - TreeNode parent = htNodes[cat.ID]; + TreeNode parent = nodes[cat.ID]; TreeNode unitNode = createTreeNode(unit); parent.Nodes.Add(unitNode); parent.Expand(); //make sure it's expanded @@ -243,13 +243,13 @@ private void RemoveUnitFromTree(Unit unit) { - TreeNode unitNode = htNodes[unit.ID]; + TreeNode unitNode = nodes[unit.ID]; unit.NameChanged-= UnitNameChangedMethod; if (unitNode!=null) { unitNode.Remove(); - htNodes.Remove(unit.ID); + nodes.Remove(unit.ID); } } @@ -303,15 +303,15 @@ private void miEdit_Click(object sender, System.EventArgs e) { - editUnit(); + EditUnit(); } private void treeView_DoubleClick(object sender, System.EventArgs e) { - editUnit(); + EditUnit(); } - private void editUnit() + private void EditUnit() { TreeNode selected = treeView.SelectedNode; @@ -319,14 +319,14 @@ { Unit unit = (Unit)selected.Tag; - if (htUnitWindows.ContainsKey(unit.ID)) + if (unitWindows.ContainsKey(unit.ID)) { - ((FrmUnit)htUnitWindows[unit.ID]).Focus(); + unitWindows[unit.ID].Focus(); } else { FrmUnit unitForm = new FrmUnit(unit, commandStack); - htUnitWindows.Add(unit.ID, unitForm); + unitWindows.Add(unit.ID, unitForm); unitForm.MdiParent = this.MdiParent; unitForm.Closing+=new CancelEventHandler(unitForm_Closing); unitForm.Show(); @@ -339,7 +339,7 @@ if (obj is Unit) { Unit unit = (Unit)obj; - TreeNode node = htNodes[unit.ID]; + TreeNode node = nodes[unit.ID]; if (node!=null) { @@ -367,13 +367,13 @@ if (sender is FrmUnit) { FrmUnit unitForm = (FrmUnit)sender; - htUnitWindows.Remove(unitForm.Unit.ID); + unitWindows.Remove(unitForm.Unit.ID); } } private void FrmArmyTree_TreeNameChanged(WarFoundryObject obj, string oldValue, string newValue) { - TreeNode node = htNodes[obj.ID]; + TreeNode node = nodes[obj.ID]; if (node!=null) { diff -r cf644b2c65e6 -r 93b3d23147ba FrmMain.cs --- a/FrmMain.cs Sun Sep 13 19:03:37 2009 +0000 +++ b/FrmMain.cs Mon Sep 14 20:43:52 2009 +0000 @@ -142,7 +142,6 @@ armyTree = new FrmArmyTree(CommandStack); armyTree.MdiParent = this; - armyTree.Show(); armyTree.StartPosition = FormStartPosition.Manual; armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10); ControlTranslator.TranslateControl(armyTree); @@ -851,6 +850,7 @@ miCloseArmy.Enabled = false; miExportArmyAs.Enabled = false; DisableCategoryButtons(); + armyTree.Hide(); } else { @@ -862,6 +862,7 @@ miCloseArmy.Enabled = true; miExportArmyAs.Enabled = true; EnableCategoryButtons(); + armyTree.Show(); if (newArmy.Race.HasCategoryOverrides()) {