具备界面基础功能
This commit is contained in:
29
SHH.CameraDashboard/Converters/BoolToMaxScaleConverter.cs
Normal file
29
SHH.CameraDashboard/Converters/BoolToMaxScaleConverter.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace SHH.CameraDashboard;
|
||||
|
||||
/// <summary>
|
||||
/// 布尔值转最大缩放比例转换器
|
||||
/// </summary>
|
||||
public class BoolToMaxScaleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 如果 AllowExpand (value) 为 true
|
||||
if (value is bool allow && allow)
|
||||
{
|
||||
// 允许放大:最大支持 200% (即放大 2 倍)
|
||||
// 你也可以改成 300 或根据业务需求调整
|
||||
return 200.0;
|
||||
}
|
||||
|
||||
// 不允许放大:最大限制在 100% (原图大小)
|
||||
return 100.0;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace SHH.CameraDashboard;
|
||||
|
||||
// 2. 对象为空时显示,不为空时隐藏 (用于显示提示文字)
|
||||
public class InverseNullToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value == null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
19
SHH.CameraDashboard/Converters/NullToVisibilityConverter.cs
Normal file
19
SHH.CameraDashboard/Converters/NullToVisibilityConverter.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace SHH.CameraDashboard;
|
||||
|
||||
// 1. 对象为空时隐藏,不为空时显示
|
||||
public class NullToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value == null ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
34
SHH.CameraDashboard/Converters/SubscriptionTypeConverter.cs
Normal file
34
SHH.CameraDashboard/Converters/SubscriptionTypeConverter.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user