# HG changeset patch # User IBBoard # Date 1282765883 0 # Node ID eb7db8495bb55b239318d03f1cdb804d14968973 # Parent f9f6e9db5350d2c7e950035024c202c9e26f3eef 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 diff -r f9f6e9db5350 -r eb7db8495bb5 FrmAddEquipment.cs --- a/FrmAddEquipment.cs Wed Aug 25 16:01:12 2010 +0000 +++ b/FrmAddEquipment.cs Wed Aug 25 19:51:23 2010 +0000 @@ -7,10 +7,14 @@ using Gtk; using IBBoard.WarFoundry.GUI.GTK.Util; using IBBoard.GtkSharp; +using log4net.Repository.Hierarchy; +using log4net; namespace IBBoard.WarFoundry.GUI.GTK { - public partial class FrmAddEquipment : Gtk.Dialog, IAddEquipmentUI + public partial class FrmAddEquipment : Dialog, IAddEquipmentUI { + private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment)); + public event SingleArgMethodInvoker UnitEquipmentItemChoiceChanged; public FrmAddEquipment() @@ -47,21 +51,29 @@ public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber) { - + log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent); + rbEquipNumeric.Sensitive = isRatioLimit; + numericAmount.Sensitive = isRatioLimit; + numericAmount.SetRange(minNumber, maxNumber); + percentageAmount.SetRange(minPercent, maxPercent); } public void SetUnitEquipmentLimitsEnabled(bool isEnabled) { - } public bool ShowControl() { - return Run() == (int)ResponseType.Ok; + int result = Run(); + bool okayClicked = (result == (int)ResponseType.Ok); + this.Hide(); + this.Dispose(); + return okayClicked; } - protected virtual void CancelButtonClicked (object sender, System.EventArgs e) + protected virtual void CancelButtonClicked(object sender, System.EventArgs e) { + log.Debug("Cancel clicked"); Respond(ResponseType.Cancel); } } diff -r f9f6e9db5350 -r eb7db8495bb5 UIControl/AddEquipmentUIControl.cs --- a/UIControl/AddEquipmentUIControl.cs Wed Aug 25 16:01:12 2010 +0000 +++ b/UIControl/AddEquipmentUIControl.cs Wed Aug 25 19:51:23 2010 +0000 @@ -47,6 +47,8 @@ int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); minNumber = Math.Max(0, minNumber); + ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercent, maxPercent, minNumber, maxNumber); + } private double RoundPercentage(double percent) @@ -54,7 +56,6 @@ return Math.Round(percent, 1); } - //TODO Make abstract public void Show() { ui.ShowControl(); diff -r f9f6e9db5350 -r eb7db8495bb5 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Wed Aug 25 16:01:12 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmAddEquipment.cs Wed Aug 25 19:51:23 2010 +0000 @@ -24,9 +24,9 @@ private global::Gtk.RadioButton rbEquipPercent; - private global::Gtk.SpinButton spinbutton1; + private global::Gtk.SpinButton numericAmount; - private global::Gtk.SpinButton spinbutton2; + private global::Gtk.SpinButton percentageAmount; private global::Gtk.Label lblEquipAmount; @@ -59,6 +59,7 @@ this.lstEquipment = new global::Gtk.TreeView(); this.lstEquipment.CanFocus = true; this.lstEquipment.Name = "lstEquipment"; + this.lstEquipment.HeadersVisible = false; this.GtkScrolledWindow.Add(this.lstEquipment); this.table1.Add(this.GtkScrolledWindow); global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1[this.GtkScrolledWindow])); @@ -135,28 +136,28 @@ w8.XOptions = ((global::Gtk.AttachOptions)(4)); w8.YOptions = ((global::Gtk.AttachOptions)(4)); // Container child table2.Gtk.Table+TableChild - this.spinbutton1 = new global::Gtk.SpinButton(0, 100, 1); - this.spinbutton1.CanFocus = true; - this.spinbutton1.Name = "spinbutton1"; - this.spinbutton1.Adjustment.PageIncrement = 10; - this.spinbutton1.ClimbRate = 1; - this.spinbutton1.Numeric = true; - this.table2.Add(this.spinbutton1); - global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton1])); + this.numericAmount = new global::Gtk.SpinButton(0, 100, 1); + this.numericAmount.CanFocus = true; + this.numericAmount.Name = "numericAmount"; + this.numericAmount.Adjustment.PageIncrement = 10; + this.numericAmount.ClimbRate = 1; + this.numericAmount.Numeric = true; + this.table2.Add(this.numericAmount); + global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.table2[this.numericAmount])); w9.LeftAttach = ((uint)(1)); w9.RightAttach = ((uint)(2)); w9.XOptions = ((global::Gtk.AttachOptions)(0)); w9.YOptions = ((global::Gtk.AttachOptions)(4)); // Container child table2.Gtk.Table+TableChild - this.spinbutton2 = new global::Gtk.SpinButton(0, 100, 1); - this.spinbutton2.CanFocus = true; - this.spinbutton2.Name = "spinbutton2"; - this.spinbutton2.Adjustment.PageIncrement = 10; - this.spinbutton2.ClimbRate = 1; - this.spinbutton2.Digits = ((uint)(1)); - this.spinbutton2.Numeric = true; - this.table2.Add(this.spinbutton2); - global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.spinbutton2])); + this.percentageAmount = new global::Gtk.SpinButton(0, 100, 1); + this.percentageAmount.CanFocus = true; + this.percentageAmount.Name = "percentageAmount"; + this.percentageAmount.Adjustment.PageIncrement = 10; + this.percentageAmount.ClimbRate = 1; + this.percentageAmount.Digits = ((uint)(1)); + this.percentageAmount.Numeric = true; + this.table2.Add(this.percentageAmount); + global::Gtk.Table.TableChild w10 = ((global::Gtk.Table.TableChild)(this.table2[this.percentageAmount])); w10.TopAttach = ((uint)(1)); w10.BottomAttach = ((uint)(2)); w10.LeftAttach = ((uint)(1)); @@ -212,6 +213,7 @@ this.buttonCancel.UseStock = true; this.buttonCancel.UseUnderline = true; this.buttonCancel.Label = "gtk-cancel"; + this.buttonCancel.Clicked+= CancelButtonClicked; this.AddActionWidget(this.buttonCancel, -6); global::Gtk.ButtonBox.ButtonBoxChild w17 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w16[this.buttonCancel])); w17.Expand = false; diff -r f9f6e9db5350 -r eb7db8495bb5 gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Wed Aug 25 16:01:12 2010 +0000 +++ b/gtk-gui/gui.stetic Wed Aug 25 19:51:23 2010 +0000 @@ -1062,10 +1062,62 @@ + + + True + 100 + 10 + 1 + 1 + True + + + 1 + 2 + False + 0 + Fill + False + False + False + False + True + False + + + + + + True + 100 + 10 + 1 + 1 + 1 + True + + + 1 + 2 + 1 + 2 + False + 0 + Fill + False + False + False + False + True + False + + + True + True True True True @@ -1131,57 +1183,6 @@ False - - - - True - 100 - 10 - 1 - 1 - True - - - 1 - 2 - False - 0 - Fill - False - False - False - False - True - False - - - - - - True - 100 - 10 - 1 - 1 - 1 - True - - - 1 - 2 - 1 - 2 - False - 0 - Fill - False - False - False - False - True - False - - 0