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 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"); } } }