/// <summary> /// 解析并显示开关量 /// </summary> /// <param Name="bin">开关量内存结构</param> public void fromBin(BinaryBin bin, byte[] byteBuffer) { ///位置和尺寸 this.Location = new Point(bin.rect.sX, bin.rect.sY); this.Width = bin.rect.eX - bin.rect.sX; this.Height = bin.rect.eY - bin.rect.sY; ///开关量类型 _typeByte = bin.type; ///显示字体 Dictionary <Byte, Font> FontConfig = new Dictionary <Byte, Font>(); FontConfig.Add(8, new Font("华文细黑", 8)); FontConfig.Add(12, new Font("华文细黑", 12)); FontConfig.Add(16, new Font("华文细黑", 16)); this.Font = FontConfig[bin.font]; ///显示内容 if (bin.type == 0) { this.Text = Encoding.Unicode.GetString(bin.trueText); customList.Add(Encoding.Unicode.GetString(bin.trueText)); customList.Add(Encoding.Unicode.GetString(bin.falseText)); trueColor = Color.FromArgb((Int32)bin.trueClr); trueBgColor = Color.FromArgb((Int32)bin.trueBgClr); falseColor = Color.FromArgb((Int32)bin.falseClr); falseBgColor = Color.FromArgb((Int32)bin.falseBgClr); } else { SVPixmapFile file = new SVPixmapFile(); customImageList.Add(file.getFromFile(byteBuffer, bin.trueClr)); customImageList.Add(file.getFromFile(byteBuffer, bin.falseClr)); } }
/// <summary> /// 生成下装文件 /// </summary> /// <param oldName="pageArrayBin">下装配置文件</param> /// <param oldName="serialize">序列化对象</param> public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageCount = pageArrayBin.pageCount; UInt32 binaryCount = pageArrayBin.pageArray[pageCount].binaryNum++; if (pageArrayBin.pageArray[pageCount].m_binary == null) { pageArrayBin.pageArray[pageCount].m_binary = new BinaryBin[SVLimit.PAGE_BOOL_MAXNUM]; } BinaryBin binaryBin = pageArrayBin.pageArray[pageCount].m_binary[binaryCount]; binaryBin.id = ID; binaryBin.rect.sX = (UInt16)Rect.X; binaryBin.rect.sY = (UInt16)Rect.Y; binaryBin.rect.eX = (UInt16)(Rect.Width + binaryBin.rect.sX); binaryBin.rect.eY = (UInt16)(Rect.Height + binaryBin.rect.sY); binaryBin.font = (Byte)_font.Size; binaryBin.type = _type; ///存放字符串相关的属性和文本信息 if (_type == 0) { binaryBin.trueClr = (UInt32)TrueColor.ToArgb(); binaryBin.trueBgClr = (UInt32)TrueBgColor.ToArgb(); binaryBin.falseClr = (UInt32)FalseColor.ToArgb(); binaryBin.falseBgClr = (UInt32)FalseBgColor.ToArgb(); binaryBin.vinfoInvalid = (UInt32)ExceptionColor.ToArgb(); binaryBin.vinfoInvalidBg = (UInt32)ExceptionBgColor.ToArgb(); binaryBin.trueText = new Byte[SVLimit.BINARY_MAX_LEN]; if (CustomTrueText != null) { copyDestByteArray(Encoding.Unicode.GetBytes(CustomTrueText), binaryBin.trueText); } binaryBin.falseText = new Byte[SVLimit.BINARY_MAX_LEN]; if (CustomFlaseText != null) { copyDestByteArray(Encoding.Unicode.GetBytes(CustomFlaseText), binaryBin.falseText); } } else ///存放与背景图片有关的信息 { ///为真的图片地址 var trueAddress = this.TruePicture.bitmap8Data(Rect.Width, Rect.Height); if (trueAddress != null) { binaryBin.trueClr = (UInt32)serialize.ToArray().Length; serialize.pack(trueAddress); } ///为假的图片地址 var falseAddress = this.FlasePicture.bitmap8Data(Rect.Width, Rect.Height); if (falseAddress != null) { binaryBin.falseClr = (UInt32)serialize.ToArray().Length; serialize.pack(falseAddress); } ///异常的图片地址 var exAddress = this.ExPicture.bitmap8Data(Rect.Width, Rect.Height); if (exAddress != null) { binaryBin.vinfoInvalid = (UInt32)serialize.ToArray().Length; serialize.pack(exAddress); } } ///根据名称来获取地址 var varInstance = SVVaribleType.instance(); binaryBin.addrOffset = varInstance.strToAddress(_var.VarName, _var.VarBlockType); binaryBin.varType = (Byte)varInstance.strToType(_var.VarName, _var.VarBlockType); pageArrayBin.pageArray[pageCount].m_binary[binaryCount] = binaryBin; }