Changes in Description

Add new Paramcontrol with Range Validation
move Values from general to Etcher-Robot step Table
Add File Extension to Save/Open File Dialog
This commit is contained in:
2026-03-09 12:19:09 +01:00
parent ff9add4081
commit a753f1c7a7
7 changed files with 199 additions and 47 deletions

View File

@@ -0,0 +1,80 @@
using CommunityToolkit.Mvvm.ComponentModel;
using InfineonHMI.Common;
using System.ComponentModel.DataAnnotations;
using TwinCAT.TypeSystem;
namespace Common;
public sealed class InRangeAttribute(string propMin, string propMax) : ValidationAttribute
{
public string PropMin { get; } = propMin;
public string PropMax { get; } = propMax;
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
{
object instance = validationContext.ObjectInstance;
int minValue = (int)(instance.GetType().GetProperty(PropMin)?.GetValue(instance) ?? 1);
int maxValue = (int)(instance.GetType().GetProperty(PropMax)?.GetValue(instance) ?? 1);
int tempValue = (int)(value ?? 1);
if (tempValue <= maxValue && tempValue >= minValue)
return ValidationResult.Success;
return new($"Value has to be greater than {minValue} and smaller then {maxValue}");
}
}
public sealed partial class ParamControlIntRangeVm : ObservableValidator, IDisposable, IChangeTrackingEx
{
private int initValue;
[ObservableProperty]
private int iMin;
[ObservableProperty]
private int iMax;
[ObservableProperty] private string sName;
private int value;
[InRangeAttribute(nameof(IMin), nameof(IMax))]
public int Value
{
get => this.value;
set
{
SetProperty(ref this.value, value, true);
if (value >= IMin && value <= IMax)
{
}
}
}
public ParamControlIntRangeVm()
{
SName = "No Name:";
Value = 0;
initValue = Value;
}
public void Dispose()
{
}
public void AcceptChanges()
{
initValue = Value;
}
public bool IsChanged => initValue != Value;
public void DiscardChanges()
{
Value = initValue;
}
}