Changeset 7424 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
- Timestamp:
- 01/27/12 16:58:29 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
r7421 r7424 2 2 using System.Collections.Generic; 3 3 using System.ComponentModel; 4 using System.Text.RegularExpressions; 4 5 using System.Windows.Forms; 5 6 using HeuristicLab.Clients.Hive.CloudManager.Azure; … … 108 109 } 109 110 } 110 }111 112 private bool ValidateInput() {113 bool valid = true;114 // TODO: input validation115 // see http://stackoverflow.com/questions/769184/winform-ui-validation116 return valid;117 111 } 118 112 … … 166 160 if (cmbChooseSubscription.SelectedItem != null) { 167 161 Subscription sub = (Subscription)cmbChooseSubscription.SelectedItem; 168 if (ValidateInput()) { 162 // the controls collection can be the whole form or just a panel or group 163 if (Validation.hasValidationErrors(this.Controls)) { 164 return; 165 } else { 169 166 bool newHostedServiceChecked = cbNewHostedService.Checked; 170 167 bool regionChecked = rbRegion.Checked; … … 301 298 } 302 299 } 300 301 private void tbServiceName_Validating(object sender, CancelEventArgs e) { 302 if (cbNewHostedService.Checked) { 303 string url = tbServiceName.Text.Trim(); 304 if (url == String.Empty) { 305 errorProvider.SetError(tbServiceName, "A URL is required for the hosted service."); 306 e.Cancel = true; 307 } else if (!isValidHostedServiceUrl(url)) { 308 errorProvider.SetError(tbLabel, "A hosted service name must be between 1 and 63 " + 309 "characters long, and be composed of letters, numbers " + 310 "and hyphens. Hyphens shouldn't be first or last letter."); 311 e.Cancel = true; 312 } else { 313 errorProvider.SetError(tbServiceName, ""); 314 } 315 } 316 } 317 318 private void tbLabel_Validating(object sender, CancelEventArgs e) { 319 if (cbNewHostedService.Checked) { 320 if (tbLabel.Text.Trim() == String.Empty) { 321 errorProvider.SetError(tbLabel, "A name is required for the hosted service."); 322 e.Cancel = true; 323 } else { 324 errorProvider.SetError(tbLabel, ""); 325 } 326 } 327 } 328 329 private bool isValidHostedServiceUrl(string url) { 330 string regexString = @"[a-zA-Z0-9]+[a-zA-Z0-9-]{0,61}[a-zA-Z0-9]+"; //TODO 331 Regex regex = new Regex(regexString); 332 if (regex.IsMatch(url)) { 333 return true; 334 } else { 335 return false; 336 } 337 } 303 338 } 304 339 }
Note: See TracChangeset
for help on using the changeset viewer.