TextProgram.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using HNWD.Pregrant.Common;
  6. using HNWD.Pregrant.DataAccess;
  7. using HNWD.Pregrant.Model;
  8. using System.Windows.Forms;
  9. namespace HNWD.LatticeScreen.Server
  10. {
  11. internal class TextProgram : ProgramBase
  12. {
  13. private readonly Int16 MatrixHeight = 16 ;
  14. private readonly string splitStr = "\r\n";
  15. public TextProgram(LedLatticeScreen ledLatticeScreen):base()
  16. {
  17. this.ledLatticeScreen = ledLatticeScreen;
  18. }
  19. public override void PlayWithErase()
  20. {
  21. this.GetTextAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN);
  22. this.ledLatticeScreen.JHErase();
  23. //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)) ;
  24. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  25. if(this.wd_ProgramInfo.PROGRAM_TEXT.Contains(this.splitStr))
  26. {
  27. string[] splitedstr = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { this.splitStr }, StringSplitOptions.RemoveEmptyEntries);
  28. for (Int16 i = 0; i < splitedstr.Length; i++)
  29. {
  30. 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]);
  31. }
  32. }
  33. else
  34. {
  35. 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);
  36. }
  37. this.ResponseMessage();
  38. }
  39. public override void PlayWithoutErase()
  40. {
  41. this.GetTextAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN);
  42. if (this.wd_ProgramInfo.PROGRAM_TEXT.Contains(this.splitStr))
  43. {
  44. string[] splitedstr = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { this.splitStr }, StringSplitOptions.RemoveEmptyEntries);
  45. for (Int16 i = 0; i < splitedstr.Length; i++)
  46. {
  47. 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]);
  48. }
  49. }
  50. else
  51. {
  52. 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);
  53. }
  54. this.ResponseMessage();
  55. }
  56. }
  57. }