예제 #1
0
        private void ConnectBtn_Click(object sender, EventArgs e)
        {
            if (Program.Accounts.Count < 1 || ConnectingBot)
            {
                return;
            }
            BotsExpected = Program.Accounts.Count - Program.Connections.Count;
            if (BotsExpected == 0)
            {
                return;
            }
            AnimationDisplay = string.Format("Connecting% | (1/{0})", BotsExpected);
            AnimationTmr.Start();

            BotsLoaded    = 0;
            ConnectingBot = true;
            UpdateAccountUI(false);
            UpdateConnectionFeats(false);

            Task.Factory.StartNew(() =>
            {
                HSession[] HSs = Program.Accounts.Values.Where(H => !Program.Connections.ContainsKey(H)).ToArray();
                foreach (HSession H in HSs)
                {
                    H.OnConnected    += H_OnConnected;
                    H.DataToClient   += H_DataToClient;
                    H.OnDisconnected += H_OnDisconnected;
                    H.Connect();
                }
            });
        }
예제 #2
0
        private void AccountTxt_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!LoggingIn && !ConnectingBot)
            {
                string AN = AccountTxt.Text;
                if (!AN.Contains("@"))
                {
                    UpdateAccountUI(false);
                    UpdateConnectionFeats(false);
                    AnimationDisplay = string.Format("Grabbing Avatar% | {0}", AN);
                    AnimationTmr.Start();

                    Task.Factory.StartNew(new Action(() =>
                    {
                        bool isLoggedIn  = Program.Accounts[AN].IsLoggedIn;
                        bool isConnected = Program.Accounts[AN].IsConnected;
                        if (!isLoggedIn)
                        {
                            Invoke(new Action(() =>
                            {
                                AvatarPctbx.Image = Resources.Avatar;
                                AccountTxt.Items.Remove(Program.Accounts[AN].PlayerName);
                                AccountTxt.Items.Add(Program.Accounts[AN].Email);
                                AccountTxt.SelectedIndex = AccountTxt.Items.IndexOf(Program.Accounts[AN].Email);
                            }));

                            Program.Accounts.Remove(AN);
                            UpdateAccountUI(false);
                            UpdateConnectionFeats(true);
                            DisplayFinish(string.Format("You've been signed out! | {0}", AN), false);
                        }
                        else
                        {
                            ConnectedLbl.Invoke(new Action(() =>
                            {
                                ConnectedLbl.Text      = isConnected.ToString();
                                ConnectedLbl.ForeColor = isConnected ? Color.DarkGreen : Color.DarkRed;
                            }));

                            Image Avatar = SKore.GetPlayerAvatar(AN, Program.Accounts[AN].Hotel);
                            AvatarPctbx.Invoke(new Action(() => { AvatarPctbx.Image = Avatar; }));
                            UpdateAccountUI(true);
                            UpdateConnectionFeats(true);
                            DisplayFinish(string.Format("Avatar Grabbed! | {0}", AN), false);
                        }
                    }));
                }
                else
                {
                    ConnectedLbl.Text      = "False";
                    ConnectedLbl.ForeColor = Color.DarkRed;
                    AvatarPctbx.Image      = Resources.Avatar;
                    UpdateAccountUI(false);
                    UpdateConnectionFeats(true);
                }
            }
        }
예제 #3
0
        private void DisplayFinish(string Status, bool UpdateProfileUI = true)
        {
            if (InvokeRequired)
            {
                Invoke(DisplayFinishCB, Status, UpdateProfileUI); return;
            }

            AnimationTmr.Stop();
            StatusTxt.Text = Status;
            LoggingIn      = ConnectingBot = false;
            if (UpdateProfileUI)
            {
                AccountTxt_SelectedIndexChanged(Status, EventArgs.Empty);
            }
        }
예제 #4
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            LoggingIn = true;
            UpdateAccountUI(false);
            UpdateConnectionFeats(false);

            if (AllAccountsChckbx.Checked)
            {
                #region Account Login: Multiple
                int      LoginCount = 0;
                int      LoginFails = AccountTxt.Items.Count;
                string[] Accounts   = AccountTxt.Items.Cast <object>().Select(i => i.ToString()).ToArray();
                AnimationDisplay = string.Format("Logging In% | (1/{0})", Accounts.Length);
                AnimationTmr.Start();
                foreach (string Account in Accounts)
                {
                    if (Account.Contains('@'))
                    {
                        Program.Emails[Account].BeginLogin(new AsyncCallback((iAr) =>
                        {
                            HSession HS = (HSession)iAr.AsyncState;
                            if (HS.EndLogin(iAr))
                            {
                                LoginFails--;
                                Program.Accounts[HS.PlayerName] = HS;
                                Invoke(new Action(() =>
                                {
                                    AccountTxt.Items.Remove(HS.Email);
                                    AccountTxt.Items.Add(HS.PlayerName);
                                    AccountTxt.SelectedIndex = AccountTxt.Items.IndexOf(HS.PlayerName);
                                }));
                            }
                            AnimationDisplay = string.Format("Logging In% | ({0}/{1})", LoginCount + 2, Accounts.Length);
                            if (++LoginCount == Accounts.Length)
                            {
                                DisplayFinish(string.Format("Login(s) Succeeded! | ({0}/{1})", Accounts.Length - LoginFails, Accounts.Length));
                            }
                        }), Program.Emails[Account]);
                    }
                    else
                    {
                        Program.Accounts[Account].BeginLogin(new AsyncCallback((iAr) =>
                        {
                            if ((iAr.AsyncState as HSession).EndLogin(iAr))
                            {
                                LoginFails--;
                            }
                            AnimationDisplay = string.Format("Logging In% | ({0}/{1})", LoginCount + 2, Accounts.Length);
                            if (++LoginCount == Accounts.Length)
                            {
                                DisplayFinish(string.Format("Login(s) Succeeded! | ({0}/{1})", Accounts.Length - LoginFails, Accounts.Length));
                            }
                        }), Program.Accounts[Account]);
                    }
                }
                #endregion
            }
            else
            {
                #region Account Login: Single
                string AN = AccountTxt.Text;
                AnimationDisplay = string.Format("Logging In% | {0}", AN);
                AnimationTmr.Start();
                if (AN.Contains("@"))
                {
                    Program.Emails[AN].BeginLogin(new AsyncCallback((iAr) =>
                    {
                        HSession HS = (HSession)iAr.AsyncState;
                        if (HS.EndLogin(iAr))
                        {
                            Program.Accounts[HS.PlayerName] = HS;
                            Invoke(new Action(() =>
                            {
                                AccountTxt.Items.Remove(HS.Email);
                                AccountTxt.Items.Add(HS.PlayerName);
                                AccountTxt.SelectedIndex = AccountTxt.Items.IndexOf(HS.PlayerName);
                            }));
                            DisplayFinish("Login Success! | " + AN);
                        }
                        else
                        {
                            DisplayFinish("Login Failed! | " + AN);
                        }
                    }), Program.Emails[AN]);
                }
                else
                {
                    Program.Accounts[AN].BeginLogin(new AsyncCallback((iAr) =>
                    {
                        DisplayFinish(string.Format("Login {0}! | {1}", (iAr.AsyncState as HSession).EndLogin(iAr) ? "Success" : "Failed", AN));
                    }), Program.Accounts[AN]);
                }
                #endregion
            }
        }