Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MessageLogNotify.cs 1.8 KiB

pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
pirms 2 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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, Brush> Info { get; set; }
  14. /// <summary>
  15. /// 常规日志显示
  16. /// </summary>
  17. /// <param name="info">日志消息</param>
  18. /// <param name="brush">日志显示颜色</param>
  19. public void Show(string info, Brush brush = null)
  20. {
  21. Info?.Invoke($"消息:{info}", brush == null ? Brushes.Green : brush);
  22. }
  23. /// <summary>
  24. /// 应用程序异常日志显示
  25. /// </summary>
  26. /// <param name="info">日志信息</param>
  27. /// <param name="brush">日志显示颜色</param>
  28. public void ShowEx(string info, Brush brush = null)
  29. {
  30. Info?.Invoke($"异常:{info}", brush == null ? Brushes.Red : brush);
  31. }
  32. /// <summary>
  33. /// 错误日志显示
  34. /// </summary>
  35. /// <param name="info">日志信息</param>
  36. /// <param name="brush">日志显示颜色</param>
  37. public void ShowError(string info, Brush brush = null)
  38. {
  39. Info?.Invoke($"错误:{info}", brush == null ? Brushes.Red : brush);
  40. }
  41. /// <summary>
  42. /// 警告日志显示
  43. /// </summary>
  44. /// <param name="info">日志信息</param>
  45. /// <param name="brush">日志显示颜色</param>
  46. public void ShowWarning(string info, Brush brush = null)
  47. {
  48. Info?.Invoke($"警告:{info}", brush == null ? Brushes.Olive : brush);
  49. }
  50. }
  51. }