添加项目文件。

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.Data;
namespace UIShare.Converters
{
public class BoolArrayConverter : IValueConverter
{
// bool[] -> string
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool[] arr)
return "[" + string.Join(",", arr.Select(b => b.ToString().ToLower())) + "]";
return "";
}
// string -> bool[]
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string s)
{
s = s.Trim('[', ']', ' ');
if (string.IsNullOrWhiteSpace(s)) return Array.Empty<bool>();
var parts = s.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
return parts.Select(p =>
{
if (bool.TryParse(p, out var b)) return b;
if (p == "1") return true;
if (p == "0") return false;
return false;
}).ToArray();
}
return Array.Empty<bool>();
}
}
}