using connor_zwcadm.util; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace connor_zwcadm.model { public class BOMBlockInfo { public string TitleBlockName { get; } public string BOMBlockName { get; } public string BOMHeaderBlockName { get; } public double Dx { get; } public double Dy { get; } public string AttrIndex { get; } private BOMBlockInfo(string titleBlockName, string bomBlockName, string bomHeaderBlockName,string attrIndex, double dx, double dy) { TitleBlockName = titleBlockName; BOMBlockName = bomBlockName; BOMHeaderBlockName = bomHeaderBlockName; AttrIndex = attrIndex; Dx = dx; Dy = dy; } public string GetInfo() { return string.Format("标题栏[{0}] 明细栏表头[{1}] 明细栏[{2}] 序号属性[{3}] 坐标[{4}, {5}]", TitleBlockName, BOMHeaderBlockName, BOMBlockName,AttrIndex, Dx, Dy); } public static BOMBlockInfo Parse(string config) { if (string.IsNullOrWhiteSpace(config)) { return null; } string[] split = config.Split('='); if (KUtil.GetLen(split) != 5) { return null; } string titleBlockName = split[0]; string bomHeaderBlockName = split[1]; string bomBlockName = split[2]; string attrIndex = split[3]; string[] position = split[4].Split(','); if (KUtil.GetLen(position) != 2) { return null; } try { double dx = double.Parse(position[0]); double dy = double.Parse(position[1]); if (!string.IsNullOrWhiteSpace(titleBlockName) && !string.IsNullOrWhiteSpace(bomHeaderBlockName) && !string.IsNullOrWhiteSpace(bomBlockName) && !string.IsNullOrWhiteSpace(attrIndex)) { return new BOMBlockInfo(titleBlockName, bomBlockName, bomHeaderBlockName, attrIndex, dx, dy); } } catch(Exception e) { } return null; } } }