Files
Artemis/src/Artemis.UI/Converters/InverseBooleanConverter.cs
T
SpoinkyNL df1b4cf6ef Profile editor - Fixed new profile elements not always appearing
UI - Fixed all the memory leaks I could find, closing the UI now frees a lot of RAM
Noise brush - Decreased memory usage by removing unused 4D noise
Layout editor - Fixed device properties not always applying
2020-07-29 00:29:05 +02:00

34 lines
1.0 KiB
C#

using System;
using System.Globalization;
using System.Windows.Data;
namespace Artemis.UI.Converters
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(bool))
return !(bool) value;
if (targetType == typeof(bool?))
return !(bool?) value;
throw new InvalidOperationException("The target must be a boolean");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(bool))
return !(bool) value;
if (targetType == typeof(bool?))
return !(bool?) value;
throw new InvalidOperationException("The target must be a boolean");
}
#endregion
}
}