优化设置界面Tcp显示

This commit is contained in:
hsc
2026-06-11 16:09:47 +08:00
parent 5cac253cb8
commit a9ee9e974e
4 changed files with 10 additions and 11 deletions

View File

@@ -8,14 +8,14 @@ using UIShare.ViewModelBase;
namespace SettingModule.ViewModels.Dialogs
{
/// <summary>
/// TCP 连接配置对话框 VM。
/// Tcp 连接配置对话框 VM。
/// 通过 DialogParameters 接收宿主 DeviceInfoVM保存时把副本写回宿主。
/// </summary>
public class TCPConfigViewModel : DialogViewModelBase
{
#region
private string _title = "TCP 连接配置";
private string _title = "Tcp 连接配置";
public string Title
{
get => _title;
@@ -105,7 +105,7 @@ namespace SettingModule.ViewModels.Dialogs
{
_hostDevice.TcpConfig ??= new TcpConfigVM();
Config.CopyTo(_hostDevice.TcpConfig);
_hostDevice.ConnectionType = "TCP";
_hostDevice.ConnectionType = "Tcp";
}
RequestClose.Invoke(ButtonResult.OK);
@@ -121,7 +121,7 @@ namespace SettingModule.ViewModels.Dialogs
if (parameters.ContainsKey("Device"))
{
_hostDevice = parameters.GetValue<DeviceInfoVM>("Device");
Title = $"TCP 连接配置 - {_hostDevice?.DeviceName}";
Title = $"Tcp 连接配置 - {_hostDevice?.DeviceName}";
Config = new TcpConfigVM(_hostDevice?.TcpConfig);
}
else if (parameters.ContainsKey("Config"))

View File

@@ -145,7 +145,7 @@ namespace SettingModule.ViewModels
/// <summary>
/// 打开"连接配置"对话框。按 SelectedDevice.ConnectionType 决定开 TCP 还是串口对话框。
/// 打开"连接配置"对话框。按 SelectedDevice.ConnectionType 决定开 Tcp 还是串口对话框。
/// </summary>
private void OnOpenConnectionConfig()
{
@@ -164,7 +164,7 @@ namespace SettingModule.ViewModels
if (string.IsNullOrEmpty(dialogName))
{
StatusMessage = "当前设备未配置连接方式(请先选择 TCP 或 Serial";
StatusMessage = "当前设备未配置连接方式(请先选择 Tcp 或 Serial";
return;
}

View File

@@ -310,20 +310,20 @@
<ComboBox materialDesign:HintAssist.Hint="" Grid.Row="0" Grid.Column="1"
Margin="0,4"
ItemsSource="{Binding ConnectionTypes}"
SelectedItem="{Binding SelectedDevice.ConnectionType}"/>
SelectedItem="{Binding SelectedDevice.ConnectionType,Mode=TwoWay}"/>
<Button Grid.Row="0" Grid.Column="2"
Content="配置..."
Margin="8,4,0,4" Padding="14,2"
Command="{Binding OpenConnectionConfigCommand}"/>
<!-- TCP 参数预览 -->
<!-- Tcp 参数预览 -->
<StackPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
Margin="0,4,0,0" Orientation="Horizontal">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedDevice.ConnectionType}" Value="TCP">
<DataTrigger Binding="{Binding SelectedDevice.ConnectionType}" Value="Tcp">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
@@ -414,7 +414,6 @@
VerticalAlignment="Center"
FontWeight="Bold"/>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Button Content="重置" Command="{Binding ResetCommand}" Padding="12,4"/>
<Button Content="保存" Command="{Binding SaveCommand}" Padding="12,4" Margin="6,0,0,0"/>
</StackPanel>
</Grid>

View File

@@ -43,7 +43,7 @@ namespace UIShare.UIViewModel
/// 连接方式:"None" / "TCP" / "Serial"。
/// 用于决定 SettingView 上"配置..."按钮打开哪一个对话框。
/// </summary>
private string _connectionType = "None";
private string _connectionType ;
public string ConnectionType
{
get => _connectionType;