using SWRIS.Enums;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace SWRIS.Converters
{
    public class ModuleTypeToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && (ModuleType)value is ModuleType moduleType)
            {
                parameter = parameter ?? "Tcp";
                if (moduleType == ModuleType.ModbusRtu)
                {
                    return parameter.ToString() == "Serial" ? Visibility.Visible : Visibility.Collapsed;
                }
                else
                {
                    return parameter.ToString() == "Tcp" ? Visibility.Visible : Visibility.Collapsed;
                }
            }
            return Visibility.Collapsed;
        }

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