# HG changeset patch # User IBBoard # Date 1282752072 0 # Node ID f9f6e9db5350d2c7e950035024c202c9e26f3eef # Parent 28b242612ad760d8627a57f4a70a68775db18131 Re #60: Add UI to add/remove/edit weapons in GTK * Add selection change notification from equipment list * Make ShowControl method return a boolean to say what the user did with it * Re-implement ShowControl to use Run() instead of ShowNow() so we can get a response result diff -r 28b242612ad7 -r f9f6e9db5350 FrmAddEquipment.cs --- a/FrmAddEquipment.cs Wed Aug 25 15:21:56 2010 +0000 +++ b/FrmAddEquipment.cs Wed Aug 25 16:01:12 2010 +0000 @@ -6,14 +6,17 @@ using IBBoard.WarFoundry.API.Objects; using Gtk; using IBBoard.WarFoundry.GUI.GTK.Util; +using IBBoard.GtkSharp; namespace IBBoard.WarFoundry.GUI.GTK { public partial class FrmAddEquipment : Gtk.Dialog, IAddEquipmentUI { + public event SingleArgMethodInvoker UnitEquipmentItemChoiceChanged; + public FrmAddEquipment() { this.Build(); - + lstEquipment.Selection.Changed += OnSelectionChanged; TreeViewColumn equipColumn = new TreeViewColumn(); equipColumn.Title = "Equipment"; CellRendererText equipCell = new CellRendererText(); @@ -21,8 +24,14 @@ equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName); lstEquipment.AppendColumn(equipColumn); } - - public event SingleArgMethodInvoker UnitEquipmentItemChoiceChanged; + + protected virtual void OnSelectionChanged(object o, EventArgs e) + { + if (UnitEquipmentItemChoiceChanged!=null) + { + UnitEquipmentItemChoiceChanged((UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment)); + } + } public void SetUnitEquipmentItems(UnitEquipmentItem[] items) { @@ -46,17 +55,15 @@ } - public void ShowControl() + public bool ShowControl() { - ShowNow(); + return Run() == (int)ResponseType.Ok; } protected virtual void CancelButtonClicked (object sender, System.EventArgs e) { Respond(ResponseType.Cancel); - } - - + } } } diff -r 28b242612ad7 -r f9f6e9db5350 UIControl/Interfaces/IAddEquipmentUI.cs --- a/UIControl/Interfaces/IAddEquipmentUI.cs Wed Aug 25 15:21:56 2010 +0000 +++ b/UIControl/Interfaces/IAddEquipmentUI.cs Wed Aug 25 16:01:12 2010 +0000 @@ -15,8 +15,6 @@ /// event SingleArgMethodInvoker UnitEquipmentItemChoiceChanged; - - /// /// Sets the equipment items that should be displayed on the form /// @@ -56,7 +54,10 @@ /// /// Shows the control and awaits a user action (close or okay) /// - void ShowControl(); + /// + /// true if the control was closed with "Okay", else false + /// + bool ShowControl(); } } diff -r 28b242612ad7 -r f9f6e9db5350 Util/GtkWarFoundryUtil.cs --- a/Util/GtkWarFoundryUtil.cs Wed Aug 25 15:21:56 2010 +0000 +++ b/Util/GtkWarFoundryUtil.cs Wed Aug 25 16:01:12 2010 +0000 @@ -14,5 +14,4 @@ (cell as CellRendererText).Text = equip.Name; } } -} - +} \ No newline at end of file diff -r 28b242612ad7 -r f9f6e9db5350 gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Wed Aug 25 15:21:56 2010 +0000 +++ b/gtk-gui/gui.stetic Wed Aug 25 16:01:12 2010 +0000 @@ -1066,7 +1066,6 @@ True - True True True True