using System;
using System.Linq;
using System.Text;
using System.Drawing;
namespace HNWD.LatticeScreen.Server
{
internal class CallingProgram : ProgramBase
{
public CallingProgram(LedLatticeScreen ledLatticeScreen, string CallId)
: base()
{
this.ledLatticeScreen = ledLatticeScreen;
this.CallId = CallId;
}
///
/// ascii转字符
///
///
private static string Chr()
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
byte[] byteArray = new byte[] { (byte)3 };
string strCharacter = asciiEncoding.GetString(byteArray);
return (strCharacter);
}
///
/// ascii转字符
///
///
private static string Chr2()
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
byte[] byteArray = new byte[] { (byte)96 };
string strCharacter = asciiEncoding.GetString(byteArray);
return (strCharacter);
}
///
/// 字符转ascii
///
///
///
public static int Asc(string character)
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
return (intAsciiCode);
}
public override void PlayWithErase()
{
this.ledLatticeScreen.JHErase();
if(this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr())||this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr2()))
{
string[] splited = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[]{Chr() , Chr2() },StringSplitOptions.RemoveEmptyEntries);
if(this.ledLatticeScreen.Width > 64)
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[0]);
}
else if (splited.Length>1)
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[1]);
}
}
else
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
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);
}
this.ResponseMessage();
}
public override void PlayWithoutErase()
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
if (this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr()) || this.wd_ProgramInfo.PROGRAM_TEXT.Contains(Chr2()))
{
string[] splited = this.wd_ProgramInfo.PROGRAM_TEXT.Split(new string[] { Chr() , Chr2() }, StringSplitOptions.RemoveEmptyEntries);
if (this.ledLatticeScreen.Width > 64)
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[0]);
}
else if (splited.Length > 1)
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
this.responseByLedCommand = LedControl.JHDrawText(this.ledLatticeScreen.hdl, 0, 0, Convert.ToUInt16(this.ledLatticeScreen.Width), Convert.ToUInt16(this.ledLatticeScreen.Height), 0xE12, splited[1]);
}
}
else
{
/* 调用屏幕操作中的DrawText接口来立即显示一段文本 */
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);
}
this.ResponseMessage();
}
}
}