changeset 55:eb7db8495bb5

Re #60: Add UI to add/remove/edit weapons in GTK * Make some manual changes to the Steic-generated file until MonoDevelop bug 634447 is resolved * Add logging to UI * Make control close once we're done with it * Set values for equipment controls
author IBBoard <dev@ibboard.co.uk>
date Wed, 25 Aug 2010 19:51:23 +0000
parents f9f6e9db5350
children 0c5fbb54bfb0
files FrmAddEquipment.cs UIControl/AddEquipmentUIControl.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs gtk-gui/gui.stetic
diffstat 4 files changed, 92 insertions(+), 76 deletions(-) [+]
line diff
     1.1 --- a/FrmAddEquipment.cs	Wed Aug 25 16:01:12 2010 +0000
     1.2 +++ b/FrmAddEquipment.cs	Wed Aug 25 19:51:23 2010 +0000
     1.3 @@ -7,10 +7,14 @@
     1.4  using Gtk;
     1.5  using IBBoard.WarFoundry.GUI.GTK.Util;
     1.6  using IBBoard.GtkSharp;
     1.7 +using log4net.Repository.Hierarchy;
     1.8 +using log4net;
     1.9  namespace IBBoard.WarFoundry.GUI.GTK
    1.10  {
    1.11 -	public partial class FrmAddEquipment : Gtk.Dialog, IAddEquipmentUI
    1.12 +	public partial class FrmAddEquipment : Dialog, IAddEquipmentUI
    1.13  	{
    1.14 +		private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment));
    1.15 +		
    1.16  		public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
    1.17  		
    1.18  		public FrmAddEquipment()
    1.19 @@ -47,21 +51,29 @@
    1.20  
    1.21  		public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
    1.22  		{
    1.23 -			
    1.24 +			log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
    1.25 +			rbEquipNumeric.Sensitive = isRatioLimit;
    1.26 +			numericAmount.Sensitive = isRatioLimit;
    1.27 +			numericAmount.SetRange(minNumber, maxNumber);
    1.28 +			percentageAmount.SetRange(minPercent, maxPercent);
    1.29  		}
    1.30  
    1.31  		public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
    1.32  		{
    1.33 -			
    1.34  		}
    1.35  
    1.36  		public bool ShowControl()
    1.37  		{
    1.38 -			return Run() == (int)ResponseType.Ok;
    1.39 +			int result = Run();
    1.40 +			bool okayClicked = (result == (int)ResponseType.Ok);
    1.41 +			this.Hide();
    1.42 +			this.Dispose();
    1.43 +			return okayClicked;
    1.44  		}
    1.45  		
    1.46 -		protected virtual void CancelButtonClicked (object sender, System.EventArgs e)
    1.47 +		protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
    1.48  		{
    1.49 +			log.Debug("Cancel clicked");
    1.50  			Respond(ResponseType.Cancel);
    1.51  		}		
    1.52  	}
     2.1 --- a/UIControl/AddEquipmentUIControl.cs	Wed Aug 25 16:01:12 2010 +0000
     2.2 +++ b/UIControl/AddEquipmentUIControl.cs	Wed Aug 25 19:51:23 2010 +0000
     2.3 @@ -47,6 +47,8 @@
     2.4  			int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip);
     2.5  			minNumber = Math.Max(0, minNumber);
     2.6  			
     2.7 +			ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercent, maxPercent, minNumber, maxNumber);
     2.8 +			
     2.9  		}
    2.10  		
    2.11  		private double RoundPercentage(double percent)
    2.12 @@ -54,7 +56,6 @@
    2.13  			return Math.Round(percent, 1);
    2.14  		}
    2.15  		
    2.16 -		//TODO Make abstract
    2.17  		public void Show()
    2.18  		{
    2.19  			ui.ShowControl();
     3.1 --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Wed Aug 25 16:01:12 2010 +0000
     3.2 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs	Wed Aug 25 19:51:23 2010 +0000
     3.3 @@ -24,9 +24,9 @@
     3.4  
     3.5  		private global::Gtk.RadioButton rbEquipPercent;
     3.6  
     3.7 -		private global::Gtk.SpinButton spinbutton1;
     3.8 +		private global::Gtk.SpinButton numericAmount;
     3.9  
    3.10 -		private global::Gtk.SpinButton spinbutton2;
    3.11 +		private global::Gtk.SpinButton percentageAmount;
    3.12  
    3.13  		private global::Gtk.Label lblEquipAmount;
    3.14  
    3.15 @@ -59,6 +59,7 @@
    3.16  			this.lstEquipment = new global::Gtk.TreeView();
    3.17  			this.lstEquipment.CanFocus = true;
    3.18  			this.lstEquipment.Name = "lstEquipment";
    3.19 +			this.lstEquipment.HeadersVisible = false;
    3.20  			this.GtkScrolledWindow.Add(this.lstEquipment);
    3.21  			this.table1.Add(this.GtkScrolledWindow);
    3.22  			global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow]));
    3.23 @@ -135,28 +136,28 @@
    3.24  			w8.XOptions = ((global::Gtk.AttachOptions)(4));
    3.25  			w8.YOptions = ((global::Gtk.AttachOptions)(4));
    3.26  			// Container child table2.Gtk.Table+TableChild
    3.27 -			this.spinbutton1 = new global::Gtk.SpinButton(0, 100, 1);
    3.28 -			this.spinbutton1.CanFocus = true;
    3.29 -			this.spinbutton1.Name = "spinbutton1";
    3.30 -			this.spinbutton1.Adjustment.PageIncrement = 10;
    3.31 -			this.spinbutton1.ClimbRate = 1;
    3.32 -			this.spinbutton1.Numeric = true;
    3.33 -			this.table2.Add(this.spinbutton1);
    3.34 -			global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton1]));
    3.35 +			this.numericAmount = new global::Gtk.SpinButton(0, 100, 1);
    3.36 +			this.numericAmount.CanFocus = true;
    3.37 +			this.numericAmount.Name = "numericAmount";
    3.38 +			this.numericAmount.Adjustment.PageIncrement = 10;
    3.39 +			this.numericAmount.ClimbRate = 1;
    3.40 +			this.numericAmount.Numeric = true;
    3.41 +			this.table2.Add(this.numericAmount);
    3.42 +			global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.numericAmount]));
    3.43  			w9.LeftAttach = ((uint)(1));
    3.44  			w9.RightAttach = ((uint)(2));
    3.45  			w9.XOptions = ((global::Gtk.AttachOptions)(0));
    3.46  			w9.YOptions = ((global::Gtk.AttachOptions)(4));
    3.47  			// Container child table2.Gtk.Table+TableChild
    3.48 -			this.spinbutton2 = new global::Gtk.SpinButton(0, 100, 1);
    3.49 -			this.spinbutton2.CanFocus = true;
    3.50 -			this.spinbutton2.Name = "spinbutton2";
    3.51 -			this.spinbutton2.Adjustment.PageIncrement = 10;
    3.52 -			this.spinbutton2.ClimbRate = 1;
    3.53 -			this.spinbutton2.Digits = ((uint)(1));
    3.54 -			this.spinbutton2.Numeric = true;
    3.55 -			this.table2.Add(this.spinbutton2);
    3.56 -			global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton2]));
    3.57 +			this.percentageAmount = new global::Gtk.SpinButton(0, 100, 1);
    3.58 +			this.percentageAmount.CanFocus = true;
    3.59 +			this.percentageAmount.Name = "percentageAmount";
    3.60 +			this.percentageAmount.Adjustment.PageIncrement = 10;
    3.61 +			this.percentageAmount.ClimbRate = 1;
    3.62 +			this.percentageAmount.Digits = ((uint)(1));
    3.63 +			this.percentageAmount.Numeric = true;
    3.64 +			this.table2.Add(this.percentageAmount);
    3.65 +			global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.percentageAmount]));
    3.66  			w10.TopAttach = ((uint)(1));
    3.67  			w10.BottomAttach = ((uint)(2));
    3.68  			w10.LeftAttach = ((uint)(1));
    3.69 @@ -212,6 +213,7 @@
    3.70  			this.buttonCancel.UseStock = true;
    3.71  			this.buttonCancel.UseUnderline = true;
    3.72  			this.buttonCancel.Label = "gtk-cancel";
    3.73 +			this.buttonCancel.Clicked+= CancelButtonClicked;
    3.74  			this.AddActionWidget(this.buttonCancel, -6);
    3.75  			global::Gtk.ButtonBox.ButtonBoxChild w17 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w16[this.buttonCancel]));
    3.76  			w17.Expand = false;
     4.1 --- a/gtk-gui/gui.stetic	Wed Aug 25 16:01:12 2010 +0000
     4.2 +++ b/gtk-gui/gui.stetic	Wed Aug 25 19:51:23 2010 +0000
     4.3 @@ -1062,10 +1062,62 @@
     4.4                        </packing>
     4.5                      </child>
     4.6                      <child>
     4.7 +                      <widget class="Gtk.SpinButton" id="numericAmount">
     4.8 +                        <property name="MemberName" />
     4.9 +                        <property name="CanFocus">True</property>
    4.10 +                        <property name="Upper">100</property>
    4.11 +                        <property name="PageIncrement">10</property>
    4.12 +                        <property name="StepIncrement">1</property>
    4.13 +                        <property name="ClimbRate">1</property>
    4.14 +                        <property name="Numeric">True</property>
    4.15 +                      </widget>
    4.16 +                      <packing>
    4.17 +                        <property name="LeftAttach">1</property>
    4.18 +                        <property name="RightAttach">2</property>
    4.19 +                        <property name="AutoSize">False</property>
    4.20 +                        <property name="XOptions">0</property>
    4.21 +                        <property name="YOptions">Fill</property>
    4.22 +                        <property name="XExpand">False</property>
    4.23 +                        <property name="XFill">False</property>
    4.24 +                        <property name="XShrink">False</property>
    4.25 +                        <property name="YExpand">False</property>
    4.26 +                        <property name="YFill">True</property>
    4.27 +                        <property name="YShrink">False</property>
    4.28 +                      </packing>
    4.29 +                    </child>
    4.30 +                    <child>
    4.31 +                      <widget class="Gtk.SpinButton" id="percentageAmount">
    4.32 +                        <property name="MemberName" />
    4.33 +                        <property name="CanFocus">True</property>
    4.34 +                        <property name="Upper">100</property>
    4.35 +                        <property name="PageIncrement">10</property>
    4.36 +                        <property name="StepIncrement">1</property>
    4.37 +                        <property name="ClimbRate">1</property>
    4.38 +                        <property name="Digits">1</property>
    4.39 +                        <property name="Numeric">True</property>
    4.40 +                      </widget>
    4.41 +                      <packing>
    4.42 +                        <property name="TopAttach">1</property>
    4.43 +                        <property name="BottomAttach">2</property>
    4.44 +                        <property name="LeftAttach">1</property>
    4.45 +                        <property name="RightAttach">2</property>
    4.46 +                        <property name="AutoSize">False</property>
    4.47 +                        <property name="XOptions">0</property>
    4.48 +                        <property name="YOptions">Fill</property>
    4.49 +                        <property name="XExpand">False</property>
    4.50 +                        <property name="XFill">False</property>
    4.51 +                        <property name="XShrink">False</property>
    4.52 +                        <property name="YExpand">False</property>
    4.53 +                        <property name="YFill">True</property>
    4.54 +                        <property name="YShrink">False</property>
    4.55 +                      </packing>
    4.56 +                    </child>
    4.57 +                    <child>
    4.58                        <widget class="Gtk.RadioButton" id="rbEquipAll">
    4.59                          <property name="MemberName" />
    4.60                          <property name="CanFocus">True</property>
    4.61                          <property name="Label" translatable="yes" />
    4.62 +                        <property name="Active">True</property>
    4.63                          <property name="DrawIndicator">True</property>
    4.64                          <property name="HasLabel">True</property>
    4.65                          <property name="UseUnderline">True</property>
    4.66 @@ -1131,57 +1183,6 @@
    4.67                          <property name="YShrink">False</property>
    4.68                        </packing>
    4.69                      </child>
    4.70 -                    <child>
    4.71 -                      <widget class="Gtk.SpinButton" id="spinbutton1">
    4.72 -                        <property name="MemberName" />
    4.73 -                        <property name="CanFocus">True</property>
    4.74 -                        <property name="Upper">100</property>
    4.75 -                        <property name="PageIncrement">10</property>
    4.76 -                        <property name="StepIncrement">1</property>
    4.77 -                        <property name="ClimbRate">1</property>
    4.78 -                        <property name="Numeric">True</property>
    4.79 -                      </widget>
    4.80 -                      <packing>
    4.81 -                        <property name="LeftAttach">1</property>
    4.82 -                        <property name="RightAttach">2</property>
    4.83 -                        <property name="AutoSize">False</property>
    4.84 -                        <property name="XOptions">0</property>
    4.85 -                        <property name="YOptions">Fill</property>
    4.86 -                        <property name="XExpand">False</property>
    4.87 -                        <property name="XFill">False</property>
    4.88 -                        <property name="XShrink">False</property>
    4.89 -                        <property name="YExpand">False</property>
    4.90 -                        <property name="YFill">True</property>
    4.91 -                        <property name="YShrink">False</property>
    4.92 -                      </packing>
    4.93 -                    </child>
    4.94 -                    <child>
    4.95 -                      <widget class="Gtk.SpinButton" id="spinbutton2">
    4.96 -                        <property name="MemberName" />
    4.97 -                        <property name="CanFocus">True</property>
    4.98 -                        <property name="Upper">100</property>
    4.99 -                        <property name="PageIncrement">10</property>
   4.100 -                        <property name="StepIncrement">1</property>
   4.101 -                        <property name="ClimbRate">1</property>
   4.102 -                        <property name="Digits">1</property>
   4.103 -                        <property name="Numeric">True</property>
   4.104 -                      </widget>
   4.105 -                      <packing>
   4.106 -                        <property name="TopAttach">1</property>
   4.107 -                        <property name="BottomAttach">2</property>
   4.108 -                        <property name="LeftAttach">1</property>
   4.109 -                        <property name="RightAttach">2</property>
   4.110 -                        <property name="AutoSize">False</property>
   4.111 -                        <property name="XOptions">0</property>
   4.112 -                        <property name="YOptions">Fill</property>
   4.113 -                        <property name="XExpand">False</property>
   4.114 -                        <property name="XFill">False</property>
   4.115 -                        <property name="XShrink">False</property>
   4.116 -                        <property name="YExpand">False</property>
   4.117 -                        <property name="YFill">True</property>
   4.118 -                        <property name="YShrink">False</property>
   4.119 -                      </packing>
   4.120 -                    </child>
   4.121                    </widget>
   4.122                    <packing>
   4.123                      <property name="Position">0</property>