BTool.MsgLogForm.DisplayLogMsg C# (CSharp) Méthode

DisplayLogMsg() public méthode

public DisplayLogMsg ( SharedAppObjs msgType, string msg, string time ) : void
msgType SharedAppObjs
msg string
time string
Résultat void
        public void DisplayLogMsg(SharedAppObjs.MsgType msgType, string msg, string time)
        {
            dspMsgMutex.WaitOne();
            rtbUpdate = true;
            if (InvokeRequired)
            {
                try
                {
                    BeginInvoke((Delegate)new MsgLogForm.DisplayLogMsgDelegate(DisplayLogMsg), (object)msgType, (object)msg, (object)time);
                }
                catch
                {
                }
            }
            else
            {
                string str1 = string.Empty;
                bool flag = false;
                string str2;
                switch (msgType)
                {
                    case SharedAppObjs.MsgType.Incoming:
                        str2 = "<Rx> - ";
                        if (!tsmiDisplayRxPackets.Checked)
                        {
                            flag = true;
                            break;
                        }
                        else
                            break;
                    case SharedAppObjs.MsgType.Outgoing:
                        str2 = "<Tx> - ";
                        if (!tsmiDisplayTxPackets.Checked)
                        {
                            flag = true;
                            break;
                        }
                        else
                            break;
                    case SharedAppObjs.MsgType.Info:
                        str2 = "<Info> - ";
                        break;
                    case SharedAppObjs.MsgType.Warning:
                        str2 = "<Warning> - ";
                        break;
                    case SharedAppObjs.MsgType.Error:
                        str2 = "<Error> - ";
                        break;
                    case SharedAppObjs.MsgType.RxDump:
                        str2 = "Dump(Rx):\n";
                        if (!tsmiDisplayRxDumps.Checked)
                        {
                            flag = true;
                            break;
                        }
                        else
                            break;
                    case SharedAppObjs.MsgType.TxDump:
                        str2 = "Dump(Tx):\n";
                        if (!tsmiDisplayTxDumps.Checked)
                        {
                            flag = true;
                            break;
                        }
                        else
                            break;
                    default:
                        str2 = "<Unknown> - ";
                        break;
                }
                if (!flag)
                {
                    rtbMsgBox.SuspendLayout();
                    try
                    {
                        rtbMsgBox.SelectionStart = rtbMsgBox.TextLength;
                        rtbMsgBox.SelectionLength = 0;
                        if (msgType != SharedAppObjs.MsgType.RxDump && msgType != SharedAppObjs.MsgType.TxDump)
                        {
                            rtbMsgBox.SelectionColor = MessageColor[(int)msgType];
                            ++msgNumber;
                            string str3 = string.Empty;
                            string str4 = time != null ? time : DateTime.Now.ToString("hh:mm:ss.fff");
                            rtbMsgBox.AppendText("[" + msgNumber.ToString() + "] : " + str2 + str4 + "\n" + msg);
                        }
                        else
                        {
                            rtbMsgBox.SelectionColor = Color.Black;
                            rtbMsgBox.AppendText(str2 + msg + "\n");
                        }
                        if ((msgType == SharedAppObjs.MsgType.Incoming || msgType == SharedAppObjs.MsgType.Outgoing) && (msgType != SharedAppObjs.MsgType.Incoming || tsmiDisplayRxDumps.Checked))
                        {
                            if (msgType == SharedAppObjs.MsgType.Outgoing)
                            {
                                if (tsmiDisplayTxDumps.Checked)
                                    goto label_26;
                            }
                            else
                                goto label_26;
                        }
                        rtbMsgBox.AppendText("------------------------------------------------------------------------------------------------------------------------\n");
                    }
                    catch
                    {
                    }
                label_26:
                    rtbMsgBox.ResumeLayout();
                }
            }
            rtbUpdate = false;
            dspMsgMutex.ReleaseMutex();
        }