Flow.Launcher/Plugins/Flow.Launcher.Plugin.Url/Converters/InverseBoolConverter.cs

26 lines
732 B
C#
Raw Permalink Normal View History

2025-09-05 10:39:31 +00:00
using System;
2025-09-05 10:40:28 +00:00
using System.Globalization;
2025-09-05 10:39:31 +00:00
using System.Windows.Data;
namespace Flow.Launcher.Plugin.Url.Converters;
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBoolConverter : IValueConverter
{
2025-09-05 10:40:28 +00:00
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
2025-09-05 10:39:31 +00:00
{
if (value is not bool)
throw new ArgumentException("value should be boolean", nameof(value));
2025-09-05 10:39:31 +00:00
return !(bool)value;
}
2025-09-05 10:40:28 +00:00
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
2025-09-05 10:39:31 +00:00
{
if (value is not bool)
throw new ArgumentException("value should be boolean", nameof(value));
return !(bool)value;
2025-09-05 10:39:31 +00:00
}
}