2025-07-04 22:39:44 +08:00
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2025-09-06 12:03:39 +08:00
|
|
|
using DMS.WPF.ViewModels.Items;
|
2025-07-04 22:39:44 +08:00
|
|
|
|
2025-07-19 11:11:01 +08:00
|
|
|
namespace DMS.WPF.ViewModels.Dialogs;
|
2025-07-04 22:39:44 +08:00
|
|
|
|
2025-09-06 12:03:39 +08:00
|
|
|
public partial class MqttDialogViewModel : DialogViewModelBase<MqttServerItemViewModel>
|
2025-07-04 22:39:44 +08:00
|
|
|
{
|
2025-09-06 12:03:39 +08:00
|
|
|
[ObservableProperty]
|
|
|
|
|
private MqttServerItemViewModel _mqttServer;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private string _title;
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private string _primaryButText;
|
|
|
|
|
|
|
|
|
|
public MqttDialogViewModel()
|
|
|
|
|
{
|
|
|
|
|
MqttServer = new MqttServerItemViewModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MqttDialogViewModel(MqttServerItemViewModel mqttServer)
|
|
|
|
|
{
|
|
|
|
|
MqttServer = new MqttServerItemViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = mqttServer.Id,
|
|
|
|
|
ServerName = mqttServer.ServerName,
|
|
|
|
|
ServerUrl = mqttServer.ServerUrl,
|
|
|
|
|
Port = mqttServer.Port,
|
|
|
|
|
Username = mqttServer.Username,
|
|
|
|
|
Password = mqttServer.Password,
|
|
|
|
|
IsActive = mqttServer.IsActive,
|
|
|
|
|
SubscribeTopic = mqttServer.SubscribeTopic,
|
|
|
|
|
PublishTopic = mqttServer.PublishTopic,
|
|
|
|
|
ClientId = mqttServer.ClientId,
|
|
|
|
|
CreatedAt = mqttServer.CreatedAt,
|
|
|
|
|
ConnectedAt = mqttServer.ConnectedAt,
|
|
|
|
|
ConnectionDuration = mqttServer.ConnectionDuration,
|
2025-09-10 18:15:31 +08:00
|
|
|
MessageFormat = mqttServer.MessageFormat,
|
|
|
|
|
MessageHeader = mqttServer.MessageHeader,
|
|
|
|
|
MessageContent = mqttServer.MessageContent,
|
|
|
|
|
MessageFooter = mqttServer.MessageFooter
|
2025-09-06 12:03:39 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void PrimaryButton()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Close(MqttServer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void CancelButton()
|
|
|
|
|
{
|
|
|
|
|
Close(null);
|
|
|
|
|
}
|
2025-07-04 22:39:44 +08:00
|
|
|
}
|