using OTSDataType; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace OTSMeasureApp._0_OTSModel.OTSDataType { public enum AutoRegulateType { EveryPeriod = 0, EverySample = 1 } internal class CBrightnessContrastRegulateParam:ISlo { public CBrightnessContrastRegulateParam() { brightphaseGrayvalue = 0; darkphaseGrayvalue = 0; } public Point stdMaterialOTSPos = new Point(); public int brightphaseGrayvalue; public string brightphaseelement = ""; public int darkphaseGrayvalue; public string darkphaseelement = ""; public int mag = 100; //放大倍数 public double initialBrightness; public double initialContrast; public int period = 60;//minutes to run the regulation public AutoRegulateType autoRegulateType = AutoRegulateType.EveryPeriod; //自动调节类型 public bool toRun = false; public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode) { xInt xbrphasevalue = new xInt(); xInt xdarkphasevalue = new xInt(); xInt xmag= new xInt(); xString xbrphaseelement = new xString(); xString xdarkphaseelement = new xString(); xPoint xStart = new xPoint(); xBool xtorun = new xBool(); xDouble xinitialBrightness = new xDouble(this.initialBrightness); xDouble xinitialContrast = new xDouble(this.initialContrast); xInt xPeriod = new xInt(this.period); xString xAutoRegulateType = new xString(this.autoRegulateType.ToString()); Slo slo = new Slo(); slo.Register("ToRun", xtorun); slo.Register("BrightPhaseElement", xbrphaseelement); slo.Register("BrightPhaseValue", xbrphasevalue); slo.Register("DarkPhaseElement", xdarkphaseelement); slo.Register("DarkPhaseValue", xdarkphasevalue); slo.Register("mag", xmag); slo.Register("InitialBrightness", xinitialBrightness); slo.Register("InitialContrast", xinitialContrast); slo.Register("StdMaterialOTSPos", xStart); slo.Register("Period", xPeriod); slo.Register("AutoRegulateType", xAutoRegulateType); if (isStoring) { xStart.AssignValue(stdMaterialOTSPos); xbrphaseelement.AssignValue(brightphaseelement); xbrphasevalue.AssignValue(brightphaseGrayvalue); xdarkphaseelement.AssignValue(darkphaseelement); xdarkphasevalue.AssignValue(darkphaseGrayvalue); xmag.AssignValue(mag); xtorun.AssignValue(toRun); xinitialBrightness.AssignValue(initialBrightness); xinitialContrast.AssignValue(initialContrast); xPeriod.AssignValue(period); xAutoRegulateType.AssignValue(autoRegulateType.ToString()); slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); stdMaterialOTSPos = xStart.value(); brightphaseelement = xbrphaseelement.value(); brightphaseGrayvalue = xbrphasevalue.value(); darkphaseelement = xdarkphaseelement.value(); darkphaseGrayvalue = xdarkphasevalue.value(); mag = xmag.value(); toRun = xtorun.value(); initialBrightness = xinitialBrightness.value(); initialContrast = xinitialContrast.value(); period = xPeriod.value(); autoRegulateType = (AutoRegulateType)Enum.Parse(typeof(AutoRegulateType), xAutoRegulateType.value(), true); } } } }