using System; using System.Collections.Generic; using System.Linq; using System.Text; using HNWD.Pregrant.Common; using HNWD.Pregrant.DataAccess; using HNWD.Pregrant.Model; using System.Windows.Forms; namespace HNWD.LatticeScreen.Server { internal class TextProgram : ProgramBase { private readonly Int16 MatrixHeight = 16 ; private readonly string splitStr = "\r\n"; public TextProgram(LedLatticeScreen ledLatticeScreen):base() { this.ledLatticeScreen = ledLatticeScreen; } public override void PlayWithErase() { this.GetTextAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN); this.ledLatticeScreen.JHErase(); //LedControl.JHFillRect(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_Y),Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_HEIGHT)) ; /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */ if(this.wd_ProgramInfo.PROGRAM_TEXT.Contains(this.splitStr)) { string[] splitedstr = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { this.splitStr }, StringSplitOptions.RemoveEmptyEntries); for (Int16 i = 0; i < splitedstr.Length; i++) { this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(MatrixHeight * i), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(MatrixHeight), this.AlignMode, splitedstr[i]); } } else { responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_Y), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_HEIGHT), this.AlignMode, this.wd_ProgramInfo.PROGRAM_TEXT); } this.ResponseMessage(); } public override void PlayWithoutErase() { this.GetTextAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN); if (this.wd_ProgramInfo.PROGRAM_TEXT.Contains(this.splitStr)) { string[] splitedstr = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { this.splitStr }, StringSplitOptions.RemoveEmptyEntries); for (Int16 i = 0; i < splitedstr.Length; i++) { this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(MatrixHeight * i), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(MatrixHeight), this.AlignMode, splitedstr[i]); } } else { responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_Y), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_HEIGHT), this.AlignMode, this.wd_ProgramInfo.PROGRAM_TEXT); } this.ResponseMessage(); } } }