mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-26 20:26:00 +08:00
6df6b96b2a
添加直播状态图标 添加复制主播名、房间号的右键菜单 调整高级设置 Cookie Textbox
34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace BililiveRecorder.WPF.Converters
|
|
{
|
|
internal class BoolToValueConverter : DependencyObject, IValueConverter
|
|
{
|
|
public static readonly DependencyProperty TrueValueProperty = DependencyProperty.Register(nameof(TrueValue), typeof(object), typeof(BoolToValueConverter), new PropertyMetadata(null));
|
|
public static readonly DependencyProperty FalseValueProperty = DependencyProperty.Register(nameof(FalseValue), typeof(object), typeof(BoolToValueConverter), new PropertyMetadata(null));
|
|
|
|
public object TrueValue { get => GetValue(TrueValueProperty); set => SetValue(TrueValueProperty, value); }
|
|
public object FalseValue { get => GetValue(FalseValueProperty); set => SetValue(FalseValueProperty, value); }
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value == null)
|
|
{
|
|
return FalseValue;
|
|
}
|
|
else
|
|
{
|
|
return (bool)value ? TrueValue : FalseValue;
|
|
}
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value != null ? value.Equals(TrueValue) : false;
|
|
}
|
|
}
|
|
}
|