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 Update.Converters
{
    public class IconConverter : IMultiValueConverter
    {

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string processName = values[0] as string;
            Dictionary<string, BitmapSource> icons = values[1] as Dictionary<string, BitmapSource>;
            if (string.IsNullOrEmpty(processName))
            {
                return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
            }
            if (icons == null)
            {
                return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
            }

            if (!icons.ContainsKey(processName))
            {
                return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
            }
            return icons[processName];
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}