diff FrmNewUnitEquipment.cs @ 8:755e60be28be

Re #61 - Complete structure of WarFoundry API objects * Update to using UnitEquipmentItem where properties have moved from EquipmentItem * Add UnitEquipmentChoice as replacement for UnitEquipmentItemObj
author IBBoard <dev@ibboard.co.uk>
date Sun, 05 Apr 2009 13:50:41 +0000
parents 8935971e307c
children 19bdbb80999c
line wrap: on
line diff
--- a/FrmNewUnitEquipment.cs	Sat Mar 07 21:08:31 2009 +0000
+++ b/FrmNewUnitEquipment.cs	Sun Apr 05 13:50:41 2009 +0000
@@ -189,21 +189,20 @@
 		private void setValue()
 		{
 			UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem;
-			EquipmentItem equip = equipItem.EquipmentItem;
 
 			if (cbEquipAll.Checked)
 			{
-				commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, -1));
+                commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, -1));
 			}
 			else
 			{
-				if (equip.IsRatioLimit)
+                if (equipItem.IsRatioLimit)
 				{
-					commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, (float)((double)numEquipAmount.Value / 100.0)));
+                    commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0));
 				}
 				else
 				{
-					commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, (float)numEquipAmount.Value));
+                    commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value));
 				}
 			}
 		}
@@ -215,7 +214,7 @@
 
 		private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e)
 		{
-			numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).EquipmentItem.MinNumber != -1 && !cbEquipAll.Checked;
+			numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != -1 && !cbEquipAll.Checked;
 			setOkayButton();
 		}
 
@@ -230,13 +229,12 @@
 			if (listItems.SelectedIndex > -1)
 			{
 				UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem;
-				EquipmentItem equip = equipItem.EquipmentItem;
 				required = equipItem.IsRequired;
 
-				if (equip.IsRatioLimit)
+                if (equipItem.IsRatioLimit)
 				{
-					numEquipAmount.Minimum = (decimal)Math.Round(equip.MinNumber * 100, 2);
-					numEquipAmount.Maximum = (decimal)Math.Round(equip.MaxNumber * 100, 2);
+                    numEquipAmount.Minimum = (decimal)Math.Round(equipItem.MinNumber * 100.0, 2);
+                    numEquipAmount.Maximum = (decimal)Math.Round(equipItem.MaxNumber * 100.0, 2);
 					numEquipAmount.Value = numEquipAmount.Minimum;
 					cbEquipAll.Enabled = false;
 					lblPercent.Visible = true;
@@ -244,11 +242,11 @@
 				}
 				else
 				{
-					numEquipAmount.Minimum = (decimal)(equip.MinNumber != -1 ? equip.MinNumber : unit.Size);
-					numEquipAmount.Maximum = (decimal)(equip.MaxNumber != -1 ? equip.MaxNumber : unit.Size);
+                    numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != -1 ? equipItem.MinNumber : unit.Size);
+                    numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != -1 ? equipItem.MaxNumber : unit.Size);
 					numEquipAmount.Value = numEquipAmount.Minimum;
-					cbEquipAll.Enabled = equip.MinNumber != -1;
-					cbEquipAll.Checked = equip.MinNumber == -1;
+                    cbEquipAll.Enabled = equipItem.MinNumber != -1;
+                    cbEquipAll.Checked = equipItem.MinNumber == -1;
 					numEquipAmount.Width = 144;
 				}
 			}