/// <summary> /// Perform a disconnection procedure. /// </summary> private void DoDisconnect() { btnStartStop.Enabled = false; // Stop capture if running. StopCapture(); // Stop the timer and perform the last update from session. tSync.Stop(); if (Session != null) { Session.Disconnect(); UpdateFromSession(); Session = null; } // Disable "Join Master" area. SetSendArea(false); // Re-enable the pre-connect groups. grpLoginSettings.Enabled = true; grpCaptureSettings.Enabled = true; btnConnect.Text = "&Connect"; }
/// <summary> /// Perform the connection procedure. /// </summary> private void DoConnect() { CaptureData = false; bWaitForLogin = true; // Make sure we're ready for it. if (!CanConnect()) { return; } // Get hostname and port we're connecting to in the end. string addr = (cbCustomServer.Checked) ? tbFurcAddress.Text : Program.Settings.DEFAULT_FURC_ADDRESS; ushort port = (cbCustomServer.Checked) ? (ushort)tbFurcPort.Value : Program.Settings.DEFAULT_FURC_PORT; // Disable pre-connect groups - can't modify them online. SetSettings(false); ClearLog(); UpdateToCharacter(); Session = new FurcSession(addr, port, FurcCharacter); try { Session.Connect(); } catch (Exception e) { string msg = "Cannot connect: " + e.Message; PutLog(msg); ShowError(msg); return; } DataAnalyzer = new Analyzer(); tSync.Start(); btnConnect.Text = "&Disconnect"; }