Пример #1
0
        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                UserPassword password = new UserPassword
                {
                    Username = lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[1].Text
                };

                if (password.ShowDialog() == DialogResult.OK)
                {
                    AWBProfiles.SetPassword(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text), password.GetPassword);
                }
            }
            finally
            {
                LoadProfiles();
            }
        }
Пример #2
0
        private void AWBProfilesForm_Load(object sender, EventArgs e)
        {
            string lua = AWBProfiles.LastUsedAccount;

            if (!string.IsNullOrEmpty(lua))
            {
                int id;
                int.TryParse(lua, out id);

                AWBProfile p = AWBProfiles.GetProfile(id);

                if (p == null)
                {
                    txtUsername.Text = lua;
                    return;
                }

                txtUsername.Text = (id > 0) ? p.Username : lua;
            }
        }
Пример #3
0
        private void btnQuickLogin_Click(object sender, EventArgs e)
        {
            string user     = txtUsername.Text;
            string password = txtPassword.Text;

            if (chkSaveProfile.Checked)
            {
                var profile = new AWBProfile {
                    Username = user
                };
                if (chkSavePassword.Checked)
                {
                    profile.Password = password;
                }
                AWBProfiles.AddEditProfile(profile);
            }

            AWBProfiles.LastUsedAccount = user;
            PerformLogin(user, password);
        }
Пример #4
0
        /// <summary>
        /// Login based on selected item on the form
        /// </summary>
        private void Login()
        {
            try
            {
                if (SelectedItem < 0)
                {
                    return;
                }

                Cursor = Cursors.WaitCursor;
                CurrentSettingsProfile =
                    string.IsNullOrEmpty(lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[3].Text)
                        ? ""
                        : lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[3].Text;

                if (lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[2].Text == "Yes")
                {//Get 'Saved' Password
                    PerformLogin(AWBProfiles.GetPassword(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text)));
                }
                else
                {//Get Password from User
                    UserPassword password = new UserPassword
                    {
                        Username = lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[1].Text
                    };

                    if (password.ShowDialog(this) == DialogResult.OK)
                    {
                        PerformLogin(password.GetPassword);
                    }
                }

                AWBProfiles.LastUsedAccount = lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text;

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
            }
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("The Username cannot be blank");
            }
            else
            {
                if (Editid == -1 && AWBProfiles.GetProfile(txtUsername.Text) != null)
                {
                    MessageBox.Show("Username \"" + txtUsername.Text + "\" already exists.", "Username exists");
                    return;
                }

                AWBProfile profile = new AWBProfile {
                    Username = txtUsername.Text
                };

                if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text))
                {
                    profile.Password = txtPassword.Text;
                }

                profile.DefaultSettings = txtPath.Text;

                int idUpload = AWBProfiles.GetIDOfUploadAccount();

                if (chkUseForUpload.Checked && (idUpload != -1) && (idUpload != Editid))
                {
                    AWBProfiles.SetOtherAccountsAsNotForUpload();
                }

                profile.UseForUpload = chkUseForUpload.Checked;
                profile.Notes        = txtNotes.Text;

                profile.ID = Editid;
                AWBProfiles.AddEditProfile(profile);

                DialogResult = DialogResult.Yes;
            }
        }
