using MainShell.Filewritable; using Newtonsoft.Json; using System; using System.ComponentModel; using System.Runtime.CompilerServices; namespace MainShell.DeviceMaintance.Model { public class LaserCompensationSetting : MXJM.FileWritable.JsonFileWritableBase, INotifyPropertyChanged { private string _axisName = "Axis_Stage_Y3"; public string AxisName { get { return _axisName; } set { SetAndNotify(ref _axisName, value); } } private double _startPos; public double StartPos { get { return _startPos; } set { SetAndNotify(ref _startPos, value); } } private double _steps = 1.0d; public double Steps { get { return _steps; } set { SetAndNotify(ref _steps, value); } } private int _stepsCount = 5; public int StepsCount { get { return _stepsCount; } set { SetAndNotify(ref _stepsCount, value); } } private double _jumpPos = 1.0d; public double JumpPos { get { return _jumpPos; } set { SetAndNotify(ref _jumpPos, value); } } private int _workCount = 1; public int WorkCount { get { return _workCount; } set { SetAndNotify(ref _workCount, value); } } private double _speed = 5.0d; public double Speed { get { return _speed; } set { SetAndNotify(ref _speed, value); } } private double _dwellTime = 0.5d; public double DwellTime { get { return _dwellTime; } set { SetAndNotify(ref _dwellTime, value); } } [JsonIgnore] public override string Dir => Paths.CalibSettingPath; [JsonIgnore] public override string FileName => "LaserCompensationSetting.json"; public event PropertyChangedEventHandler PropertyChanged; public void LoadFromFile() { Read(); } public void SaveToFile() { Write(); } protected bool SetAndNotify(ref T field, T value, [CallerMemberName] string propertyName = null) { if (Equals(field, value)) { return false; } field = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); return true; } } }