vue-java-tutorials/CSharp/SerialPort/Base-2-Window/ViewModel/MainWindowViewModel.cs

23 lines
777 B
C#
Raw Normal View History

2025-06-23 23:05:34 +08:00
using System.IO.Ports;
2025-07-08 17:15:03 +08:00
using Base_2_Window.Model;
2025-06-23 23:05:34 +08:00
using Base_2_Window.MVVM;
namespace Base_2_Window.ViewModel;
public class MainWindowViewModel : ViewModelBase
{
2025-07-08 17:15:03 +08:00
public MainWindowViewModel()
{
SerialPortModel = new SerialPortModel()
{
SerialPortNames = SerialPort.GetPortNames().Select(s => s).ToList(),
BaudRates = new List<int> { 9600 },
DataBits = new List<int> { 6, 7, 8 },
StopBitsList = new List<StopBits> { StopBits.None, StopBits.One, StopBits.Two, StopBits.OnePointFive },
ParityList = new List<Parity>
{ Parity.None, Parity.Even, Parity.Mark, Parity.None, Parity.Odd, Parity.Space }
};;
}
2025-06-23 23:05:34 +08:00
2025-07-08 17:15:03 +08:00
public SerialPortModel SerialPortModel { get; set; }
2025-06-23 23:05:34 +08:00
}