comparison FrmMain.cs @ 226:4ada3252d1ea

Re #101: Make army names and sizes modifiable after creation * Fix up translations * Correct enabling of menu item * Add translation text * Update army names in tree and app title when edited
author IBBoard <dev@ibboard.co.uk>
date Mon, 29 Aug 2011 20:53:53 +0100
parents 5233147ca7e4
children c06d0865ff27
comparison
equal deleted inserted replaced
225:5233147ca7e4 226:4ada3252d1ea
47 47
48 private CommandStack commandStack; 48 private CommandStack commandStack;
49 49
50 public ObjectAddDelegate UnitAddedMethod; 50 public ObjectAddDelegate UnitAddedMethod;
51 public ObjectRemoveDelegate UnitRemovedMethod; 51 public ObjectRemoveDelegate UnitRemovedMethod;
52 public StringValChangedDelegate ArmyNameChangedMethod;
52 public DoubleValChangedDelegate PointsValueChangedMethod; 53 public DoubleValChangedDelegate PointsValueChangedMethod;
54 public IntValChangedDelegate MaxPointsValueChangedMethod;
53 55
54 private FrmArmyTree armyTree; 56 private FrmArmyTree armyTree;
55 private string loadedFilePath; 57 private string loadedFilePath;
56 private Dictionary<string, FrmUnit> unitWindows; 58 private Dictionary<string, FrmUnit> unitWindows;
57 59
146 148
147 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged); 149 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(FrmMain_GameSystemChanged);
148 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged); 150 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged);
149 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod); 151 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
150 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod); 152 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
153 ArmyNameChangedMethod = new StringValChangedDelegate(FrmMain_ArmyNameChangedMethod);
151 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); 154 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
155 MaxPointsValueChangedMethod = new IntValChangedDelegate(FrmMain_MaxPointsValueChangedMethod);
152 156
153 sbErrorPanel.Color = Color.Red; 157 sbErrorPanel.Color = Color.Red;
154 SetPointsPanelToolTipText(); 158 SetPointsPanelToolTipText();
155 159
156 // hack to load default files 160 // hack to load default files
576 this.toolStripSeparator4.Name = "toolStripSeparator4"; 580 this.toolStripSeparator4.Name = "toolStripSeparator4";
577 this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6); 581 this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
578 // 582 //
579 // miEditArmy 583 // miEditArmy
580 // 584 //
585 this.miEditArmy.Enabled = false;
581 this.miEditArmy.Name = "miEditArmy"; 586 this.miEditArmy.Name = "miEditArmy";
582 this.miEditArmy.Size = new System.Drawing.Size(152, 22); 587 this.miEditArmy.Size = new System.Drawing.Size(152, 22);
583 this.miEditArmy.Text = "&edit army"; 588 this.miEditArmy.Text = "&edit army";
584 this.miEditArmy.Click += new System.EventHandler(this.miEditArmy_Click); 589 this.miEditArmy.Click += new System.EventHandler(this.miEditArmy_Click);
585 // 590 //
911 { 916 {
912 CommandStack.Reset(); 917 CommandStack.Reset();
913 loadedFilePath = null; 918 loadedFilePath = null;
914 miSaveArmy.Enabled = false; 919 miSaveArmy.Enabled = false;
915 bttnSaveArmy.Enabled = false; 920 bttnSaveArmy.Enabled = false;
916 miEditArmy.Enabled = (CurrentArmy == null); 921 miEditArmy.Enabled = (CurrentArmy != null);
917 //TODO: Subscribe to an "army changed" event here 922 //TODO: Subscribe to an "army changed" event here
918 SetPointsPanelText(); 923 SetPointsPanelText();
919 SetAppTitle(); 924 SetAppTitle();
920 } 925 }
921 926
942 { 947 {
943 if (oldArmy != null) 948 if (oldArmy != null)
944 { 949 {
945 oldArmy.UnitAdded -= UnitAddedMethod; 950 oldArmy.UnitAdded -= UnitAddedMethod;
946 oldArmy.UnitRemoved -= UnitRemovedMethod; 951 oldArmy.UnitRemoved -= UnitRemovedMethod;
952 oldArmy.NameChanged -= ArmyNameChangedMethod;
947 oldArmy.PointsValueChanged -= PointsValueChangedMethod; 953 oldArmy.PointsValueChanged -= PointsValueChangedMethod;
954 oldArmy.MaxPointsValueChanged -= MaxPointsValueChangedMethod;
948 } 955 }
949 } 956 }
950 957
951 private void CloseAllUnitWindows() 958 private void CloseAllUnitWindows()
952 { 959 {
964 { 971 {
965 if (newArmy != null) 972 if (newArmy != null)
966 { 973 {
967 newArmy.UnitAdded += UnitAddedMethod; 974 newArmy.UnitAdded += UnitAddedMethod;
968 newArmy.UnitRemoved += UnitRemovedMethod; 975 newArmy.UnitRemoved += UnitRemovedMethod;
976 newArmy.NameChanged += ArmyNameChangedMethod;
969 newArmy.PointsValueChanged += PointsValueChangedMethod; 977 newArmy.PointsValueChanged += PointsValueChangedMethod;
978 newArmy.MaxPointsValueChanged += MaxPointsValueChangedMethod;
970 } 979 }
971 } 980 }
972 981
973 private void SetNullArmyState() 982 private void SetNullArmyState()
974 { 983 {
1295 private void miOpenArmy_Click(object sender, EventArgs e) 1304 private void miOpenArmy_Click(object sender, EventArgs e)
1296 { 1305 {
1297 OpenArmy(); 1306 OpenArmy();
1298 } 1307 }
1299 1308
1309 private void FrmMain_ArmyNameChangedMethod(WarFoundryObject obj, string oldString, string newString)
1310 {
1311 SetAppTitle();
1312 }
1313
1300 private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal) 1314 private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal)
1315 {
1316 if (obj is Army)
1317 {
1318 SetPointsPanelText();
1319 }
1320 }
1321
1322 private void FrmMain_MaxPointsValueChangedMethod(WarFoundryObject obj, int oldVal, int newVal)
1301 { 1323 {
1302 if (obj is Army) 1324 if (obj is Army)
1303 { 1325 {
1304 SetPointsPanelText(); 1326 SetPointsPanelText();
1305 } 1327 }