using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace MWS.Domain.Common.Converts
{
    public class BoolToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!bool.TryParse(value.ToString(), out bool isTrue))
            {
                return Visibility.Collapsed;
            }

            if (isTrue)
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Collapsed;
            }
        }

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