Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
annotate UI/EquipmentAmountControl.cs @ 101:3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
* Intermediary fix for locations in the UI for amount translations
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Nov 2009 21:27:39 +0000 |
parents | c7afc7824f50 |
children | e598c0d2584d |
rev | line source |
---|---|
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
1 using System; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
2 using System.Collections.Generic; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
3 using System.ComponentModel; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
4 using System.Drawing; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
5 using System.Data; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
6 using System.Text; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
7 using System.Windows.Forms; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
8 using log4net; |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
9 using IBBoard.CustomMath; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
10 using IBBoard.Lang; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
11 using IBBoard.Limits; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
12 using IBBoard.WarFoundry.API; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
13 using IBBoard.WarFoundry.API.Objects; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
14 using IBBoard.WarFoundry.API.Util; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
15 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
16 namespace IBBoard.WarFoundry.GUI.WinForms.UI |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
17 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
18 public partial class EquipmentAmountControl : UserControl |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
19 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
20 private ILog log = LogManager.GetLogger(typeof(EquipmentAmountControl)); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
21 private Unit unit; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
22 private UnitEquipmentItem equip; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
23 public event EventHandler ValueChanged; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
24 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
25 public EquipmentAmountControl() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
26 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
27 InitializeComponent(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
28 rbEquipAll.Text = Translation.GetTranslation("rbEquipAll", "equip all"); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
29 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
30 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
31 public void SetUnit(Unit equipUnit) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
32 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
33 unit = equipUnit; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
34 log.Debug("Set unit to: " + (unit == null ? "null" : unit.Name)); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
35 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
36 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
37 public void SetUnitEquipmentItem(UnitEquipmentItem unitEquipment) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
38 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
39 equip = unitEquipment; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
40 log.Debug("Set equipment to: " + (equip == null ? "null" : equip.Name)); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
41 SetWidgetValues(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
42 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
43 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
44 private void OnValueChanged() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
45 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
46 if (ValueChanged != null) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
47 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
48 ValueChanged(this, new EventArgs()); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
49 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
50 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
51 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
52 private void SetWidgetValues() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
53 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
54 if (equip != null) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
55 { |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
56 IgnoreWidgets(); |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
57 |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
58 log.Debug("Equipment update"); |
89
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
59 bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
60 log.Debug("Equipment is ratio? " + (equipIsRatioLimit ? "yes" : "no")); |
89
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
61 double maxPercent = RoundPercentage(UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
62 maxPercent = Math.Max(0, maxPercent); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
63 log.Debug("Equipment max percentage: " + maxPercent); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
64 double minPercent = RoundPercentage(UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
65 minPercent = Math.Max(0, minPercent); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
66 log.Debug("Equipment min percentage: " + minPercent); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
67 int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
68 maxNumber = Math.Max(0, maxNumber); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
69 log.Debug("Equipment max count: " + maxNumber); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
70 int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
71 minNumber = Math.Max(0, minNumber); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
72 log.Debug("Equipment min count: " + minNumber); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
73 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
74 SetUpDownControlMinMaxes(minPercent, maxPercent, minNumber, maxNumber); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
75 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
76 if (equipIsRatioLimit) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
77 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
78 SetEquipmentAmountsFromPercentage(minPercent); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
79 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
80 else |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
81 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
82 SetEquipmentAmountsFromNumber(minNumber); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
83 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
84 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
85 rbEquipAll.Enabled = equipIsRatioLimit && maxPercent == 100; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
86 rbEquipAll.Checked = equipIsRatioLimit && minPercent == 100; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
87 log.Debug("rbEquipAll: " + (rbEquipAll.Enabled ? "enabled":"disabled") + " " + (rbEquipAll.Checked ? "checked" : "unchecked")); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
88 percentage.Enabled = equipIsRatioLimit && minPercent != 100; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
89 rbPercentage.Enabled = percentage.Enabled; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
90 rbPercentage.Checked = equipIsRatioLimit && !rbEquipAll.Checked; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
91 log.Debug("rbPercentage: " + (rbPercentage.Enabled ? "enabled" : "disabled") + " " + (rbPercentage.Checked ? "checked" : "unchecked")); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
92 numeric.Enabled = !equipIsRatioLimit || minPercent != 100; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
93 rbNumeric.Enabled = numeric.Enabled; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
94 rbNumeric.Checked = !equipIsRatioLimit; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
95 log.Debug("rbNumeric: " + (rbNumeric.Enabled ? "enabled" : "disabled") + " " + (rbNumeric.Checked ? "checked" : "unchecked")); |
91 | 96 SetUnitEquipmentItemAmount(); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
97 |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
98 ListenToWidgets(); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
99 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
100 else |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
101 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
102 log.Debug("Null equipment - no widget update"); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
103 Enabled = false; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
104 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
105 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
106 |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
107 private void IgnoreWidgets() |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
108 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
109 percentage.ValueChanged -= percentage_ValueChanged; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
110 numeric.ValueChanged -= numeric_ValueChanged; |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
111 rbEquipAll.CheckedChanged -= rbEquipAll_CheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
112 rbNumeric.CheckedChanged -= radioCheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
113 rbPercentage.CheckedChanged -= radioCheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
114 } |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
115 |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
116 private void ListenToWidgets() |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
117 { |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
118 percentage.ValueChanged += percentage_ValueChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
119 numeric.ValueChanged += numeric_ValueChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
120 rbEquipAll.CheckedChanged += rbEquipAll_CheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
121 rbNumeric.CheckedChanged += radioCheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
122 rbPercentage.CheckedChanged += radioCheckedChanged; |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
123 } |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
124 |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
125 private void SetUpDownControlMinMaxes(double minPercent, double maxPercent, int minNumber, int maxNumber) |
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
126 { |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
127 SetUpDownControlMinMax(percentage, minPercent, maxPercent); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
128 SetUpDownControlMinMax(numeric, (decimal) minNumber, (decimal) maxNumber); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
129 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
130 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
131 private void SetUpDownControlMinMax(NumericUpDown upDownControl, double min, double max) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
132 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
133 SetUpDownControlMinMax(upDownControl, (decimal)min, (decimal)max); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
134 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
135 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
136 private void SetUpDownControlMinMax(NumericUpDown upDownControl, decimal min, decimal max) |
88
340e711ca4c3
Re #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
137 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
138 log.Debug("Set "+upDownControl.Name+" min and max to: "+min+", "+max); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
139 upDownControl.Minimum = min; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
140 upDownControl.Maximum = max; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
141 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
142 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
143 private void rbEquipAll_CheckedChanged(object sender, EventArgs e) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
144 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
145 bool equipAll = rbEquipAll.Checked; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
146 numeric.Enabled = !equipAll; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
147 percentage.Enabled = !equipAll; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
148 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
149 if (equipAll) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
150 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
151 numeric.Value = unit.Size; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
152 percentage.Value = 100; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
153 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
154 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
155 radioCheckedChanged(sender, e); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
156 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
157 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
158 private void percentage_ValueChanged(object sender, EventArgs e) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
159 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
160 log.Debug("Percentage value changed"); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
161 SetNumericValueFromPercentage(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
162 rbEquipAll.Checked = (percentage.Value == 100 && !rbNumeric.Checked); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
163 OnValueChanged(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
164 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
165 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
166 private void SetNumericValueFromPercentage() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
167 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
168 numeric.ValueChanged -= numeric_ValueChanged; |
88
340e711ca4c3
Re #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
169 numeric.Value = CalculateNumericValueFromPercentage(percentage.Value); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
170 numeric.ValueChanged += numeric_ValueChanged; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
171 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
172 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
173 private decimal CalculateNumericValueFromPercentage(decimal percent) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
174 { |
96
057498981bde
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
175 decimal calcedAmount = (decimal) IBBoard.CustomMath.IBBMath.Round((double)(unit.Size * (percent / 100)), equip.RoundNumberUp); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
176 log.Debug("Numeric value calculated from percentage: "+percent+"% -> "+calcedAmount); |
96
057498981bde
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
177 return Math.Min(Math.Max(calcedAmount, numeric.Minimum), numeric.Maximum); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
178 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
179 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
180 private void numeric_ValueChanged(object sender, EventArgs e) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
181 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
182 log.Debug("Numeric value changed"); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
183 SetPercentageValueFromNumeric(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
184 OnValueChanged(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
185 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
186 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
187 private void SetPercentageValueFromNumeric() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
188 { |
88
340e711ca4c3
Re #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
189 int number = (int)numeric.Value; |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
190 percentage.ValueChanged -= percentage_ValueChanged; |
88
340e711ca4c3
Re #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
85
diff
changeset
|
191 percentage.Value = CalcualtePercentageValueFromNumber(number); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
192 percentage.ValueChanged += percentage_ValueChanged; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
193 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
194 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
195 private decimal CalcualtePercentageValueFromNumber(int number) |
89
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
196 { |
96
057498981bde
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
197 decimal calcedAmount = (decimal) RoundPercentage(IBBoard.CustomMath.IBBMath.Percentage(number, unit.Size)); |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
198 log.Debug("Numeric value calculated from percentage: " + number + " -> " + calcedAmount+"%"); |
96
057498981bde
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
93
diff
changeset
|
199 return Math.Min(Math.Max(calcedAmount, percentage.Minimum), percentage.Maximum); |
89
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
200 } |
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
201 |
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
202 private double RoundPercentage(double percent) |
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
203 { |
971f7801f984
Fixes #205: Odd/prime numbers causes a crash
IBBoard <dev@ibboard.co.uk>
parents:
88
diff
changeset
|
204 return Math.Round(percent, 1); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
205 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
206 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
207 public double EquipmentAmount |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
208 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
209 get |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
210 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
211 double val = 0; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
212 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
213 if (rbNumeric.Checked) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
214 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
215 val = (double) numeric.Value; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
216 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
217 else if (rbPercentage.Checked) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
218 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
219 val = (double) percentage.Value; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
220 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
221 else if (rbEquipAll.Checked) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
222 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
223 val = 100; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
224 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
225 else |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
226 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
227 val = 0; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
228 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
229 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
230 return val; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
231 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
232 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
233 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
234 public bool IsRatioEquipmentAmount |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
235 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
236 get |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
237 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
238 return !rbNumeric.Checked; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
239 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
240 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
241 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
242 private void SetUnitEquipmentItemAmount() |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
243 { |
101
3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
244 double equipAmountNum = UnitEquipmentUtil.GetEquipmentAmount(unit, equip); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
245 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
246 if (equipAmountNum > 0) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
247 { |
101
3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
248 bool isRatio = UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equip); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
249 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
250 if (isRatio) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
251 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
252 SetEquipmentAmountsFromPercentage(equipAmountNum); |
93 | 253 |
254 if (equipAmountNum == 100) | |
255 { | |
256 rbEquipAll.Checked = true; | |
257 } | |
258 else | |
259 { | |
260 rbPercentage.Checked = true; | |
261 } | |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
262 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
263 else |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
264 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
265 int equipAmount = (int) equipAmountNum; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
266 SetEquipmentAmountsFromNumber(equipAmount); |
93 | 267 rbNumeric.Checked = true; |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
268 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
269 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
270 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
271 |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
272 private void SetEquipmentAmountsFromPercentage(double equipAmount) |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
273 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
274 log.Debug("Set equipment amount from percentage: " + equipAmount); |
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
275 decimal decEquipAmount = (decimal) equipAmount; |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
276 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
277 if (decEquipAmount > percentage.Maximum) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
278 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
279 string percentageTooLarge = Translation.GetTranslation("equipPercentageTooLarge", "The current percentage ({0}%) was larger than the maximum for the equipment item ({1}%). The maximum value will be used instead.", equipAmount, percentage.Maximum); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
280 string percentageTooLargeTitle = Translation.GetTranslation("equipPercentageTooLargeTitle", "Equipment percentage too large"); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
281 MessageBox.Show(ParentForm, percentageTooLarge, percentageTooLargeTitle); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
282 decEquipAmount = percentage.Maximum; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
283 log.Debug("Limited equipment amount to " + decEquipAmount); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
284 OnValueChanged(); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
285 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
286 else if (decEquipAmount < percentage.Minimum) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
287 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
288 string percentageTooSmall = Translation.GetTranslation("equipPercentageTooSmall", "The current percentage ({0}%) was smaller than the minimum for the equipment item ({1}%). The minimum value will be used instead.", equipAmount, percentage.Minimum); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
289 string percentageTooSmallTitle = Translation.GetTranslation("equipPercentageTooSmallTitle", "Equipment percentage too small"); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
290 MessageBox.Show(ParentForm, percentageTooSmall, percentageTooSmallTitle); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
291 decEquipAmount = percentage.Minimum; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
292 log.Debug("Limited equipment amount to " + decEquipAmount); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
293 OnValueChanged(); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
294 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
295 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
296 numeric.Value = CalculateNumericValueFromPercentage(decEquipAmount); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
297 percentage.Value = decEquipAmount; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
298 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
299 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
300 private void SetEquipmentAmountsFromNumber(int equipAmount) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
301 { |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
302 log.Debug("Set equipment percentage from amount: " + equipAmount); |
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
303 |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
304 if (equipAmount > numeric.Maximum) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
305 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
306 string amountTooLarge = Translation.GetTranslation("equipNumberTooLarge", "The current amount ({0}) was larger than the maximum for the equipment item ({1}). The maximum value will be used instead.", equipAmount, numeric.Maximum); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
307 string amountTooLargeTitle = Translation.GetTranslation("equipNumberTooLargeTitle", "Equipment amount too large"); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
308 MessageBox.Show(ParentForm, amountTooLarge, amountTooLargeTitle); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
309 equipAmount = (int)numeric.Maximum; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
310 log.Debug("Limited equipment amount to " + equipAmount); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
311 OnValueChanged(); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
312 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
313 else if (equipAmount < numeric.Minimum) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
314 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
315 string amountTooSmall = Translation.GetTranslation("equipNumberTooSmall", "The current amount ({0}) was smaller than the minimum for the equipment item ({1}). The minimum value will be used instead.", equipAmount, numeric.Minimum); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
316 string amountTooSmallTitle = Translation.GetTranslation("equipNumberTooSmallTitle", "Equipment amount too small"); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
317 MessageBox.Show(ParentForm, amountTooSmall, amountTooSmallTitle); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
318 equipAmount = (int) numeric.Minimum; |
97
e356134d73c4
Re #209: equipmentslot Value problem
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
319 log.Debug("Limited equipment amount to " + equipAmount); |
98
c7afc7824f50
Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents:
97
diff
changeset
|
320 OnValueChanged(); |
90
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
321 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
322 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
323 percentage.Value = CalcualtePercentageValueFromNumber(equipAmount); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
324 numeric.Value = equipAmount; |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
325 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
326 |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
327 private void radioCheckedChanged(object sender, EventArgs e) |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
328 { |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
329 OnValueChanged(); |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
330 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
331 } |
63ca28bd8ada
Re #179: Translations throughout GUI
IBBoard <dev@ibboard.co.uk>
parents:
89
diff
changeset
|
332 } |