设置界面优化
This commit is contained in:
@@ -678,6 +678,7 @@ namespace ADP.ViewModels
|
||||
|
||||
_globalInfo.ContextDic.Remove(targetRegionName);
|
||||
_globalInfo.StepRunningDic.Remove(targetRegionName);
|
||||
_globalInfo.ScopeDic.Remove(targetRegionName);
|
||||
|
||||
var parameters = new NavigationParameters { { "Name", targetRegionName } };
|
||||
_regionManager.RequestNavigate(targetRegionName, "ProtocolStartView", parameters);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MainModule.ViewModels
|
||||
public ScopedContext _scopedContext { get; }
|
||||
public StepRunning _stepRunning { get; }
|
||||
public GlobalInfo _globalInfo { get; }
|
||||
public SystemConfig _systemConfig { get; }
|
||||
public SystemConfig _systemConfig { get; set; }
|
||||
|
||||
// 5 个子 ViewModel 全部从同一个 scope 解析,自动注入同一个 ScopedContext
|
||||
public CommandTreeViewModel CommandTreeVM { get; }
|
||||
@@ -50,7 +50,6 @@ namespace MainModule.ViewModels
|
||||
// 在该作用域内解析 ScopedContext —— 当前作用域唯一
|
||||
_scopedContext = _scope.Resolve<ScopedContext>();
|
||||
_stepRunning = _scope.Resolve<StepRunning>();
|
||||
_systemConfig=_scope.Resolve<SystemConfig>();
|
||||
// 关键:从同一个 _scope 解析 5 个子 VM,DI 会把同一个 ScopedContext 注入它们
|
||||
CommandTreeVM = _scope.Resolve<CommandTreeViewModel>();
|
||||
StepsManagerVM = _scope.Resolve<StepsManagerViewModel>();
|
||||
@@ -108,6 +107,18 @@ namespace MainModule.ViewModels
|
||||
_globalInfo.ContextDic.Add(TestStatus, _scopedContext);
|
||||
_globalInfo.StepRunningDic.Add(TestStatus, _stepRunning);
|
||||
_globalInfo.ScopeDic.Add(TestStatus, _scope);
|
||||
_systemConfig = _scope.Resolve<SystemConfig>();
|
||||
if (ConfigService.IsExit(TestStatus))
|
||||
{
|
||||
string filePath = System.IO.Path.Combine(_systemConfig.SystemPath, $"{TestStatus}.json");
|
||||
if (System.IO.File.Exists(filePath))
|
||||
{
|
||||
string json = System.IO.File.ReadAllText(filePath);
|
||||
|
||||
// 🔥 关键:把 json 数据直接灌入当前实例,对象引用没有任何改变
|
||||
Newtonsoft.Json.JsonConvert.PopulateObject(json, _systemConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ namespace MainModule.ViewModels
|
||||
region.Remove(myView);
|
||||
}
|
||||
}, parameters);
|
||||
|
||||
_moduleManager.LoadModule("MonitorModule");
|
||||
_moduleManager.LoadModule("SettingModule");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
|
||||
namespace MonitorModule
|
||||
{
|
||||
[Module(OnDemand = true)]
|
||||
public class MonitorModule: IModule
|
||||
{
|
||||
public void OnInitialized(IContainerProvider containerProvider)
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace MonitorModule.ViewModels
|
||||
Plot.Title = $"监控 - {TestStatus}";
|
||||
Plot.InvalidatePlot(false);
|
||||
_scope = _globalInfo.ScopeDic[TestStatus];
|
||||
_scopedContext = _globalInfo.ContextDic[TestStatus];
|
||||
_scopedContext = _scope.Resolve<ScopedContext>();
|
||||
IsInitiated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace MonitorModule.ViewModels
|
||||
{
|
||||
TestStatus = navigationContext.Parameters.GetValue<string>("Name");
|
||||
_scope = _globalInfo.ScopeDic[TestStatus];
|
||||
_scopedContext = _globalInfo.ContextDic[TestStatus];
|
||||
_scopedContext = _scope.Resolve<ScopedContext>();
|
||||
IsInitiated = true;
|
||||
}
|
||||
LoadTables();
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -8,7 +8,26 @@ namespace UIShare.GlobalVariable
|
||||
public static class ConfigService
|
||||
{
|
||||
private static readonly object _fileLock = new();
|
||||
/// <summary>
|
||||
/// 根据标题查询配置文件是否存在
|
||||
/// </summary>
|
||||
public static bool IsExit(string title)
|
||||
{
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 临时实例化一个对象以获取默认的 SystemPath
|
||||
var dummy = new SystemConfig();
|
||||
string configPath = Path.Combine(dummy.SystemPath, $"{title}.json");
|
||||
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据标题(格子标识)加载独立的配置文件
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using DeviceCommand.Base;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -27,6 +28,8 @@ namespace UIShare.GlobalVariable
|
||||
public PackIconKind RunIcon { get; set; } = PackIconKind.Play;
|
||||
public StepModel SelectedStep { get; set; }
|
||||
public ParameterModel SelectedParameter { get; set; }
|
||||
|
||||
public List<IBaseInterface> DeviceList { get; set; } = new();
|
||||
// 【新增测试属性】:每个实例被 new 出来时独一无二的随机身份
|
||||
// 证 ID
|
||||
public int DebugRandomId { get; private set; }
|
||||
|
||||
@@ -26,14 +26,68 @@ namespace UIShare.GlobalVariable
|
||||
public string DefaultProgramFilePath { get; set; } = "";
|
||||
public string DefaultBLFFilePath { get; set; } = "";
|
||||
public string DefaultDBCFilePath { get; set; } = "";
|
||||
public ObservableCollection<DeviceInfoModel> DeviceList = new();
|
||||
// public ObservableCollection<DeviceInfoModel> DeviceList { get; set; } = new()
|
||||
//{
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "IT7800E",
|
||||
// DeviceType = "IT7800E",
|
||||
// Remark = "交流可编程电源供应器",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = true,
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
public ObservableCollection<DeviceInfoModel> DeviceList { get; set; } = new()
|
||||
{
|
||||
new DeviceInfoModel { DeviceName = "DAQ_001", DeviceType = "数据采集卡", Remark = "8 通道电压采集", IsEnabled = true, IsConnected = false },
|
||||
new DeviceInfoModel { DeviceName = "PSU_002", DeviceType = "可编程电源", Remark = "0-30V / 0-5A", IsEnabled = true, IsConnected = false },
|
||||
new DeviceInfoModel { DeviceName = "CAN_003", DeviceType = "CAN 通讯卡", Remark = "双通道 CAN-FD", IsEnabled = false, IsConnected = false },
|
||||
new DeviceInfoModel { DeviceName = "IO_004", DeviceType = "数字 I/O", Remark = "16 进 16 出", IsEnabled = true, IsConnected = false },
|
||||
new DeviceInfoModel { DeviceName = "Serial_005", DeviceType = "串口", Remark = "RS232 / RS485", IsEnabled = true, IsConnected = false },
|
||||
};
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "N36200",
|
||||
// DeviceType = "N36200",
|
||||
// Remark = "宽范围可编程直流电源",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = true,
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "N36600",
|
||||
// DeviceType = "N36600",
|
||||
// Remark = "便携式宽范围可编程直流电源",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = false,
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "N69200",
|
||||
// DeviceType = "N69200",
|
||||
// Remark = "可编程直流电子负载",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = true,
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "SDS2000X_HD",
|
||||
// DeviceType = "SDS2000X_HD",
|
||||
// Remark = "数字存储示波器",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = true,
|
||||
// IsConnected = false
|
||||
// },
|
||||
|
||||
// new DeviceInfoModel
|
||||
// {
|
||||
// DeviceName = "SPAW7000",
|
||||
// DeviceType = "SPAW7000",
|
||||
// Remark = "功率分析记录仪",
|
||||
// ConnectionType = "Tcp",
|
||||
// IsEnabled = true,
|
||||
// IsConnected = false
|
||||
// }
|
||||
//};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Common.csproj" />
|
||||
<ProjectReference Include="..\DeviceCommand\DeviceCommand.csproj" />
|
||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace UIShare.ViewModelBase
|
||||
public IEventAggregator _eventAggregator;
|
||||
public IDialogService _dialogService;
|
||||
public IRegionManager _regionManager;
|
||||
public IModuleManager _moduleManager;
|
||||
private INotificationManager _notificationManager;
|
||||
private GlobalInfo _globalInfo;
|
||||
public NavigateViewModelBase(IContainerProvider containerProvider)
|
||||
@@ -21,6 +22,7 @@ namespace UIShare.ViewModelBase
|
||||
_globalInfo=containerProvider.Resolve<GlobalInfo>();
|
||||
_eventAggregator = containerProvider.Resolve<IEventAggregator>();
|
||||
_dialogService = containerProvider.Resolve<IDialogService>();
|
||||
_moduleManager = containerProvider.Resolve<IModuleManager>();
|
||||
_regionManager = containerProvider.Resolve<IRegionManager>();
|
||||
_notificationManager = containerProvider.Resolve<INotificationManager>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user