参数配置界面弹窗添加
This commit is contained in:
@@ -5,7 +5,6 @@ using UIShare.GlobalVariable;
|
||||
using UIShare.PubEvent;
|
||||
using UIShare.UIViewModel;
|
||||
using UIShare.ViewModelBase;
|
||||
|
||||
namespace SettingModule.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
@@ -74,8 +73,16 @@ namespace SettingModule.ViewModels
|
||||
public ICommand RefreshCommand { get; }
|
||||
public ICommand SaveCommand { get; }
|
||||
public ICommand ResetCommand { get; }
|
||||
/// <summary>打开当前选中设备的连接配置对话框(按 ConnectionType 选择 TCP / 串口)。</summary>
|
||||
public ICommand OpenConnectionConfigCommand { get; }
|
||||
#endregion
|
||||
|
||||
/// <summary>支持的连接方式列表,供"连接方式"ComboBox 使用。</summary>
|
||||
public ObservableCollection<string> ConnectionTypes { get; } = new()
|
||||
{
|
||||
"None", "TCP", "Serial"
|
||||
};
|
||||
|
||||
public SettingViewModel(IContainerExtension container) : base(container)
|
||||
{
|
||||
_scope = container.CreateScope();
|
||||
@@ -89,6 +96,7 @@ namespace SettingModule.ViewModels
|
||||
RefreshCommand = new DelegateCommand(OnExpand);
|
||||
SaveCommand = new DelegateCommand(OnSave);
|
||||
ResetCommand = new DelegateCommand(OnReset);
|
||||
OpenConnectionConfigCommand = new DelegateCommand(OnOpenConnectionConfig);
|
||||
|
||||
// 进来默认选中第一个,让右侧不为空
|
||||
if (DeviceList.Count > 0)
|
||||
@@ -146,6 +154,40 @@ namespace SettingModule.ViewModels
|
||||
}
|
||||
StatusMessage = $"已重置设备 [{SelectedDevice.DeviceName}] 的配置";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开"连接配置"对话框。按 SelectedDevice.ConnectionType 决定开 TCP 还是串口对话框。
|
||||
/// </summary>
|
||||
private void OnOpenConnectionConfig()
|
||||
{
|
||||
if (SelectedDevice == null)
|
||||
{
|
||||
StatusMessage = "请先在左侧选择设备";
|
||||
return;
|
||||
}
|
||||
|
||||
var dialogName = SelectedDevice.ConnectionType switch
|
||||
{
|
||||
"TCP" => "TCPConfig",
|
||||
"Serial" => "SerialPortConfig",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
if (string.IsNullOrEmpty(dialogName))
|
||||
{
|
||||
StatusMessage = "当前设备未配置连接方式(请先选择 TCP 或 Serial)";
|
||||
return;
|
||||
}
|
||||
|
||||
var p = new DialogParameters { { "Device", SelectedDevice } };
|
||||
_dialogService.ShowDialog(dialogName, p, r =>
|
||||
{
|
||||
if (r.Result == ButtonResult.OK)
|
||||
{
|
||||
StatusMessage = $"已更新 [{SelectedDevice.DeviceName}] 的连接参数({DateTime.Now:HH:mm:ss})";
|
||||
}
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导航
|
||||
|
||||
Reference in New Issue
Block a user