using MainShell.Models; using MwFramework.ManagerService; using Stylet; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MainShell.Recipe.Models { public class SubstrateInfo : PropertyChangedBase, IParameterItem { private MxSize _substrateSize = new MxSize(); public MxSize SubstrateSize { get { return _substrateSize; } set { SetAndNotify(ref _substrateSize, value); } } private MxSize _padSize; public MxSize PadSize { get { return _padSize; } set { SetAndNotify(ref _padSize, value); } } private double _thickness; public double ThickNess { get { return _thickness; } set { SetAndNotify(ref _thickness, value); } } private double _pitchX; public double PitchX { get { return _pitchX; } set { SetAndNotify(ref _pitchX, value); } } private double _pitchY; public double PitchY { get { return _pitchY; } set { SetAndNotify(ref _pitchY, value); } } private int _rowNumber; public int RowNumber { get { return _rowNumber; } set { SetAndNotify(ref _rowNumber, value); } } private int _colNumber; public int ColNumber { get { return _colNumber; } set { SetAndNotify(ref _colNumber, value); } } private double _recheckPitch; public double RecheckPitch { get { return _recheckPitch; } set { SetAndNotify(ref _recheckPitch, value); } } public IParameterItem Clone() { // 1. 首先执行浅拷贝,复制所有值类型字段(如 Thickness, PitchX 等) var clone = this.MemberwiseClone() as SubstrateInfo; // 2. 手动深拷贝引用类型对象 (MxSize) // 如果不这样做,clone 和原对象将指向内存中的同一个 MxSize 实例 if (this.SubstrateSize != null) { clone.SubstrateSize = new MxSize { Width = this.SubstrateSize.Width, Height = this.SubstrateSize.Height }; } if (this.PadSize != null) { clone.PadSize = new MxSize { Width = this.PadSize.Width, Height = this.PadSize.Height }; } return clone; } } }