Exemplo n.º 1
0
        /// <summary>
        /// 更新动态区域
        /// </summary>
        /// <param name="value1"></param>
        /// <param name="value2"></param>
        /// <returns></returns>
        public bool UpdateArea(string value1, string value2 = "")
        {
            if (!this.ConnectStatus)
            {
                return(false);
            }
            string value = value1 + value2;

            Led5kSDK.bx_5k_area_header bx_5k = new Led5kSDK.bx_5k_area_header();
            bx_5k.AreaType    = 0x06;
            bx_5k.AreaX       = 0;
            bx_5k.AreaY       = 0;
            bx_5k.AreaWidth   = 96 / 8;
            bx_5k.AreaHeight  = 32;
            bx_5k.Lines_sizes = 1; //行间距
            bx_5k.RunMode     = 0; //运行模式 0自动循环显示 1完成后停留在最后一页 2超时未完成删除该信息
            bx_5k.Timeout     = 2; //超时时间 秒

            bx_5k.Reserved1   = 0;
            bx_5k.Reserved2   = 0;
            bx_5k.Reserved3   = 0;
            bx_5k.SingleLine  = 0x02;
            bx_5k.NewLine     = 0x02;//自动换行
            bx_5k.DisplayMode = 0x01;
            bx_5k.ExitMode    = 0x00;
            bx_5k.Speed       = 1;

            byte[] AreaText = System.Text.Encoding.Default.GetBytes(value);
            bx_5k.DataLen = AreaText.Length;

            int x = Led5kSDK.SCREEN_SendDynamicArea(m_dwCurHand, bx_5k, (ushort)bx_5k.DataLen, AreaText);

            return(x == 0);
        }
Exemplo n.º 2
0
        public byte[] AreaToByteArray()
        {
            //计算header的大小:结构体bx_5k_area_header的大小
            Led5kSDK.bx_5k_area_header tu = new Led5kSDK.bx_5k_area_header();
            int hsz = Marshal.SizeOf(tu);

            //计算len的大小
            byte[] tmp = System.Text.Encoding.Default.GetBytes(text);
            int    len = tmp.Length + hsz + 2;

            header.DataLen = tmp.Length;
            //先copy len
            byte[] bt = new byte[len];
            //byte[] lenToByte = System.BitConverter.GetBytes(len);
            short Len = (short)(len - 2);

            byte[] lenToByte = System.BitConverter.GetBytes(Len);
            lenToByte.CopyTo(bt, 0);
            int index = lenToByte.Length;

            //再copy header
            //分配结构体大小的内存空间
            IntPtr structPtr = Marshal.AllocHGlobal(hsz);

            //将结构体拷到分配好的内存空间
            Marshal.StructureToPtr(header, structPtr, false);

            //从内存空间拷到AreaDataList数组
            Marshal.Copy(structPtr, bt, index, hsz);
            //释放内存空间
            Marshal.FreeHGlobal(structPtr);
            //copy text
            tmp.CopyTo(bt, index + hsz);
            return(bt);
        }
Exemplo n.º 3
0
        public int getAreaLen()
        {
            Led5kSDK.bx_5k_area_header tu = new Led5kSDK.bx_5k_area_header();
            int hsz = Marshal.SizeOf(tu);

            //再考header

            byte[] tmp = System.Text.Encoding.Default.GetBytes(text);
            int    len = tmp.Length + hsz + 2;

            return(len);
        }
Exemplo n.º 4
0
        public int getAreaLen()
        {
            Led5kSDK.bx_5k_area_header tu = new Led5kSDK.bx_5k_area_header();
            int hsz = Marshal.SizeOf(tu);

            //再考header
            text = text.Replace("₩₩F", "\\F");
            List <byte[]> Byte_Area = new List <byte[]>();
            int           Byte_t    = 0;

            string[] str_Area = text.Trim().Split('\\');
            int      font     = 0;

            for (int n = 0; n < str_Area.Length; n++)
            {
                if (n > 0 && str_Area[n].Length > 1)
                {
                    if (str_Area[n].Substring(0, 2).Equals("FK"))
                    {
                        font = 1;
                        if (str_Area[n].Length > 5)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 5));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 5);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                    else if (str_Area[n].Substring(0, 2).Equals("FE") || str_Area[n].Substring(0, 2).Equals("FO") || str_Area[n].Substring(0, 2).Equals("WF") || str_Area[n].Substring(0, 2).Equals("WC"))
                    {
                        font = 0;
                        byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        byte[] special   = new byte[special_1.Length + 1];
                        special[0] = 0x5c;
                        for (int c = 0; c < special_1.Length; c++)
                        {
                            special[c + 1] = special_1[c];
                        }
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                    else if (str_Area[n].Substring(0, 1).Equals("C") || str_Area[n].Substring(0, 1).Equals("D") || str_Area[n].Substring(0, 1).Equals("B") || str_Area[n].Substring(0, 1).Equals("T"))
                    {
                        if (font == 1)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 2));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 2);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                    else if (str_Area[n].Substring(0, 1).Equals("n"))
                    {
                        if (font == 1)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 1));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 1);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                }
                else
                {
                    if (n > 0)
                    {
                        byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        byte[] special   = new byte[special_1.Length + 1];
                        special[0] = 0x5c;
                        for (int c = 0; c < special_1.Length; c++)
                        {
                            special[c + 1] = special_1[c];
                        }
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                    else
                    {
                        byte[] special = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                }
            }
            byte[] tmp = new byte[Byte_t];
            int    g   = 0;

            for (int n = 0; n < Byte_Area.Count(); n++)
            {
                if (n > 0)
                {
                    for (int j = 0; j < Byte_Area[n].Length; j++)
                    {
                        tmp[g + j] = Byte_Area[n][j];
                    }
                    g += Byte_Area[n].Length;
                }
                else
                {
                    for (int j = 0; j < Byte_Area[n].Length; j++)
                    {
                        tmp[j] = Byte_Area[n][j];
                    }
                    g += Byte_Area[n].Length;
                }
            }
            int len = tmp.Length + hsz + 4;

            return(len);
        }
