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