LatencyToTextConverter.cs 906 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. namespace ClashDotNetFramework.Models.Converters
  9. {
  10. public class LatencyToTextConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. long latency = (long)value;
  15. switch (latency)
  16. {
  17. case 0:
  18. case -1:
  19. return "Timeout";
  20. case -2:
  21. return "Check";
  22. default:
  23. return $"{latency} ms";
  24. }
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }