Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
diff FrmAddEquipment.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 |
line wrap: on
line diff
--- a/FrmAddEquipment.cs Fri Dec 31 11:36:06 2010 +0000 +++ b/FrmAddEquipment.cs Fri Dec 31 12:01:18 2010 +0000 @@ -10,30 +10,38 @@ using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; using IBBoard.WarFoundry.GUI.GTK.Util; using log4net; +using IBBoard.Lang; namespace IBBoard.WarFoundry.GUI.GTK { public partial class FrmAddEquipment : TranslatableDialog, IAddEquipmentUI { private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment)); + public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged; public event MethodInvoker UnitEquipmentAmountTypeChanged; public event MethodInvoker UnitEquipmentAmountChanged; private bool isRatioLimited; - + public FrmAddEquipment() { this.Build(); lstEquipment.Selection.Changed += OnSelectionChanged; TreeViewColumn equipColumn = new TreeViewColumn(); - equipColumn.Title = "Equipment"; CellRendererText equipCell = new CellRendererText(); equipColumn.PackStart(equipCell, true); equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName); - lstEquipment.AppendColumn(equipColumn); + lstEquipment.AppendColumn(equipColumn); + Translate(); } - + + protected override void Translate() + { + base.Translate(); + lstEquipment.Columns[0].Title = Translation.GetTranslation("frmAddEquipmentColumnTitle", "equipment"); + } + private void OnUnitEquipmentAmountChanged() { if (UnitEquipmentAmountChanged != null) @@ -41,7 +49,7 @@ UnitEquipmentAmountChanged(); } } - + private void OnUnitEquipmentAmountTypeChanged() { if (UnitEquipmentAmountChanged != null) @@ -49,7 +57,7 @@ UnitEquipmentAmountTypeChanged(); } } - + protected void OnSelectionChanged(object o, EventArgs e) { if (UnitEquipmentItemChoiceChanged != null) @@ -108,41 +116,41 @@ this.Hide(); return okayClicked; } - + protected virtual void CancelButtonClicked(object sender, System.EventArgs e) { log.Debug("Cancel clicked"); Respond(ResponseType.Cancel); } - + protected virtual void OkayButtonClicked(object sender, System.EventArgs e) { log.Debug("Okay clicked"); Respond(ResponseType.Ok); } - + public void SetOkayEnabledState(bool enabled) { buttonOk.Sensitive = enabled; } - + protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e) { OnUnitEquipmentAmountChanged(); } - + protected virtual void RadioButtonClicked(object sender, System.EventArgs e) { OnUnitEquipmentAmountTypeChanged(); } - + public void SetNumericAmountEnabledState(bool enabled) { double minPercent = GetMinPercentage(); rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100); numericAmount.Sensitive = rbEquipNumeric.Sensitive; } - + public void SetPercentageAmountEnabledState(bool enabled) { if (enabled) @@ -176,7 +184,7 @@ percentageAmount.GetRange(out min, out max); return min; } - + public void ListenToWidgets() { rbEquipAll.Clicked += RadioButtonClicked; @@ -186,7 +194,7 @@ percentageAmount.ValueChanged += SpinButtonValueChanged; lstEquipment.Selection.Changed += OnSelectionChanged; } - + public void IgnoreWidgets() { rbEquipAll.Clicked -= RadioButtonClicked; @@ -196,7 +204,7 @@ percentageAmount.ValueChanged -= SpinButtonValueChanged; lstEquipment.Selection.Changed -= OnSelectionChanged; } - + public UnitEquipmentItem SelectedUnitEquipmentItem { get @@ -204,7 +212,7 @@ return (UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment); } } - + public bool IsRatioEquipmentAmount { get @@ -212,7 +220,7 @@ return !rbEquipNumeric.Active; } } - + public int EquipmentNumericAmount { get @@ -225,7 +233,7 @@ numericAmount.Value = value; } } - + public double EquipmentPercentageAmount { get