增加摄像头中控台项目
This commit is contained in:
107
SHH.CameraDashboard/MainWindow.xaml.cs
Normal file
107
SHH.CameraDashboard/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace SHH.CameraDashboard
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private bool _isDarkTheme = true;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 1. 【日志联动】HttpService -> 底部报警栏 (精准匹配你提供的逻辑)
|
||||
// 确保你的 ApiLogEntry 字段已根据我之前的建议对齐
|
||||
HttpService.OnApiLog += (log) =>
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
BottomDock.PushLog(log);
|
||||
});
|
||||
};
|
||||
|
||||
// 2. 【设备联动】侧边栏选中 -> 设备首页详情
|
||||
Sidebar.OnDeviceSelected += (device) =>
|
||||
{
|
||||
// 更新右侧 主视图
|
||||
DeviceHome.UpdateDevice(device);
|
||||
|
||||
// 联动:向诊断日志推送一条“选中设备”的虚拟日志(可选)
|
||||
BottomDock.LatestLogText.Text = $"当前选中设备: {device.DisplayName} ({device.IpAddress})";
|
||||
|
||||
// 如果右侧配置面板开着,最好关掉它
|
||||
RightConfigPanel.Visibility = Visibility.Collapsed;
|
||||
};
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 1. 窗口基础操作 (拖拽/最小化/关闭)
|
||||
// ============================
|
||||
private void OnTitleBarMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
this.DragMove();
|
||||
}
|
||||
|
||||
private void OnMinimize(object sender, RoutedEventArgs e) => this.WindowState = WindowState.Minimized;
|
||||
private void OnClose(object sender, RoutedEventArgs e) => this.Close();
|
||||
|
||||
// ============================
|
||||
// 2. 界面交互逻辑
|
||||
// ============================
|
||||
|
||||
// 切换侧边栏展开/收起
|
||||
private void ToggleSidebar(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Sidebar.Width > 0)
|
||||
Sidebar.Width = 0;
|
||||
else
|
||||
Sidebar.Width = 250;
|
||||
}
|
||||
|
||||
// 切换主题 (使用你定义的 ThemeManager)
|
||||
private void ToggleTheme(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isDarkTheme = !_isDarkTheme;
|
||||
// 确保 ThemeManager.ChangeTheme 逻辑未变动
|
||||
ThemeManager.ChangeTheme(_isDarkTheme ? ThemeType.Dark : ThemeType.Light);
|
||||
}
|
||||
|
||||
// 打开/关闭右侧配置面板
|
||||
private void OpenRightPanel(object sender, RoutedEventArgs e) => RightConfigPanel.Visibility = Visibility.Visible;
|
||||
private void CloseRightPanel(object sender, RoutedEventArgs e) => RightConfigPanel.Visibility = Visibility.Collapsed;
|
||||
|
||||
// ============================
|
||||
// 3. 向导模态框逻辑 (完整保留)
|
||||
// ============================
|
||||
private void OpenWizard(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var wizard = new WizardControl();
|
||||
|
||||
// 当向导请求关闭时
|
||||
wizard.RequestClose += (s, args) =>
|
||||
{
|
||||
CloseModal();
|
||||
// 关键:向导可能修改了全局服务器列表,通知侧边栏刷新
|
||||
Sidebar.ReloadServers();
|
||||
};
|
||||
|
||||
ModalContainer.Content = wizard;
|
||||
ModalLayer.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void CloseModal_Click(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// 点击遮罩层背景关闭
|
||||
CloseModal();
|
||||
}
|
||||
|
||||
private void CloseModal()
|
||||
{
|
||||
ModalLayer.Visibility = Visibility.Collapsed;
|
||||
ModalContainer.Content = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user