Ejemplo n.º 1
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(string txtMsg, string strTip, bool blnIsShowTime, System.Drawing.Color color)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByText d = new SetTextCallbackByText(WriteTxt);
                    this.Invoke(d, new object[] { txtMsg, strTip, blnIsShowTime, color });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

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

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

                        strBuilder.Append(txtMsg);
                        strBuilder.Append("\n");

                        this.SelectionStart = this.Text.Length;
                        this.SelectionColor = color;
                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

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

                        if (this.Text.Length > KJMaxLength)
                        {
                            SaveFile();     //保持文本文件啊
                            this.Text = "";
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch
            { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 显示消息
        /// </summary>
        public void WriteTxt(string txtMsg, string strTip, bool blnIsShowTime, System.Drawing.Color color)
        {
            try
            {
                if (this.InvokeRequired)
                {
                    SetTextCallbackByText d = new SetTextCallbackByText(WriteTxt);
                    this.Invoke(d, new object[] { txtMsg, strTip, blnIsShowTime, color });
                }
                else
                {
                    //this.Focus();

                    try
                    {
                        StringBuilder strBuilder = new StringBuilder();

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

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

                        strBuilder.Append(txtMsg);
                        strBuilder.Append("\n");

                        this.SelectionStart = this.Text.Length;
                        this.SelectionColor = color;
                        this.AppendText(strBuilder.ToString());

                        strBuilder = null;

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

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