BooleanToBitmapImageConvert.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. using System.Windows.Media.Imaging;
  9. namespace ivf_tl_Manage.Converts
  10. {
  11. public class BooleanToBitmapImageConvert : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. try
  16. {
  17. var type = parameter.ToString();
  18. bool s = (bool)value;
  19. if (s)
  20. {
  21. switch (type)
  22. {
  23. case "PassWord":
  24. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EditPassWordMouseOverIcon.png", UriKind.Absolute));
  25. }
  26. }
  27. switch (type)
  28. {
  29. case "PassWord":
  30. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EditPassWordIcon.png", UriKind.Absolute));
  31. }
  32. return null;
  33. }
  34. catch (Exception)
  35. {
  36. return null;
  37. }
  38. }
  39. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  40. {
  41. throw new NotImplementedException();
  42. }
  43. }
  44. }