private void DecryptPassword() { string file = txtFilePath.Text; var password = txtBxPassword.Password; var salt = MasterConfigManager.getInstance().getPasswordSalt(); FileEncryptor.Decrypt(file, password, salt); listboxuseraccounts.ItemsSource = UserAccountsManager.getInstance().getUserAccounts(); }
public MainWindow() { SplashScreen sc = new SplashScreen(SPLASHSCRNIMGPATH); sc.Show(false); sc.Close(TimeSpan.FromSeconds(3)); System.Threading.Thread.Sleep(3000); sc = null; InitializeComponent(); this.DataContext = this; string projectDirectory = String.Empty; #if (DEBUG) //projectDirectory = @"C:\Program Files (x86)\AccountsManager"; projectDirectory = AppDomain.CurrentDomain.BaseDirectory; #else projectDirectory = AppDomain.CurrentDomain.BaseDirectory; #endif txtFilePath.Text = projectDirectory + ACCTSMGRFILEPATH; try { if (String.IsNullOrEmpty(projectDirectory + ACCTSMGRUSERSCONFIGPATH) || !File.Exists(projectDirectory + ACCTSMGRUSERSCONFIGPATH)) { throw new FileNotFoundException("Accounts Manager can't find specified config file " + projectDirectory + ACCTSMGRUSERSCONFIGPATH + " Application will now shutdown."); } if (String.IsNullOrEmpty(projectDirectory + ACCTSMGRFILEPATH) || !File.Exists(projectDirectory + ACCTSMGRFILEPATH)) { throw new FileNotFoundException("Accounts Manager can't find specified config file " + projectDirectory + ACCTSMGRFILEPATH + " Application will now shutdown."); } MasterConfigManager.getInstance(projectDirectory + ACCTSMGRUSERSCONFIGPATH); if (String.IsNullOrEmpty(MasterConfigManager.getInstance().getPasswordHash())) { System.Windows.MessageBox.Show("No master password has been set yet. " + Environment.NewLine + "Please enter a master password to be used to encrypt file."); SetMasterPasswordWindow smpw = new SetMasterPasswordWindow(); smpw.ShowDialog(); } if (MasterConfigManager.getInstance().getIsFileEncrypted() == false) { lblStatus.Visibility = Visibility.Hidden; } UserAccountsManager.getInstance(projectDirectory + ACCTSMGRFILEPATH); listboxuseraccounts.ItemsSource = UserAccountsManager.getInstance().getUserAccounts(); } catch (FileNotFoundException ex) { showErrorWindow(ex); } catch (FileFormatException ex) { showErrorWindow(ex); } }
private void btnClickChangeAccountInfo(object sender, RoutedEventArgs e) { UserAccountsManager.getInstance().CurrentUserAccount = listboxuseraccounts.SelectedItem as UserAccount; if (UserAccountsManager.getInstance().CurrentUserAccount == null) { System.Windows.MessageBox.Show("Please select an account first."); return; } ChangeAccountWindow caw = new ChangeAccountWindow(); caw.ChangeAccountInfoEvent += caw_ChangeAccountInfoEvent; caw.CurrentUserAccount = UserAccountsManager.getInstance().CurrentUserAccount; caw.Show(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtBoxSearch.Text)) { MessageBox.Show("Please enter something to search for"); return; } UserAccount ua = UserAccountsManager.getInstance().searchForUserAccount(txtBoxSearch.Text.ToLower()); if (ua == null) { MessageBox.Show("No matches found"); return; } if (SearchForUserAccountEvent != null) { SearchForUserAccountEvent(ua); this.Close(); } }
private void btnClickDelete(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtFilePath.Text)) { System.Windows.MessageBox.Show("Please select a file first"); return; } if (listboxuseraccounts.SelectedItem == null) { System.Windows.MessageBox.Show("Please select a user account first."); return; } try { UserAccount accountToBeDeleted = listboxuseraccounts.SelectedItem as UserAccount; UserAccountsManager.getInstance().deleteUserAccount(accountToBeDeleted); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); return; } }
private void caw_ChangeAccountInfoEvent(string domain, string username, string password) { UserAccountsManager.getInstance().editUserAccount(UserAccountsManager.getInstance().CurrentUserAccount, username, password, domain); listboxuseraccounts.ItemsSource = null; listboxuseraccounts.ItemsSource = UserAccountsManager.getInstance().getUserAccounts(); }
private void acw_AddUserAccountEvent(string user, string password, string domain) { listboxuseraccounts.ItemsSource = null; UserAccountsManager.getInstance().addUserAccount(user, password, domain); listboxuseraccounts.ItemsSource = UserAccountsManager.getInstance().getUserAccounts(); }
void sw_SearchForUserAccountEvent(UserAccount account) { listboxuseraccounts.SelectedItem = UserAccountsManager.getInstance().getUserAccount(account); listboxuseraccounts.ScrollIntoView(listboxuseraccounts.SelectedItem); }