From 465b21a32c4875d3bb2f3199c405ab6a6baced52 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Sat, 20 Jul 2024 10:52:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=BD=E5=B1=89=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=98=AF=E6=89=93=E5=BC=80=E5=88=99=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E9=80=80=E5=87=BA=E5=8F=8A=E6=93=8D=E4=BD=9C=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/ViewModels/HomeWindowViewModel.cs | 55 +++++++++++++++++---- DM_Weight/Views/HomeWindow.xaml | 4 +- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index 2d7c0ac..cf9b75c 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -24,6 +24,8 @@ using Newtonsoft.Json.Linq; using DM_Weight.msg; using DM_Weight.HIKVISION; using System.Threading; +using MaterialDesignThemes.Wpf; +using System.Windows.Media; namespace DM_Weight.ViewModels { @@ -34,8 +36,8 @@ namespace DM_Weight.ViewModels private readonly IDialogService _dialogService; private UserList? _userList; private UserList? _userList2; - - + + /// /// 冰箱温度 /// @@ -50,6 +52,21 @@ namespace DM_Weight.ViewModels get => loginMode == 2; } + private SolidColorBrush _colorBrush; + + public SolidColorBrush SnackbarBackground + { + get => _colorBrush; + set => SetProperty(ref _colorBrush, value); + } + private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3)); + + public ISnackbarMessageQueue SnackbarMessageQueue + { + get => _snackbarMessageQueue; + set => SetProperty(ref _snackbarMessageQueue, value); + } + private PremissionDm? _selectedMenu; private PremissionDm? _selectedChildMenu; @@ -153,7 +170,16 @@ namespace DM_Weight.ViewModels // SelectedChildMenu = value.Children[0]; // } //} - SetProperty(ref _selectedMenu, value); + if (!_portUtil.Operate) + { + SetProperty(ref _selectedMenu, value); + } + else + { + logger.Info($"未关闭抽屉切换菜单"); + SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); + SnackbarMessageQueue.Enqueue("请关闭抽屉后再切换菜单"); + } } } @@ -167,12 +193,21 @@ namespace DM_Weight.ViewModels SelectedMenu = viewName.SelectedItem as PremissionDm; if (SelectedMenu.PremissionName == "退出") { - - _chkFunction.HIKStopDVRRecord(); - logger.Info($"用户【{Operator?.Nickname}】退出登录"); - Operator = null; - Reviewer = null; - _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + if (!_portUtil.Operate) + { + _chkFunction.HIKStopDVRRecord(); + logger.Info($"用户【{Operator?.Nickname}】退出登录"); + Operator = null; + Reviewer = null; + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + } + else + { + logger.Info($"未关闭抽屉操作退出"); + SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c")); + SnackbarMessageQueue.Enqueue("请关闭抽屉后再退出"); + return; + } } else { @@ -353,7 +388,7 @@ namespace DM_Weight.ViewModels { //指定时间内无人操作鼠标键盘则停止录像 - if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord) + if (!_portUtil.Operate && CheckComputerFreeState.GetLastInputTime() > stopRecord) { _chkFunction.HIKStopDVRRecord(); } diff --git a/DM_Weight/Views/HomeWindow.xaml b/DM_Weight/Views/HomeWindow.xaml index 90ef497..406f271 100644 --- a/DM_Weight/Views/HomeWindow.xaml +++ b/DM_Weight/Views/HomeWindow.xaml @@ -123,6 +123,8 @@ - +