2018-03-29 11:39:44 +08:00
|
|
|
|
using System;
|
2018-11-07 07:14:00 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-25 15:14:27 +08:00
|
|
|
|
using System.Globalization;
|
2018-11-07 07:14:00 +08:00
|
|
|
|
using System.Linq;
|
2018-03-25 15:14:27 +08:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
|
|
|
namespace BililiveRecorder.WPF
|
|
|
|
|
{
|
2018-11-07 07:14:00 +08:00
|
|
|
|
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
|
2018-03-29 11:39:44 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 07:14:00 +08:00
|
|
|
|
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
|
2018-03-25 15:14:27 +08:00
|
|
|
|
{
|
2018-03-26 04:46:24 +08:00
|
|
|
|
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
|
2018-03-25 15:14:27 +08:00
|
|
|
|
{
|
2018-03-26 04:46:24 +08:00
|
|
|
|
if (value[0] is bool IsMonitoring && value[1] is bool IsRecording)
|
2018-03-25 15:14:27 +08:00
|
|
|
|
{
|
2018-03-26 04:46:24 +08:00
|
|
|
|
int i = (IsMonitoring ? 1 : 0) + (IsRecording ? 2 : 0);
|
2018-03-25 15:14:27 +08:00
|
|
|
|
switch (i)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
return "闲置中";
|
|
|
|
|
case 1:
|
|
|
|
|
return "监控中";
|
|
|
|
|
case 2:
|
|
|
|
|
case 3:
|
|
|
|
|
return "录制中";
|
|
|
|
|
default:
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-26 04:46:24 +08:00
|
|
|
|
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
2018-03-25 15:14:27 +08:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-22 00:43:29 +08:00
|
|
|
|
|
|
|
|
|
internal class BoolToValueConverter<T> : IValueConverter
|
|
|
|
|
{
|
|
|
|
|
public T FalseValue { get; set; }
|
|
|
|
|
public T TrueValue { get; set; }
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class BoolToStringConverter : BoolToValueConverter<string> { }
|
|
|
|
|
|
2018-03-25 15:14:27 +08:00
|
|
|
|
}
|