private void SetSettings() { //Terminal TCP.GetSettings(); TerminalIpTextBox.Text = TCP.IP; TerminalPortTextBox.Text = TCP.Port.ToString(); //Decoder SerialPortManager spm = new SerialPortManager(); PortNameComboBox.ItemsSource = spm.CurrentSerialSettings.PortNameCollection; BaudRateComboBox.ItemsSource = spm.CurrentSerialSettings.BaudRateCollection; DataBitsComboBox.ItemsSource = spm.CurrentSerialSettings.DataBitsCollection; ParityComboBox.ItemsSource = Enum.GetValues(typeof(System.IO.Ports.Parity)); StopBitsComboBox.ItemsSource = Enum.GetValues(typeof(System.IO.Ports.StopBits)); try { spm.CurrentSerialSettings.GetSettings(); PortNameComboBox.SelectedValue = spm.CurrentSerialSettings.PortNameCollection.Any(x => x == spm.CurrentSerialSettings.PortName) ? spm.CurrentSerialSettings.PortName : null; BaudRateComboBox.SelectedValue = spm.CurrentSerialSettings.BaudRate; DataBitsComboBox.SelectedValue = spm.CurrentSerialSettings.DataBits; ParityComboBox.SelectedValue = spm.CurrentSerialSettings.Parity; StopBitsComboBox.SelectedValue = spm.CurrentSerialSettings.StopBits; } catch (Exception ex) { log.Error($"[{ Settings.GetLine(new StackTrace(true))}]:Error getting the settings: {ex}"); } }