using System.ComponentModel; using System.Drawing.Design; using Telerik.WinControls; using Telerik.WinControls.Data; namespace Pilz.UI.Telerik.Controls.RadValidationProvider; /// /// RadValidationRule provides a validation logic which compares RadControl's Property with Rule's Value. /// public class RadValidationRuleEx : FilterDescriptor, IRadValidationRuleEx { #region Fields private List controls = []; private string toolTipText = string.Empty; private bool caseSensitive = false; private bool autoToolTip = false; private string toolTipTitle = "Validation Failed"; #endregion #region Cstor public RadValidationRuleEx() : base() { PropertyName = "Text"; } public RadValidationRuleEx(string propertyName, FilterOperator filterOperator) : base(propertyName, filterOperator, null) { } public RadValidationRuleEx(string propertyName, FilterOperator filterOperator, object value) : base(propertyName, filterOperator, value) { } #endregion /// /// Associates this rule with the specified RadControl descendant. /// /// A RadControl descendant that represents the editor. public virtual void AddControl(RadControl control) { if (control != null && !controls.Contains(control)) { controls.Add(control); } } /// /// Removes the specified RadControl descendant from this rule. /// /// A RadControl descendant that represents the editor. public virtual void RemoveControl(RadControl control) { if (control == null) { return; } while (controls.Contains(control)) { controls.Remove(control); } } /// /// Inherit property. Not used in RadValidation Rule /// [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] public override bool IsFilterEditor { get { return base.IsFilterEditor; } set { base.IsFilterEditor = value; } } /// /// Associated RadControl descendants to this Rule /// [Editor(DesignerConsts.RadValidationRuleAssociatedControlsEditorString, typeof(UITypeEditor))] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public List Controls { get { return controls; } set { controls = value; } } /// /// Gets or sets the Value of this rule. Controls in the rule will be evaluated against this value. /// [Editor(DesignerConsts.RadValidationRuleValueEditorString, typeof(UITypeEditor))] public override object Value { get { return base.Value; } set { base.Value = value; } } /// /// Gets or Sets the ToolTip Text. This text will be shown as ToolTip text when rule validation fails. /// [DefaultValue("")] public string ToolTipText { get { return toolTipText; } set { toolTipText = value; } } /// /// Enable or Disable the ToolTip when validation fails. /// [DefaultValue(false)] public bool AutoToolTip { get { return this.autoToolTip; } set { this.autoToolTip = value; } } /// /// Gets or Sets the ToolTip Title Text. This text will be shown as ToolTip Title text when rule validation fails. /// [DefaultValue("Validation Failed")] public string ToolTipTitle { get { return this.toolTipTitle; } set { this.toolTipTitle = value; } } /// /// Enable or Disable the case sensitive Rule's Like operator. /// [DefaultValue(false)] public bool CaseSensitive { get { return this.caseSensitive; } set { this.caseSensitive = value; } } /// /// The Name of the Property from Control. This Property will be evaluated against the Rule's Value property. /// [DefaultValue("Text")] public override string PropertyName { get { return base.PropertyName; } set { base.PropertyName = value; } } }