Example #1
0
        /// <summary>
        /// 输出显示信息
        /// </summary>
        /// <param name="strData">显示数据</param>
        /// <param name="strTitle">显示标题</param>
        /// <param name="strMark">显示备注</param>
        private void OutputInfo(string strData, string strTitle = "提示", string strMark = "串口1")
        {
            Font  font  = objSerialInfoConfig.Font;
            Color color = Color.Black;

            switch (strTitle)
            {
            case " ":
                richTextInfo.AppendTextColorful(strData + " ", Color.Green, false);
                return;

            case "提示":
                color = Color.Black;
                break;

            case "发送":
                color = (strMark == "串口1") ? objSerialInfoConfig.Color1Write : objSerialInfoConfig.Color2Write;
                if (chkShowSend.Checked == false)
                {
                    return;
                }
                break;

            case "接收":
                color = (strMark == "串口1") ? objSerialInfoConfig.Color1Receive : objSerialInfoConfig.Color2Receive;
                break;

            case "错误":
                color = Color.Red;
                break;

            case "警告":
                color = Color.Orange;
                break;

            default:
                return;
            }
            string strHead = "";

            if (chkShowSerial.Checked)
            {
                strHead += "[" + strMark + "]";
            }
            if (chkShowSend.Checked)
            {
                strHead += "[" + strTitle + "]";
            }
            if (chkShowTime.Checked)
            {
                strHead += "[" + DateTime.Now.ToString(objSerialInfoConfig.TimeFormat) + "]";
            }
            if (isLockTextUpdata)
            {
                richTextBuffer.AppendTextColorFont(strHead + strData, color, font, objSerialInfoConfig.FrameWarp);
            }
            else
            {
                CloseFocus(richTextInfo);
                richTextInfo.AppendTextColorFont(strHead + strData, color, font, objSerialInfoConfig.FrameWarp);
            }
        }