Files
EngineeringSync/EngineeringSync.TrayApp/Converters/Converters.cs

33 lines
1.5 KiB
C#
Raw Normal View History

using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace EngineeringSync.TrayApp.Converters;
/// <summary>Gibt "Neues Projekt" oder "Projekt bearbeiten" zurück.</summary>
public class NewEditHeaderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value is true ? "Neues Projekt anlegen" : "Projekt bearbeiten";
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}
/// <summary>Gibt Visibility.Visible zurück wenn der String nicht leer ist.</summary>
public class StringToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}
/// <summary>Invertiert Boolean für Visibility (true = Collapsed, false = Visible).</summary>
public class InverseBoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value is true ? Visibility.Collapsed : Visibility.Visible;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}