예제 #1
0
        private void CustomBtn2_Click(object sender, EventArgs e)
        {
            //Register
            using (var form = new RegisterForm())
            {
                form.ShowDialog();
                if (form.DialogResult != DialogResult.OK)
                {
                    return;
                }

                //Save UserConfig
                if (Program.UserConfig == null)
                {
                    Program.UserConfig = new UserConfig
                    {
                        LoginInfo = new LoginInfo
                        {
                            Email      = form.tb_Mail.Text,
                            Password   = form.tb_Password.Text,
                            RememberMe = true
                        }
                    };
                }
                else
                {
                    Program.UserConfig.LoginInfo.Email      = form.tb_Mail.Text;
                    Program.UserConfig.LoginInfo.Password   = form.tb_Password.Text;
                    Program.UserConfig.LoginInfo.RememberMe = true;
                }
                try
                {
                    Program.UserConfig.Save(Program.UserConfigFilePath);
                }
                catch (Exception)
                {
                    //
                }
            }

            //Login
            using (var form = new LoginForm())
            {
                var dr = form.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    if (form.CurrentUser == null)
                    {
                        return;
                    }

                    Program.CurrentUser = form.CurrentUser;

                    gamerCard1.UserName = $@"{Program.CurrentUser.ProfileName}";
                    gamerCard1.Rank     = $@"{Program.CurrentUser.Rank}";

                    panelManager1.SelectedPanel = managedPanel1;
                }
                else
                {
                    panelManager1.SelectedPanel = managedPanel2;
                }
            }
        }