| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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;
- namespace ivf_tl_Operate.Converts
- {
- public class PicImageSourceConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- try
- {
- if (values.Count() != 2)
- {
- if (parameter.ToString() == "1")
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/LastEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- else
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/NextEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- }
- var a = values[0];
- var b = values[1];
- if (a == null || b == null)
- {
- if (parameter.ToString() == "1")
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/LastEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- else
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/NextEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- }
- int currentNum = int.Parse(a.ToString());
- int allNum = int.Parse(b.ToString());
- if (parameter.ToString() == "1")
- {
- if (currentNum > 0)
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/LastEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- else
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/LastEmbryoDiscard.png", UriKind.RelativeOrAbsolute));
- }
- }
- else
- {
- if (currentNum < (allNum - 1))
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/NextEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- else
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/NextEmbryoDiscard.png", UriKind.RelativeOrAbsolute));
- }
- }
- }
- catch (Exception)
- {
- if (parameter.ToString() == "1")
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/LastEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- else
- {
- return new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/NextEmbryoUsable.png", UriKind.RelativeOrAbsolute));
- }
- }
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|