Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
comparison FrmAddEquipment.cs @ 57:293d204e40db
Re #60: Add UI to add/remove/edit weapons in GTK
* Make enabling/disabling fit the values passed (copied from existing WinForms checks)
* Add extra interface methods and properties to get necessary values from UI to use in command
* Implement new interface methods
* Implement command execution
* Make use of IDisposable interface instead of defining Dispose ourselves
Also:
* Use existing method of printing exception stack traces in main window
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 26 Aug 2010 19:30:22 +0000 |
parents | 0c5fbb54bfb0 |
children | e7ad676a7344 |
comparison
equal
deleted
inserted
replaced
56:0c5fbb54bfb0 | 57:293d204e40db |
---|---|
34 | 34 |
35 protected virtual void OnSelectionChanged(object o, EventArgs e) | 35 protected virtual void OnSelectionChanged(object o, EventArgs e) |
36 { | 36 { |
37 if (UnitEquipmentItemChoiceChanged!=null) | 37 if (UnitEquipmentItemChoiceChanged!=null) |
38 { | 38 { |
39 UnitEquipmentItemChoiceChanged((UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment)); | 39 UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 public void SetUnitEquipmentItems(UnitEquipmentItem[] items) | 43 public void SetUnitEquipmentItems(UnitEquipmentItem[] items) |
44 { | 44 { |
67 SetEnabledState(); | 67 SetEnabledState(); |
68 } | 68 } |
69 | 69 |
70 private void SetEnabledState() | 70 private void SetEnabledState() |
71 { | 71 { |
72 rbEquipNumeric.Sensitive = (limitsEnabled && ratioLimited); | 72 rbEquipNumeric.Sensitive = (limitsEnabled && !ratioLimited); |
73 numericAmount.Sensitive = (limitsEnabled && ratioLimited); | 73 numericAmount.Sensitive = (limitsEnabled && !ratioLimited); |
74 rbEquipPercent.Sensitive = limitsEnabled; | 74 double minPercentage = GetMinPercentage(); |
75 percentageAmount.Sensitive = limitsEnabled; | 75 rbEquipPercent.Sensitive = limitsEnabled && minPercentage != 100; |
76 rbEquipAll.Sensitive = limitsEnabled; | 76 percentageAmount.Sensitive = limitsEnabled && minPercentage != 100; |
77 lblEquipAll.Sensitive = limitsEnabled; | 77 double maxPercentage = GetMaxPercentage(); |
78 rbEquipAll.Sensitive = limitsEnabled && maxPercentage == 100; | |
79 lblEquipAll.Sensitive = limitsEnabled && maxPercentage == 100; | |
80 } | |
81 | |
82 private double GetMaxPercentage() | |
83 { | |
84 double min, max; | |
85 percentageAmount.GetRange(out min, out max); | |
86 return max; | |
87 } | |
88 | |
89 private double GetMinPercentage() | |
90 { | |
91 double min, max; | |
92 percentageAmount.GetRange(out min, out max); | |
93 return min; | |
78 } | 94 } |
79 | 95 |
80 public bool ShowControl() | 96 public bool ShowControl() |
81 { | 97 { |
82 int result = Run(); | 98 int result = Run(); |
94 protected virtual void OkayButtonClicked(object sender, System.EventArgs e) | 110 protected virtual void OkayButtonClicked(object sender, System.EventArgs e) |
95 { | 111 { |
96 log.Debug("Okay clicked"); | 112 log.Debug("Okay clicked"); |
97 Respond(ResponseType.Ok); | 113 Respond(ResponseType.Ok); |
98 } | 114 } |
115 | |
116 public UnitEquipmentItem SelectedUnitEquipmentItem | |
117 { | |
118 get | |
119 { | |
120 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment); | |
121 } | |
122 } | |
123 | |
124 | |
125 public bool IsRatioEquipmentAmount | |
126 { | |
127 get | |
128 { | |
129 return !rbEquipNumeric.Active; | |
130 } | |
131 } | |
132 | |
133 | |
134 public int EquipmentNumericAmount | |
135 { | |
136 get | |
137 { | |
138 return (int)numericAmount.Value; | |
139 } | |
140 } | |
141 | |
142 | |
143 public double EquipmentPercentageAmount | |
144 { | |
145 get | |
146 { | |
147 double percent; | |
148 | |
149 if (rbEquipAll.Active) | |
150 { | |
151 percent = 100; | |
152 } | |
153 else | |
154 { | |
155 percent = percentageAmount.Value; | |
156 } | |
157 | |
158 return percent; | |
159 } | |
160 } | |
99 } | 161 } |
100 } | 162 } |
101 | 163 |