///<summary>初始化</summary> private void Initialize() { SerialPortDevice.RefreshPortNames(); SerialPortDevice.PortNamesChanged += OnPortNamesChanged; m_Device.StateChanged += OnStateChanged; m_Device.Error += OnError; PortNames = SerialPortDevice.PortNames; m_IsPropertyEnabled = true; var length = PortNames.Length; if (length > 0) { if (PortIndex < 0 || PortIndex >= PortNames.Length) { PortIndex = 0; } } else { if (PortIndex >= 0) { PortIndex = -1; } IsSimulator = true; } }
///<summary>当点击刷新按钮时</summary> private void OnButtonRefreshClick(object sender, RoutedEventArgs e) { SerialPortDevice.RefreshPortNames(); }