ProgramQueuer/ProgramQueuer/Helpers/ValueConverters.cs

46 lines
1.2 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
namespace ProgramQueuer.Helpers
{
[ValueConversion(typeof(bool), typeof(Visibility))]
public class BoolToVisibililty : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool visible = (bool)value;
if (visible)
return Visibility.Visible;
return Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Visibility visible = (Visibility)value;
if (visible == Visibility.Hidden)
return false;
return true;
}
}
[ValueConversion(typeof(bool), typeof(bool))]
public class InvertBool : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
}
}