Beispiel #1
0
        private void AccountLogin(LOGINMETHOD mode = LOGINMETHOD.NORMAL)
        {
            if (lvData.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select a single account to login to!", "Login account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Class.Account _account;
            if (!Globals.CurrentProfile.Profiles.TryGetValue(lvData.SelectedItems[0].SubItems[0].Text, out _account))
            {
                MessageBox.Show("Reference error!", "Login Account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _account.Login(mode);
        }
Beispiel #2
0
        // Login the account
        public bool Login(LOGINMETHOD mode = LOGINMETHOD.NORMAL)
        {
            if (string.IsNullOrWhiteSpace(this.Username) || string.IsNullOrWhiteSpace(this.Password))
            {
                MessageBox.Show("This account doesn't contain any credentials to login to", "Login Account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (Globals.IsLoggingIn)
            {
                MessageBox.Show("The application is already actively logging in an account!", "Login Account", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // Make sure steam is closed. Only check if logging in with normal or force
            if (mode < LOGINMETHOD.NORMAL_NO_CHECK)
            {
                Process[] _temp_proc_list;
                while ((_temp_proc_list = Process.GetProcessesByName("Steam")).Count() > 0)
                {
                    if (mode == LOGINMETHOD.FORCE || MessageBox.Show("OWL has detected that the Steam client is still running. Would you like to close it forcibly? This is not recommended since it can cause instability. Only choose this option if you know what you're doing.", "Login Account", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        foreach (Process steam in _temp_proc_list)
                        {
                            steam.Kill();
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    Thread.Sleep(800); // lazy
                }
            }

            Globals.IsLoggingIn = true;
            Globals.hFormMain.FormMain_UpdateTitle();

            if (Globals.LastAccountLogin != null)
            {
                Globals.LastAccountLogin.LVI.BackColor = System.Drawing.Color.FromArgb(255, 42, 42, 42);
            }

            Globals.LastAccountLogin = this;
            this.LVI.BackColor       = System.Drawing.Color.FromArgb(255, 20, 20, 20);

            Globals.CurrentProfile.LastAccountLoggedIn = this.LVI.SubItems[0].Text;

            new Thread(new ThreadStart(() =>
            {
                if (mode == LOGINMETHOD.CLICK_CREDENTIALS)
                {
                    Class.Account _acc = this;
                    new Forms.ClickLogin(ref _acc).ShowDialog();
                }
                else
                {
                    Process.Start(Globals.Config.steamPath + "/Steam.exe", $"-login \"{this.Username}\" \"{this.Password}\" {Globals.Config.steamParam}");
                }

                Globals.hFormMain.Invoke(new Action(() =>
                {
                    Globals.IsLoggingIn = false;
                    Globals.hFormMain.FormMain_UpdateTitle();
                }));
            }
                                       )).Start();

            return(true);
        }