154 lines
4.3 KiB
C#
154 lines
4.3 KiB
C#
using System.ComponentModel;
|
|
using System.Drawing.Design;
|
|
using Telerik.WinControls;
|
|
using Telerik.WinControls.Data;
|
|
|
|
namespace Pilz.UI.WinForms.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 = 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
|
|
|
|
/// <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(false)]
|
|
public bool AutoToolTip
|
|
{
|
|
get { return autoToolTip; }
|
|
set { 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 toolTipTitle; }
|
|
set { toolTipTitle = value; }
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Enable or Disable the case sensitive Rule's Like operator.
|
|
/// </summary>
|
|
[DefaultValue(false)]
|
|
public bool CaseSensitive
|
|
{
|
|
get { return caseSensitive; }
|
|
set { 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; }
|
|
}
|
|
}
|