Example #1
0
        public void Draw()
        {
            List <byte> byteList = new List <byte>();

            //设置字体大小
            XingKongScreen.SetFontSize((int)FontSize);

            //生成坐标数据
            IEnumerable <byte> left = BitConverter.GetBytes(Left).Reverse();
            IEnumerable <byte> top  = BitConverter.GetBytes(Top).Reverse();

            //生成字符串数据
            byte[] str = Encoding.GetEncoding("GBK").GetBytes(Text);

            IEnumerable <byte> length = BitConverter.GetBytes((short)(9 + str.Length + 1 + 4)).Reverse();

            byteList.Add(0xA5);
            byteList.AddRange(length);
            byteList.Add(0x30);
            byteList.AddRange(left);
            byteList.AddRange(top);
            byteList.AddRange(str);
            byteList.Add(0x00);
            byteList.AddRange(new byte[] { 0xCC, 0x33, 0xC3, 0x3C });

            byte checkByte = XingKongScreen.getCheckByte(byteList);

            byteList.Add(checkByte);

            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                XingKongScreen.Write(byteList);
            }
            NeedDraw = false;
        }
Example #2
0
        public static void DrawLine(Point from, Point to)
        {
            byte[]             command = new byte[] { 0xA5, 0x00, 0x11, 0x22, 0x00, 0x0A, 0x00, 0x0A, 0x00, 0xFF, 0x00, 0xFF, 0xCC, 0x33, 0xC3, 0x3C, 0x96 };
            IEnumerable <byte> fx      = BitConverter.GetBytes((short)(from.X));
            IEnumerable <byte> fy      = BitConverter.GetBytes((short)(from.Y));
            IEnumerable <byte> tx      = BitConverter.GetBytes((short)(to.X));
            IEnumerable <byte> ty      = BitConverter.GetBytes((short)(to.Y));

            command[4] = fx.ElementAt(1);
            command[5] = fx.ElementAt(0);
            command[6] = fy.ElementAt(1);
            command[7] = fy.ElementAt(0);

            command[8]  = tx.ElementAt(1);
            command[9]  = tx.ElementAt(0);
            command[10] = ty.ElementAt(1);
            command[11] = ty.ElementAt(0);

            byte checkbyte = XingKongScreen.getCheckByte(command, true);

            command[16] = checkbyte;

            XingKongScreen.Write(command);
        }