增加摄像头中控台项目
This commit is contained in:
64
SHH.CameraDashboard/Controls/BottomDockControl.xaml.cs
Normal file
64
SHH.CameraDashboard/Controls/BottomDockControl.xaml.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SHH.CameraDashboard
|
||||
{
|
||||
public partial class BottomDockControl : UserControl
|
||||
{
|
||||
private bool _isExpanded = false;
|
||||
|
||||
public BottomDockControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 核心修正:这里必须使用 WebApiDiag,因为它对应你 XAML 里的 x:Name
|
||||
if (this.WebApiDiag != null)
|
||||
{
|
||||
// 订阅 DiagnosticControl 抛出的关闭事件
|
||||
this.WebApiDiag.RequestCollapse += (s, e) =>
|
||||
{
|
||||
// 当子页面点击“关闭”按钮时,执行收回面板的方法
|
||||
HideExpandedPanel();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 逻辑:隐藏上方的大面板
|
||||
private void HideExpandedPanel()
|
||||
{
|
||||
ExpandedPanel.Visibility = Visibility.Collapsed;
|
||||
ArrowIcon.Text = "▲"; // 箭头恢复向上
|
||||
}
|
||||
|
||||
// 接收全局日志,分发给内部控件,并更新状态栏摘要
|
||||
public void PushLog(ApiLogEntry log)
|
||||
{
|
||||
// 1. 推送给内部的诊断控件 (详细列表)
|
||||
WebApiDiag.PushLog(log);
|
||||
|
||||
// 2. 更新底部状态栏 (摘要)
|
||||
string statusIcon = log.IsSuccess ? "✅" : "❌";
|
||||
LatestLogText.Text = $"{statusIcon} [{log.Time:HH:mm:ss}] {log.Method} {log.Url} ({log.StatusCode})";
|
||||
LatencyText.Text = $"{log.DurationMs}ms";
|
||||
|
||||
// 如果失败,可以将状态栏背景变红一下(可选)
|
||||
if (!log.IsSuccess)
|
||||
{
|
||||
// 这里简单处理,如果想要复杂的动画可以使用 Storyboard
|
||||
LatestLogText.Foreground = new SolidColorBrush(Colors.Yellow);
|
||||
}
|
||||
else
|
||||
{
|
||||
LatestLogText.Foreground = Brushes.White;
|
||||
}
|
||||
}
|
||||
|
||||
private void TogglePanel_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
_isExpanded = !_isExpanded;
|
||||
ExpandedPanel.Visibility = _isExpanded ? Visibility.Visible : Visibility.Collapsed;
|
||||
ArrowIcon.Text = _isExpanded ? "▼" : "▲";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user