Пример #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //Save our settings on the following conditions:
            //The user has checked the appropriet checkbox
            //The content has changed from last being loaded.
            if (chkSaveLogin.Checked != false)
            {
                //If the checkbox is checked
                if (chkSaveLogin.Checked != setSaveLogin | txtFirstName.Text != setFirstName | txtLastName.Text != setLastName | cbxLocation.Text != setLLocation)
                {
                    //If there have been any changes from when
                    //the settings were last loaded.
                    //Setting up our child node settings.
                    string strSettings = "<SaveLoginInfo value=\"" + chkSaveLogin.Checked.ToString().ToLower() + "\"/>" +
                                         "<FirstName value=\"" + txtFirstName.Text + "\"/>" +
                                         "<LastName value=\"" + txtLastName.Text + "\"/>" +
                                         "<LoginLocation value=\"" + cbxLocation.Text + "\"/>";
                    //Sending off the settings to be saved.
                    prefs.SaveSettings(txtFirstName.Text + "_" + txtLastName.Text, "LoginSettings", strSettings);
                    //Clean up the combo box that lists profiles.
                    if (cbxProfiles.Items.Contains("No profiles found."))
                    {
                        cbxProfiles.Items.Remove("No profiles found.");
                    }
                    cbxProfiles.Items.Add(txtFirstName.Text + "_" + txtLastName.Text);
                    cbxProfiles.SelectedItem = txtFirstName.Text + "_" + txtLastName.Text;
                }
            }
            else
            {
                //If unchecked, delete the login settings
                //no point in having unused information remain.
                prefs.DeleteSettings(cbxProfiles.Text, "LoginSettings");
            }

            btnLogin.Enabled = false;

            rtbStatus.Text = "Logging in...";
            Application.DoEvents();

            netcom.LoginOptions.FirstName     = txtFirstName.Text;
            netcom.LoginOptions.LastName      = txtLastName.Text;
            netcom.LoginOptions.Password      = txtPassword.Text;
            netcom.LoginOptions.StartLocation = cbxLocation.Text;
            netcom.Login();
        }
Пример #2
0
 private void btnReconnect_Click(object sender, EventArgs e)
 {
     netcom.Login();
 }
