Push Changes from Techcrafters Repo
This commit is contained in:
@@ -2,32 +2,31 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HMIToolkit
|
||||
namespace HMIToolkit;
|
||||
|
||||
public sealed partial class AnalogRangeValidator : ValidationRule
|
||||
{
|
||||
public sealed partial class AnalogRangeValidator : ValidationRule
|
||||
{
|
||||
public float Min { get; set; }
|
||||
public float Min { get; set; }
|
||||
|
||||
public float Max { get; set; }
|
||||
public float Max { get; set; }
|
||||
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
float analogValue = 0;
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
float analogValue = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if (((string)value).Length > 0)
|
||||
analogValue = float.Parse((string)value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ValidationResult(false, $"Illegal characters or {e.Message}");
|
||||
}
|
||||
try
|
||||
{
|
||||
if (((string)value).Length > 0)
|
||||
analogValue = float.Parse((string)value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ValidationResult(false, $"Illegal characters or {e.Message}");
|
||||
}
|
||||
|
||||
if ((analogValue < Min) || (analogValue > Max))
|
||||
return new ValidationResult(false, $"Please enter a value in the range: {Min}-{Max}.");
|
||||
if ((analogValue < Min) || (analogValue > Max))
|
||||
return new ValidationResult(false, $"Please enter a value in the range: {Min}-{Max}.");
|
||||
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
@@ -2,31 +2,30 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace HMIToolkit
|
||||
namespace HMIToolkit;
|
||||
|
||||
/// <summary>
|
||||
/// Interaktionslogik für AnalogValue.xaml
|
||||
/// </summary>
|
||||
public partial class AnalogValue : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für AnalogValue.xaml
|
||||
/// </summary>
|
||||
public partial class AnalogValue : UserControl
|
||||
{
|
||||
public bool IsReadonly { get; set; }
|
||||
public bool IsReadonly { get; set; }
|
||||
|
||||
public AnalogValue()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Unloaded += OnUnloaded;
|
||||
}
|
||||
public AnalogValue()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
private void OnUnloaded(object? sender, EventArgs e)
|
||||
{
|
||||
var disposable = DataContext as IDisposable;
|
||||
disposable?.Dispose();
|
||||
}
|
||||
private void OnUnloaded(object? sender, EventArgs e)
|
||||
{
|
||||
var disposable = DataContext as IDisposable;
|
||||
disposable?.Dispose();
|
||||
}
|
||||
|
||||
private void NumberValidation(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
Regex regex = new("^[-+]?[0-9]*,?[0-9]+$");
|
||||
e.Handled = regex.IsMatch(e.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void NumberValidation(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
Regex regex = new("^[-+]?[0-9]*,?[0-9]+$");
|
||||
e.Handled = regex.IsMatch(e.Text);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user