示例#1
0
        /// <summary>
        /// Removes a selected combobox item from memory and overwrites the file with the new data.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(cbWebsites.Text))
            {
                var descriptionName = cbWebsites.Text;
                UserSessionData.UserInformationCollection.Remove(UserSessionData.UserInformationCollection.Where(x => x.Description == cbWebsites.Text).FirstOrDefault());
                UserSessionData.SaveData();
                UserSessionData.LoadData();
                BindDescriptionMenu();
                notification = new DialogBox(descriptionName + " has been successfully removed!", MetroFramework.MetroColorStyle.Green, this.DesktopLocation, "Information Removed");
                notification.Show();
            }
            else
            {
                notification = new DialogBox("There must be a website selected to remove data information for.", MetroFramework.MetroColorStyle.Red, this.DesktopLocation, "No Website Selected");
                notification.Show();
            }

            if (!UserSessionData.UserInformationCollection.Any())
            {
                if (notification != null)
                {
                    notification.Close();
                }

                PasswordManagement.SelectTab(InfoAddTab);
                notification = new DialogBox("All websites have been removed. Add new ones if you would like!", this.Style, this.DesktopLocation);
                notification.Show();
            }
        }
示例#2
0
        /// <summary>
        /// Updates the user information collection in memory and writes to it's respective file
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbWebDescription.Text) && !string.IsNullOrEmpty(tbNewPassword.Text) && !string.IsNullOrEmpty(tbConfirmNewPassword.Text))
            {
                var descriptionName = tbWebDescription.Text;
                var siteList        = UserSessionData.UserInformationCollection.Select(x => x.Description);
                if (!siteList.Contains(tbWebDescription.Text))
                {
                    if (tbNewPassword.Text.Equals(tbConfirmNewPassword.Text))
                    {
                        UserData.UserInformation newInfo = new UserData.UserInformation();
                        newInfo.Description = tbWebDescription.Text;
                        newInfo.Password    = tbConfirmNewPassword.Text;
                        UserSessionData.UserInformationCollection.Add(newInfo);
                        UserSessionData.LoadOrCreateEncryptionKey();
                        UserSessionData.SaveData();
                        UserSessionData.LoadData();
                        BindDescriptionMenu();

                        if (cbRedirect.Checked)
                        {
                            PasswordManagement.SelectTab(InfoManagementTab);
                        }
                        else
                        {
                            ClearApplicationData();
                        }

                        notification = new DialogBox("Information for: " + descriptionName + " has been successfully added!", MetroFramework.MetroColorStyle.Green, this.DesktopLocation, "Information Saved");
                        notification.Show();
                    }
                    else
                    {
                        notification = new DialogBox("Your passwords must patch.", MetroFramework.MetroColorStyle.Red, this.DesktopLocation, "Error");
                        notification.Show();
                    }
                }
                else
                {
                    notification = new DialogBox(descriptionName + " already exists.", MetroFramework.MetroColorStyle.Red, this.DesktopLocation, "Error");
                    notification.Show();
                }
            }
            else
            {
                notification = new DialogBox("A Description, Password and Confirmation Password are needed.", MetroFramework.MetroColorStyle.Red, this.DesktopLocation, "Error");
                notification.Show();
            }
        }
示例#3
0
 /// <summary>
 /// Resets the application and data to first time use. All passwords and keys are deleted.
 /// Files are recreated on selection screen.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void btnReset_Click(object sender, EventArgs e)
 {
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.WorkInformation);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.PersonalInformation);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.SharedInformation);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.SocialMediaInformation);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.OtherInformation);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.Key);
     File.Delete(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.InitializationVector);
     ClearApplicationData();
     InitialDisplayModeSelected = false;
     PasswordManagement.DisableTab(InfoManagementTab);
     PasswordManagement.DisableTab(InfoAddTab);
     PasswordManagement.SelectTab(InfoTypeSelectionTab);
     notification = new DialogBox("All data has been Reset! A new key has been generated. Please do not modify it.", MetroFramework.MetroColorStyle.Silver, this.DesktopLocation, "Reset");
     notification.Show();
 }
示例#4
0
        /// <summary>
        /// Loads /creates encryption keys and file data based on what was selected
        /// on the selection screen
        /// </summary>
        /// <param name="sender">The selected metro tile.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void SetDisplayMode(object sender, EventArgs e)
        {
            if (!InitialDisplayModeSelected)
            {
                PasswordManagement.EnableTab(InfoManagementTab);
                PasswordManagement.EnableTab(InfoAddTab);
            }

            if (notification != null)
            {
                notification.Close();
            }

            ClearApplicationData();
            cbWebsites.DataSource = null;
            var tile = (MetroFramework.Controls.MetroTile)sender;

            switch (tile.Name)
            {
            case "mtWork":
                this.Text  = Constants.InformationSelectionScreen.WorkManagement;
                this.Style = MetroFramework.MetroColorStyle.Default;
                Display    = new DisplayMode(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.WorkInformation);
                break;

            case "mtPersonal":
                this.Text  = Constants.InformationSelectionScreen.PersonalManagement;
                this.Style = MetroFramework.MetroColorStyle.Yellow;
                Display    = new DisplayMode(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.PersonalInformation);
                break;

            case "mtSocialMedia":
                this.Text  = Constants.InformationSelectionScreen.SocialMediaManagement;
                this.Style = MetroFramework.MetroColorStyle.Purple;
                Display    = new DisplayMode(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.SocialMediaInformation);
                break;

            case "mtSharedContent":
                this.Text  = Constants.InformationSelectionScreen.SharedContentManagement;
                this.Style = MetroFramework.MetroColorStyle.Green;
                Display    = new DisplayMode(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.SharedInformation);
                break;

            case "mtOther":
                this.Text  = Constants.InformationSelectionScreen.OtherManagement;
                this.Style = MetroFramework.MetroColorStyle.Orange;
                Display    = new DisplayMode(AppDomain.CurrentDomain.BaseDirectory + Constants.FilePaths.OtherInformation);
                break;

            default:
                break;
            }

            this.Refresh();
            UserSessionData = new UserData(Display);
            if (UserSessionData.LoadOrCreateEncryptionKey())
            {
                if (UserSessionData.LoadData())
                {
                    PasswordManagement.SelectTab(InfoManagementTab);
                    BindDescriptionMenu();
                }
                else
                {
                    PasswordManagement.SelectTab(InfoAddTab);
                    notification = new DialogBox(Constants.InformationSelectionScreen.NoData, this.Style, this.DesktopLocation);
                    notification.Show();
                }
            }
            else
            {
                PasswordManagement.SelectTab(InfoAddTab);
                notification = new DialogBox(Constants.InformationSelectionScreen.FirstTimeUseMessage, this.Style, this.DesktopLocation);
                notification.Show();
            }
        }
示例#5
0
 /// <summary>
 /// Resets the app settings to default and redirects the user from the Add tab
 /// to the selection tab.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void btnCancel_Click(object sender, EventArgs e)
 {
     ClearApplicationData();
     PasswordManagement.SelectTab(InfoTypeSelectionTab);
 }