MaterialCode.cs 5.9 KB
using System;
using System.Collections.Generic;
using System.Drawing;

namespace Model
{
    public class MaterialCode
    {
        public int ID { get; set; } = -1;
        public string Text { get; set; } = "";
        public string CodeType { get; set; } = "";
        public float CenterX { get; set; } = 0;
        public float CenterY { get; set; } = 0;
        public float Angle { get; set; } = 0;
        public float Width { get; set; } = 0;
        public float Height { get; set; } = 0;
        public float Distance { get; set; } = 0;

        public MaterialCode Clone()
        {
            MaterialCode node = new();
            System.Reflection.PropertyInfo[] destination = node.GetType().GetProperties();
            System.Reflection.PropertyInfo[] orgin = GetType().GetProperties();
            for (int i = 0; i < destination.Length; i++)
                destination[i].SetValue(node, orgin[i].GetValue(this));
            return node;
        }
    }









    ///// <summary>
    ///// 物料原始条形码类
    ///// </summary>
    //public class MaterialCode : ICloneable
    //{
    //    public int ID { get; set; }
    //    /// <summary>
    //    /// 文本
    //    /// </summary>
    //    public string Text { get; set; }
    //    /// <summary>
    //    /// 条码类型
    //    /// </summary>
    //    public string CodeType { get; set; }
    //    /// <summary>
    //    /// 中心点
    //    /// </summary>
    //    public PointF Center { get; set; }
    //    /// <summary>
    //    /// 角度,3点钟方向0°,逆时针为正,顺时针为负。
    //    /// </summary>
    //    public float Angle { get; set; }
    //    /// <summary>
    //    /// 宽度
    //    /// </summary>
    //    public float Width { get; set; }
    //    /// <summary>
    //    /// 高度
    //    /// </summary>
    //    public float Height { get; set; }
    //    /// <summary>
    //    /// 中心点到原点直线方程的距离
    //    /// </summary>
    //    public double Distance { get; set; }

    //    public bool MatchingStart { get; set; } = false;
    //    public string MatchingStartText { get; set; } = "";
    //    public bool MatchingEnd { get; set; } = false;
    //    public string MatchingEndText { get; set; } = "";
    //    public bool MatchingMiddle { get; set; } = false;
    //    public string MatchingMiddleText { get; set; } = "";
    //    public bool MatchingCaseSensitivity { get; set; } = false;

    //    public bool MatchingMinLength { get; set; } = false;
    //    public int MatchingMinLengthValue { get; set; } = 1;
    //    public bool MatchingMaxLength { get; set; } = false;
    //    public int MatchingMaxLengthValue { get; set; } = 1;
        


    //    /// <summary>
    //    /// 关键字
    //    /// </summary>
    //    public string Keyword { set; get; }
    //    /// <summary>
    //    /// 字符串截取起始
    //    /// </summary>
    //    public int Start { set; get; }
    //    /// <summary>
    //    /// 字符串截取长度
    //    /// </summary>
    //    public int Length { set; get; }

    //    public object Clone()
    //    {
    //        MaterialCode node = new MaterialCode();
    //        System.Reflection.PropertyInfo[] info1 = node.GetType().GetProperties();
    //        System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
    //        for (int i = 0; i < info1.Length; i++)
    //            info1[i].SetValue(node, info2[i].GetValue(this));
    //        return node;
    //    }
    //}

    ///// <summary>
    ///// 物料原始条码对应的OCR类
    ///// </summary>
    //public class OriginalCodeOCR : ICloneable
    //{
    //    /// <summary>
    //    /// 条码ID
    //    /// </summary>
    //    public int CodeID { set; get; }
    //    /// <summary>
    //    /// 与指定条码的偏移
    //    /// </summary>
    //    public Point Offset { set; get; }
    //    /// <summary>
    //    /// 识别区域的大小
    //    /// </summary>
    //    public Size Size { set; get; }
    //    /// <summary>
    //    /// 模式,用于替换
    //    /// </summary>
    //    public string Mode { set; get; } = "";

    //    public object Clone()
    //    {
    //        OriginalCodeOCR node = new OriginalCodeOCR();
    //        System.Reflection.PropertyInfo[] info1 = node.GetType().GetProperties();
    //        System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
    //        for (int i = 0; i < info1.Length; i++)
    //            info1[i].SetValue(node, info2[i].GetValue(this));
    //        return node;
    //    }
    //}

    ///// <summary>
    ///// 物料模板类
    ///// </summary>
    //public class MaterialTemplate: ICloneable
    //{
    //    public List<MaterialCode> Code = new List<MaterialCode>();
    //    public List<OriginalCodeOCR> OCR = new List<OriginalCodeOCR>();
    //    public string FilePath { get; set; } = "";
    //    public string ImagePath { get; set; } = "";
    //    public Bitmap Image { get; set; } = null;
    //    public string Name { get; set; } = "";
    //    public int PrimaryCode { get; set; } = -1;

    //    public object Clone()
    //    {
    //        MaterialTemplate node = new MaterialTemplate
    //        {
    //            Code = new List<MaterialCode>(),
    //            OCR = new List<OriginalCodeOCR>()
    //        };

    //        for (int i = 0; i < Code.Count; i++)
    //            node.Code.Add((MaterialCode)Code[i].Clone());
    //        for (int i = 0; i < OCR.Count; i++)
    //            node.OCR.Add((OriginalCodeOCR)OCR[i].Clone());

    //        System.Reflection.PropertyInfo[] info1 = node.GetType().GetProperties();
    //        System.Reflection.PropertyInfo[] info2 = this.GetType().GetProperties();
    //        for (int i = 0; i < info1.Length; i++)
    //            info1[i].SetValue(node, info2[i].GetValue(this));
    //        return node;
    //    }
    //}



}