using OTSDataType; using OTSModelSharp; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace OTSMeasureApp._0_OTSModel.OTSDataType { public class CSpecialGrayRange:ISlo { public CIntRange range=new CIntRange(); public CIntRange diameterRange = new CIntRange(); public bool ifCollectXray; public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode) { xInt xStart = new xInt(); xInt xEnd = new xInt(); xInt xdiaStart = new xInt(); xInt xdiaEnd = new xInt(); xBool xIfXray = new xBool(); Slo slo = new Slo(); slo.Register("start", xStart); slo.Register("end", xEnd); slo.Register("diameterStart", xdiaStart); slo.Register("diameterEnd", xdiaEnd); slo.Register("collectXray", xIfXray); if (isStoring) { xStart.AssignValue(range.GetStart()); xEnd.AssignValue(range.GetEnd()); xdiaStart.AssignValue(diameterRange.GetStart()); xdiaEnd.AssignValue(diameterRange.GetEnd()); xIfXray.AssignValue(ifCollectXray); slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); range.SetStart(xStart.value()); range.SetEnd(xEnd.value()); diameterRange.SetStart(xdiaStart.value()); diameterRange.SetEnd(xdiaEnd.value()); ifCollectXray = xIfXray.value(); } } } public class CSpecialGrayRangeParam: ISlo { const string STRSPECIALGRAYCONFIGFILE = "SpecialGrayConfig.xml"; private List Ranges=new List(); private bool isToRun=false; private bool isInited=false; public CSpecialGrayRangeParam() { } public static string GetParamFileFullName() { String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\" + STRSPECIALGRAYCONFIGFILE; return path; } public bool GetIsToRun() { if (isInited == false) { LoadParam(); isInited = true; } return isToRun; } public void SetIsToRun(bool value) { isToRun = value; } public bool IsInited { get => isInited; set => isInited = value; } public List GetSpecialGreyRanges() { if (isInited == false) { LoadParam(); isInited = true; } return Ranges; } public void SetSpecailGrayRanges(List value) { Ranges = value; } public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode) { Collection xRangelist = new Collection(); xBool xtoRun = new xBool(); Slo slo = new Slo(); slo.Register("ToRun", xtoRun); slo.Register("GrayRangeList", xRangelist); if (isStoring) { xtoRun.AssignValue(isToRun); for (int i = 0; i < Ranges.Count; i++) { xRangelist.addItem(Ranges[i]); } slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); isToRun = xtoRun.value(); Ranges.Clear(); for (int i = 0; i < xRangelist.size(); i++) { Ranges.Add(xRangelist.getItem(i)); } } } public bool LoadParam() { String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\"+ STRSPECIALGRAYCONFIGFILE; // 5. check if the stage file exist if (File.Exists(path)) {// the stage file exist XmlDocument doc = new XmlDocument(); //载入xml文件 doc.Load(path); XmlNode root = doc.SelectSingleNode("XMLData"); Serialize(false, doc, root); isInited = true; return true; } return false; } } }