Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
annotate UI/EquipmentAmountControl.cs @ 80:c243b043aa62
Re #179: Make sure that translations are used throughout UI
* Put names back on menu items
* Add some more translation calls
* Make some extra items translatable
* Update English translation file
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 21 Oct 2009 20:11:18 +0000 |
parents | 431cc3ace26c |
children | e749b748e7ea |
rev | line source |
---|---|
78
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
1 using System; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
2 using System.Collections.Generic; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
3 using System.ComponentModel; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
4 using System.Drawing; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
5 using System.Data; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
6 using System.Text; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
7 using System.Windows.Forms; |
80
c243b043aa62
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
8 using IBBoard.CustomMath; |
78
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
9 using IBBoard.WarFoundry.API; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
10 using IBBoard.WarFoundry.API.Objects; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
11 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
12 namespace IBBoard.WarFoundry.GUI.WinForms.UI |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
13 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
14 public partial class EquipmentAmountControl : UserControl |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
15 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
16 private Unit unit; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
17 private UnitEquipmentItem equip; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
18 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
19 public EquipmentAmountControl() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
20 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
21 InitializeComponent(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
22 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
23 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
24 public void SetUnit(Unit equipUnit) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
25 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
26 unit = equipUnit; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
27 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
28 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
29 public void SetUnitEquipmentItem(UnitEquipmentItem unitEquipment) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
30 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
31 equip = unitEquipment; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
32 SetWidgetValues(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
33 SetUnitEquipmentItemAmount(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
34 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
35 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
36 public event EventHandler ValueChanged; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
37 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
38 private void OnValueChanged() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
39 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
40 if (ValueChanged != null) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
41 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
42 ValueChanged(this, new EventArgs()); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
43 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
44 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
45 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
46 private void SetWidgetValues() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
47 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
48 if (equip != null) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
49 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
50 if (equip.IsRatioLimit) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
51 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
52 double minPercent = equip.MinPercentage; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
53 double maxPercent = equip.MaxPercentage; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
54 int minNumber = (int) CalculateNumericValueFromPercentage(minPercent); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
55 int maxNumber = (int) CalculateNumericValueFromPercentage(maxPercent); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
56 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
57 rbEquipAll.Enabled = maxPercent == 100; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
58 SetUpDownControlMinMaxes(minPercent, maxPercent, minNumber, maxNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
59 SetEquipmentAmountsFromPercentage(minPercent); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
60 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
61 if (minPercent == 100) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
62 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
63 rbEquipAll.Checked = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
64 percentage.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
65 rbPercentage.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
66 numeric.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
67 rbNumeric.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
68 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
69 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
70 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
71 rbPercentage.Checked = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
72 percentage.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
73 rbPercentage.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
74 numeric.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
75 rbNumeric.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
76 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
77 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
78 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
79 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
80 int minNumber = equip.MinNumber; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
81 int maxNumber = equip.MaxNumber; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
82 double minPercent = (double) CalcualtePercentageValueFromNumber(minNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
83 double maxPercent = (double) CalcualtePercentageValueFromNumber(maxNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
84 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
85 percentage.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
86 rbPercentage.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
87 rbEquipAll.Enabled = maxNumber == WarFoundryCore.INFINITY; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
88 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
89 SetUpDownControlMinMaxes(minPercent, maxPercent, minNumber, maxNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
90 SetEquipmentAmountsFromNumber(minNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
91 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
92 if (minNumber == WarFoundryCore.INFINITY) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
93 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
94 numeric.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
95 rbNumeric.Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
96 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
97 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
98 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
99 rbNumeric.Checked = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
100 numeric.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
101 rbNumeric.Enabled = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
102 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
103 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
104 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
105 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
106 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
107 Enabled = false; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
108 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
109 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
110 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
111 private void SetUpDownControlMinMaxes(double minPercent, double maxPercent, int minNumber, int maxNumber) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
112 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
113 percentage.ValueChanged -= percentage_ValueChanged; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
114 numeric.ValueChanged -= numeric_ValueChanged; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
115 SetUpDownControlMinMax(percentage, minPercent, maxPercent); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
116 SetUpDownControlMinMax(numeric, (decimal) minNumber, (decimal) maxNumber); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
117 percentage.ValueChanged += percentage_ValueChanged; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
118 numeric.ValueChanged += numeric_ValueChanged; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
119 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
120 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
121 private void SetUpDownControlMinMax(NumericUpDown upDownControl, double min, double max) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
122 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
123 SetUpDownControlMinMax(upDownControl, (decimal)min, (decimal)max); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
124 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
125 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
126 private void SetUpDownControlMinMax(NumericUpDown upDownControl, decimal min, decimal max) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
127 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
128 upDownControl.Minimum = (min == WarFoundryCore.INFINITY ? unit.Size : min); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
129 upDownControl.Maximum = (max == WarFoundryCore.INFINITY ? unit.Size : max); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
130 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
131 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
132 private void rbEquipAll_CheckedChanged(object sender, EventArgs e) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
133 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
134 bool equipAll = rbEquipAll.Checked; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
135 numeric.Enabled = !equipAll; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
136 percentage.Enabled = !equipAll; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
137 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
138 if (equipAll) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
139 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
140 numeric.Value = unit.Size; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
141 percentage.Value = 100; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
142 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
143 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
144 radioCheckedChanged(sender, e); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
145 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
146 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
147 private void percentage_ValueChanged(object sender, EventArgs e) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
148 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
149 SetNumericValueFromPercentage(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
150 rbEquipAll.Checked = (percentage.Value == 100 && !rbNumeric.Checked); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
151 OnValueChanged(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
152 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
153 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
154 private void SetNumericValueFromPercentage() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
155 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
156 double percent = (double)percentage.Value; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
157 numeric.Value = CalculateNumericValueFromPercentage(percent); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
158 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
159 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
160 private decimal CalculateNumericValueFromPercentage(double percent) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
161 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
162 return (decimal) IBBMath.Round(unit.Size * (percent / 100.0), equip.RoundNumberUp); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
163 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
164 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
165 private void numeric_ValueChanged(object sender, EventArgs e) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
166 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
167 SetPercentageValueFromNumeric(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
168 OnValueChanged(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
169 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
170 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
171 private void SetPercentageValueFromNumeric() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
172 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
173 int number = (int)numeric.Value; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
174 percentage.Value = CalcualtePercentageValueFromNumber(number); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
175 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
176 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
177 private decimal CalcualtePercentageValueFromNumber(int number) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
178 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
179 decimal percent = 0; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
180 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
181 if (number > 0) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
182 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
183 percent = (decimal) Math.Round((number / (unit.Size * 1.0)) * 100, 1); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
184 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
185 else if (number == WarFoundryCore.INFINITY) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
186 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
187 percent = 100; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
188 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
189 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
190 return percent; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
191 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
192 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
193 public double EquipmentAmount |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
194 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
195 get |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
196 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
197 double val = 0; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
198 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
199 if (rbNumeric.Checked) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
200 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
201 val = (double) numeric.Value; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
202 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
203 else if (rbPercentage.Checked) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
204 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
205 val = (double) percentage.Value; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
206 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
207 else if (rbEquipAll.Checked) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
208 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
209 val = WarFoundryCore.INFINITY; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
210 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
211 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
212 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
213 val = 0; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
214 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
215 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
216 return val; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
217 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
218 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
219 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
220 public bool IsRatioEquipmentAmount |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
221 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
222 get |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
223 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
224 return rbPercentage.Checked; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
225 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
226 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
227 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
228 private void SetUnitEquipmentItemAmount() |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
229 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
230 double equipAmountNum = unit.GetEquipmentAmount(equip); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
231 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
232 if (equipAmountNum > 0) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
233 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
234 bool isRatio = unit.GetEquipmentAmountIsRatio(equip); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
235 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
236 if (isRatio) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
237 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
238 SetEquipmentAmountsFromPercentage(equipAmountNum); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
239 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
240 else if (equipAmountNum == WarFoundryCore.INFINITY) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
241 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
242 rbEquipAll.Checked = true; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
243 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
244 else |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
245 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
246 int equipAmount = (int) equipAmountNum; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
247 SetEquipmentAmountsFromNumber(equipAmount); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
248 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
249 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
250 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
251 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
252 private void SetEquipmentAmountsFromPercentage(double equipAmountNum) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
253 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
254 numeric.Value = CalculateNumericValueFromPercentage(equipAmountNum); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
255 percentage.Value = (decimal) equipAmountNum; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
256 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
257 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
258 private void SetEquipmentAmountsFromNumber(int equipAmount) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
259 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
260 rbEquipAll.Checked = (equipAmount == WarFoundryCore.INFINITY); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
261 equipAmount = (equipAmount == WarFoundryCore.INFINITY ? unit.Size : equipAmount); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
262 percentage.Value = CalcualtePercentageValueFromNumber(equipAmount); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
263 numeric.Value = equipAmount; |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
264 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
265 |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
266 private void radioCheckedChanged(object sender, EventArgs e) |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
267 { |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
268 OnValueChanged(); |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
269 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
270 } |
431cc3ace26c
Fixes #187: Error when adding equipment with minNum > unit size
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
271 } |