using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PaintDotNet.Annotation.ImageCollect { public enum LockType { NULL = 0, AREA = 1, SIZE = 2 } public abstract class DrawStithchingBase : DrawObject { public static int ViewWidth = 2048; public static int ViewHeight = 2048; public static float Interval = 0.1f; private static int _OffsetX; private static int _OffsetY; public static int OffsetX { get => _OffsetX + SystemOffset; set { _OffsetX = value; } } public static int OffsetY { get => _OffsetY + SystemOffset; set { _OffsetY = value; } } private const int SystemOffset = 21; protected int[] tiles = new int[2]; protected List zscan = new List(); /// /// 锁定方式 /// public static LockType lockType = LockType.NULL; protected RectangleF rectangleMax = new RectangleF(); protected List> _points = new List>(); /// /// 获取拼图区域划分的网格数 /// public virtual int[] GetTiles() { int[] result = new int[2]; result[0] = tiles[0];// * 2; result[1] = tiles[1];// * 2; return result; } public virtual int ColumnNum { get => tiles[0]; } public virtual int RowNum { get => tiles[1]; } public List deletedPointId = new List(); /// /// 获取拼图区域面积 /// /// public virtual double GetArea() { double m_unitLength; this.ISurfaceBox.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out m_unitLength); double area = Math.Round((rectangleMax.Width * m_unitLength * rectangleMax.Height * m_unitLength / 1000000), 3); return area; } public virtual void Lock(LockType type) { lockType = type; } public virtual List> GetViewPoints() { return _points; } public virtual void DeletePoint(int index) { deletedPointId.Add(index); } public virtual void SetZAxisScan(ZScanParameter zScanParameter, int pIndex = 999999) { if (pIndex == 999999) { zscan.Clear(); for (int j = 0; j < tiles[1]; j++) { for (int i = 0; i < tiles[0]; i++) { zscan.Add(zScanParameter.Clone()); } } } else { zscan[pIndex] = zScanParameter.Clone(); } } public virtual ZScanParameter GetZAxisScan(int index) { return zscan[index]; } /// /// 计算偏移后的点 /// protected Func OffsetPointF = (x, y) => new PointF(x + OffsetX, y + OffsetY); } public class ZScanParameter { public double Start; public double Stop; public int Times = 5; public double Track; public ZScanParameter Clone() { return MemberwiseClone() as ZScanParameter; } } }