Exemplo n.º 1
0
        private static LogMessage AddToLogs(string tag, string message,
                                            string stackTrace    = null,
                                            LogMessage.Type type = LogMessage.Type.Info)
        {
#if DEBUG_CONSOLE
            var log = new LogMessage()
            {
                Message     = message,
                MessageType = type,
                StackTrace  = stackTrace,
                Tag         = tag,
                CreateTime  = DateTime.Now.ToString("yyyy.MM.dd  HH:mm:ss  fff"),
            };

            // Add logs
            Logs.Add(log);

            // Check capacity
            while (Logs.Count > MaxLogCount)
            {
                Logs.RemoveAt(0);
            }

            return(log);
#else
            return(null);
#endif
        }
Exemplo n.º 2
0
        private void Communication_LogReceived(LogMessage.Type type, string Log)
        {
            Viewer.UpadateLogColorInvoke UpdateLogwColor = LogUpdatewColor;
            // 根據 type 改變 Log 文字的顏色
            Color tans_color = SystemColors.ControlText;

            switch (type)
            {
            case LogMessage.Type.Normal:
                break;

            case LogMessage.Type.Infomation:
                tans_color = Color.Blue;
                break;

            case LogMessage.Type.Successful:
                tans_color = Color.Green;
                break;

            case LogMessage.Type.Warning:
                tans_color = Color.Yellow;
                break;

            case LogMessage.Type.Error:
                tans_color = Color.Red;
                break;

            default:
                break;
            }

            // 印出至 RichTextBox
            if (Log != "")
            {
                Invoke(UpdateLogwColor, new Object[] { Log, true, tans_color });
            }
        }