UdpLog.cs 761 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using System.Net.NetworkInformation;
  5. using System.Net.Sockets;
  6. using System.Windows;
  7. namespace FastGithub.UI
  8. {
  9. public class UdpLog
  10. {
  11. public DateTime Timestamp { get; set; }
  12. public LogLevel Level { get; set; }
  13. public string Message { get; set; } = string.Empty;
  14. public string SourceContext { get; set; } = string.Empty;
  15. public string Color => this.Level <= LogLevel.Information ? "#333" : "IndianRed";
  16. /// <summary>
  17. /// 复制到剪贴板
  18. /// </summary>
  19. public void SetToClipboard()
  20. {
  21. Clipboard.SetText($"{this.Timestamp:yyyy-MM-dd HH:mm:ss.fff}\r\n{this.Message}");
  22. }
  23. }
  24. }