comparison FrmUnit.cs @ 109:f4d3e64bdb18

Fixes #221: Changing unit size doesn't update text of equipment items * Simple fix - on unit size change, re-set all equipment item values in the table
author IBBoard <dev@ibboard.co.uk>
date Thu, 17 Dec 2009 20:54:55 +0000
parents 83c259516041
children 18d607b0249b
comparison
equal deleted inserted replaced
108:6871c9788ce1 109:f4d3e64bdb18
458 private void unit_UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue) 458 private void unit_UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue)
459 { 459 {
460 if (obj is Unit && obj.Equals(unit)) 460 if (obj is Unit && obj.Equals(unit))
461 { 461 {
462 unitSize.Value = newValue; 462 unitSize.Value = newValue;
463
464 foreach (UnitEquipmentChoice choice in equipmentChoices.Values)
465 {
466 SetEquipmentListValue(choice);
467 }
463 } 468 }
464 } 469 }
465 470
466 private void equipmentList_SelectedIndexChanged(object sender, System.EventArgs e) 471 private void equipmentList_SelectedIndexChanged(object sender, System.EventArgs e)
467 { 472 {
488 { 493 {
489 equipmentList.Items.Remove(equipChoice); 494 equipmentList.Items.Remove(equipChoice);
490 } 495 }
491 else 496 else
492 { 497 {
493 int idx = equipmentList.Items.IndexOf(equipChoice); 498 SetEquipmentListValue(equipChoice);
494
495 if (idx > -1)
496 {
497 equipmentList.Items[idx] = equipChoice;
498 }
499 else
500 {
501 equipmentList.Items.Add(equipChoice);
502 }
503 } 499 }
500 }
501 }
502
503 private void SetEquipmentListValue(UnitEquipmentChoice equipChoice)
504 {
505 int idx = equipmentList.Items.IndexOf(equipChoice);
506
507 if (idx > -1)
508 {
509 equipmentList.Items[idx] = equipChoice;
510 }
511 else
512 {
513 equipmentList.Items.Add(equipChoice);
504 } 514 }
505 } 515 }
506 516
507 private void EditWeapon() 517 private void EditWeapon()
508 { 518 {