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,25 @@
<UserControl x:Class="Common.ParamControlIntRange"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:common="clr-namespace:Common"
d:DataContext="{d:DesignInstance Type=common:ParamControlIntRangeVm, IsDesignTimeCreatable=True}"
mc:Ignorable="d"
d:DesignWidth="600"
d:DesignHeight="120"
Width="Auto"
Height="Auto">
<Grid Height="70">
<Grid.ColumnDefinitions>
<!-- <ColumnDefinition Width="Auto" /> -->
<ColumnDefinition Width="400" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Label x:Name="tbName" Grid.Column="0" Content="{Binding SName, Mode=OneWay }" FontSize="30" VerticalAlignment="Center"/>
<TextBox x:Name="tbValue" Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10" Width="Auto" FontSize="30" Grid.Column="1" MaxLines="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" IsReadOnly="{Binding Readonly}" />
</Grid>
</UserControl>

View File

@@ -0,0 +1,31 @@
using System.Text.RegularExpressions;
using System.Windows.Controls;
using System.Windows.Input;
namespace Common;
/// <summary>
/// Interaktionslogik für AnalogValue.xaml
/// </summary>
public partial class ParamControlIntRange : UserControl
{
public bool IsReadonly { get; set; }
public ParamControlIntRange()
{
InitializeComponent();
// Unloaded += OnUnloaded;
}
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);
}
}

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;
}
}