diff FrmNewUnit.cs @ 142:f23e5b40ca9d

Re #344: Show unit requirement failures * Add new widget for displaying failures nicely * Use widget for displaying failures in main window * Use widget for displaying failures in new unit dialog
author IBBoard <dev@ibboard.co.uk>
date Tue, 18 Oct 2011 21:03:35 +0100
parents 76b73f15d07e
children 354c1d2ad086
line wrap: on
line diff
--- a/FrmNewUnit.cs	Mon Oct 17 20:53:07 2011 +0100
+++ b/FrmNewUnit.cs	Tue Oct 18 21:03:35 2011 +0100
@@ -108,24 +108,17 @@
 				ICollection<string> failureMessages;
 				Validation result = RequirementHandler.AllowsAdding(type, unitArmy, out failureMessages);
 				bool validationFailed = !Validates.AsOkay(result);
-				lblNewUnitWarning.Visible = validationFailed;
+				validationWidget.Visible = validationFailed;
 
 				if (validationFailed)
 				{
-					StringBuilder sb = new StringBuilder();
-
-					foreach (string msg in failureMessages)
-					{
-						sb.AppendLine(msg);
-					}
-
-					lblNewUnitWarning.Text = sb.ToString();
+					validationWidget.SetMessages(failureMessages);
 				}
 			}
 			else
 			{
 				bttnCreate.Sensitive = false;
-				lblNewUnitWarning.Visible = false;
+				validationWidget.Visible = false;
 			}
 		}