BoolBurshConverter.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 
  2. namespace HistoryView.Converters;
  3. internal class BoolBurshConverter : IValueConverter
  4. {
  5. object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
  6. {
  7. if (value is not bool b)
  8. return null;
  9. try
  10. {
  11. return b switch
  12. {
  13. true => Application.Current.Resources["NormalColor"],
  14. false => Application.Current.Resources["EmergencyColor"]
  15. };
  16. }
  17. catch
  18. {
  19. return null;
  20. }
  21. }
  22. object? IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  23. {
  24. return null;
  25. }
  26. }
  27. internal class BoolBurshConverter2 : IValueConverter
  28. {
  29. object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
  30. {
  31. if (value is not bool b)
  32. return Application.Current.Resources["LightThemeColor"];
  33. try
  34. {
  35. return b switch
  36. {
  37. true => Application.Current.Resources["LightThemeColor"],
  38. false => Application.Current.Resources["LightEmergencyColor"]
  39. };
  40. }
  41. catch
  42. {
  43. return null;
  44. }
  45. }
  46. object? IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  47. {
  48. return null;
  49. }
  50. }