mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 03:32:20 +08:00
80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Windows.Data;
|
|
|
|
namespace BililiveRecorder.WPF
|
|
{
|
|
internal class ValueConverterGroup : List<IValueConverter>, IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
internal class EnumToBooleanConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value.Equals(parameter);
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value.Equals(true) ? parameter : Binding.DoNothing;
|
|
}
|
|
}
|
|
|
|
internal class BooleanInverterConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return !(bool)value;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return !(bool)value;
|
|
}
|
|
}
|
|
|
|
internal class RecordStatusConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value[0] is bool IsMonitoring && value[1] is bool IsRecording)
|
|
{
|
|
int i = (IsMonitoring ? 1 : 0) + (IsRecording ? 2 : 0);
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return "闲置中";
|
|
case 1:
|
|
return "监控中";
|
|
case 2:
|
|
case 3:
|
|
return "录制中";
|
|
default:
|
|
return string.Empty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|