private void btnConnect_Click(object sender, EventArgs e) { try { var port = Convert.ToInt32(txtPort.Text); MDSController = new MDSController(txtIPAddress.Text, port); _settings.SetStringValue("LastConnectedIPAddress", txtIPAddress.Text); _settings.SetIntegerValue("LastConnectedTCPPort", port); Close(); } catch { MDSGuiHelper.ShowErrorMessage("Please check IP address and TCP Port. TCP port must be numeric."); } }