Exemplo n.º 5
0
        public byte[] AreaToByteArray()
        {
            //计算header的大小:结构体bx_5k_area_header的大小
            Led5kSDK.bx_5k_area_header tu = new Led5kSDK.bx_5k_area_header();
            int hsz = Marshal.SizeOf(tu);

            //计算len的大小
            text = text.Replace("₩₩F", "\\F");
            List <byte[]> Byte_Area = new List <byte[]>();
            int           Byte_t    = 0;

            string[] str_Area = text.Trim().Split('\\');
            int      font     = 0;

            for (int n = 0; n < str_Area.Length; n++)
            {
                if (n > 0 && str_Area[n].Length > 1)
                {
                    if (str_Area[n].Substring(0, 2).Equals("FK"))
                    {
                        font = 1;
                        if (str_Area[n].Length > 5)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 5));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 5);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                    else if (str_Area[n].Substring(0, 2).Equals("FE") || str_Area[n].Substring(0, 2).Equals("FO") || str_Area[n].Substring(0, 2).Equals("WF") || str_Area[n].Substring(0, 2).Equals("WC"))
                    {
                        font = 0;
                        byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        byte[] special   = new byte[special_1.Length + 1];
                        special[0] = 0x5c;
                        for (int c = 0; c < special_1.Length; c++)
                        {
                            special[c + 1] = special_1[c];
                        }
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                    else if (str_Area[n].Substring(0, 1).Equals("C") || str_Area[n].Substring(0, 1).Equals("D") || str_Area[n].Substring(0, 1).Equals("B") || str_Area[n].Substring(0, 1).Equals("T"))
                    {
                        if (font == 1)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 2));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 2);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                    else if (str_Area[n].Substring(0, 1).Equals("n"))
                    {
                        if (font == 1)
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n].Substring(0, 1));
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;

                            string Area_str = str_Area[n].Remove(0, 1);
                            byte[] Korean   = System.Text.Encoding.Unicode.GetBytes(Area_str);
                            for (int k = 0; k < Korean.Length / 2; k++)
                            {
                                byte a = Korean[k * 2];
                                Korean[k * 2]     = Korean[k * 2 + 1];
                                Korean[k * 2 + 1] = a;
                            }
                            Byte_Area.Add(Korean);
                            Byte_t += Korean.Length;
                        }
                        else
                        {
                            byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                            byte[] special   = new byte[special_1.Length + 1];
                            special[0] = 0x5c;
                            for (int c = 0; c < special_1.Length; c++)
                            {
                                special[c + 1] = special_1[c];
                            }
                            Byte_Area.Add(special);
                            Byte_t += special.Length;
                        }
                    }
                }
                else
                {
                    if (n > 0)
                    {
                        byte[] special_1 = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        byte[] special   = new byte[special_1.Length + 1];
                        special[0] = 0x5c;
                        for (int c = 0; c < special_1.Length; c++)
                        {
                            special[c + 1] = special_1[c];
                        }
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                    else
                    {
                        byte[] special = System.Text.Encoding.Default.GetBytes(str_Area[n]);
                        Byte_Area.Add(special);
                        Byte_t += special.Length;
                    }
                }
            }
            byte[] tmp = new byte[Byte_t];
            int    g   = 0;

            for (int n = 0; n < Byte_Area.Count(); n++)
            {
                if (n > 0)
                {
                    for (int j = 0; j < Byte_Area[n].Length; j++)
                    {
                        tmp[g + j] = Byte_Area[n][j];
                    }
                    g += Byte_Area[n].Length;
                }
                else
                {
                    for (int j = 0; j < Byte_Area[n].Length; j++)
                    {
                        tmp[j] = Byte_Area[n][j];
                    }
                    g += Byte_Area[n].Length;
                }
            }
            int len = tmp.Length + hsz + 4;

            header.DataLen = tmp.Length;
            //先copy len
            byte[] bt = new byte[len];
            //byte[] lenToByte = System.BitConverter.GetBytes(len);
            byte[] lenToByte = System.BitConverter.GetBytes(len);
            lenToByte.CopyTo(bt, 0);
            int index = lenToByte.Length;

            //再copy header
            //分配结构体大小的内存空间
            IntPtr structPtr = Marshal.AllocHGlobal(hsz);

            //将结构体拷到分配好的内存空间
            Marshal.StructureToPtr(header, structPtr, false);

            //从内存空间拷到AreaDataList数组
            Marshal.Copy(structPtr, bt, index, hsz);
            //释放内存空间
            Marshal.FreeHGlobal(structPtr);
            //copy text
            tmp.CopyTo(bt, index + hsz);
            return(bt);
        }