//worker thread //------------- private void backgroundWorkerConnect_DoWork(object sender, DoWorkEventArgs e) { DeviceSettings sessionInfo = (DeviceSettings)e.Argument; try { _connecting = true; _connected = _session.OpenSession(sessionInfo.Host, sessionInfo.Username, sessionInfo.Password); //check remember settings if (_connected) { if (checkBoxSave.Checked) { SettingsUtils.SaveSettings(new ToolSettings { Device = _selectedModem, Username = sessionInfo.Username, Password = sessionInfo.Password, Host = sessionInfo.Host, }); } else { SettingsUtils.DeleteSettings(); } //refresh ThreadUtils.SetButtonTextFromThread(buttonConnect, "Refreshing, please wait..."); _session.RefreshData(); } } catch (Exception ex) { MessageBox.Show("Unexpected error occurred. Debug info: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitDebugMode() { //get textbox values string host = textBoxIpAddress.Text; string username = "******"; //overwrite textbox value string password = textBoxPassword.Text; //init session _session = new Bbox3Session(backgroundWorkerGetLineData, _profiles, true); if (_session.OpenSession(host, username, password)) { buttonConnect.Enabled = false; panelDebug.Visible = true; panelInfo.Visible = false; panelLogin.Visible = false; } else { //set button text buttonConnect.Text = "Connect"; buttonConnect.Enabled = true; MessageBox.Show("Could not connect to device.", "Connection failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void initDebugMode() { //get textbox values string host = textBoxIpAddress.Text; string username = "******"; //overwrite textbox value string password = textBoxPassword.Text; //init session _session = new Bbox3Session(backgroundWorkerGetLineData, _profiles, true); if (_session.OpenSession(host, username, password)) { buttonConnect.Enabled = false; panelDebug.Visible = true; panelInfo.Visible = false; panelLogin.Visible = false; } else { //set button text buttonConnect.Text = "Connect"; buttonConnect.Enabled = true; MessageBox.Show("Could not connect to device.", "Connection failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } }