/// <summary> /// Initializes a new instance of the <see cref="EditField_DialogEntry" /> class. /// </summary> /// <param name="ID">The identifier.</param> /// <param name="text">The text.</param> /// <param name="help">The help.</param> /// <param name="parentEntry">The parent entry.</param> /// <param name="parentDialog">The parent dialog.</param> /// <param name="status">The status.</param> /// <param name="minimizeType">Type of the minimize.</param> /// <param name="boxHeightType">Type of the box height.</param> /// <param name="maxTextLength">Maximum length of the text.</param> /// <param name="characterRestriction">The character restriction.</param> /// <param name="directValidation">if set to <c>true</c> field will be validated directly. if <c>false</c> only when saved. Manual validation is needed!.</param> public EditField_DialogEntry( string ID, string text, string help = "...", DialogEntry parentEntry = null, Dialog parentDialog = null, DialogEntryStatus status = DialogEntryStatus.Unknown, MinimizeTypes minimizeType = MinimizeTypes.Unknown, BoxHeightTypes boxHeightType = BoxHeightTypes.Unknown, Boolean isGraphical = true, int maxTextLength = 20, InputRestrictionTypes characterRestriction = InputRestrictionTypes.Unrestricted, Boolean directValidation = true ) : base(ID, text, help, DialogEntryType.EditField, status, parentEntry, parentDialog) { InputBox = new EditField_InputBox(minimizeType, boxHeightType, isGraphical); EventManager = new EditField_EventManager(); if (!validateForSpaces(Title)) { Title = ""; } InputManager = new EditField_InputManager(Title); Validator = new EditField_Validator(maxTextLength, characterRestriction, directValidation); }
/// <summary> /// Initializes a new instance of the <see cref="EditField_Validator" /> class. /// </summary> /// <param name="maxTextLength">Maximum length of the text.</param> /// <param name="type">The type.</param> /// <param name="directValidation">if set to <c>true</c> field will be validated directly. if <c>false</c> only when saved. Manual validation is needed!.</param> public EditField_Validator(int maxTextLength, InputRestrictionTypes type, Boolean directValidation = true) { MaxTextLength = maxTextLength; this.InputRestrictionType = type; regExPattern = getRegExPattern(InputRestrictionType); regEx = new System.Text.RegularExpressions.Regex(regExPattern); _directValidation = directValidation; }
private static string getRegExPattern(InputRestrictionTypes EditFieldType) { String pattern = ""; switch (EditFieldType) { case InputRestrictionTypes.Unknown: break; case InputRestrictionTypes.Alphabet: pattern = "^[A-Za-z]*$"; break; case InputRestrictionTypes.AlphabetWithWhitespace: pattern = "^[ A-Za-z]*$"; break; case InputRestrictionTypes.AlphaNumeric: pattern = "^[A-Za-z0-9]*$"; break; case InputRestrictionTypes.AlphaNumericWithWhitespace: pattern = "^[ A-Za-z0-9]*$"; break; case InputRestrictionTypes.NumericSingle: pattern = "^[0-9]?$"; break; case InputRestrictionTypes.Numeric: pattern = "^[0-9]*$"; break; case InputRestrictionTypes.IntegerType: pattern = "Int32Type"; break; case InputRestrictionTypes.DoubleType: pattern = "DoubleType"; break; case InputRestrictionTypes.Custom: case InputRestrictionTypes.Unrestricted: default: break; } return(pattern); }
/// <summary> /// Initializes a new instance of the <see cref="EditField_DialogEntry"/> class. /// </summary> /// <param name="entry">The entry.</param> /// <param name="minimizeType">Type of the minimize.</param> /// <param name="boxHeightType">Type of the box height.</param> /// <param name="maxTextLength">Maximum length of the text.</param> /// <param name="characterRestriction">The character restriction.</param> /// <param name="directValidation">if set to <c>true</c> field will be validated directly. if <c>false</c> only when saved. Manual validation is needed!.</param> public EditField_DialogEntry( DialogEntry entry, MinimizeTypes minimizeType = MinimizeTypes.Unknown, BoxHeightTypes boxHeightType = BoxHeightTypes.Unknown, Boolean isGraphical = true, int maxTextLength = 20, InputRestrictionTypes characterRestriction = InputRestrictionTypes.Unrestricted, Boolean directValidation = true) : base(entry.ID, entry.Title, entry.Help, DialogEntryType.EditField, entry.Status, entry.ParentEntry, entry.ParentDialog) { InputBox = new EditField_InputBox(minimizeType, boxHeightType, isGraphical); EventManager = new EditField_EventManager(); if (!validateForSpaces(Title)) { Title = ""; } InputManager = new EditField_InputManager(Title); Validator = new EditField_Validator(maxTextLength, characterRestriction, directValidation); }
/// <summary> /// Initializes a new instance of the <see cref="EditField_Validator" /> class. /// </summary> /// <param name="directValidation">if set to <c>true</c> field will be validated directly. if <c>false</c> only when saved. Manual validation is needed!.</param> public EditField_Validator(Boolean directValidation = true) { MaxTextLength = MAX_TEXT_LENGTH; InputRestrictionType = InputRestrictionTypes.Unrestricted; _directValidation = directValidation; }