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