using Telerik.WinControls;
using Telerik.WinControls.UI;
namespace Pilz.UI.Telerik.Controls.RadValidationProvider;
public delegate void RadValidationEventHandlerEx(object sender, RadValidationEventArgsEx e);
public class RadValidationEventArgsEx : EventArgs
{
const string DefaultToolTipTitle = "Validation Failed";
private readonly Control control;
private readonly IRadValidationRuleEx validationRule;
private bool displayIconAndToolTip = true;
private string errorTitle = DefaultToolTipTitle;
private bool enableToolTipShadow = true;
///
/// Gets or Sets the ValidationHelperElement descendant that contains the Error image. This element is set next to the validated control.
///
public ValidationHelperElement ValidationHelperElement { get; set; }
///
/// Gets or Sets the result from the rule evaluation.
///
public bool IsValid { get; set; }
///
/// Get the Control which is evaluated in the ValidationRule.
///
public Control Control { get { return control; } }
///
/// Error image that will displayed next to the Validated control.
///
public Image ErrorImage { get; set; }
///
/// Error SVG image that will displayed next to the Validated control.
///
public RadSvgImage ErrorSvgImage { get; set; }
///
/// Gets or sets the custom ToolTip for the Rule.
///
public ToolTip ToolTip { get; set; }
///
/// Sets the X position of the ToolTip.
///
public int? ToolTipX { get; set; }
///
/// Sets the Y position of the ToolTip.
///
public int? ToolTipY { get; set; }
///
/// Sets the ToolTip's duration in Milliseconds
///
public int? ToolTipDuration { get; set; }
///
/// The Rule that fires this event.
///
public IRadValidationRuleEx ValidationRule { get { return validationRule; } }
///
/// Sets or Gets the ToolTip's Text.
///
public string ErrorText { get; set; }
///
/// Sets or Gets the ToolTip's Title.
///
public string ErrorTitle { get { return errorTitle; } set { errorTitle = value; } }
///
/// Enable or Disable the Error border and error image.
///
public bool DisplayIconAndToolTip { get { return displayIconAndToolTip; } set { displayIconAndToolTip = value; } }
///
/// Enable or Disable the ToolTip shadow.
///
public bool EnableToolTipShadow { get { return enableToolTipShadow; } set { enableToolTipShadow = value; } }
///
/// Construct the RadValidationEventArgs object.
///
/// The validated control. Must be RadEditorControl descendant
/// Erorr image
/// Error text
/// Error title
/// Validation rule
/// Validatation failed
public RadValidationEventArgsEx(
Control control,
Image errorImage,
string errorText,
string errorTitle,
IRadValidationRuleEx validationRule,
bool isFailed)
{
this.control = control;
ErrorImage = errorImage;
ErrorText = errorText;
this.validationRule = validationRule;
IsValid = !isFailed;
this.errorTitle = errorTitle;
}
}