private void Cbstop_SelectionChanged(object sender, SelectionChangedEventArgs e) { var temp = (string)((ComboBoxItem)Cbstop.SelectedItem).Content; StopBits stop; StopBits.TryParse(temp, true, out stop); Settings.Default.ScannerSettings.StopBits = stop; Settings.Default.Save(); SerialPortErrorHandler(); }
public Configuration() { InitializeComponent(); var com = MainSettings.Default.COM; if (string.IsNullOrWhiteSpace(com)) { foreach (string s in System.IO.Ports.SerialPort.GetPortNames()) { cComPortList.Items.Add(s); } } else { cComPortList.Items.Add(com); cComPortList.SelectedItem = cComPortList.Items[0]; // cComPortList.FindString(com);// FindStringExact(com); } if (!string.IsNullOrWhiteSpace(MainSettings.Default.AreaHeight.ToString())) { tHeight.Text = MainSettings.Default.AreaHeight.ToString(); } if (!string.IsNullOrWhiteSpace(MainSettings.Default.AreaWidth.ToString())) { tWidth.Text = MainSettings.Default.AreaWidth.ToString(); } tPatientPath.ScrollBars = System.Windows.Forms.ScrollBars.Horizontal; if (!string.IsNullOrWhiteSpace(MainSettings.Default.PatientFolderPath.ToString())) { tPatientPath.Text = MainSettings.Default.PatientFolderPath; path = MainSettings.Default.PatientFolderPath; } if (!string.IsNullOrWhiteSpace(MainSettings.Default.BaudRate.ToString())) { tBaudRate.Text = MainSettings.Default.BaudRate.ToString(); } if (!string.IsNullOrWhiteSpace(MainSettings.Default.DataBits.ToString())) { tDataBits.Text = MainSettings.Default.DataBits.ToString(); } if (!string.IsNullOrWhiteSpace(MainSettings.Default.Handshake)) { cHandshake.DataSource = Enum.GetValues(typeof(Handshake)); Handshake hand; var tmp = Handshake.TryParse(MainSettings.Default.Handshake, out hand); if (tmp) { cHandshake.SelectedItem = hand; } } if (!string.IsNullOrWhiteSpace(MainSettings.Default.Parity)) { cParity.DataSource = Enum.GetValues(typeof(Parity)); Parity parity; var tmp = Parity.TryParse(MainSettings.Default.Parity, out parity); if (tmp) { cParity.SelectedItem = parity; } } if (!string.IsNullOrWhiteSpace(MainSettings.Default.StopBits)) { cStopBits.DataSource = Enum.GetValues(typeof(StopBits)); StopBits stopBits; var tmp = StopBits.TryParse(MainSettings.Default.StopBits, out stopBits); if (tmp) { cStopBits.SelectedItem = stopBits; } } if (!string.IsNullOrWhiteSpace(MainSettings.Default.TimeOut.ToString())) { tTimeOut.Text = MainSettings.Default.TimeOut.ToString(); } if (!string.IsNullOrWhiteSpace(MainSettings.Default.STX)) { tSTX.Text = MainSettings.Default.STX; } if (!string.IsNullOrWhiteSpace(MainSettings.Default.ETX)) { tETX.Text = MainSettings.Default.ETX; } if (!string.IsNullOrWhiteSpace(MainSettings.Default.DLE)) { tDLE.Text = MainSettings.Default.DLE; } if (!string.IsNullOrWhiteSpace(MainSettings.Default.StartBitmapSign)) { tSBitmap.Text = MainSettings.Default.StartBitmapSign; } tConnected.Text = "Niepołączony z matą."; }