共有变量添加
This commit is contained in:
@@ -44,6 +44,11 @@ namespace SettingModule.ViewModels
|
||||
{
|
||||
get => _deviceList;
|
||||
set => SetProperty(ref _deviceList, value);
|
||||
}
|
||||
public ObservableCollection<SharedParameter> SharedParameterList
|
||||
{
|
||||
get => _sharedParameterList;
|
||||
set => SetProperty(ref _sharedParameterList, value);
|
||||
}
|
||||
|
||||
public string StatusMessage
|
||||
@@ -72,6 +77,7 @@ namespace SettingModule.ViewModels
|
||||
private string _testStatus = string.Empty;
|
||||
private DeviceInfoVM? _selectedDevice;
|
||||
private ObservableCollection<DeviceInfoVM> _deviceList;
|
||||
private ObservableCollection<SharedParameter> _sharedParameterList;
|
||||
private string _statusMessage = "请在左侧选择设备查看 / 编辑配置";
|
||||
#endregion
|
||||
public SettingViewModel(IContainerExtension container) : base(container)
|
||||
@@ -199,6 +205,20 @@ namespace SettingModule.ViewModels
|
||||
SelectedDevice = DeviceList[0];
|
||||
}
|
||||
DeviceList = SystemConfig.DeviceList;
|
||||
SharedParameterList=SystemConfig.SharedParameterList;
|
||||
if (SharedParameterList.Count == 0)
|
||||
{
|
||||
foreach (var device in SystemConfig.ParameterList)
|
||||
{
|
||||
var sharedParam = new SharedParameter
|
||||
{
|
||||
Id = device.ID.ToString(),
|
||||
ParameterName = device.Name,
|
||||
Value = device.Value is int intVal ? intVal : Convert.ToInt32(device.Value)
|
||||
};
|
||||
SharedParameterList.Add(sharedParam);
|
||||
}
|
||||
}
|
||||
IsInitiated = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,6 +462,33 @@
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Background="White"
|
||||
BorderBrush="#E0E0E0" BorderThickness="1"
|
||||
CornerRadius="4" Padding="14"
|
||||
Margin="0,0,0,12">
|
||||
<StackPanel>
|
||||
<TextBlock Text="公共变量(SharedParameterList)" FontWeight="Bold" FontSize="14" Margin="0,0,0,10"/>
|
||||
<TextBlock Foreground="#888" FontSize="12" TextWrapping="Wrap"
|
||||
Text="每个台架可独立设置自己的通道号等整型变量;新建或打开程序时会用此处值覆盖程序中的同名变量。" Margin="0,0,0,10"/>
|
||||
<ItemsControl ItemsSource="{Binding SharedParameterList}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0,4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="160"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="{Binding ParameterName}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Background="White"
|
||||
BorderBrush="#E0E0E0" BorderThickness="1"
|
||||
CornerRadius="4" Padding="14"
|
||||
|
||||
Reference in New Issue
Block a user