private void fillupForm(String sHostname)
        {
            HostnameComboBox.Text = sHostname;
            UsernameTextBox.Text  = "";
            //PortTextBox.Text = "";
            PasswordTextBox.Text = "";

            m_ci.loadFromRegistry(sHostname);
            HostnameComboBox.Focus();
            if (m_ci.hostname.Length > 0)
            {
                HostnameComboBox.Text = m_ci.hostname;
                UsernameTextBox.Focus();
            }
            UseHttpsCheckbox.Checked = m_ci.useHttps;
            if (-1 != m_ci.port)
            {
                PortTextBox.Text = m_ci.port.ToString();
            }
            if (m_ci.username.Length > 0)
            {
                UsernameTextBox.Text = m_ci.username;
                PasswordTextBox.Focus();
            }
            System.Net.WebProxy proxy = m_ci.getWebProxy();
            if (null != proxy)
            {
                UseProxyCheckBox.Checked = true;
                ProxyAddressTextBox.Text = proxy.Address.Host;
                ProxyPortTextBox.Text    = Convert.ToString(proxy.Address.Port);
                if (null != proxy.Credentials)
                {
                    ProxyUserTextBox.Text = ((System.Net.NetworkCredential)proxy.Credentials).UserName;
                }
            }
            else
            {
                UseProxyCheckBox.Checked = false;
                ProxyAddressTextBox.Text = "";
                ProxyPortTextBox.Text    = "";
                ProxyUserTextBox.Text    = "";
                ProxyPassTextBox.Text    = "";
            }
        }
        private void fillupForm(String sHostname)
        {
            HostnameComboBox.Text = sHostname;
            UsernameTextBox.Text  = "";
            //PortTextBox.Text = "";
            PasswordTextBox.Text = "";

            Clients.ConnectionInfo.loadFromRegistry(sHostname);
            HostnameComboBox.Focus();
            if (Clients.ConnectionInfo.hostname.Length > 0)
            {
                HostnameComboBox.Text = Clients.ConnectionInfo.hostname;
                UsernameTextBox.Focus();
            }
            if (Clients.ConnectionInfo.port > 0)
            {
                PortTextBox.Text = Convert.ToString(Clients.ConnectionInfo.port);
            }
            if (Clients.ConnectionInfo.username.Length > 0)
            {
                UsernameTextBox.Text = Clients.ConnectionInfo.username;
                PasswordTextBox.Focus();
            }
        }
        private void OKLinkLabel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (0 == HostnameComboBox.Text.Length)
            {
                MessageBox.Show("Please enter a hostname.", "Missing information");
                HostnameComboBox.Focus();
            }
            else if (0 == PortTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a port.", "Missing information");
                PortTextBox.Text = "443";
                PortTextBox.Focus();
            }
            else if (0 == EndpointTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a endpoint (default of /iControl/iControlPortal.cgi).", "Missing information");
                EndpointTextBox.Text = "/iControl/iControlPortal.cgi";
                EndpointTextBox.Focus();
            }
            else if (0 == UsernameTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a username.", "Missing information");
                UsernameTextBox.Focus();
            }
            else if (0 == PasswordTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a password.", "Missing information");
                PasswordTextBox.Focus();
            }
            else if (UseProxyCheckBox.Checked && (ProxyAddressTextBox.Text.Length == 0))
            {
                MessageBox.Show("If you are using a proxy server, please specify the address");
                ProxyAddressTextBox.Focus();
            }
            else if (UseProxyCheckBox.Checked && (ProxyPortTextBox.Text.Length == 0))
            {
                MessageBox.Show("If you are using a proxy server, please specify the port");
                ProxyPortTextBox.Focus();
            }
            else
            {
                bool bInitialized = false;
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                m_ci.setEndpoint(HostnameComboBox.Text, Convert.ToInt32(PortTextBox.Text), EndpointTextBox.Text);
                m_ci.setCredentials(UsernameTextBox.Text, PasswordTextBox.Text);

                // Now verify if we can connect to the host
                if (null == m_interfaces)
                {
                    m_interfaces = new iControl.Interfaces();
                }

                if (UseProxyCheckBox.Checked)
                {
                    bInitialized = m_interfaces.initialize(HostnameComboBox.Text, Convert.ToUInt32(PortTextBox.Text), UsernameTextBox.Text, PasswordTextBox.Text, ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text), ProxyUserTextBox.Text, ProxyPassTextBox.Text, m_ci.useHttps);
                }
                else
                {
                    bInitialized = m_interfaces.initialize(HostnameComboBox.Text, Convert.ToUInt32(PortTextBox.Text), UsernameTextBox.Text, PasswordTextBox.Text, m_ci.useHttps);
                }

                if (bInitialized)
                {
                    try
                    {
                        //sysInfo.Url = m_ci.buildURL();
                        iControl.SystemProductInformation prodInfo = m_interfaces.SystemSystemInfo.get_product_information();
                        if (null != prodInfo.product_code)
                        {
                            m_ci.setHostType(prodInfo.product_code);
                        }

                        // Check for GTM Support
                        bool bGTMLicensed = false;
                        for (int i = 0; i < prodInfo.product_features.Length; i++)
                        {
                            if (prodInfo.product_features[i].Equals("GTM Rules"))
                            {
                                bGTMLicensed = true;
                                break;
                            }
                        }
                        m_ci.setGTMLicensed(bGTMLicensed);

                        //sysInfo.Dispose();
                        Cursor.Current    = System.Windows.Forms.Cursors.Default;
                        this.DialogResult = DialogResult.OK;

                        // Update proxy info in connection info class
                        if (UseProxyCheckBox.Checked)
                        {
                            m_ci.setWebProxy(ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text),
                                             ProxyUserTextBox.Text, ProxyPortTextBox.Text);
                        }

                        if (SaveConfigCheckBox.Checked)
                        {
                            m_ci.saveToRegistry(HostnameComboBox.Text);
                        }

                        if (UseProxyCheckBox.Checked)
                        {
                            m_ci.setWebProxy(ProxyAddressTextBox.Text, Convert.ToInt32(ProxyPortTextBox.Text), ProxyUserTextBox.Text, ProxyPassTextBox.Text);
                        }

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    catch (System.Net.WebException)
                    {
                        MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                    }
                    catch (System.UriFormatException)
                    {
                        MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                    }
                }
                else
                {
                    MessageBox.Show(this, "Invalid Connection Information...", "Error");
                }

                //sysInfo.Dispose();
                Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
        private void OKLinkLabel_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (0 == HostnameComboBox.Text.Length)
            {
                MessageBox.Show("Please enter a hostname.", "Missing information");
                HostnameComboBox.Focus();
            }
            else if (0 == PortTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a port.", "Missing information");
                PortTextBox.Text = "443";
                PortTextBox.Focus();
            }
            else if (0 == EndpointTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a endpoint (default of /iControl/iControlPortal.cgi).", "Missing information");
                EndpointTextBox.Text = "/iControl/iControlPortal.cgi";
                EndpointTextBox.Focus();
            }
            else if (0 == UsernameTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a username.", "Missing information");
                UsernameTextBox.Focus();
            }
            else if (0 == PasswordTextBox.Text.Length)
            {
                MessageBox.Show("Please enter a password.", "Missing information");
                PasswordTextBox.Focus();
            }
            else
            {
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                Clients.ConnectionInfo.setEndpoint(HostnameComboBox.Text, Convert.ToInt32(PortTextBox.Text), EndpointTextBox.Text);
                Clients.ConnectionInfo.setCredentials(UsernameTextBox.Text, PasswordTextBox.Text);

                // Now verify if we can connect to the host
                iControl.SystemSystemInfo sysInfo = new iControl.SystemSystemInfo();
                sysInfo.Credentials     = Clients.ConnectionInfo.creds;
                sysInfo.PreAuthenticate = true;

                try
                {
                    sysInfo.Url = Clients.ConnectionInfo.buildURL();
                    iControl.SystemProductInformation prodInfo = sysInfo.get_product_information();
                    if (null != prodInfo.product_code)
                    {
                        Clients.ConnectionInfo.setHostType(prodInfo.product_code);
                    }

                    // Check for GTM Support
                    bool bGTMLicensed = false;
                    for (int i = 0; i < prodInfo.product_features.Length; i++)
                    {
                        if (prodInfo.product_features[i].Equals("GTM Rules"))
                        {
                            bGTMLicensed = true;
                            break;
                        }
                    }
                    Clients.ConnectionInfo.setGTMLicensed(bGTMLicensed);

                    sysInfo.Dispose();
                    Cursor.Current    = System.Windows.Forms.Cursors.Default;
                    this.DialogResult = DialogResult.OK;

                    if (SaveConfigCheckBox.Checked)
                    {
                        Clients.ConnectionInfo.saveToRegistry(HostnameComboBox.Text);
                    }

                    this.Close();
                }
                catch (System.Net.WebException)
                {
                    MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                }
                catch (System.UriFormatException)
                {
                    MessageBox.Show(this, "Connection could not be established to specified host", "Error");
                }

                sysInfo.Dispose();
                Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }