mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
61e9b9e5af
## 修复 - `Settings.lps`不存在时启动失败的问题 - 读取模组信息时失败的问题
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
|
|
namespace HKW.WPF.Converters;
|
|
|
|
/// <summary>
|
|
/// 全部为布尔值转换器
|
|
/// </summary>
|
|
public class AllIsBoolConverter : MultiValueToBoolConverter<AllIsBoolConverter>
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static readonly DependencyProperty BoolOnNullProperty = DependencyProperty.Register(
|
|
nameof(BoolOnNull),
|
|
typeof(bool),
|
|
typeof(AllIsBoolConverter),
|
|
new PropertyMetadata(false)
|
|
);
|
|
|
|
/// <summary>
|
|
/// 目标为空时的指定值
|
|
/// </summary>
|
|
[DefaultValue(false)]
|
|
public bool BoolOnNull
|
|
{
|
|
get => (bool)GetValue(BoolOnNullProperty);
|
|
set => SetValue(BoolOnNullProperty, value);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="values"></param>
|
|
/// <param name="targetType"></param>
|
|
/// <param name="parameter"></param>
|
|
/// <param name="culture"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public override object Convert(
|
|
object[] values,
|
|
Type targetType,
|
|
object parameter,
|
|
CultureInfo culture
|
|
)
|
|
{
|
|
var boolValue = TargetBoolValue;
|
|
var nullValue = BoolOnNull;
|
|
return values.All(o => HKWUtils.HKWUtils.GetBool(o, boolValue, nullValue));
|
|
}
|
|
}
|