增加摄像头中控台项目
This commit is contained in:
52
SHH.CameraDashboard/Controls/DeviceHomeControl.xaml.cs
Normal file
52
SHH.CameraDashboard/Controls/DeviceHomeControl.xaml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SHH.CameraDashboard
|
||||
{
|
||||
public partial class DeviceHomeControl : UserControl
|
||||
{
|
||||
private CameraInfo _currentDevice;
|
||||
|
||||
public DeviceHomeControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// 供外部调用,切换显示的设备
|
||||
public void UpdateDevice(CameraInfo device)
|
||||
{
|
||||
_currentDevice = device;
|
||||
|
||||
if (device == null)
|
||||
{
|
||||
EmptyView.Visibility = Visibility.Visible;
|
||||
DetailView.Visibility = Visibility.Collapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
// 切换到详情视图
|
||||
EmptyView.Visibility = Visibility.Collapsed;
|
||||
DetailView.Visibility = Visibility.Visible;
|
||||
|
||||
// 绑定数据到界面控件
|
||||
TxtName.Text = device.DisplayName;
|
||||
TxtIp.Text = device.IpAddress;
|
||||
TxtStreamUrl.Text = $"rtsp://{device.IpAddress}:554/live/main";
|
||||
|
||||
// 根据状态切换颜色和文字
|
||||
if (device.Status == "Playing" || device.Status == "Connected")
|
||||
{
|
||||
TxtStatus.Text = "在线运行";
|
||||
TxtStatus.Foreground = new SolidColorBrush(Color.FromRgb(78, 201, 176)); // Green
|
||||
BadgeStatus.Background = new SolidColorBrush(Color.FromArgb(30, 78, 201, 176));
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtStatus.Text = "离线/断开";
|
||||
TxtStatus.Foreground = new SolidColorBrush(Color.FromRgb(244, 71, 71)); // Red
|
||||
BadgeStatus.Background = new SolidColorBrush(Color.FromArgb(30, 244, 71, 71));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user