Exemplo n.º 1
0
        private void BtnEditAccount_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Account    EditAcc      = (Account)AccountsDataGrid.SelectedItem;
                AddAccount AddAccWindow = new AddAccount();
                AddAccWindow.Owner               = this;
                AddAccWindow.TxtAccName.Text     = EditAcc.Name;
                AddAccWindow.TxtAccId.Text       = EditAcc.LoginId.ToString();
                AddAccWindow.TxtAccEmail.Text    = EditAcc.Email;
                AddAccWindow.TxtAccPassword.Text = EditAcc.Password;
                AddAccWindow.ShowDialog();

                if (AddAccWindow.DialogResult.HasValue && AddAccWindow.DialogResult.Value)
                {
                    string apiurl            = "";
                    string supersecretstring = "";
                    switch (AddAccWindow.CmbServer.Text)
                    {
                    case "Ugaris":
                        apiurl            = "http://ugaris.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "A3Res":
                        apiurl            = "http://a3res.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "Reborn":
                        apiurl            = "http://www.astoniareborn.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "Invicta":
                        apiurl            = "https://www.a3invicta.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    default:
                        apiurl            = "http://ugaris.com/api/launcher.php";
                        supersecretstring = "";
                        break;
                    }
                    Account Changedacc = new Account();
                    Changedacc.Name          = AddAccWindow.TxtAccName.Text;
                    Changedacc.LoginId       = Int32.Parse(AddAccWindow.TxtAccId.Text);
                    Changedacc.Email         = AddAccWindow.TxtAccEmail.Text;
                    Changedacc.Password      = AddAccWindow.TxtAccPassword.Text;
                    Changedacc.CharacterList = GetAccountCharactersJson(string.Format("{0}?Login={1}&password={2}&sprsecret={3}", apiurl, AddAccWindow.TxtAccId.Text, AddAccWindow.TxtAccPassword.Text, supersecretstring));
                    Changedacc.Server        = AddAccWindow.CmbServer.Text;
                    Changedacc.AddedOn       = DateTime.Now;

                    accounts.Remove(EditAcc);
                    accounts.Add(Changedacc);
                }
                else
                {
                    logger("User Canceled");
                }
            }
            catch (Exception er)
            {
                logger(er.ToString());
            }
        }
Exemplo n.º 2
0
        private void BtnAddAccount_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AddAccount AddAccWindow = new AddAccount();
                AddAccWindow.Owner = this;
                AddAccWindow.ShowDialog();
                if (AddAccWindow.DialogResult.HasValue && AddAccWindow.DialogResult.Value)
                {
                    string apiurl            = "";
                    string supersecretstring = "";
                    switch (AddAccWindow.CmbServer.Text)
                    {
                    case "Ugaris":
                        apiurl            = "http://ugaris.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "A3Res":
                        apiurl            = "http://a3res.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "Reborn":
                        apiurl            = "http://www.astoniareborn.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    case "Invicta":
                        apiurl            = "https://www.a3invicta.com/api/launcher.php";
                        supersecretstring = "";
                        break;

                    default:
                        apiurl            = "http://ugaris.com/api/launcher.php";
                        supersecretstring = "";
                        break;
                    }
                    Account NewAccount = new Account();
                    NewAccount.CharacterList =
                        GetAccountCharactersJson(string.Format(
                                                     "{0}?Login={1}&password={2}&sprsecret={3}", apiurl,
                                                     AddAccWindow.TxtAccId.Text, AddAccWindow.TxtAccPassword.Text, supersecretstring));
                    NewAccount.LoginId  = Int32.Parse(AddAccWindow.TxtAccId.Text);
                    NewAccount.Password = AddAccWindow.TxtAccPassword.Text;
                    NewAccount.Name     = AddAccWindow.TxtAccName.Text;
                    NewAccount.Email    = AddAccWindow.TxtAccEmail.Text;
                    NewAccount.AddedOn  = DateTime.Now;
                    NewAccount.Server   = AddAccWindow.CmbServer.Text;

                    accounts.Add(NewAccount);
                }
                else
                {
                    MessageBox.Show("User clicked Cancel");
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show("You must use a number as Login ID");
                logger(ex.ToString());
            }
            catch (WebException er)
            {
                MessageBox.Show("There was an error with the API, Contact the server owner or check your internet connection");
                logger(er.ToString());
            }
            catch (Exception er)
            {
                MessageBox.Show("An error occured, please try again. If error persists please contact Server Owner. error: " + er);
                logger(er.ToString());
            }
        }