diff --git a/WireSockUI/Forms/frmMain.cs b/WireSockUI/Forms/frmMain.cs index a807333..374225c 100644 --- a/WireSockUI/Forms/frmMain.cs +++ b/WireSockUI/Forms/frmMain.cs @@ -489,8 +489,7 @@ private void OnProfileClick(object sender, EventArgs e) if (e != EventArgs.Empty) { // Check if the current state is connected or connecting. - if ((_currentState == ConnectionState.Connected || _currentState == ConnectionState.Connecting) && - e != EventArgs.Empty) + if (_currentState == ConnectionState.Connected || _currentState == ConnectionState.Connecting) { var reconnect = false; @@ -505,50 +504,25 @@ private void OnProfileClick(object sender, EventArgs e) // Proceed with reconnecting if the reconnect flag is set. if (!reconnect) return; - // Set the tunnel mode based on the application settings. - _wiresock.TunnelMode = Settings.Default.UseAdapter - ? WireSockManager.Mode.VirtualAdapter - : WireSockManager.Mode.Transparent; - - // Get the selected profile. - var profile = lstProfiles.SelectedItems[0].Text; - - // Connect to the selected profile and update the state to connecting if successful. - if (_wiresock.Connect(profile)) - UpdateState(ConnectionState.Connecting); - } - else - { - // Set the tunnel mode based on the application settings. - _wiresock.TunnelMode = Settings.Default.UseAdapter - ? WireSockManager.Mode.VirtualAdapter - : WireSockManager.Mode.Transparent; - - // Get the selected profile. - var profile = lstProfiles.SelectedItems[0].Text; - - // Connect to the selected profile and update the state to connecting if successful. - if (_wiresock.Connect(profile)) - UpdateState(ConnectionState.Connecting); } } else { // Update the state to disconnected. UpdateState(ConnectionState.Disconnected); + } - // Set the tunnel mode based on the application settings. - _wiresock.TunnelMode = Settings.Default.UseAdapter - ? WireSockManager.Mode.VirtualAdapter - : WireSockManager.Mode.Transparent; + // Set the tunnel mode based on the application settings. + _wiresock.TunnelMode = Settings.Default.UseAdapter + ? WireSockManager.Mode.VirtualAdapter + : WireSockManager.Mode.Transparent; - // Get the selected profile. - var profile = lstProfiles.SelectedItems[0].Text; + // Get the selected profile. + var profile = lstProfiles.SelectedItems[0].Text; - // Connect to the selected profile and update the state to connecting if successful. - if (_wiresock.Connect(profile)) - UpdateState(ConnectionState.Connecting); - } + // Connect to the selected profile and update the state to connecting if successful. + if (_wiresock.Connect(profile)) + UpdateState(ConnectionState.Connecting); } private void OnWireSockLogMessage(WireSockManager.LogMessage logMessage)