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

namespace QC.QTMApplication;

public class BoolToVisibilityConverter : IValueConverter
{
	public bool InvertVisibility { get; set; }

	public object Convert(object converterValue, Type converterTargetType, object converterParameter, CultureInfo cultureInfo)
	{
		try
		{
			bool flag = System.Convert.ToBoolean(converterValue, cultureInfo);
			if (converterParameter != null && System.Convert.ToBoolean(converterParameter, cultureInfo))
			{
				flag = !flag;
			}
			if (InvertVisibility)
			{
				flag = !flag;
			}
			if (flag)
			{
				return Visibility.Visible;
			}
			return Visibility.Collapsed;
		}
		catch
		{
			throw new InvalidOperationException("Error converting bool to visible");
		}
	}

	public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
	{
		return (!(bool)value) ? Visibility.Collapsed : Visibility.Visible;
	}
}
