comparison FrmNewUnit.cs @ 77:68804784bf6f

Re #86: Complete initial GTK# UI * Add About dialog * Make sure app builds as "WarFoundry-GTK.exe" * Move all UI components to IBBoard.WarFoundry.GUI.GTK namespace
author IBBoard <dev@ibboard.co.uk>
date Sat, 18 Dec 2010 16:42:51 +0000
parents 7055b24cfc79
children b0089e875754
comparison
equal deleted inserted replaced
76:7055b24cfc79 77:68804784bf6f
8 using IBBoard.GtkSharp.Translatable; 8 using IBBoard.GtkSharp.Translatable;
9 using IBBoard.WarFoundry.API.Objects; 9 using IBBoard.WarFoundry.API.Objects;
10 using IBBoard.WarFoundry.API.Requirements; 10 using IBBoard.WarFoundry.API.Requirements;
11 using log4net; 11 using log4net;
12 12
13 namespace IBBoard.WarFoundry.GTK 13 namespace IBBoard.WarFoundry.GUI.GTK
14 { 14 {
15 public partial class FrmNewUnit : TranslatableDialog 15 public partial class FrmNewUnit : TranslatableDialog
16 { 16 {
17 private ILog logger = LogManager.GetLogger(typeof(FrmNewUnit)); 17 private ILog logger = LogManager.GetLogger(typeof(FrmNewUnit));
18 private UnitType unitType; 18 private UnitType unitType;
19 private Army unitArmy; 19 private Army unitArmy;
20 20
21 public FrmNewUnit(Race race, Category cat, Army army) 21 public FrmNewUnit(Race race, Category cat, Army army)
22 { 22 {
23 this.Build(); 23 this.Build();
24 unitArmy = army; 24 unitArmy = army;
25 25
40 } 40 }
41 41
42 lstUnitTypes.Model = store; 42 lstUnitTypes.Model = store;
43 lstUnitTypes.Selection.Changed += new EventHandler(OnSelectionChanged); 43 lstUnitTypes.Selection.Changed += new EventHandler(OnSelectionChanged);
44 } 44 }
45 45
46 private void RenderUnitTypeName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) 46 private void RenderUnitTypeName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
47 { 47 {
48 UnitType type = (UnitType)model.GetValue(iter, 0); 48 UnitType type = (UnitType)model.GetValue(iter, 0);
49 (cell as CellRendererText).Text = type.Name; 49 (cell as CellRendererText).Text = type.Name;
50 } 50 }
51 51
52 protected virtual void OnSelectionChanged(object o, EventArgs e) 52 protected virtual void OnSelectionChanged(object o, EventArgs e)
53 { 53 {
54 SetSelectUnitEnabledVal(); 54 SetSelectUnitEnabledVal();
55 } 55 }
56 56
57 public UnitType SelectedUnit 57 public UnitType SelectedUnit
58 { 58 {
59 get { return unitType; } 59 get { return unitType; }
60 } 60 }
61 61
62 private UnitType GetSelectedUnitType() 62 private UnitType GetSelectedUnitType()
63 { 63 {
64 TreeModel model; 64 TreeModel model;
65 TreeIter iter; 65 TreeIter iter;
66 lstUnitTypes.Selection.GetSelected(out model, out iter); 66 lstUnitTypes.Selection.GetSelected(out model, out iter);
71 toReturn = (UnitType)model.GetValue(iter, 0); 71 toReturn = (UnitType)model.GetValue(iter, 0);
72 } 72 }
73 73
74 return toReturn; 74 return toReturn;
75 } 75 }
76 76
77 private void SetSelectUnitEnabledVal() 77 private void SetSelectUnitEnabledVal()
78 { 78 {
79 UnitType type = GetSelectedUnitType(); 79 UnitType type = GetSelectedUnitType();
80 80
81 if (type != null) 81 if (type != null)