You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 line
1.9 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace HKCardManager
  7. {
  8. public class MessageLogNotify
  9. {
  10. private volatile static MessageLogNotify _Instance;
  11. public static MessageLogNotify GetInstance => _Instance ?? (_Instance = new MessageLogNotify());
  12. private MessageLogNotify() { }
  13. public Action<string, Color> Info { get; set; }
  14. /// <summary>
  15. /// 常规日志显示
  16. /// </summary>
  17. /// <param name="info">日志消息</param>
  18. /// <param name="brush">日志显示颜色</param>
  19. public void Show(string info, Color brush = default)
  20. {
  21. Info?.Invoke($"消息:{info}", brush == default ? Color.Green : brush);
  22. }
  23. /// <summary>
  24. /// 应用程序异常日志显示
  25. /// </summary>
  26. /// <param name="info">日志信息</param>
  27. /// <param name="brush">日志显示颜色</param>
  28. public void ShowEx(string info, Color brush = default)
  29. {
  30. Info?.Invoke($"异常:{info}", brush == default ? Color.Red : brush);
  31. }
  32. /// <summary>
  33. /// 错误日志显示
  34. /// </summary>
  35. /// <param name="info">日志信息</param>
  36. /// <param name="brush">日志显示颜色</param>
  37. public void ShowError(string info, Color brush = default)
  38. {
  39. Info?.Invoke($"错误:{info}", brush == default ? Color.Red : brush);
  40. }
  41. /// <summary>
  42. /// 警告日志显示
  43. /// </summary>
  44. /// <param name="info">日志信息</param>
  45. /// <param name="brush">日志显示颜色</param>
  46. public void ShowWarning(string info, Color brush = default)
  47. {
  48. Info?.Invoke($"警告:{info}", brush == default ? Color.Olive : brush);
  49. }
  50. }
  51. }