CallingProgram.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Drawing;
  5. namespace HNWD.LatticeScreen.Server
  6. {
  7. internal class CallingProgram : ProgramBase
  8. {
  9. public CallingProgram(LedLatticeScreen ledLatticeScreen, string CallId)
  10. : base()
  11. {
  12. this.ledLatticeScreen = ledLatticeScreen;
  13. this.CallId = CallId;
  14. }
  15. /// <summary>
  16. /// ascii转字符
  17. /// </summary>
  18. /// <returns></returns>
  19. private static string Chr()
  20. {
  21. System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
  22. byte[] byteArray = new byte[] { (byte)3 };
  23. string strCharacter = asciiEncoding.GetString(byteArray);
  24. return (strCharacter);
  25. }
  26. /// <summary>
  27. /// ascii转字符
  28. /// </summary>
  29. /// <returns></returns>
  30. private static string Chr2()
  31. {
  32. System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
  33. byte[] byteArray = new byte[] { (byte)96 };
  34. string strCharacter = asciiEncoding.GetString(byteArray);
  35. return (strCharacter);
  36. }
  37. /// <summary>
  38. /// 字符转ascii
  39. /// </summary>
  40. /// <param name="character"></param>
  41. /// <returns></returns>
  42. public static int Asc(string character)
  43. {
  44. System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
  45. int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
  46. return (intAsciiCode);
  47. }
  48. public override void PlayWithErase()
  49. {
  50. this.ledLatticeScreen.JHErase();
  51. if(this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr())||this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr2()))
  52. {
  53. string[] splited = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[]{Chr() , Chr2() },StringSplitOptions.RemoveEmptyEntries);
  54. if(this.ledLatticeScreen.Width > 64)
  55. {
  56. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  57. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[0]);
  58. }
  59. else if (splited.Length>1)
  60. {
  61. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  62. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[1]);
  63. }
  64. }
  65. else
  66. {
  67. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  68. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, this.wd_ProgramInfo.PROGRAM_TEXT);
  69. }
  70. this.ResponseMessage();
  71. }
  72. public override void PlayWithoutErase()
  73. {
  74. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  75. if (this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr()) || this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr2()))
  76. {
  77. string[] splited = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { Chr() , Chr2() }, StringSplitOptions.RemoveEmptyEntries);
  78. if (this.ledLatticeScreen.Width > 64)
  79. {
  80. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  81. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[0]);
  82. }
  83. else if (splited.Length > 1)
  84. {
  85. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  86. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[1]);
  87. }
  88. }
  89. else
  90. {
  91. /* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
  92. this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, this.wd_ProgramInfo.PROGRAM_TEXT);
  93. }
  94. this.ResponseMessage();
  95. }
  96. }
  97. }