Beispiel #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (DialogUtility.ShowConfirmDialog(this, "Delete?", "Are you sure you want to delete this account?"))
     {
         DeleteAccount();
     }
 }
Beispiel #2
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_isNew)
            {
                if (!string.IsNullOrWhiteSpace(_fileName) && !string.IsNullOrWhiteSpace(_password))
                {
                    SaveAccountCollection();
                    _isDirty = false;
                    return;
                }

                _fileName = null;
                _password = null;
                FileDialogResult <string> fileResult = DialogUtility.ShowSaveFileDialog(this, FILE_FILTER, _initialFileDialogDirectory);
                if (fileResult.Result == DialogResult.OK && fileResult.ResultObject != null)
                {
                    _fileName = fileResult.ResultObject;
                    FormDialogResult <string> passwordResult = DialogUtility.ShowPasswordDialog(this);
                    if (passwordResult.Result == DialogResult.OK && passwordResult.ResultObject != null)
                    {
                        _password = passwordResult.ResultObject;
                        SaveAccountCollection();
                        _isDirty = false;
                    }
                }
            }
            else
            {
                SaveAccountCollection();
                _isDirty = false;
            }
        }
Beispiel #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FormDialogResult <Account> result = DialogUtility.ShowAccountDialog(this, _accountCollection, "Add Account", "Add", true);

            if (result.Result == DialogResult.OK && result.ResultObject != null)
            {
                _accountCollection.Add(result.ResultObject);
                UpdateFileChangedStatus(true);
                SetListDataSource();
            }
        }
Beispiel #4
0
 private bool CanExit()
 {
     if (_accountCollection != null && _isDirty)
     {
         bool result = DialogUtility.ShowConfirmDialog(this, "Exit?", "Changes have not been saved.  Are you sure you want to exit?");
         return(result);
     }
     else
     {
         return(true);
     }
 }
Beispiel #5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            _okButtonClicked = false;
            if (string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                DialogUtility.ShowErrorMessageBox(this, "Password Required", "A password is required.");
                return;
            }

            txtPassword.Text  = txtPassword.Text;
            this.DialogResult = DialogResult.OK;
            _okButtonClicked  = true;
            this.Close();
        }
Beispiel #6
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int selectedIndex = lstAccounts.SelectedIndex;

            if (selectedIndex > -1)
            {
                Account selectedAccount           = GetAccountFromIndex(selectedIndex);
                FormDialogResult <Account> result = DialogUtility.ShowAccountDialog(this, _accountCollection, "Edit Account", "Edit", false, selectedAccount);
                if (result.Result == DialogResult.OK && result.ResultObject != null)
                {
                    UpdateExistingAccount(result.ResultObject);
                    UpdateFileChangedStatus(true);
                    SetListDataSource();
                }
            }
        }
Beispiel #7
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            _okButtonClicked = false;
            List <string> errorMessages = new List <string>();
            bool          isValid       = ValidateAccountForm(out errorMessages);

            if (!isValid)
            {
                DialogUtility.ShowErrorMessageBox(this, "Validation Error", errorMessages);
                return;
            }

            this.AccountObject = GetAccountFromForm();
            this.DialogResult  = DialogResult.OK;
            _okButtonClicked   = true;
            this.Close();
        }
Beispiel #8
0
        private AccountCollection OpenAccountCollection()
        {
            AccountCollection collection = null;

            FileDialogResult <string> fileResult = DialogUtility.ShowOpenFileDialog(this, FILE_FILTER, _initialFileDialogDirectory);

            if (fileResult.Result != DialogResult.OK && fileResult.ResultObject == null)
            {
                return(null);
            }
            _fileName = fileResult.ResultObject;

            FormDialogResult <string> passwordResult = DialogUtility.ShowPasswordDialog(this);

            if (passwordResult.Result != DialogResult.OK && passwordResult.ResultObject == null)
            {
                return(null);
            }
            _password = passwordResult.ResultObject;

            IFactory factory = FormFactory.GetFactory(_password, _appSettings.Value.IV, _appSettings.Value.Salt);
            IStorage storage = factory.GetStorage();

            ActionList actionList = factory.GetActionList();

            try
            {
                string serialized = storage.RetrieveData(_fileName);
                collection = actionList.ReverseActions <AccountCollection>(serialized);
            }
            catch (DeserializationException)
            {
                DialogUtility.ShowErrorMessageBox(this, "Error", "Incorrect password.");
            }

            return(collection);
        }