change UI to UI.WinForms

This commit is contained in:
2025-06-16 11:50:17 +02:00
parent fa3a9da07e
commit 299867a910
116 changed files with 318 additions and 319 deletions

View File

@@ -0,0 +1,96 @@
using System.ComponentModel;
using Telerik.WinControls.Data;
//using System.Linq;
namespace Pilz.UI.WinForms.Telerik.Controls.RadValidationProvider;
/// <summary>
/// RadValidationRuleWithTargetControl provides a validation logic which compares RadControl's Property with TargetControl's property.
/// </summary>
public class RadValidationRuleWithTargetControlEx : RadValidationRuleEx
{
private string sourceControlPropertyName = "Text";
public RadValidationRuleWithTargetControlEx()
{
}
/// <summary>
/// Gets or sets the Target Control. This control's property value will be used in the Rule evaluation.
/// </summary>
[DefaultValue(null)]
public Control TargetControl { get; set; }
/// <summary>
/// The name of the property that will be used in the Rule evaluation.
/// </summary>
[DefaultValue("Text")]
public string TargetControlPropertyName
{
get { return sourceControlPropertyName; }
set { sourceControlPropertyName = value; }
}
/// <summary>
/// Gets the Rule expression.
/// </summary>
/// <value>The Rule expression.</value>
public override string Expression
{
get
{
if (TargetControl != null)
Value = CalculateValue();
return base.Expression;
}
}
/// <summary>
/// Gets or sets the Value of this rule. Controls in the rule will be evaluated against this value.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override object Value
{
get
{
if (TargetControl != null && !string.IsNullOrEmpty(TargetControlPropertyName))
{
try
{
base.Value = RadValidationProviderEx.GetSubPropertyValue(TargetControl, TargetControlPropertyName);//TargetControl.GetType().GetProperty(TargetControlPropertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance).GetValue(TargetControl, null);
}
catch { }
}
return base.Value;
}
set
{
base.Value = value;
}
}
protected virtual object CalculateValue()
{
if (TargetControl.Site != null)
return string.Format("{0}.{1}", TargetControl.Name, TargetControlPropertyName);
if (!string.IsNullOrEmpty(TargetControlPropertyName))
{
try
{
return RadValidationProviderEx.GetSubPropertyValue(TargetControl, TargetControlPropertyName);//this.TargetControl.GetType().GetProperty(this.TargetControlPropertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance).GetValue(this.TargetControl, null);
}
catch
{ }
}
return null;
}
}