Files
DMS/DMS.WPF/ViewModels/Dialogs/MqttAliasBatchEditDialogViewModel.cs
2025-07-19 11:11:01 +08:00

35 lines
1.1 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using DMS.WPF.Models;
using DMS.WPF.Models;
namespace DMS.WPF.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<Variable> 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>();
}
}