示例#1
0
        private async void BtnAddNaverId_Click(object sender, EventArgs e)
        {
            var        objectOneKey = new OneKeyForm.OneKeyObject();
            OneKeyForm form         = new OneKeyForm(objectOneKey);

            form.ShowDialog();

            if (!string.IsNullOrEmpty(objectOneKey.OneKeyId))
            {
                this.tabControl1.Enabled = false;
                var naverCookie = await NaverIdService.LoginNaver(objectOneKey.OneKeyId);

                this.tabControl1.Enabled = true;

                if (string.IsNullOrEmpty(naverCookie))
                {
                    MessageBox.Show("Naver登录失败,请重试。");
                    return;
                }

                this.MapleConfig.DefaultNaverCookie   = naverCookie;
                this.MapleConfig.DefaultNaverNickName = objectOneKey.NaverName;

                this.MapleConfig.LoginData.Add(new LoginData()
                {
                    Guid             = Util.ConvertDateTimeToInt(DateTime.Now).ToString(),
                    IsDefault        = this.MapleConfig.LoginData.Count <= 0,
                    AccountTag       = objectOneKey.NaverName,
                    AccountCookieStr = naverCookie
                });
                this.ReloadAccount();
                this.MapleConfig.Save();
            }
        }
示例#2
0
        private async Task <bool> LoginBySelect(string accountGuidId)
        {
            return(await Task.Run(new Func <bool>(() =>
            {
                this.MapleConfig.LoginData.ForEach(x => x.IsDefault = false);
                var account = this.MapleConfig.LoginData.First(x => x.Guid == accountGuidId);
                account.IsDefault = true;
                this.MapleConfig.DefaultNaverCookie = account.AccountCookieStr;
                this.MapleConfig.DefaultNaverNickName = account.AccountTag;
                this.MapleConfig.Save();
                if (account == null)
                {
                    Log("出现了不可能的错误,账号指定错误...");
                    return false;
                }

                Log($"准备启动{account.AccountTag}...");
                var naverCookie = NaverIdService.ReLoginNaver(account.AccountCookieStr).Result;
                if (string.IsNullOrEmpty(naverCookie))
                {
                    Log($"{account.AccountTag}的登录失败。帮助提示1-1.");
                    return false;
                }
                NaverIdService.ReLoadCookieContainer(naverCookie, ref this.MapleCookie);
                this.MapleEncPwd = MapleIdService.LoginMaple(this.MapleCookie, this.MapleConfig.DeveloperMode).Result;
                if (string.IsNullOrEmpty(this.MapleEncPwd))
                {
                    Log("冒险岛登录失败,请查看帮助提示2-1.");
                    return false;
                }
                Log($" {account.AccountTag} 登录成功,愉快的冒险吧(●ˇ∀ˇ●)...");

                if (!this.MapleConfig.CkNotLoadMapleIds)
                {
                    var mapleIds = MapleIdService.LoadMapleIds(this.MapleCookie, this.MapleConfig.DeveloperMode).Result;
                    this.BeginInvoke(new Action(() =>
                    {
                        this.MapleIds.DropDownItems.Clear();
                        foreach (var idItem in mapleIds)
                        {
                            this.MapleIds.DropDownItems.Add(idItem);
                        }
                        this.MapleIds.Visible = true;
                    }));
                }

                this.BeginInvoke(new Action(() =>
                {
                    this.DefaultAccount.Text = this.MapleConfig.DefaultNaverNickName;
                    this.BtnStartGame.Enabled = true;
                }));
                return true;
            })));
        }
示例#3
0
        private async Task <bool> Login()
        {
            return(await Task.Run(new Func <bool>(() =>
            {
                Log($"准备启动{this.MapleConfig.DefaultNaverNickName}...");
                var naverCookie = NaverIdService.ReLoginNaver(this.MapleConfig.DefaultNaverCookie).Result;
                if (string.IsNullOrEmpty(naverCookie))
                {
                    Log($"{this.MapleConfig.DefaultNaverNickName}的登录失败。请查看帮助提示1-1.");
                    this.MapleConfig.DefaultNaverCookie = "";
                    this.MapleConfig.DefaultNaverNickName = "";
                    this.MapleConfig.Save();
                    return false;
                }
                NaverIdService.ReLoadCookieContainer(naverCookie, ref this.MapleCookie);
                this.MapleEncPwd = MapleIdService.LoginMaple(this.MapleCookie, this.MapleConfig.DeveloperMode).Result;
                if (string.IsNullOrEmpty(this.MapleEncPwd))
                {
                    Log("冒险岛登录失败,请查看帮助提示2-1.");
                    return false;
                }
                Log($" {this.MapleConfig.DefaultNaverNickName} 登录成功,愉快的冒险吧(●ˇ∀ˇ●)...");

                if (!this.MapleConfig.CkNotLoadMapleIds)
                {
                    var mapleIds = MapleIdService.LoadMapleIds(this.MapleCookie, this.MapleConfig.DeveloperMode).Result;
                    this.BeginInvoke(new Action(() =>
                    {
                        this.MapleIds.DropDownItems.Clear();
                        foreach (var idItem in mapleIds)
                        {
                            this.MapleIds.DropDownItems.Add(idItem);
                        }
                        this.MapleIds.Visible = true;
                    }));
                }

                this.BeginInvoke(new Action(() =>
                {
                    this.DefaultAccount.Text = this.MapleConfig.DefaultNaverNickName;
                    this.BtnStartGame.Enabled = true;
                }));
                return true;
            })));
        }