Exemplo n.º 1
0
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="color">字体颜色</param>
        public void ShowMessage(string msg, Color color)
        {
            if (RtbMsg.InvokeRequired == false)
            {
                if (RtbMsg.Text.Length > 20000)
                {
                    RtbMsg.Clear();
                }

                try
                {
                    int    tempTextLength = RtbMsg.Text.Length;
                    string strInfo        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "  " + msg;
                    RtbMsg.AppendText(strInfo + Environment.NewLine);
                    RtbMsg.Select(tempTextLength, strInfo.Length);
                    RtbMsg.SelectionColor = color;
                    RtbMsg.Select(RtbMsg.Text.Length, 0);
                    RtbMsg.ScrollToCaret();
                }
                catch (Exception ex)
                {
                    string forStyleCope = "吃掉他" + ex.Message;
                }
            }
            else
            {
                WriteMessageOnScreen delegateShowMsg = new WriteMessageOnScreen(this.ShowMessage);
                this.BeginInvoke(delegateShowMsg, msg, color);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="color">字体颜色</param>
        /// <param name="iswriteLog">是否记录日志</param>
        public void ShowMessage(string msg, Color color, bool iswriteLog)
        {
            if (rtbShowWorkingLog.InvokeRequired == false)
            {
                if (rtbShowWorkingLog.Text.Length > 20000)
                {
                    rtbShowWorkingLog.Clear();
                    LogStr.Remove(0, LogStr.Length);
                }

                try
                {
                    int    tempTextLength = rtbShowWorkingLog.Text.Length;
                    string strInfo        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "  " + msg;
                    if (iswriteLog)
                    {
                        LogManager.Log.WriteException(new AppException(strInfo, null, ExceptionLevel.Info));
                    }

                    rtbShowWorkingLog.AppendText(strInfo + Environment.NewLine);
                    rtbShowWorkingLog.Select(tempTextLength, strInfo.Length);
                    rtbShowWorkingLog.SelectionColor = color;
                    rtbShowWorkingLog.Select(rtbShowWorkingLog.Text.Length, 0);
                    rtbShowWorkingLog.ScrollToCaret();
                    LogStr.Append(rtbShowWorkingLog.Text);
                }
                catch (Exception ex)
                {
                    string forStyleCope = "吃掉他" + ex.Message;
                }
            }
            else
            {
                WriteMessageOnScreen delegateShowMsg = new WriteMessageOnScreen(this.ShowMessage);
                this.BeginInvoke(delegateShowMsg, msg, color, iswriteLog);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="color">字体颜色</param>
        /// <param name="iswriteLog">是否记录日志</param>
        public void ShowMessage(string msg, Color color, bool iswriteLog)
        {
            if (rtbShowWorkingLog.InvokeRequired == false)
            {
                if (rtbShowWorkingLog.Text.Length > 20000)
                {
                    rtbShowWorkingLog.Clear();
                    LogStr.Remove(0, LogStr.Length);
                }

                try
                {
                    int tempTextLength = rtbShowWorkingLog.Text.Length;
                    string strInfo = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "  " + msg;
                    if (iswriteLog)
                    {
                        LogManager.Log.WriteException(new AppException(strInfo, null, ExceptionLevel.Info));
                    }

                    rtbShowWorkingLog.AppendText(strInfo + Environment.NewLine);
                    rtbShowWorkingLog.Select(tempTextLength, strInfo.Length);
                    rtbShowWorkingLog.SelectionColor = color;
                    rtbShowWorkingLog.Select(rtbShowWorkingLog.Text.Length, 0);
                    rtbShowWorkingLog.ScrollToCaret();
                    LogStr.Append(rtbShowWorkingLog.Text);
                }
                catch (Exception ex)
                {
                    string forStyleCope = "吃掉他" + ex.Message;
                }
            }
            else
            {
                WriteMessageOnScreen delegateShowMsg = new WriteMessageOnScreen(this.ShowMessage);
                this.BeginInvoke(delegateShowMsg, msg, color, iswriteLog);
            }
        }