2024-09-20 10:50:32 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
namespace Serein.Workbench.Tool.Converters
|
2024-09-20 10:50:32 +08:00
|
|
|
|
{
|
2024-10-14 17:29:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据bool类型控制可见性
|
|
|
|
|
|
/// </summary>
|
2024-09-20 10:50:32 +08:00
|
|
|
|
[ValueConversion(typeof(bool), typeof(Visibility))]
|
|
|
|
|
|
public class InvertableBooleanToVisibilityConverter : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
enum Parameters
|
|
|
|
|
|
{
|
|
|
|
|
|
Normal, Inverted
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType,
|
|
|
|
|
|
object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
var boolValue = (bool)value;
|
|
|
|
|
|
var direction = (Parameters)Enum.Parse(typeof(Parameters), (string)parameter);
|
|
|
|
|
|
|
|
|
|
|
|
if (direction == Parameters.Inverted)
|
|
|
|
|
|
return !boolValue ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
|
|
|
|
|
|
|
|
return boolValue ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-30 22:20:02 +08:00
|
|
|
|
public object? ConvertBack(object value, Type targetType,
|
2024-09-20 10:50:32 +08:00
|
|
|
|
object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|