using MWS.Library.Enums;
using MWSDomain.Common.CoreLib.Helper;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace MWSDomain.Common.Converts
{
    /// <summary>
    /// 枚举注解转换器
    /// </summary>
    public class EnumConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && value is ContextMenuType context)
            {
                return GetEnumAttrbute.GetDescription(context).ModuleName;
            }
            return string.Empty;
        }

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

    /// <summary>
    /// 枚举显示转换器
    /// </summary>
    public class EnumVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && value is ContextMenuType context)
            {
                if (context.Equals(ContextMenuType.ListMode))
                    return Visibility.Collapsed;
                else
                    return Visibility.Visible;
            }
            return Visibility.Collapsed;
        }

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