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;
using HBLConsole.Model;

namespace HBLConsole.Converter
{
    public class VisibleConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && parameter != null)
            {
                if (DeviceTypeSort.GetInstance.DevceTypes.ContainsKey(parameter.ToString()))
                {
                    List<string> list = DeviceTypeSort.GetInstance.DevceTypes[parameter.ToString()];
                    if (list != null)
                    {
                        var result = list.FirstOrDefault(p => p == value.ToString() && value?.ToString()?.Length > 0);
                        if (result != null)
                        {
                            return Visibility.Visible;
                        }
                    }
                }
            }
            return Visibility.Collapsed;
        }

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