设置界面优化
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
|
||||
namespace SettingModule
|
||||
{
|
||||
[Module(OnDemand = true)]
|
||||
public class SettingModule : IModule
|
||||
{
|
||||
public void OnInitialized(IContainerProvider containerProvider)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SettingModule.Views.Dialogs"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:helpers="clr-namespace:UIShare.Helpers;assembly=UIShare"
|
||||
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
|
||||
mc:Ignorable="d"
|
||||
@@ -14,20 +15,29 @@
|
||||
Width="440"
|
||||
Height="430">
|
||||
<prism:Dialog.WindowStyle>
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="ResizeMode" Value="NoResize"/>
|
||||
|
||||
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DialogUserManageStyle}"
|
||||
TargetType="Window" />
|
||||
</prism:Dialog.WindowStyle>
|
||||
|
||||
<UserControl.Resources>
|
||||
<converters:StringToVisibilityConverter x:Key="StringToVisibility"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<GroupBox Padding="12,8,12,8"
|
||||
Header="{Binding Title}"
|
||||
<GroupBox Padding="12,8,12,8" materialDesign:HintAssist.Hint=""
|
||||
helpers:WindowDragHelper.EnableWindowDrag="True">
|
||||
<GroupBox.Header>
|
||||
<Grid Margin="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Title}"
|
||||
Foreground="White"
|
||||
VerticalAlignment="Center"
|
||||
Margin="5,0,10,0" />
|
||||
</Grid>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
@@ -56,6 +66,7 @@
|
||||
Text="串口名称:"
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="0" Grid.Column="1" Margin="0,6"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
IsEditable="True"
|
||||
ItemsSource="{Binding AvailablePorts}"
|
||||
Text="{Binding Config.PortName, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
@@ -68,6 +79,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonBaudRates}"
|
||||
Text="{Binding Config.BaudRate, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
@@ -76,6 +88,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
ItemsSource="{Binding DataBitsList}"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
SelectedItem="{Binding Config.DataBits}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
@@ -83,6 +96,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
ItemsSource="{Binding StopBitsList}"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
SelectedItem="{Binding Config.StopBits}"/>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
@@ -90,6 +104,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
ItemsSource="{Binding ParityList}"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
SelectedItem="{Binding Config.Parity}"/>
|
||||
|
||||
<TextBlock Grid.Row="5" Grid.Column="0"
|
||||
@@ -97,6 +112,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonTimeouts}"
|
||||
Text="{Binding Config.ReadTimeout, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
@@ -105,6 +121,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonTimeouts}"
|
||||
Text="{Binding Config.WriteTimeout, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<UserControl x:Class="SettingModule.Views.Dialogs.TCPConfigView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SettingModule.Views.Dialogs"
|
||||
@@ -14,10 +15,8 @@
|
||||
Width="420"
|
||||
Height="320">
|
||||
<prism:Dialog.WindowStyle>
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="ResizeMode" Value="NoResize"/>
|
||||
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
|
||||
</Style>
|
||||
<Style BasedOn="{StaticResource DialogUserManageStyle}"
|
||||
TargetType="Window" />
|
||||
</prism:Dialog.WindowStyle>
|
||||
|
||||
<UserControl.Resources>
|
||||
@@ -25,8 +24,20 @@
|
||||
</UserControl.Resources>
|
||||
|
||||
<GroupBox Padding="12,8,12,8"
|
||||
Header="{Binding Title}"
|
||||
helpers:WindowDragHelper.EnableWindowDrag="True">
|
||||
<GroupBox.Header>
|
||||
<Grid Margin="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Title}"
|
||||
Foreground="White"
|
||||
VerticalAlignment="Center"
|
||||
Margin="5,0,10,0" />
|
||||
</Grid>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
@@ -51,6 +62,7 @@
|
||||
Text="IP 地址:"
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="0,6"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
Text="{Binding Config.IPAddress, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
@@ -58,6 +70,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonPorts}"
|
||||
Text="{Binding Config.Port, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
@@ -66,6 +79,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonTimeouts}"
|
||||
Text="{Binding Config.SendTimeout, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
@@ -74,6 +88,7 @@
|
||||
VerticalAlignment="Center" Margin="0,6"/>
|
||||
<ComboBox Grid.Row="3" Grid.Column="1" Margin="0,6"
|
||||
IsEditable="True"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
ItemsSource="{Binding CommonTimeouts}"
|
||||
Text="{Binding Config.ReceiveTimeout, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:prism="http://prismlibrary.com/"
|
||||
xmlns:b="clr-namespace:UIShare.Behaviors;assembly=UIShare"
|
||||
xmlns:converters="clr-namespace:UIShare.Converters;assembly=UIShare"
|
||||
@@ -235,19 +236,19 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="设备名称:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="0" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SelectedDevice.DeviceName, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="设备类型:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="1" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SelectedDevice.DeviceType, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="备注说明:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="2" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SelectedDevice.Remark, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="启用状态:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="1" Margin="0,6"
|
||||
<CheckBox materialDesign:HintAssist.Hint="" Grid.Row="3" Grid.Column="1" Margin="0,6"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding SelectedDevice.IsEnabled}"
|
||||
Content="启用此设备"/>
|
||||
@@ -306,7 +307,7 @@
|
||||
Text="连接方式:"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,4"/>
|
||||
<ComboBox Grid.Row="0" Grid.Column="1"
|
||||
<ComboBox materialDesign:HintAssist.Hint="" Grid.Row="0" Grid.Column="1"
|
||||
Margin="0,4"
|
||||
ItemsSource="{Binding ConnectionTypes}"
|
||||
SelectedItem="{Binding SelectedDevice.ConnectionType}"/>
|
||||
@@ -437,17 +438,9 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="标题:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.Title, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="TSMaster 名称:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.TSMasterName, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="性能等级:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<Grid Grid.Row="2" Grid.Column="1" Margin="0,4">
|
||||
@@ -490,23 +483,23 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="DLL 路径:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="0" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.DLLFilePath, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="子程序路径:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="1" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.SubProgramFilePath, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="默认程序文件:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="2" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.DefaultProgramFilePath, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Text="默认 BLF 文件:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="3" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.DefaultBLFFilePath, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Text="默认 DBC 文件:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Margin="0,4"
|
||||
<TextBox materialDesign:HintAssist.Hint="" Grid.Row="4" Grid.Column="1" Margin="0,4"
|
||||
Text="{Binding SystemConfig.DefaultDBCFilePath, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
@@ -518,13 +511,25 @@
|
||||
<StackPanel>
|
||||
<TextBlock Text="只读信息" FontWeight="Bold" FontSize="14" Margin="0,0,0,10"/>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="140"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="系统数据目录:" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding SystemConfig.SystemPath}"
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="标题:" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="0,4" Foreground="#555"
|
||||
Text="{Binding SystemConfig.Title}"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="TSMaster 名称:" VerticalAlignment="Center" Margin="0,4"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0,4" Foreground="#555"
|
||||
Text="{Binding SystemConfig.TSMasterName}"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Text="系统数据目录:" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="2"
|
||||
Text="{Binding SystemConfig.SystemPath}" Margin="0,4"
|
||||
Foreground="#555"
|
||||
TextWrapping="Wrap"/>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user