public void Message(MsgKind kind, Location?source, string message) { if (WarningsAreErrors && (kind == MsgKind.WARNING)) { kind = MsgKind.ERROR; } HasErrored |= (kind == MsgKind.ERROR); if (!IgnoredKinds.Contains(kind)) { if (KIND_DISPLAY_DICT.TryGetValue(kind, out LogDisplayConfig config)) { if (!NoColoredTags && config.tagColor.HasValue) { Console.ForegroundColor = config.tagColor.Value; } Output.Write("{0}: ", config.tag); if (!NoColoredTags) { Console.ResetColor(); } if (source.HasValue) { Output.Write("{0}:{1}:{2}: ", source.Value.file, source.Value.lineNum, source.Value.colNum); } Output.WriteLine(message); } } }
/// <summary>Format error messages for the task list</summary> private string GetFormattedErrorMessage( string fileName, int line, int column, MsgKind kind, string errorNumber, string errorText) { string errorCode = ""; switch (kind) { case MsgKind.Error: errorCode = this.ErrorString; break; case MsgKind.Warning: errorCode = this.WarningString; break; default: errorCode = ""; break; } var message = new StringBuilder(); if (!string.IsNullOrEmpty(fileName)) { message.AppendFormat(CultureInfo.CurrentCulture, "{0}({1},{2}):", fileName, line, column); } message.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}: {2}", errorCode, errorNumber, errorText); message.AppendLine(); return(message.ToString()); }
} //�f�t�H���g�R���X�g���N�^�̉B�� static public DialogResult Show(MsgKind msgKind, string msg) { var buttons = MessageBoxButtons.OK; var icon = MessageBoxIcon.Error; switch (msgKind) { case MsgKind.Stop: buttons = MessageBoxButtons.RetryCancel; break; case MsgKind.Question: buttons = MessageBoxButtons.OKCancel; icon = MessageBoxIcon.Question; break; case MsgKind.Infomation: icon = MessageBoxIcon.Information; break; case MsgKind.Warning: icon = MessageBoxIcon.Warning; break; } return(MessageBox.Show(msg, Application.ProductName, buttons, icon)); }
/// <summary> /// 弹出指定消息框 /// </summary> /// <param name="kind">消息框种类</param> /// <param name="icon">显示大图标</param> /// <param name="caption">消息大标题</param> /// <param name="title">消息小标题</param> /// <param name="content">消息内容</param> /// <returns></returns> public static DialogResult Show(MsgKind kind, IconNum icon, string caption, string content, Size size) { FrmMsg fm = new FrmMsg(content.Length); fm.Size = size; fm.msgkind = kind; fm.Message = content; fm.Caption = caption; fm.iconNum = icon; return(fm.ShowDialog()); }
/// <summary> /// 弹出指定消息框 /// </summary> /// <param name="kind">消息框种类</param> /// <param name="icon">显示大图标</param> /// <param name="caption">消息大标题</param> /// <param name="title">消息小标题</param> /// <param name="content">消息内容</param> /// <returns></returns> public static DialogResult Show(MsgKind kind, IconNum icon, string caption, string content) { Form wnd = (Form)AppDomain.CurrentDomain.GetData("MainWindow"); return((DialogResult)wnd.Invoke(new Func <DialogResult>(delegate() { FrmMsg fm = new FrmMsg(content.Length); fm.msgkind = kind; fm.Message = content; fm.Caption = caption; fm.iconNum = icon; return fm.ShowDialog(); }))); }
/// <summary> /// Adds the necessary newlines and direction indicators /// </summary> /// <param name="isIncoming">Direction of logged data</param> protected void PrepareFor(MsgKind msgKind, bool isIncoming) { bool direction = (msgKind == MsgKind.Formatted) || (msgKind == MsgKind.Data && (isIncoming != LastIsIncoming || LastMsgKind != MsgKind.Data)); bool newline = (ShowTime != TimeFormat.None || (msgKind == MsgKind.Data && (isIncoming != LastIsIncoming || LastMsgKind != MsgKind.Data)) || (msgKind == MsgKind.Text) || (msgKind == MsgKind.Formatted)) && (Window.LinesCount > 1 || Window.Text.Length > 0); // lines count is much faster to check, but invalid first time var msg = new StringBuilder(); if (newline) { msg.AppendLine(); } if (ShowTime == TimeFormat.ProgramTime) { msg.AppendFormat("{0}:{1:D2}:{2:D2}.{3:D3} ", (int)_sw.Elapsed.TotalHours, _sw.Elapsed.Minutes, _sw.Elapsed.Seconds, (int)_sw.Elapsed.Milliseconds); } else if (ShowTime == TimeFormat.LocalTime) { var now = DateTime.Now.TimeOfDay; msg.AppendFormat("[{0}] ", now.ToString()); } if (direction) { msg.Append(" "); msg.Append(isIncoming ? "<<" : ">>"); msg.Append(" "); } TextStyle style = isIncoming ? IncomingStyle : OutGoingStyle; LogRaw(msg.ToString(), style, false); LastIsIncoming = isIncoming; LastMsgKind = msgKind; }
public static DialogResult Show(MsgKind msgKind, string msg) { var buttons = MessageBoxButtons.OK; var icon = MessageBoxIcon.Error; switch (msgKind) { case MsgKind.Stop: buttons = MessageBoxButtons.RetryCancel; break; case MsgKind.Question: buttons = MessageBoxButtons.OKCancel; icon = MessageBoxIcon.Question; break; case MsgKind.Infomation: icon = MessageBoxIcon.Information; break; case MsgKind.Warning: icon = MessageBoxIcon.Warning; break; } return MessageBox.Show(msg, Application.ProductName, buttons, icon); }
/// <summary>Format error messages for the task list</summary> private string GetFormattedErrorMessage( string fileName, int line, int column, MsgKind kind, string errorNumber, string errorText) { string errorCode = ""; switch (kind) { case MsgKind.Error: errorCode = this.ErrorString; break; case MsgKind.Warning: errorCode = this.WarningString; break; default: errorCode = ""; break; } var message = new StringBuilder(); if (!string.IsNullOrEmpty(fileName)) message.AppendFormat(CultureInfo.CurrentCulture, "{0}({1},{2}):", fileName, line, column); message.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}: {2}", errorCode, errorNumber, errorText); message.AppendLine(); return message.ToString(); }
public void Message(MsgKind kind, string message) { Message(kind, null, message); }
public static DialogResult Show(MsgKind kind, string caption, string content, Size size) { return(Show(kind, IconNum.note, caption, content, size)); }
/// <summary> /// 弹出消息 /// </summary> /// <param name="kind">消息框种类</param> /// <param name="caption">消息大标题</param> /// <param name="title">消息小标题</param> /// <param name="content">消息内容</param> /// <returns></returns> public static DialogResult Show(MsgKind kind, string caption, string title, string content) { return(Show(kind, IconNum.note, caption, content)); }