示例#1
0
        private void connect()
        {
            if (String.IsNullOrWhiteSpace(this.usernameTextBox.Text) ||
                String.IsNullOrWhiteSpace(this.passwordTextBox.Text) ||
                String.IsNullOrWhiteSpace(this.siteConfigTextBox.Text))
            {
                MessageBox.Show("Site Config Path, Username and Password fields must all be completed before you will be able to connect to your VPN.", "Required Fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            statusTextBox.Text   = "";
            connectPanel.Visible = false;
            statusPanel.Visible  = true;

            ShrewCredentials credentials = new ShrewCredentials();

            credentials.username                = this.usernameTextBox.Text;
            credentials.password                = this.passwordTextBox.Text;
            credentials.siteConfigPath          = this.siteConfigTextBox.Text;
            credentials.connectOnStart          = this.checkboxConnectOnStart.Checked;
            credentials.formLogin               = this.formloginTextBox.Text;
            credentials.authenticateOnConnected = this.checkboxAuth.Checked;
            connection = new ShrewConnection(credentials);
            if (checkBoxSave.Checked)
            {
                try
                {
                    ShrewConfiguration.SaveCredentials(credentials);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Unable to save credentials! " + exc.Message, "Error Saving Credentials!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                ShrewConfiguration.DeleteCredentials();
            }
            connection.Connect();
        }
示例#2
0
 private void destroyConnection()
 {
     this.connection.Shutdown();
     this.connection = null;
 }