设备编辑1

This commit is contained in:
hsc
2026-06-12 09:25:40 +08:00
parent a62b6cbc8f
commit ffb22e1f20
3 changed files with 111 additions and 19 deletions

View File

@@ -67,29 +67,44 @@ namespace TestingModule.ViewModels
private ScopedContext _ScopedContext { get; set; }
private readonly SystemConfig _systemConfig;
private readonly GlobalInfo _globalInfo;
private readonly DeviceManager _deviceManager;
#region
public ICommand ParameterAddCommand { get; set; }
public ICommand ParameterEditCommand { get; set; }
public ICommand ParameterDeleteCommand { get; set; }
public ICommand DeviceEditCommand { get; set; }
public ICommand ReconnnectCommand { get; set; }
public ICommand ReConnectCommand { get; set; }
public ICommand CloseCommand { get; set; }
public ICommand LoadedCommand { get; set; }
#endregion
public ParametersManagerViewModel(IContainerProvider containerProvider, ScopedContext scopedContext, SystemConfig systemConfig, GlobalInfo globalInfo) : base(containerProvider)
public ParametersManagerViewModel(IContainerProvider containerProvider) : base(containerProvider)
{
_ScopedContext = scopedContext;
_systemConfig = systemConfig;
_globalInfo = globalInfo;
_ScopedContext = containerProvider.Resolve<ScopedContext>();
_systemConfig = containerProvider.Resolve<SystemConfig>();
_deviceManager = containerProvider.Resolve<DeviceManager>();
_globalInfo = containerProvider.Resolve<GlobalInfo>();
Program = _ScopedContext.Program;
ParameterAddCommand = new DelegateCommand(ParameterAdd);
ParameterEditCommand = new DelegateCommand(ParameterEdit);
ParameterDeleteCommand = new DelegateCommand(ParameterDelete);
DeviceEditCommand = new DelegateCommand(DeviceEdit);
ReConnectCommand = new AsyncDelegateCommand(OnReConnect);
CloseCommand = new AsyncDelegateCommand(OnClose);
LoadedCommand = new DelegateCommand(OnLoad);
}
#region
private void OnLoad()
{
DeviceInfoVM = _systemConfig.DeviceList;
} private async Task OnReConnect()
{
await _deviceManager.ConnectSpecifiedDevice(SelectedDevice.DeviceName);
} private async Task OnClose()
{
await _deviceManager.CloseDeviceAsync(SelectedDevice.DeviceName);
}
private void DeviceEdit()
{
if (!_globalInfo.IsAdmin) return;
@@ -98,14 +113,7 @@ namespace TestingModule.ViewModels
return;
}
var type = SelectedDevice.DeviceType.Split('.').Last();
if(type=="E36233A"|| type == "IT6724CReverse")
{
_dialogService.Show("Backfeed");
}
else
{
_dialogService.Show(type);
}
_dialogService.Show(type);
}
private void ParameterDelete()

View File

@@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
@@ -18,7 +19,11 @@
<converters:ParameterCategoryToStringConverter x:Key="ParameterCategoryToStringConverter" />
<converters:ParameterValueToStringConverter x:Key="ParameterValueToStringConverter" />
</UserControl.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding LoadedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
<GroupBox Header="设备/参数">
<TabControl>
@@ -123,7 +128,7 @@
<MenuItem Header="编辑"
Command="{Binding DeviceEditCommand}" />
<MenuItem Header="重新连接"
Command="{Binding ReconnnectCommand}" />
Command="{Binding ReConnectCommand}" />
<MenuItem Header="关闭"
Command="{Binding CloseCommand}" />
</ContextMenu>