Esempio n. 1
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(byte[] txtBytes)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByBytes2 d = new SetTextCallbackByBytes2(WriteTxt);
                    this.Invoke(d, new object[] { txtBytes });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

                        for (int j = 0; j < txtBytes.Length; j++)
                        {
                            strBuilder.Append(txtBytes[j].ToString("X2"));
                            strBuilder.Append(" ");
                        }
                        strBuilder.Append("\n");

                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

                        if (this.Text.Length > KJMaxLength)
                        {
                            this.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch { }
        }
Esempio n. 2
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(byte[] txtBytes)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByBytes2 d = new SetTextCallbackByBytes2(WriteTxt);
                    this.Invoke(d, new object[] { txtBytes });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

                        for (int j = 0; j < txtBytes.Length; j++)
                        {
                            strBuilder.Append(txtBytes[j].ToString("X2"));
                            strBuilder.Append(" ");
                        }
                        strBuilder.Append("\n");

                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

                        if (this.Text.Length > KJMaxLength)
                        {
                            this.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch { }
        }