using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using Xylem.Common.Logic.ProductionOrderCore.TestResults; namespace CordonelAssemblyLine.Data { public class PressureResultDataNotifyable : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } public PressureResultDataNotifyable(PressureResultData baseData) { LeakRate = baseData.LeakRate; Passed = baseData.Passed; PcbId = baseData.PcbId; Remark = baseData.Remark; Rev = baseData.Rev; TesterName = baseData.TesterName; TestPoints = new ObservableCollection(); baseData.TestPoints.ForEach(o => TestPoints.Add(o)); TestPressure = baseData.TestPressure; } public PressureResultDataNotifyable() { } public void InternalPropertyChanged(String propertyName = "") { NotifyPropertyChanged(propertyName); } public String PcbId; private Int32 _rev; public Int32 Rev { get => _rev; set { _rev = value; InternalPropertyChanged(nameof(Rev)); } } private Boolean? _passed = false; public Boolean? Passed { get => _passed; set { _passed = value; InternalPropertyChanged(nameof(Passed)); } } private String _testerName = ""; public String TesterName { get => _testerName; set { _testerName = value; InternalPropertyChanged(nameof(TesterName)); } } private String _testPressure = "6"; public String TestPressure { get => _testPressure; set { _testPressure = value; InternalPropertyChanged(nameof(TestPressure)); } } private String _leakRate = " 0,00001"; public String LeakRate { get => _leakRate; set { _leakRate = value; InternalPropertyChanged(nameof(LeakRate)); } } private String _remark = ""; public String Remark { get => _remark; set { _remark = value; InternalPropertyChanged(nameof(Remark)); } } private ObservableCollection _testPoints = new ObservableCollection { new PressureTestPoints { Ident = 1, Input = "0,000000200000" }, new PressureTestPoints { Ident = 2, Input = "0,000000200000" }, new PressureTestPoints { Ident = 3, Input = "0,000000200000" }, new PressureTestPoints { Ident = 4, Input = "0,000000200000" }, new PressureTestPoints { Ident = 5, Input = "0,000000200000" }, new PressureTestPoints { Ident = 6, Input = "0,000000200000" }, new PressureTestPoints { Ident = 7, Input = "0,000000200000" }, new PressureTestPoints { Ident = 8, Input = "0,000000200000" }, new PressureTestPoints { Ident = 9, Input = "0,000000200000" }, new PressureTestPoints { Ident = 10, Input = "0,000000200000" } }; public ObservableCollection TestPoints { get => _testPoints; set { _testPoints = value; InternalPropertyChanged(nameof(TestPoints)); } } internal void SetAllTestPoints(String input) { foreach (var item in TestPoints) { item.Input = input; } InternalPropertyChanged(nameof(TestPoints)); } public PressureResultData ToBase() { var baseData = new PressureResultData(); baseData.LeakRate = LeakRate; baseData.Passed = Passed; baseData.PcbId = PcbId; baseData.Remark = Remark; baseData.Rev = Rev; baseData.TesterName = TesterName; baseData.TestPoints = TestPoints.ToList(); baseData.TestPressure = TestPressure; return baseData; } } }