添加抽屉状态是打开则不能退出及操作其他菜单

This commit is contained in:
maqiao 2024-07-20 10:52:36 +08:00
parent 948f91212c
commit 465b21a32c
2 changed files with 48 additions and 11 deletions

View File

@ -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;
/// <summary>
/// 冰箱温度
/// </summary>
@ -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();
}

View File

@ -123,6 +123,8 @@
</Grid>
<materialDesign:Snackbar HorizontalAlignment="Center" VerticalAlignment="Center"
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>
</Grid>
</UserControl>