2025-05-04 10:22:38 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-04-29 09:04:38 +08:00
|
|
|
|
using System.Diagnostics;
|
2025-05-04 10:22:38 +08:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using Dm;
|
2025-04-29 09:04:38 +08:00
|
|
|
|
using linesider_screen_bankend.Core.Mvvm;
|
|
|
|
|
|
using linesider_screen_bankend.Services.Interfaces;
|
2025-05-04 10:22:38 +08:00
|
|
|
|
using Prism.Commands;
|
2025-04-29 09:04:38 +08:00
|
|
|
|
using Prism.Ioc;
|
|
|
|
|
|
using Prism.Regions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace linesider_screen_bankend.Modules.ModuleName.ViewModels
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SettingsPageViewModel : RegionViewModelBase
|
|
|
|
|
|
{
|
2025-05-04 10:22:38 +08:00
|
|
|
|
|
2025-04-29 09:04:38 +08:00
|
|
|
|
private List<string> _portList;
|
|
|
|
|
|
public List<string> PortList
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _portList; }
|
|
|
|
|
|
set { SetProperty(ref _portList, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<string> _baudList;
|
|
|
|
|
|
public List<string> BaudList
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _baudList; }
|
|
|
|
|
|
set { SetProperty(ref _baudList, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _message;
|
|
|
|
|
|
public string Message
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _message; }
|
|
|
|
|
|
set { SetProperty(ref _message, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MQTT参数
|
|
|
|
|
|
private string _mqttAddress;
|
|
|
|
|
|
public string MqttAddress
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _mqttAddress; }
|
|
|
|
|
|
set { SetProperty(ref _mqttAddress, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
private string _mqttPort;
|
|
|
|
|
|
public string MqttPort
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _mqttPort; }
|
|
|
|
|
|
set { SetProperty(ref _mqttPort, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
private string _mqttClientId;
|
|
|
|
|
|
public string MqttClientId
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _mqttClientId; }
|
|
|
|
|
|
set { SetProperty(ref _mqttClientId, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
private string _mqtttTopic;
|
|
|
|
|
|
public string MqttTopic
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _mqtttTopic; }
|
|
|
|
|
|
set { SetProperty(ref _mqtttTopic, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-04 10:22:38 +08:00
|
|
|
|
// 按钮事件
|
|
|
|
|
|
private DelegateCommand _testCommand;
|
|
|
|
|
|
public DelegateCommand TestCommand =>
|
|
|
|
|
|
_testCommand ?? (_testCommand = new DelegateCommand(ExecuteTestCommand));
|
2025-04-29 09:04:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-05-04 10:22:38 +08:00
|
|
|
|
private IPortService _portService;
|
|
|
|
|
|
private IPrintService _printService;
|
|
|
|
|
|
public SettingsPageViewModel(IRegionManager regionManager, IPortService portService, IPrintService printService) :
|
2025-04-29 09:04:38 +08:00
|
|
|
|
base(regionManager)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.WriteLine("viewModel方法启动测试1");
|
|
|
|
|
|
_portService = portService;
|
2025-05-04 10:22:38 +08:00
|
|
|
|
_printService = printService;
|
2025-04-29 09:04:38 +08:00
|
|
|
|
Message = "139.224.232.211";
|
|
|
|
|
|
InitializePortAndBaudLists();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void InitializePortAndBaudLists()
|
|
|
|
|
|
{
|
|
|
|
|
|
PortList = _portService.GetPortOptions();
|
|
|
|
|
|
BaudList = _portService.GetBaudOptions();
|
|
|
|
|
|
}
|
|
|
|
|
|
public override void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
//do something
|
|
|
|
|
|
}
|
2025-05-04 10:22:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 按钮事件
|
|
|
|
|
|
void ExecuteTestCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
_printService.DoPrint("测试地址");
|
|
|
|
|
|
}
|
2025-04-29 09:04:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|