diff FrmNewUnitEquipment.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 755e60be28be
children 7c366fe55635
line wrap: on
line diff
--- a/FrmNewUnitEquipment.cs	Tue May 19 11:10:07 2009 +0000
+++ b/FrmNewUnitEquipment.cs	Tue May 19 18:51:32 2009 +0000
@@ -192,17 +192,17 @@
 
 			if (cbEquipAll.Checked)
 			{
-                commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, -1));
+				commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, WarFoundryCore.INFINITY));
 			}
 			else
 			{
-                if (equipItem.IsRatioLimit)
+				if (equipItem.IsRatioLimit)
 				{
-                    commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0));
+					commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0));
 				}
 				else
 				{
-                    commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value));
+					commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value));
 				}
 			}
 		}
@@ -214,7 +214,7 @@
 
 		private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e)
 		{
-			numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != -1 && !cbEquipAll.Checked;
+			numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != WarFoundryCore.INFINITY && !cbEquipAll.Checked;
 			setOkayButton();
 		}
 
@@ -231,10 +231,10 @@
 				UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem;
 				required = equipItem.IsRequired;
 
-                if (equipItem.IsRatioLimit)
+				if (equipItem.IsRatioLimit)
 				{
-                    numEquipAmount.Minimum = (decimal)Math.Round(equipItem.MinNumber * 100.0, 2);
-                    numEquipAmount.Maximum = (decimal)Math.Round(equipItem.MaxNumber * 100.0, 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;
@@ -242,11 +242,11 @@
 				}
 				else
 				{
-                    numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != -1 ? equipItem.MinNumber : unit.Size);
-                    numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != -1 ? equipItem.MaxNumber : unit.Size);
+					numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != WarFoundryCore.INFINITY ? equipItem.MinNumber : unit.Size);
+					numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != WarFoundryCore.INFINITY ? equipItem.MaxNumber : unit.Size);
 					numEquipAmount.Value = numEquipAmount.Minimum;
-                    cbEquipAll.Enabled = equipItem.MinNumber != -1;
-                    cbEquipAll.Checked = equipItem.MinNumber == -1;
+					cbEquipAll.Enabled = equipItem.MinNumber != WarFoundryCore.INFINITY;
+					cbEquipAll.Checked = equipItem.MinNumber == WarFoundryCore.INFINITY;
 					numEquipAmount.Width = 144;
 				}
 			}