diff --git a/uniper_hmi/UniperHMI/Common/FlowStationsViewModelBase.cs b/uniper_hmi/UniperHMI/Common/FlowStationsViewModelBase.cs new file mode 100644 index 0000000..eb59709 --- /dev/null +++ b/uniper_hmi/UniperHMI/Common/FlowStationsViewModelBase.cs @@ -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 initFlowStations = new(); + [ObservableProperty] + private ObservableCollection flowStations = new ObservableCollection(); + + 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 initEntries = new(); + [ObservableProperty] private ObservableCollection flowReceipeEntries; + + + public void AcceptChanges() + { + initEntries = new(FlowReceipeEntries); + } + + public bool IsChanged => !FlowReceipeEntries.Equals(initEntries); + public void DiscardChanges() + { + FlowReceipeEntries = new(initEntries); + } + } +} diff --git a/uniper_hmi/UniperHMI/Common/IChangeTrackingEx.cs b/uniper_hmi/UniperHMI/Common/IChangeTrackingEx.cs new file mode 100644 index 0000000..e3264d8 --- /dev/null +++ b/uniper_hmi/UniperHMI/Common/IChangeTrackingEx.cs @@ -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(); + } +} diff --git a/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs b/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs index 4c6dc75..12807d1 100644 --- a/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs +++ b/uniper_hmi/UniperHMI/Common/L4ItXmlSerializer.cs @@ -19,7 +19,7 @@ public static class L4ItXmlSerializer /// /// - public static void SerializeObject(T serializableObject, string fileName, bool encrypt = false, string rootElementName = null) + public static void SerializeObject(T serializableObject, string fileName, bool encrypt = false, string? rootElementName = null) { if (string.IsNullOrEmpty(fileName)) return; @@ -73,7 +73,7 @@ public static class L4ItXmlSerializer /// /// /// - public static T DeSerializeObject(string fileName, bool decrypt = false, string rootElementName = null) + public static T DeSerializeObject(string fileName, bool decrypt = false, string? rootElementName = null) { if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) return default!; diff --git a/uniper_hmi/UniperHMI/Common/MediaContainer.xaml b/uniper_hmi/UniperHMI/Common/MediaContainer.xaml index cda2874..a4c410e 100644 --- a/uniper_hmi/UniperHMI/Common/MediaContainer.xaml +++ b/uniper_hmi/UniperHMI/Common/MediaContainer.xaml @@ -44,7 +44,7 @@