private void serialPortSetupToolStripMenuItem_Click(object sender, EventArgs e) { using (SerialPortSetup serialPortConfig = new SerialPortSetup(_port)) { if (serialPortConfig.ShowDialog() == DialogResult.OK) { _port = serialPortConfig.SelectedPort; //This is some wierd shit that it has to be done this way, DataContractSerializer SUCKS! Cannot serialize typeof(SerialPort) because it tries to open the damn port! //So we'll ultize a custom type to save and load the settings into, then pop them into the proper place, this keeps the formatting and style of saving the xml files //the same across the board. _portSettings.PortName = _port.PortName; _portSettings.BaudRate = _port.BaudRate; _portSettings.Parity = _port.Parity; _portSettings.DataBits = _port.DataBits; _portSettings.StopBits = _port.StopBits; SaveSettings(); } else { LoadSettings(); } } }