| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- using System.Windows.Media.Imaging;
- using System.Windows.Media;
- using ivf_tl_Entity.Entity.balance;
- using System.Collections;
- namespace ivf_tl_Manage.Converts
- {
- public class AddDishOnlyVipConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- var type = parameter.ToString();
- if (value != null && value.ToString() == "1")
- {
- switch (type)
- {
- case "Background":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
- case "PassWord":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
- }
- }
- switch (type)
- {
- case "Background":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishBackgroundIcon.png", UriKind.Absolute));
- case "PassWord":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
- }
- return null;
- }
- catch (Exception)
- {
- return null;
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class AddDishEmbryoListConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- var type = parameter.ToString();
- if (value != null && value is List<Embryo> embryoList )
- {
- switch (type)
- {
- case "Background":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishVipBackgroundIcon.png", UriKind.Absolute));
- }
- }
- switch (type)
- {
- case "Background":
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/AddDishBackgroundIcon.png", UriKind.Absolute));
- }
- return null;
- }
- catch (Exception)
- {
- return null;
- }
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class CompositeCollectionConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- var compositeCollection = new CompositeCollection();
- foreach (var value in values)
- {
- if (value is IEnumerable enumerable)
- {
- compositeCollection.Add(new CollectionContainer { Collection = enumerable });
- }
- else
- {
- compositeCollection.Add(value);
- }
- }
- return compositeCollection;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException("CompositeCollectionConverter ony supports oneway bindings");
- }
- }
- }
|