vue-java-tutorials/CSharp/SerialPort/Base-2-Window/MainWindow.xaml.cs

26 lines
794 B
C#
Raw Normal View History

2025-06-23 23:05:34 +08:00
using System.IO.Ports;
2025-06-23 22:26:07 +08:00
using System.Windows;
2025-06-23 23:05:34 +08:00
using Base_2_Window.ViewModel;
2025-06-23 22:26:07 +08:00
namespace Base_2_Window;
/// <summary>
2025-06-23 23:05:34 +08:00
/// Interaction logic for MainWindow.xaml
2025-06-23 22:26:07 +08:00
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
2025-06-23 23:05:34 +08:00
DataContext = new MainWindowViewModel
{
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 22:26:07 +08:00
}
}