Пример #6
0
        /// <summary>
        /// Login based on selected item on the form
        /// </summary>
        private void login()
        {
            try
            {
                if (SelectedItem < 0)
                {
                    return;
                }

                Cursor = Cursors.WaitCursor;
                if (!string.IsNullOrEmpty(lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[3].Text))
                {
                    CurrentSettingsProfile = lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[3].Text;
                }
                else
                {
                    CurrentSettingsProfile = "";
                }

                if (lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[2].Text == "Yes")
                {//Get 'Saved' Password
                    browserLogin(AWBProfiles.GetPassword(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text)));
                }
                else
                {//Get Password from User
                    UserPassword password = new UserPassword();
                    password.SetText = "Enter password for " + lvAccounts.Items[lvAccounts.SelectedIndices[0]].SubItems[1].Text;

                    if (password.ShowDialog() == DialogResult.OK)
                    {
                        browserLogin(password.GetPassword);
                    }
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
            }
        }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("The Username cannot be blank");
            }
            else
            {
                // warn user if profile for entered user ID already exists
                if (Editid == -1 && AWBProfiles.GetProfile(txtUsername.Text) != null)
                {
                    if (MessageBox.Show("Username \"" + txtUsername.Text + "\" is already used in another profile. Are you sure you want to use this username again?",
                                        "Username already used in another profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }

                AWBProfile profile = new AWBProfile {
                    Username = txtUsername.Text
                };

                if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text))
                {
                    profile.Password = txtPassword.Text;
                }
                else
                {
                    profile.Password = "";
                }

                profile.DefaultSettings = txtPath.Text;
                profile.Notes           = txtNotes.Text;

                profile.ID = Editid;
                AWBProfiles.AddEditProfile(profile);

                DialogResult = DialogResult.Yes;
            }
        }
        /// <summary>
        /// Loads all the profiles onto the form
        /// </summary>
        private void LoadProfiles()
        {
            lvAccounts.BeginUpdate();
            lvAccounts.Items.Clear();

            foreach (AWBProfile profile in AWBProfiles.GetProfiles())
            {
                ListViewItem item = new ListViewItem(profile.ID.ToString());
                item.SubItems.Add(profile.Username);

                item.SubItems.Add(!string.IsNullOrEmpty(profile.Password) ? "Yes" : "No");

                item.SubItems.Add(profile.DefaultSettings);
                item.SubItems.Add(profile.Notes);

                lvAccounts.Items.Add(item);
            }

            UpdateUI();
            lvAccounts.ResizeColumns();
            lvAccounts.EndUpdate();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("The Username cannot be blank");
            }
            else
            {
                AWBProfile profile = new AWBProfile();

                profile.Username        = txtUsername.Text;
                profile.Password        = txtPassword.Text;
                profile.defaultsettings = txtPath.Text;

                int idUpload = AWBProfiles.GetIDOfUploadAccount();

                if (chkUseForUpload.Checked && idUpload != -1 && idUpload != editid)
                {
                    AWBProfiles.SetOtherAccountsAsNotForUpload();
                }

                profile.useforupload = chkUseForUpload.Checked;
                profile.notes        = txtNotes.Text;

                if (editid == -1)
                {
                    AWBProfiles.AddProfile(profile);
                }
                else
                {
                    profile.id = editid;
                    AWBProfiles.EditProfile(profile);
                }

                this.DialogResult = DialogResult.Yes;
            }
        }
Пример #10
0
 private void browserLogin(string Password)
 {
     browserLogin(AWBProfiles.GetUsername(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text)), Password);
 }
Пример #11
0
 private void PerformLogin(string password)
 {
     PerformLogin(AWBProfiles.GetUsername(int.Parse(lvAccounts.Items[lvAccounts.SelectedIndices[0]].Text)), password);
 }
Пример #12
0
        /// <summary>
        /// Publically accessible login, to allow calling of login via AWB startup parameters
        /// </summary>
        /// <param name="profileIdOrName">Profile ID to login to</param>
        public void Login(string profileIdOrName)
        {
            if (profileIdOrName.Length == 0)
            {
                return;
            }

            try
            {
                int        profileID;
                AWBProfile startupProfile = int.TryParse(profileIdOrName, out profileID) ? AWBProfiles.GetProfile(profileID) : AWBProfiles.GetProfile(profileIdOrName);

                if (startupProfile == null)
                {
                    MessageBox.Show(Parent, "Can't find user '" + profileIdOrName + "'.", "Command line error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (!string.IsNullOrEmpty(startupProfile.Password))
                {//Get 'Saved' Password
                    PerformLogin(startupProfile.Username, startupProfile.Password);
                }
                else
                {//Get Password from User
                    UserPassword password = new UserPassword
                    {
                        Username = startupProfile.Username
                    };

                    if (password.ShowDialog(this) == DialogResult.OK)
                    {
                        PerformLogin(startupProfile.Username, password.GetPassword);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
            }
        }