using Rs.Controls; using Rs.Framework; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Rs.MotionPlat.Commom { public class TrayPosition { private int m_row = 26; private int m_column = 10; public int RowNum { get { return m_row; } set { m_row = value; } } public int ColumnNum { get { return m_column; } set { m_column = value; } } private TrayPosition() { //for (int i = 0; i < m_row; i++) //{ // for(int j=0;j SlotPoints { get; set; } = new BindingList(); public bool Save() { try { float offsetX = Math.Abs(LeftTop.X - RightBottom.X)/(ColumnNum-1); float offsetY = Math.Abs(LeftTop.Y - LeftBottom.Y)/(RowNum-1); int index = 0; SlotPoints.Clear(); for (int i = 0; i < m_column; i++) { for (int j = 0; j < m_row; j++) { index++; TraySlot ts = new TraySlot(); ts.Index = index; ts.Row = i + 1; ts.Column = j + 1; ts.Position = new PointF(LeftTop.X + (i * offsetX), LeftTop.Y + (j * offsetY)); SlotPoints.Add(ts); } } XmlSerializerHelper.Instance.Serialize($"Recipe/{TrayName}.xml", this); } catch (Exception) { return false; } return true; } public static TrayPosition Load(string trayName,int row=26,int column=10) { XmlSerializerHelper.Instance.Deserialize($"Recipe/{trayName}.xml",out TrayPosition entity); if (entity == null) return new TrayPosition(row,column, trayName); return entity; } } }