Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            //Configure Fonts
            SkinHelper.SetFont(Controls);

            //Game Lang
            if (Program.UserConfig != null)
            {
                comboBox2.SelectedIndex = (int)Program.UserConfig.GameLanguage;
            }
            else
            {
                comboBox2.SelectedIndex = (int)GameLanguage.enUS;
            }

            //Launcher Version
            var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

            lb_Ver.Text = $"v{version.Major}{version.Minor}{version.Build}";

            //OnPropertyChanged
            Program.WebSocketClient.PropertyChanged += OnPropertyChanged;

            //Login
            if (Program.WebSocketClient.State != WebSocketClientState.Logging ||
                Program.WebSocketClient.State != WebSocketClientState.Logged)
            {
                using (var form = new LoginForm())
                {
                    var dr = form.ShowDialog();

                    if (dr != DialogResult.OK)
                    {
                        Program.WebSocketClient.AgentWebSocket.Close();
                        Environment.Exit(0);
                    }
                }
            }

            //User Info
            if (Program.RemoteUser != null)
            {
                ExecuteUserInfoResultCommand(Program.RemoteUser);
            }

            //Start xLiveBridgeServer
            Program.Server.Setup(Program.ServerConfig);
            Program.Server.Start();

            //Auto-Refresh User Info
            if (_timer != null)
            {
                return;
            }

            _timer           = new Timer(1000 * 60); //60Sec
            _timer.Elapsed  += DoUserInfo;
            _timer.AutoReset = true;
            _timer.Enabled   = true;
            _timer.Enabled   = true;
            _timer.Start();
        }