comparison 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
comparison
equal deleted inserted replaced
141:1ce4fe9ae3c1 142:f23e5b40ca9d
106 { 106 {
107 bttnCreate.Sensitive = true; 107 bttnCreate.Sensitive = true;
108 ICollection<string> failureMessages; 108 ICollection<string> failureMessages;
109 Validation result = RequirementHandler.AllowsAdding(type, unitArmy, out failureMessages); 109 Validation result = RequirementHandler.AllowsAdding(type, unitArmy, out failureMessages);
110 bool validationFailed = !Validates.AsOkay(result); 110 bool validationFailed = !Validates.AsOkay(result);
111 lblNewUnitWarning.Visible = validationFailed; 111 validationWidget.Visible = validationFailed;
112 112
113 if (validationFailed) 113 if (validationFailed)
114 { 114 {
115 StringBuilder sb = new StringBuilder(); 115 validationWidget.SetMessages(failureMessages);
116
117 foreach (string msg in failureMessages)
118 {
119 sb.AppendLine(msg);
120 }
121
122 lblNewUnitWarning.Text = sb.ToString();
123 } 116 }
124 } 117 }
125 else 118 else
126 { 119 {
127 bttnCreate.Sensitive = false; 120 bttnCreate.Sensitive = false;
128 lblNewUnitWarning.Visible = false; 121 validationWidget.Visible = false;
129 } 122 }
130 } 123 }
131 124
132 protected virtual void OnButtonCancelActivated(object sender, System.EventArgs e) 125 protected virtual void OnButtonCancelActivated(object sender, System.EventArgs e)
133 { 126 {