using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Threading.Tasks;
using Torch.Server.ViewModels;
using NLog;
using Torch.Collections;
namespace Torch.Server.Views.Converters
{
///
/// A converter to get the index of a ModItemInfo object within a collection of ModItemInfo objects
///
public class ModToListIdConverter : IMultiValueConverter
{
///
/// Converts a ModItemInfo object into its index within a Collection of ModItemInfo objects
///
///
/// Expected to contain a ModItemInfo object at index 0
/// and a Collection of ModItemInfo objects at index 1
///
/// This parameter will be ignored
/// This parameter will be ignored
/// This parameter will be ignored
/// the index of the mod within the provided mod list.
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
//if (targetType != typeof(int))
// throw new NotSupportedException("ModToIdConverter can only convert mods into int values or vise versa!");
var mod = (ModItemInfo) values[0];
var theModList = (MtObservableList) values[1];
return theModList.IndexOf(mod);
}
///
/// It is not supported to reverse this converter
///
///
///
///
///
/// Raises a NotSupportedException
public object[] ConvertBack(object values, Type[] targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException("ModToIdConverter can not convert back!");
}
}
}