实现MQTT关联变量的别名问题,实现了,同个变量发给不同的MQTT服务器的名称不同
This commit is contained in:
34
ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs
Normal file
34
ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using PMSWPF.Models;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class MqttAliasBatchEditDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _title = "批量设置MQTT别名";
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<VariableMqtt> _variablesToEdit;
|
||||
|
||||
public Mqtt SelectedMqtt { get; private set; }
|
||||
|
||||
public MqttAliasBatchEditDialogViewModel(List<VariableData> selectedVariables, Mqtt selectedMqtt)
|
||||
{
|
||||
SelectedMqtt = selectedMqtt;
|
||||
Title=$"设置:{SelectedMqtt.Name}-MQTT服务器关联变量的别名";
|
||||
VariablesToEdit = new ObservableCollection<VariableMqtt>(
|
||||
selectedVariables.Select(v => new VariableMqtt(v, selectedMqtt))
|
||||
);
|
||||
}
|
||||
|
||||
public MqttAliasBatchEditDialogViewModel()
|
||||
{
|
||||
// For design time
|
||||
VariablesToEdit = new ObservableCollection<VariableMqtt>();
|
||||
}
|
||||
}
|
||||
34
ViewModels/Dialogs/MqttAliasDialogViewModel.cs
Normal file
34
ViewModels/Dialogs/MqttAliasDialogViewModel.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace PMSWPF.ViewModels.Dialogs;
|
||||
|
||||
public partial class MqttAliasDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _title = "设置MQTT别名";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _message = "请输入变量在该MQTT服务器上的别名:";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _variableName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _mqttServerName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _mqttAlias = string.Empty;
|
||||
|
||||
public MqttAliasDialogViewModel(string variableName, string mqttServerName)
|
||||
{
|
||||
VariableName = variableName;
|
||||
MqttServerName = mqttServerName;
|
||||
Message = $"请输入变量 '{VariableName}' 在MQTT服务器 '{MqttServerName}' 上的别名:";
|
||||
}
|
||||
|
||||
public MqttAliasDialogViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user