123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- using System.IO.Ports;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace WpfTest1.SmallDialogs.Debug
- {
- /// <summary>
- /// SerialPortSetup.xaml 的交互逻辑
- /// </summary>
- public partial class SerialPortSetup : Window
- {
- public string result;
- public SerialPortSetup()
- {
- InitializeComponent();
- updateButtonClicked(null, null);
- button2.IsEnabled = false;
- }
- private void updateButtonClicked(object sender, RoutedEventArgs e)
- {
- button2.IsEnabled = false;
- comboBox.Items.Clear();
- string[] sps = SerialPort.GetPortNames();
- foreach (string s in sps) comboBox.Items.Add(s);
- }
- private void button2_Click(object sender, RoutedEventArgs e)
- {
- result = (string)comboBox.SelectedItem;
- Close();
- }
- private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- button2.IsEnabled = comboBox.SelectedItem != null;
- }
- }
- }
|