Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:ffb49ec86df7 | 10:19bdbb80999c |
---|---|
190 { | 190 { |
191 UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; | 191 UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; |
192 | 192 |
193 if (cbEquipAll.Checked) | 193 if (cbEquipAll.Checked) |
194 { | 194 { |
195 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, -1)); | 195 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, WarFoundryCore.INFINITY)); |
196 } | 196 } |
197 else | 197 else |
198 { | 198 { |
199 if (equipItem.IsRatioLimit) | 199 if (equipItem.IsRatioLimit) |
200 { | 200 { |
201 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0)); | 201 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0)); |
202 } | 202 } |
203 else | 203 else |
204 { | 204 { |
205 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value)); | 205 commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value)); |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 private void bttnCancel_Click(object sender, System.EventArgs e) | 210 private void bttnCancel_Click(object sender, System.EventArgs e) |
212 this.Close(); | 212 this.Close(); |
213 } | 213 } |
214 | 214 |
215 private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e) | 215 private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e) |
216 { | 216 { |
217 numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != -1 && !cbEquipAll.Checked; | 217 numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != WarFoundryCore.INFINITY && !cbEquipAll.Checked; |
218 setOkayButton(); | 218 setOkayButton(); |
219 } | 219 } |
220 | 220 |
221 private void listItems_SelectedIndexChanged(object sender, System.EventArgs e) | 221 private void listItems_SelectedIndexChanged(object sender, System.EventArgs e) |
222 { | 222 { |
229 if (listItems.SelectedIndex > -1) | 229 if (listItems.SelectedIndex > -1) |
230 { | 230 { |
231 UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; | 231 UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; |
232 required = equipItem.IsRequired; | 232 required = equipItem.IsRequired; |
233 | 233 |
234 if (equipItem.IsRatioLimit) | 234 if (equipItem.IsRatioLimit) |
235 { | 235 { |
236 numEquipAmount.Minimum = (decimal)Math.Round(equipItem.MinNumber * 100.0, 2); | 236 numEquipAmount.Minimum = (decimal)Math.Round(equipItem.MinNumber * 100.0, 2); |
237 numEquipAmount.Maximum = (decimal)Math.Round(equipItem.MaxNumber * 100.0, 2); | 237 numEquipAmount.Maximum = (decimal)Math.Round(equipItem.MaxNumber * 100.0, 2); |
238 numEquipAmount.Value = numEquipAmount.Minimum; | 238 numEquipAmount.Value = numEquipAmount.Minimum; |
239 cbEquipAll.Enabled = false; | 239 cbEquipAll.Enabled = false; |
240 lblPercent.Visible = true; | 240 lblPercent.Visible = true; |
241 numEquipAmount.Width = 120; | 241 numEquipAmount.Width = 120; |
242 } | 242 } |
243 else | 243 else |
244 { | 244 { |
245 numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != -1 ? equipItem.MinNumber : unit.Size); | 245 numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != WarFoundryCore.INFINITY ? equipItem.MinNumber : unit.Size); |
246 numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != -1 ? equipItem.MaxNumber : unit.Size); | 246 numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != WarFoundryCore.INFINITY ? equipItem.MaxNumber : unit.Size); |
247 numEquipAmount.Value = numEquipAmount.Minimum; | 247 numEquipAmount.Value = numEquipAmount.Minimum; |
248 cbEquipAll.Enabled = equipItem.MinNumber != -1; | 248 cbEquipAll.Enabled = equipItem.MinNumber != WarFoundryCore.INFINITY; |
249 cbEquipAll.Checked = equipItem.MinNumber == -1; | 249 cbEquipAll.Checked = equipItem.MinNumber == WarFoundryCore.INFINITY; |
250 numEquipAmount.Width = 144; | 250 numEquipAmount.Width = 144; |
251 } | 251 } |
252 } | 252 } |
253 else | 253 else |
254 { | 254 { |