添加项目文件。

This commit is contained in:
czj
2026-06-05 10:57:09 +08:00
parent f29671b374
commit d960cb5912
166 changed files with 15996 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace UIShare.Converters
{
public class BooleanToVisibilityConverter : IValueConverter
{
// 同时接受 "invert" / "inverse" / "inverted" / "reverse"(大小写不敏感)作为反转参数,
// 避免因 XAML 处用了 ConverterParameter=Inverse 而静默失效。
private static bool IsInvert(object parameter)
{
var s = parameter?.ToString()?.ToLowerInvariant();
return s == "invert" || s == "inverse" || s == "inverted" || s == "reverse";
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool input = value is bool b && b;
if (IsInvert(parameter))
input = !input;
return input ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
bool output = value is Visibility v && v == Visibility.Visible;
if (IsInvert(parameter))
output = !output;
return output;
}
}
}