Example #1
0
        private bool LoginOnServer()
        {
            try
            {
                if (LoginServer.IsConnected)
                {
                    return(true);
                }

                if ((Identifier.Text.Replace(" ", "") != "" && Password.Text.Replace(" ", "") != ""))
                {
                    if (Remember.Checked)
                    {
                        Directory.CreateDirectory(Application.StartupPath + "\\Settings\\");
                        var sw = new StreamWriter(Application.StartupPath + "\\Settings\\.login");
                        sw.WriteLine(Others.EncryptString(Identifier.Text.Trim() + "#" + Password.Text.Trim()));
                        sw.Close();
                    }
                    else
                    {
                        string fileToDelete = Application.StartupPath + "\\Settings\\.login";
                        if (File.Exists(fileToDelete))
                        {
                            File.Delete(fileToDelete);
                        }
                    }

                    LoginServer.Connect(Identifier.Text.Trim(), Password.Text.Trim());
                    while (!LoginServer.IsConnected)
                    {
                        Application.DoEvents();
                        Thread.Sleep(100);
                    }

                    return(LoginServer.IsConnected);
                }
            }
            catch (Exception ex)
            {
                Logging.WriteError("LoginOnServer(): " + ex);
            }
            MessageBox.Show(nManager.Translate.Get(nManager.Translate.Id.Please_enter_your_user_name_and_password) + ".",
                            nManager.Translate.Get(nManager.Translate.Id.Error), MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(false);
        }
Example #2
0
        private void MainFormOnLoad(object sender, EventArgs e)
        {
            try
            {
                if (Others.ExistFile(Application.StartupPath + "\\Settings\\.login"))
                {
                    var strReader = new StreamReader(Application.StartupPath + "\\Settings\\.login", Encoding.Default);
                    try
                    {
                        string   text  = Others.DecryptString(strReader.ReadLine());
                        string[] text2 = text.Split('#');
                        Identifier.Text      = text2[0];
                        Password.Text        = text2[1];
                        Identifier.ForeColor = Color.FromArgb(118, 118, 118);
                        Password.ForeColor   = Color.FromArgb(118, 118, 118);
                        if (Identifier.Text != "")
                        {
                            Remember.Checked = true;
                            if (Password.Text == "Password")
                            {
                                UseKey.Checked = true;
                                Password.Hide();
                            }
                        }
                    }
                    catch
                    {
                        Identifier.Text  = "";
                        Password.Text    = "";
                        Remember.Checked = false;
                    }
                    strReader.Close();
                }

                LoginButton.Enabled   = false;
                RefreshButton.Enabled = false;
                LoginServer.CheckServerIsOnline();
                while (!LoginServer.IsOnlineserver)
                {
                    Thread.Sleep(30);
                    Application.DoEvents();
                }
                LoginServer.CheckUpdate();
                LoginButton.Enabled   = true;
                RefreshButton.Enabled = true;

                RefreshProcessList();

                /* Begin AutoStart code */
                bool sIdFound = false;
                if (_autoStarted > 0)
                {
                    for (int i = 0; i < SessionList.Items.Count; i++)
                    {
                        Application.DoEvents();
                        object item = SessionList.Items[i];
                        if (item.ToString().Contains(_autoStarted + " -"))
                        {
                            SessionList.SelectedIndex = i;
                            sIdFound = true;
                            break;
                        }
                    }
                    if (sIdFound)
                    {
                        nManagerSetting.ActivateProductTipOff = false;
                        LoginButton_Click(new object(), new EventArgs());
                    }
                }
                /*Process.Start("https://goo.gl/TtMsEh");*/
                //else
                //    MessageBox.Show(@"Blizzard is currently very active in the Anti-Bot fight and it may not be wise to use the bot at that very moment in time.", @"WARNING / ATTENTION / ARTUNG / внимание / 注意");
                /* End AutoStart code */
            }
            catch (Exception ex)
            {
                Logging.WriteError("MainFormOnLoad(object sender, EventArgs e): " + ex);
            }
        }