mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
61e9b9e5af
## 修复 - `Settings.lps`不存在时启动失败的问题 - 读取模组信息时失败的问题
98 lines
2.7 KiB
C#
98 lines
2.7 KiB
C#
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
|
|
namespace HKW.WPF.Converters;
|
|
|
|
/// <summary>
|
|
/// 全部为布尔值转换器
|
|
/// </summary>
|
|
public class AllIsBoolToVisibilityConverter
|
|
: MultiValueToBoolConverter<AllIsBoolToVisibilityConverter>
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static readonly DependencyProperty BoolOnNullProperty = DependencyProperty.Register(
|
|
nameof(BoolOnNull),
|
|
typeof(bool),
|
|
typeof(AllIsBoolToVisibilityConverter),
|
|
new PropertyMetadata(false)
|
|
);
|
|
|
|
/// <summary>
|
|
/// 目标为空时的指定值
|
|
/// </summary>
|
|
[DefaultValue(false)]
|
|
public bool BoolOnNull
|
|
{
|
|
get => (bool)GetValue(BoolOnNullProperty);
|
|
set => SetValue(BoolOnNullProperty, value);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static readonly DependencyProperty VisibilityOnTrueProperty =
|
|
DependencyProperty.Register(
|
|
nameof(VisibilityOnTrue),
|
|
typeof(Visibility),
|
|
typeof(AllIsBoolToVisibilityConverter),
|
|
new PropertyMetadata(Visibility.Visible)
|
|
);
|
|
|
|
/// <summary>
|
|
/// 目标为空时的指定值
|
|
/// </summary>
|
|
[DefaultValue(Visibility.Visible)]
|
|
public Visibility VisibilityOnTrue
|
|
{
|
|
get => (Visibility)GetValue(TargetBoolValueProperty);
|
|
set => SetValue(TargetBoolValueProperty, value);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static readonly DependencyProperty VisibilityOnFalseProperty =
|
|
DependencyProperty.Register(
|
|
nameof(VisibilityOnFalse),
|
|
typeof(Visibility),
|
|
typeof(AllIsBoolToVisibilityConverter),
|
|
new PropertyMetadata(Visibility.Hidden)
|
|
);
|
|
|
|
/// <summary>
|
|
/// 目标为空时的指定值
|
|
/// </summary>
|
|
[DefaultValue(Visibility.Hidden)]
|
|
public Visibility VisibilityOnFalse
|
|
{
|
|
get => (Visibility)GetValue(TargetBoolValueProperty);
|
|
set => SetValue(TargetBoolValueProperty, 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))
|
|
? VisibilityOnTrue
|
|
: VisibilityOnFalse;
|
|
}
|
|
}
|