private void disconnect2() { VJoy.Release(); try { serialReader.ClosePort(); } catch (Exception) {} ActiveChannels = 0; comboProtocol.Enabled = true; comboPorts.Enabled = true; buttonPortSetup.Enabled = true; buttonPortsRefresh.Enabled = true; buttonProtocolSetup.Enabled = true; buttonConnect.Text = "Connect"; connected = false; toolStripStatusLabel.Text = "Disconnected"; comboJoysticks.Enabled = true; }
private void connect() { if (comboJoysticks.SelectedItem != null) { try { VJoy = vJoyEnumerator.GetVJoy(comboJoysticks.SelectedItem.ToString()); } catch (VJoyBase.VJoyException ex) { ErrorMessageBox(ex.Message, "VJoy Error"); return; } } serialReader = createSerialReader(); var sp = useCustomSerialParameters ? serialParameters : serialReader.GetDefaultSerialParameters(); if (!serialReader.OpenPort((string)comboPorts.SelectedItem, sp)) { ErrorMessageBox("Can not open the port", "Serial Error"); VJoy.Release(); return; } comboProtocol.Enabled = false; comboPorts.Enabled = false; buttonPortSetup.Enabled = false; buttonPortsRefresh.Enabled = false; buttonProtocolSetup.Enabled = false; buttonConnect.Text = "Disconnect"; comboJoysticks.Enabled = false; toolStripStatusLabel.Text = "Connecting ..."; connected = true; lua = new Lua(luaScript); backgroundWorker.RunWorkerAsync(); }