annotate FrmReplaceEquipment.cs @ 113:4a33b3012100 WarFoundry_v0.1RC1

* Tag v0.1RC1 release no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Mon, 17 Jan 2011 19:43:47 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (FrmAddEquipment.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using Gtk;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.GtkSharp;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.GtkSharp.Translatable;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.Lang;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using IBBoard.WarFoundry.API.Objects;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 using IBBoard.WarFoundry.GUI.GTK.Util;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 using log4net;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 namespace IBBoard.WarFoundry.GUI.GTK
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 public partial class FrmReplaceEquipment : TranslatableDialog, IReplaceEquipmentUI
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 private static ILog log = LogManager.GetLogger(typeof(FrmReplaceEquipment));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public event MethodInvoker UnitEquipmentAmountTypeChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 public event MethodInvoker UnitEquipmentAmountChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 private bool isRatioLimited;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 public FrmReplaceEquipment()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 this.Build();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 lstEquipment.Selection.Changed += OnSelectionChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 TreeViewColumn equipColumn = new TreeViewColumn();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 equipColumn.Title = "Equipment";
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 CellRendererText equipCell = new CellRendererText();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 equipColumn.PackStart(equipCell, true);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 lstEquipment.AppendColumn(equipColumn);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 Translation.TranslationChanged += Retranslate;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 Translate();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 private void Retranslate()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 Translate();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 public override void Dispose()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 Translation.TranslationChanged -= Retranslate;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 base.Dispose();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 public void ListenToWidgets()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 rbEquipAll.Clicked += RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 rbEquipNumeric.Clicked += RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 rbEquipPercent.Clicked += RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 numericAmount.ValueChanged += SpinButtonValueChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 percentageAmount.ValueChanged += SpinButtonValueChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 lstEquipment.Selection.Changed += OnSelectionChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 public void IgnoreWidgets()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 rbEquipAll.Clicked -= RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 rbEquipNumeric.Clicked -= RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 rbEquipPercent.Clicked -= RadioButtonClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 numericAmount.ValueChanged -= SpinButtonValueChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 percentageAmount.ValueChanged -= SpinButtonValueChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 lstEquipment.Selection.Changed -= OnSelectionChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 private void OnUnitEquipmentAmountChanged()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 if (UnitEquipmentAmountChanged != null)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 UnitEquipmentAmountChanged();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 private void OnUnitEquipmentAmountTypeChanged()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 if (UnitEquipmentAmountChanged != null)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 UnitEquipmentAmountTypeChanged();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 protected void OnSelectionChanged(object o, EventArgs e)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 if (UnitEquipmentItemChoiceChanged != null)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 public void SetUnitEquipmentItems(UnitEquipmentItem[] items)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 ListStore store = new ListStore(typeof(UnitEquipmentItem));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 foreach (UnitEquipmentItem equipItem in items)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 store.AppendValues(equipItem);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 lstEquipment.Model = store;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 numericAmount.SetRange(minNumber, maxNumber);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 percentageAmount.SetRange(minPercent, maxPercent);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 isRatioLimited = isRatioLimit;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 if (isRatioLimit)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 if (minPercent == 100)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 rbEquipAll.Active = true;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 else
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 rbEquipPercent.Active = true;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 else
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 rbEquipNumeric.Active = true;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 SetNumericAmountEnabledState(isEnabled);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 SetPercentageAmountEnabledState(isEnabled);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 public bool ShowControl()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 int result = Run();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 bool okayClicked = (result == (int)ResponseType.Ok);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 this.Hide();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 return okayClicked;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 log.Debug("Cancel clicked");
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 Respond(ResponseType.Cancel);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 protected virtual void OkayButtonClicked(object sender, System.EventArgs e)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 log.Debug("Okay clicked");
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 Respond(ResponseType.Ok);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 public void SetOkayEnabledState(bool enabled)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 bttnOkay.Sensitive = enabled;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 OnUnitEquipmentAmountChanged();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 protected virtual void RadioButtonClicked(object sender, System.EventArgs e)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 OnUnitEquipmentAmountTypeChanged();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 public void SetNumericAmountEnabledState(bool enabled)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 double minPercent = GetMinPercentage();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 numericAmount.Sensitive = rbEquipNumeric.Sensitive;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 public void SetPercentageAmountEnabledState(bool enabled)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 if (enabled)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 double minPercentage = GetMinPercentage();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 percentageAmount.Sensitive = rbEquipPercent.Sensitive;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 double maxPercentage = GetMaxPercentage();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 lblEquipAll.Sensitive = rbEquipAll.Sensitive;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 else
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 rbEquipPercent.Sensitive = false;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 percentageAmount.Sensitive = false;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196 rbEquipAll.Sensitive = false;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 lblEquipAll.Sensitive = false;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 private double GetMaxPercentage()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 double min, max;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 percentageAmount.GetRange(out min, out max);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 return max;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 private double GetMinPercentage()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 double min, max;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 percentageAmount.GetRange(out min, out max);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 return min;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215 public UnitEquipmentItem SelectedUnitEquipmentItem
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 get
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 public bool IsRatioEquipmentAmount
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 get
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227 return !rbEquipNumeric.Active;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 public int EquipmentNumericAmount
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 get
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235 return (int)numericAmount.Value;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
238 set
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 numericAmount.Value = value;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 public double EquipmentPercentageAmount
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246 get
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 double percent;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 if (rbEquipAll.Active)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
252 percent = 100;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
253 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
254 else
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
255 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
256 percent = percentageAmount.Value;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
257 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
258
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
259 return percent;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
260 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
261
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
262 set
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
263 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
264 percentageAmount.Value = value;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
265 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
266 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
267 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
268 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
269