Beispiel #1
0
        public void Notify(MessageEntity msgEntity)
        {
            SendOrPostCallback callback =
             delegate (object state)
             {
                 if (this.rtxRealTimeLog != null && !this.rtxRealTimeLog.IsDisposed)
                 {
                     var msg = string.Format(">> {0}:{1}:{2}\n", msgEntity.Timestamp, msgEntity.MsgContent, msgEntity.ServiceType);

                     int len1 = rtxRealTimeLog.TextLength;
                     rtxRealTimeLog.AppendText(msg);
                     int len2 = msg.Length;
                     rtxRealTimeLog.Select(len1, len2);
                     //设置颜色
                     switch (msgEntity.MessageType)
                     {
                         case EMessageType.Info:
                             rtxRealTimeLog.SelectionColor = Color.Black;
                             break;
                         case EMessageType.Warn:
                             rtxRealTimeLog.SelectionColor = Color.Yellow;
                             break;
                         case EMessageType.Error:
                             rtxRealTimeLog.SelectionColor = Color.Red;
                             break;
                         default:
                             break;
                     }

                     rtxRealTimeLog.ScrollToCaret();
                 }
             };

            uiSyncContext.Post(callback, null);
        }
 public void Notify(MessageEntity msgEntity)
 {
     Console.WriteLine(msgEntity.ServiceType.ServiceType);
 }