设置界面优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Prism.Commands;
|
||||
@@ -48,7 +49,7 @@ namespace SettingModule.ViewModels
|
||||
|
||||
public ObservableCollection<string> ConnectionTypes { get; } = new()
|
||||
{
|
||||
"None", "TCP", "Serial"
|
||||
"None", "Tcp", "Serial"
|
||||
};
|
||||
#endregion
|
||||
|
||||
@@ -72,7 +73,6 @@ namespace SettingModule.ViewModels
|
||||
public SettingViewModel(IContainerExtension container) : base(container)
|
||||
{
|
||||
_globalInfo = container.Resolve<GlobalInfo>();
|
||||
|
||||
RefreshCommand = new DelegateCommand(OnExpand);
|
||||
SaveCommand = new DelegateCommand(OnSave);
|
||||
ResetCommand = new DelegateCommand(OnReset);
|
||||
@@ -107,15 +107,23 @@ namespace SettingModule.ViewModels
|
||||
_eventAggregator.GetEvent<ExpandViewEvent>().Publish(TestStatus);
|
||||
}
|
||||
|
||||
/// <summary>保存当前选中设备的配置(占位,实际写盘逻辑后续接入)。</summary>
|
||||
/// <summary>保存当前 SystemConfig 到 SystemPath 下,文件名为 {Title}.json。</summary>
|
||||
private void OnSave()
|
||||
{
|
||||
if (SelectedDevice == null)
|
||||
if (_systemConfig == null)
|
||||
{
|
||||
StatusMessage = "无可保存的设备";
|
||||
StatusMessage = "无可保存的配置";
|
||||
return;
|
||||
}
|
||||
StatusMessage = $"已保存设备 [{SelectedDevice.DeviceName}] 的配置({DateTime.Now:HH:mm:ss})";
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_systemConfig.Title))
|
||||
{
|
||||
StatusMessage = "保存失败:标题(Title)不能为空";
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigService.Save(_systemConfig);
|
||||
StatusMessage = $"已保存配置 [{_systemConfig.Title}.json] 至 {_systemConfig.SystemPath}({DateTime.Now:HH:mm:ss})";
|
||||
}
|
||||
|
||||
/// <summary>重置当前选中设备的配置(占位)。</summary>
|
||||
@@ -142,7 +150,7 @@ namespace SettingModule.ViewModels
|
||||
|
||||
var dialogName = SelectedDevice.ConnectionType switch
|
||||
{
|
||||
"TCP" => "TCPConfig",
|
||||
"Tcp" => "TCPConfig",
|
||||
"Serial" => "SerialPortConfig",
|
||||
_ => string.Empty
|
||||
};
|
||||
@@ -153,7 +161,6 @@ namespace SettingModule.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
// 【关键修改】在此处将选中的设备以及隔离作用域内的 _systemConfig 一并传进弹窗
|
||||
var p = new DialogParameters
|
||||
{
|
||||
{ "Device", SelectedDevice },
|
||||
@@ -180,12 +187,11 @@ namespace SettingModule.ViewModels
|
||||
_scope = _globalInfo.ScopeDic[TestStatus];
|
||||
_scopedContext = _globalInfo.ContextDic[TestStatus];
|
||||
_systemConfig = _scope.Resolve<SystemConfig>();
|
||||
DeviceList = _systemConfig.DeviceList;
|
||||
if (DeviceList != null && DeviceList.Count > 0)
|
||||
{
|
||||
SelectedDevice = DeviceList[0];
|
||||
}
|
||||
|
||||
DeviceList = _systemConfig.DeviceList;
|
||||
IsInitiated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user