AddDishWindowConvert.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. using System.Windows.Media;
  10. using ivf_tl_Entity.Entity.balance;
  11. using System.Collections;
  12. namespace ivf_tl_Manage.Converts
  13. {
  14. public class AddDishOnlyVipConvert : IValueConverter
  15. {
  16. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  17. {
  18. try
  19. {
  20. var type = parameter.ToString();
  21. if (value != null && value.ToString() == "1")
  22. {
  23. switch (type)
  24. {
  25. case "Background":
  26. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
  27. case "PassWord":
  28. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
  29. }
  30. }
  31. switch (type)
  32. {
  33. case "Background":
  34. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishBackgroundIcon.png", UriKind.Absolute));
  35. case "PassWord":
  36. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
  37. }
  38. return null;
  39. }
  40. catch (Exception)
  41. {
  42. return null;
  43. }
  44. }
  45. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  46. {
  47. throw new NotImplementedException();
  48. }
  49. }
  50. public class AddDishEmbryoListConvert : IValueConverter
  51. {
  52. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  53. {
  54. try
  55. {
  56. var type = parameter.ToString();
  57. if (value != null && value is List<Embryo> embryoList )
  58. {
  59. switch (type)
  60. {
  61. case "Background":
  62. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
  63. }
  64. }
  65. switch (type)
  66. {
  67. case "Background":
  68. return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishBackgroundIcon.png", UriKind.Absolute));
  69. }
  70. return null;
  71. }
  72. catch (Exception)
  73. {
  74. return null;
  75. }
  76. }
  77. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  78. {
  79. throw new NotImplementedException();
  80. }
  81. }
  82. public class CompositeCollectionConverter : IMultiValueConverter
  83. {
  84. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  85. {
  86. var compositeCollection = new CompositeCollection();
  87. foreach (var value in values)
  88. {
  89. if (value is IEnumerable enumerable)
  90. {
  91. compositeCollection.Add(new CollectionContainer { Collection = enumerable });
  92. }
  93. else
  94. {
  95. compositeCollection.Add(value);
  96. }
  97. }
  98. return compositeCollection;
  99. }
  100. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  101. {
  102. throw new NotSupportedException("CompositeCollectionConverter ony supports oneway bindings");
  103. }
  104. }
  105. }