示例#1
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(byte[] txtBytes, string strTip, bool blnIsShowTime, int iLocStart)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByBytes d = new SetTextCallbackByBytes(WriteTxt);
                    this.Invoke(d, new object[] { txtBytes, strTip, blnIsShowTime, iLocStart });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

                        if (blnIsShowTime)
                        {
                            strBuilder.Append(DateTime.Now.ToLongTimeString());
                        }

                        strBuilder.Append(strTip + ":\t");

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

                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

                        SaveTmpFile();      //保持临时文本文件

                        if (this.Text.Length > KJMaxLength)
                        {
                            SaveFile();     //保持文本文件啊
                            this.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch { }
        }
示例#2
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(byte[] txtBytes, string strTip, bool blnIsShowTime, int iLocStart)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByBytes d = new SetTextCallbackByBytes(WriteTxt);
                    this.Invoke(d, new object[] { txtBytes, strTip, blnIsShowTime, iLocStart });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

                        if (blnIsShowTime)
                        {
                            strBuilder.Append(DateTime.Now.ToLongTimeString());
                        }

                        strBuilder.Append(strTip + ":\t");

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

                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

                        SaveTmpFile();      //保持临时文本文件

                        if (this.Text.Length > KJMaxLength)
                        {
                            SaveFile();     //保持文本文件啊
                            this.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch { }
        }