/// <summary> /// Validate if Text of textbox is empty /// </summary> /// <param name="box"> </param> /// <param name="message"> </param> private void ValidateTextEmpty(Control box, string message) { if (!box.Text.Trim().IsNullOrEmpty()) { } else { tabService.SelectTab(box.GetParentTab() ?? tabService.SelectedTab); if (box.CanFocus) box.Focus(); throw new ValidationException(message); } }
/// <summary> /// Validate Directory /// </summary> /// <param name="tb"> </param> /// <param name="caption"> </param> private void ValidateDir(Control tb, string caption) { var path = tb.Text; if (Directory.Exists(path)) return; tabService.SelectTab(tb.GetParentTab() ?? tabService.SelectedTab); if (tb.Visible && tb.Enabled && tb.CanFocus) tb.Focus(); throw new ValidationException("Path not found: '{0}' for '{1}'".F(path, caption)); }