53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace UCalc.Controls
|
|
{
|
|
public class ErrorsToVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
return (((ICollection<string>) value)?.Count ?? 0) == 0 ? Visibility.Collapsed : Visibility.Visible;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter,
|
|
System.Globalization.CultureInfo culture)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
|
|
public class ErrorsToInVisibilityConverter : IValueConverter
|
|
{
|
|
private readonly ErrorsToVisibilityConverter _converter = new ErrorsToVisibilityConverter();
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
var result = _converter.Convert(value, targetType, parameter, culture) as Visibility?;
|
|
return result == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter,
|
|
System.Globalization.CultureInfo culture)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
|
|
|
|
public class ErrorCountToVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
return (int?) value != 0 ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter,
|
|
System.Globalization.CultureInfo culture)
|
|
{
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
} |