Files
Ayay/SHH.CameraDashboard/Converters/SubscriptionTypeConverter.cs

34 lines
1.1 KiB
C#
Raw Normal View History

2026-01-01 22:40:32 +08:00
using System.Globalization;
using System.Windows.Data;
namespace SHH.CameraDashboard
{
/// <summary>
/// 将订阅类型的 int 值 (0,1,2...) 转换为中文描述
/// </summary>
public class SubscriptionTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int typeId)
{
return typeId switch
{
0 => "🖥️ 本地窗口预览",
1 => "📼 本地录像存储",
2 => "🪟 句柄绑定显示",
3 => "📡 网络转发传输",
4 => "🌐 网页端推流",
_ => $"未知类型 ({typeId})"
};
}
// 如果后端传回的是字符串枚举 (兼容性),也可以尝试转换
return value?.ToString() ?? "未知";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}