Push Changes from other Github
This commit is contained in:
50
uniper_hmi/UniperHMI/Common/FlowStationsViewModelBase.cs
Normal file
50
uniper_hmi/UniperHMI/Common/FlowStationsViewModelBase.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using InfineonHMI.Model;
|
||||
|
||||
namespace InfineonHMI.Common
|
||||
{
|
||||
public sealed partial class FlowStationsViewModelBase : ObservableValidator, IChangeTrackingEx
|
||||
{
|
||||
private ObservableCollection<StationEntry> initFlowStations = new();
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<StationEntry> flowStations = new ObservableCollection<StationEntry>();
|
||||
|
||||
public void AcceptChanges()
|
||||
{
|
||||
initFlowStations = new(FlowStations);
|
||||
}
|
||||
|
||||
public bool IsChanged => !initFlowStations.Equals(FlowStations);
|
||||
public void DiscardChanges()
|
||||
{
|
||||
FlowStations = new(initFlowStations);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class FlowReceipe : ObservableValidator, IChangeTrackingEx
|
||||
{
|
||||
|
||||
private ObservableCollection<FlowReceipeEntry> initEntries = new();
|
||||
[ObservableProperty] private ObservableCollection<FlowReceipeEntry> flowReceipeEntries;
|
||||
|
||||
|
||||
public void AcceptChanges()
|
||||
{
|
||||
initEntries = new(FlowReceipeEntries);
|
||||
}
|
||||
|
||||
public bool IsChanged => !FlowReceipeEntries.Equals(initEntries);
|
||||
public void DiscardChanges()
|
||||
{
|
||||
FlowReceipeEntries = new(initEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
uniper_hmi/UniperHMI/Common/IChangeTrackingEx.cs
Normal file
14
uniper_hmi/UniperHMI/Common/IChangeTrackingEx.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InfineonHMI.Common
|
||||
{
|
||||
public interface IChangeTrackingEx : IChangeTracking
|
||||
{
|
||||
void DiscardChanges();
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public static class L4ItXmlSerializer
|
||||
/// <param name="encrypt"></param>
|
||||
/// <param name="rootElementName"></param>
|
||||
|
||||
public static void SerializeObject<T>(T serializableObject, string fileName, bool encrypt = false, string rootElementName = null)
|
||||
public static void SerializeObject<T>(T serializableObject, string fileName, bool encrypt = false, string? rootElementName = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ public static class L4ItXmlSerializer
|
||||
/// <returns></returns>
|
||||
///
|
||||
///
|
||||
public static T DeSerializeObject<T>(string fileName, bool decrypt = false, string rootElementName = null)
|
||||
public static T DeSerializeObject<T>(string fileName, bool decrypt = false, string? rootElementName = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) return default!;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<Border Grid.Row="0" BorderBrush="White" BorderThickness="1" />
|
||||
<Border Grid.Row="1" BorderBrush="White" BorderThickness="1" />
|
||||
<Label Grid.Row="0" VerticalAlignment="Center" Content="Übervoll" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Width="200" FontSize="30"/>
|
||||
<RadioButton Margin="5" Grid.Row="1" IsChecked="{Binding Overload}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<RadioButton Margin="5" Grid.Row="1" IsChecked="{Binding Overload}" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="False"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="1">
|
||||
@@ -55,7 +55,7 @@
|
||||
<Border Grid.Row="0" BorderBrush="White" BorderThickness="1" />
|
||||
<Border Grid.Row="1" BorderBrush="White" BorderThickness="1" />
|
||||
<Label Grid.Row="0" VerticalAlignment="Center" Content="Voll" HorizontalAlignment="Center" FontSize="30"/>
|
||||
<RadioButton Grid.Row="1" Margin="5" IsChecked="{Binding Full}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<RadioButton Grid.Row="1" Margin="5" IsChecked="{Binding Full}" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="False"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="0">
|
||||
@@ -66,7 +66,7 @@
|
||||
<Border Grid.Row="0" BorderBrush="White" BorderThickness="1" />
|
||||
<Border Grid.Row="1" BorderBrush="White" BorderThickness="1" />
|
||||
<Label Grid.Row="0" VerticalAlignment="Center" Content="Leer" HorizontalAlignment="Center" FontSize="30"/>
|
||||
<RadioButton Grid.Row="1" Margin="5" IsChecked="{Binding Empty}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<RadioButton Grid.Row="1" Margin="5" IsChecked="{Binding Empty}" HorizontalAlignment="Center" VerticalAlignment="Center" IsEnabled="False"/>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Column="1" Grid.Row="1" BorderBrush="White" BorderThickness="1"/>
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- <Label Grid.Column="0" Content="{Binding SName}" VerticalAlignment="Center" HorizontalAlignment="Left"/> -->
|
||||
<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, StringFormat=N2}" Margin="10" Width="Auto" FontSize="30" Grid.Column="1" MaxLines="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" IsReadOnly="{Binding Readonly}" />
|
||||
|
||||
<TextBox x:Name="tbValue" Text="{Binding Value, Mode=TwoWay, StringFormat=N2, UpdateSourceTrigger=PropertyChanged}" Margin="10" Width="Auto" FontSize="30" Grid.Column="1" MaxLines="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" IsReadOnly="{Binding Readonly}" />
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -23,9 +23,4 @@ public partial class ParamControlFloat : UserControl
|
||||
disposable?.Dispose();
|
||||
}
|
||||
|
||||
private void NumberValidation(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
Regex regex = new("^[-+]?[0-9]*,?[0-9]+$");
|
||||
e.Handled = regex.IsMatch(e.Text);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,39 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using TwinCAT.TypeSystem;
|
||||
using Heisig.HMI.AdsManager;
|
||||
using InfineonHMI.Common;
|
||||
|
||||
namespace Common;
|
||||
|
||||
public sealed partial class ParamControlFloatVm : ObservableValidator, IDisposable
|
||||
public sealed partial class ParamControlFloatVm : ObservableValidator, IDisposable, IChangeTrackingEx
|
||||
{
|
||||
private float initValue;
|
||||
|
||||
[ObservableProperty]
|
||||
private string sName;
|
||||
|
||||
[ObservableProperty]
|
||||
private float value;
|
||||
|
||||
|
||||
public ParamControlFloatVm()
|
||||
{
|
||||
SName = "No Name:";
|
||||
Value = 0.0f;
|
||||
initValue = Value;
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void AcceptChanges()
|
||||
{
|
||||
initValue = Value;
|
||||
}
|
||||
|
||||
public bool IsChanged => initValue != Value;
|
||||
public void DiscardChanges()
|
||||
{
|
||||
Value = initValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- <Label Grid.Column="0" Content="{Binding SName}" VerticalAlignment="Center" HorizontalAlignment="Left"/> -->
|
||||
<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}" Margin="10" Width="Auto" FontSize="30" Grid.Column="1" MaxLines="1" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" IsReadOnly="{Binding Readonly}" />
|
||||
<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>
|
||||
|
||||
@@ -1,28 +1,38 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using TwinCAT.TypeSystem;
|
||||
using Heisig.HMI.AdsManager;
|
||||
using InfineonHMI.Common;
|
||||
|
||||
namespace Common;
|
||||
|
||||
public sealed partial class ParamControlIntVm : ObservableValidator, IDisposable
|
||||
public sealed partial class ParamControlIntVm : ObservableValidator, IDisposable, IChangeTrackingEx
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string sName;
|
||||
private int initValue;
|
||||
|
||||
[ObservableProperty]
|
||||
private int value;
|
||||
|
||||
public ParamControlIntVm()
|
||||
{
|
||||
SName = "No Name:";
|
||||
Value = 0;
|
||||
}
|
||||
[ObservableProperty] private string sName;
|
||||
|
||||
[ObservableProperty] private int value;
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
public ParamControlIntVm()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ public sealed partial class UserManagementWindowVm : ObservableValidator
|
||||
}
|
||||
else
|
||||
{
|
||||
// Todo: For Deployment, set Userlevel to 0 if default!
|
||||
CurrentUser = new User("unknown", "default", 100);
|
||||
}
|
||||
users = L4ItXmlSerializer.DeSerializeObject<ObservableCollection<User>>(filePath);
|
||||
|
||||
Reference in New Issue
Block a user