diff FrmAddEquipment.cs @ 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
line wrap: on
line diff
--- 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<UnitEquipmentItem> 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);
 		}		
 	}