Пример #3
0
        //private void STABrowser()
        //{
        //    using (webBrowser = new WebBrowser())
        //    {
        //        webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
        //        webBrowser.Navigating += new WebBrowserNavigatingEventHandler(webBrowser_Navigating);
        //        webBrowser.Url = new Uri(murl);
        //        webBrowser.AllowNavigation = true;
        //        //webBrowser.AllowWebBrowserDrop = false;
        //        webBrowser.Dock = DockStyle.Fill;
        //        webBrowser.IsWebBrowserContextMenuEnabled = false;
        //        webBrowser.ScriptErrorsSuppressed = true;
        //        //webBrowser.ScrollBarsEnabled = true;
        //        webBrowser.NewWindow += new CancelEventHandler(webBrowser_NewWindow);

        //        //BeginInvoke(new MethodInvoker(delegate()
        //        //{
        //        //    pnlLoginPage.Controls.Add(webBrowser);
        //        //}));

        //        pnlLoginPage.Controls.Add(webBrowser);
        //    }
        //}



        //private void webBrowser_NewWindow(object sender, CancelEventArgs e)
        //{
        //    if (string.IsNullOrEmpty(clickedurl))
        //    {
        //        HtmlElement link = webBrowser1.Document.ActiveElement;
        //        clickedurl = link.GetAttribute("href");
        //    }

        //    e.Cancel = true;

        //    if (clickedurl.StartsWith("http://slurl.", StringComparison.CurrentCultureIgnoreCase))
        //    {
        //        // Open up the TP form here
        //        string[] split = clickedurl.Split(new Char[] { '/' });
        //        string sim = split[4].ToString(CultureInfo.CurrentCulture);
        //        double x = Convert.ToDouble(split[5].ToString(CultureInfo.CurrentCulture));
        //        double y = Convert.ToDouble(split[6].ToString(CultureInfo.CurrentCulture));
        //        double z = Convert.ToDouble(split[7].ToString(CultureInfo.CurrentCulture));

        //        (new frmTeleport(instance, sim, (float)x, (float)y, (float)z, false)).Show();
        //        clickedurl = string.Empty;
        //        return;
        //    }
        //    else if (clickedurl.StartsWith("http://maps.secondlife", StringComparison.CurrentCultureIgnoreCase))
        //    {
        //        // Open up the TP form here
        //        string[] split = clickedurl.Split(new Char[] { '/' });
        //        string sim = split[4].ToString(CultureInfo.CurrentCulture);
        //        double x = Convert.ToDouble(split[5].ToString(CultureInfo.CurrentCulture));
        //        double y = Convert.ToDouble(split[6].ToString(CultureInfo.CurrentCulture));
        //        double z = Convert.ToDouble(split[7].ToString(CultureInfo.CurrentCulture));

        //        (new frmTeleport(instance, sim, (float)x, (float)y, (float)z, true)).Show();
        //        clickedurl = string.Empty;
        //        return;
        //    }

        //    System.Diagnostics.Process.Start(clickedurl);
        //    clickedurl = string.Empty;
        //}

        //private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        //{
        //    if (clickedurl != string.Empty)
        //    {
        //        e.Cancel = true;
        //        System.Diagnostics.Process.Start(e.Url.ToString());
        //    }
        //}

        //private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        //{
        //    webBrowser1.ScrollBarsEnabled = false;

        //    webBrowser1.Document.Body.Style = "overflow:hidden";
        //}

        private void BeginLogin()
        {
            try
            {
                if (string.IsNullOrEmpty(txtLastName.Text))
                {
                    txtLastName.Text = "Resident";
                }

                instance.LoggedIn             = true;
                netcom.LoginOptions.FirstName = txtFirstName.Text;
                netcom.LoginOptions.LastName  = txtLastName.Text;

                // Fix thx to METAforum member Tipi (28/06/2010). I don't know how this
                // escaped us all these years.
                string pwd = txtPassword.Text;

                if (pwd.Length > 16)
                {
                    pwd = pwd.Substring(0, 16);
                    MessageBox.Show("Your password cannot be longer than 16 characters", "METAbolt");
                    txtPassword.Focus();
                    return;
                }

                netcom.LoginOptions.Password  = pwd;  // txtPassword.Text;
                netcom.LoginOptions.UserAgent = Properties.Resources.METAboltTitle + " " + Properties.Resources.METAboltVersion;
                netcom.LoginOptions.Author    = Properties.Resources.METAboltAuthor;

                switch (cbxLocation.SelectedIndex)
                {
                case -1:     //Custom
                    netcom.LoginOptions.StartLocation       = StartLocationType.Custom;
                    netcom.LoginOptions.StartLocationCustom = cbxLocation.Text;
                    break;

                case 0:     //Home
                    netcom.LoginOptions.StartLocation = StartLocationType.Home;
                    break;

                case 1:     //Last
                    netcom.LoginOptions.StartLocation = StartLocationType.Last;
                    break;
                }

                switch (cbxGrid.SelectedIndex)
                {
                case 0:     //Main grid
                    netcom.LoginOptions.Grid = LoginGrid.MainGrid;
                    break;

                case 1:     //Beta grid
                    netcom.LoginOptions.Grid = LoginGrid.BetaGrid;
                    break;

                default:     //Custom or other
                    netcom.LoginOptions.Grid = LoginGrid.Custom;

                    string selectedgrid = cbxGrid.SelectedItem.ToString();

                    if (selectedgrid == "Other...")
                    {
                        if (txtCustomLoginUri.TextLength == 0 ||
                            txtCustomLoginUri.Text.Trim().Length == 0)
                        {
                            MessageBox.Show("You must specify the Login Uri to connect to a custom grid.", "METAbolt", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        // Check for http beginning
                        string hhder = string.Empty;

                        if (!txtCustomLoginUri.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (!txtCustomLoginUri.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
                            {
                                hhder = "http://";
                            }
                        }

                        netcom.LoginOptions.GridCustomLoginUri = hhder + txtCustomLoginUri.Text;
                    }
                    else
                    {
                        if (MGrids.ContainsKey(selectedgrid))
                        {
                            netcom.LoginOptions.GridCustomLoginUri = MGrids[selectedgrid];
                        }
                    }

                    break;
                }

                lblLoginStatus.Text      = "Logging in...";
                lblLoginStatus.ForeColor = Color.FromKnownColor(KnownColor.ControlText);

                pnlLoggingIn.Visible   = true;
                pnlLoginPrompt.Visible = false;

                btnLogin.Enabled = false;

                client.Settings.HTTP_INVENTORY = !instance.Config.CurrentConfig.DisableHTTPinv;
                client.Settings.USE_LLSD_LOGIN = instance.Config.CurrentConfig.UseLLSD;
                //instance.SetSettings();

                netcom.Login();
                //DoBrowser();
            }
            catch (Exception ex)
            {
                Logger.Log("Login (main): " + ex.Message, Helpers.LogLevel.Error);
            }
        }