Пример #1
0
        private void btnAutoLoginMojangLauncher_Click(object sender, EventArgs e)
        {
            gMojangLogin.Enabled  = false;
            gOfflineLogin.Enabled = false;

            var th = new Thread(() =>
            {
                var result = login.TryAutoLoginFromMojangLauncher();

                if (result.Result != MLoginResult.Success)
                {
                    MessageBox.Show($"Failed to AutoLogin : {result.Result}\n{result.ErrorMessage}");
                    Invoke(new Action(() =>
                    {
                        gMojangLogin.Enabled  = true;
                        gOfflineLogin.Enabled = true;
                    }));
                    return;
                }

                MessageBox.Show("Auto Login Success!");
                Invoke(new Action(() =>
                {
                    gMojangLogin.Enabled  = true;
                    gOfflineLogin.Enabled = true;

                    btnAutoLogin.Enabled = false;
                    btnAutoLoginMojangLauncher.Enabled = false;
                    btnLogin.Enabled = false;
                    btnLogin.Text    = "Auto Login\nSuccess";

                    UpdateSession(result.Session);
                }));
            });

            th.Start();
        }