comparison FrmEditEquipment.cs @ 92:58779fcd0166

Re #308: Make GTK# UI translatable * Switch lots of labels to translatable versions * Swap some default text to lower-case to make it easier to spot missing translations
author IBBoard <dev@ibboard.co.uk>
date Fri, 31 Dec 2010 12:01:18 +0000
parents 7055b24cfc79
children b4416ca69153
comparison
equal deleted inserted replaced
91:986fc923c0fa 92:58779fcd0166
9 using IBBoard.WarFoundry.GUI.GTK.Util; 9 using IBBoard.WarFoundry.GUI.GTK.Util;
10 using IBBoard.GtkSharp; 10 using IBBoard.GtkSharp;
11 using log4net.Repository.Hierarchy; 11 using log4net.Repository.Hierarchy;
12 using log4net; 12 using log4net;
13 using IBBoard.GtkSharp.Translatable; 13 using IBBoard.GtkSharp.Translatable;
14 using IBBoard.Lang;
14 15
15 namespace IBBoard.WarFoundry.GUI.GTK 16 namespace IBBoard.WarFoundry.GUI.GTK
16 { 17 {
17 public partial class FrmEditEquipment : TranslatableDialog, IEditEquipmentUI 18 public partial class FrmEditEquipment : TranslatableDialog, IEditEquipmentUI
18 { 19 {
19 private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment)); 20 private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment));
21
20 public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged; 22 public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
21 public event MethodInvoker UnitEquipmentAmountTypeChanged; 23 public event MethodInvoker UnitEquipmentAmountTypeChanged;
22 public event MethodInvoker UnitEquipmentAmountChanged; 24 public event MethodInvoker UnitEquipmentAmountChanged;
23 25
24 private bool isRatioLimited; 26 private bool isRatioLimited;
25 27
26 public FrmEditEquipment() 28 public FrmEditEquipment()
27 { 29 {
28 this.Build(); 30 this.Build();
29 TreeViewColumn equipColumn = new TreeViewColumn(); 31 Translate();
30 equipColumn.Title = "Equipment"; 32 }
31 CellRendererText equipCell = new CellRendererText(); 33
32 equipColumn.PackStart(equipCell, true);
33 equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);
34 }
35
36 public void ListenToWidgets() 34 public void ListenToWidgets()
37 { 35 {
38 rbEquipAll.Clicked += RadioButtonClicked; 36 rbEquipAll.Clicked += RadioButtonClicked;
39 rbEquipNumeric.Clicked += RadioButtonClicked; 37 rbEquipNumeric.Clicked += RadioButtonClicked;
40 rbEquipPercent.Clicked += RadioButtonClicked; 38 rbEquipPercent.Clicked += RadioButtonClicked;
41 numericAmount.ValueChanged += SpinButtonValueChanged; 39 numericAmount.ValueChanged += SpinButtonValueChanged;
42 percentageAmount.ValueChanged += SpinButtonValueChanged; 40 percentageAmount.ValueChanged += SpinButtonValueChanged;
43 } 41 }
44 42
45 public void IgnoreWidgets() 43 public void IgnoreWidgets()
46 { 44 {
47 rbEquipAll.Clicked -= RadioButtonClicked; 45 rbEquipAll.Clicked -= RadioButtonClicked;
48 rbEquipNumeric.Clicked -= RadioButtonClicked; 46 rbEquipNumeric.Clicked -= RadioButtonClicked;
49 rbEquipPercent.Clicked -= RadioButtonClicked; 47 rbEquipPercent.Clicked -= RadioButtonClicked;
50 numericAmount.ValueChanged -= SpinButtonValueChanged; 48 numericAmount.ValueChanged -= SpinButtonValueChanged;
51 percentageAmount.ValueChanged -= SpinButtonValueChanged; 49 percentageAmount.ValueChanged -= SpinButtonValueChanged;
52 } 50 }
53 51
54 private void OnUnitEquipmentAmountChanged() 52 private void OnUnitEquipmentAmountChanged()
55 { 53 {
56 if (UnitEquipmentAmountChanged != null) 54 if (UnitEquipmentAmountChanged != null)
57 { 55 {
58 UnitEquipmentAmountChanged(); 56 UnitEquipmentAmountChanged();
59 } 57 }
60 } 58 }
61 59
62 private void OnUnitEquipmentAmountTypeChanged() 60 private void OnUnitEquipmentAmountTypeChanged()
63 { 61 {
64 if (UnitEquipmentAmountChanged != null) 62 if (UnitEquipmentAmountChanged != null)
65 { 63 {
66 UnitEquipmentAmountTypeChanged(); 64 UnitEquipmentAmountTypeChanged();
106 int result = Run(); 104 int result = Run();
107 bool okayClicked = (result == (int)ResponseType.Ok); 105 bool okayClicked = (result == (int)ResponseType.Ok);
108 this.Hide(); 106 this.Hide();
109 return okayClicked; 107 return okayClicked;
110 } 108 }
111 109
112 protected virtual void CancelButtonClicked(object sender, System.EventArgs e) 110 protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
113 { 111 {
114 log.Debug("Cancel clicked"); 112 log.Debug("Cancel clicked");
115 Respond(ResponseType.Cancel); 113 Respond(ResponseType.Cancel);
116 } 114 }
117 115
118 protected virtual void OkayButtonClicked(object sender, System.EventArgs e) 116 protected virtual void OkayButtonClicked(object sender, System.EventArgs e)
119 { 117 {
120 log.Debug("Okay clicked"); 118 log.Debug("Okay clicked");
121 Respond(ResponseType.Ok); 119 Respond(ResponseType.Ok);
122 } 120 }
123 121
124 public void SetOkayEnabledState(bool enabled) 122 public void SetOkayEnabledState(bool enabled)
125 { 123 {
126 buttonOk.Sensitive = enabled; 124 buttonOk.Sensitive = enabled;
127 } 125 }
128 126
129 protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e) 127 protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e)
130 { 128 {
131 OnUnitEquipmentAmountChanged(); 129 OnUnitEquipmentAmountChanged();
132 } 130 }
133 131
134 protected virtual void RadioButtonClicked(object sender, System.EventArgs e) 132 protected virtual void RadioButtonClicked(object sender, System.EventArgs e)
135 { 133 {
136 OnUnitEquipmentAmountTypeChanged(); 134 OnUnitEquipmentAmountTypeChanged();
137 } 135 }
138 136
139 public void SetNumericAmountEnabledState(bool enabled) 137 public void SetNumericAmountEnabledState(bool enabled)
140 { 138 {
141 double minPercent = GetMinPercentage(); 139 double minPercent = GetMinPercentage();
142 rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100); 140 rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100);
143 numericAmount.Sensitive = rbEquipNumeric.Sensitive; 141 numericAmount.Sensitive = rbEquipNumeric.Sensitive;
144 } 142 }
145 143
146 public void SetPercentageAmountEnabledState(bool enabled) 144 public void SetPercentageAmountEnabledState(bool enabled)
147 { 145 {
148 if (enabled) 146 if (enabled)
149 { 147 {
150 double minPercentage = GetMinPercentage(); 148 double minPercentage = GetMinPercentage();
174 { 172 {
175 double min, max; 173 double min, max;
176 percentageAmount.GetRange(out min, out max); 174 percentageAmount.GetRange(out min, out max);
177 return min; 175 return min;
178 } 176 }
179 177
180 public bool IsRatioEquipmentAmount 178 public bool IsRatioEquipmentAmount
181 { 179 {
182 get 180 get
183 { 181 {
184 return !rbEquipNumeric.Active; 182 return !rbEquipNumeric.Active;
185 } 183 }
186 } 184 }
187 185
188 public int EquipmentNumericAmount 186 public int EquipmentNumericAmount
189 { 187 {
190 get 188 get
191 { 189 {
192 return (int)numericAmount.Value; 190 return (int)numericAmount.Value;
195 set 193 set
196 { 194 {
197 numericAmount.Value = value; 195 numericAmount.Value = value;
198 } 196 }
199 } 197 }
200 198
201 public double EquipmentPercentageAmount 199 public double EquipmentPercentageAmount
202 { 200 {
203 get 201 get
204 { 202 {
205 double percent; 203 double percent;