From 69f14ac2d21786b7846edf6e417f83c4fb4011fe Mon Sep 17 00:00:00 2001 From: rex706 Date: Wed, 8 Apr 2020 19:39:17 -0400 Subject: [PATCH] Copy profile url context menu item * Add account context menu item for copying the account profile url to the clipboard #82 * Clipboard error handling to better capture problems encountered by some users --- SAM/MainWindow.xaml.cs | 27 +++++++++++++++++++++++++-- SAM/SettingsWindow.xaml | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/SAM/MainWindow.xaml.cs b/SAM/MainWindow.xaml.cs index 4ffbdd6..13da359 100644 --- a/SAM/MainWindow.xaml.cs +++ b/SAM/MainWindow.xaml.cs @@ -342,7 +342,7 @@ private void LoadSettings() } } - //Load and validate saved window loaction. + //Load and validate saved window location. if (settings.File.KeyExists(SAMSettings.WINDOW_LEFT, SAMSettings.SECTION_LOCATION) && settings.File.KeyExists(SAMSettings.WINDOW_TOP, SAMSettings.SECTION_LOCATION)) { Left = Double.Parse(settings.File.Read(SAMSettings.WINDOW_LEFT, SAMSettings.SECTION_LOCATION)); @@ -1006,6 +1006,7 @@ private ContextMenu GenerateAccountContextMenu(Account account, int index) MenuItem clearTimeoutItem = new MenuItem(); MenuItem copyUsernameItem = new MenuItem(); MenuItem copyPasswordItem = new MenuItem(); + MenuItem copyProfileUrlItem = new MenuItem(); if (!Utils.AccountHasActiveTimeout(account)) { @@ -1020,6 +1021,7 @@ private ContextMenu GenerateAccountContextMenu(Account account, int index) clearTimeoutItem.Header = "Clear Timeout"; copyUsernameItem.Header = "Copy Username"; copyPasswordItem.Header = "Copy Password"; + copyProfileUrlItem.Header = "Copy Profile URL"; deleteItem.Click += delegate { DeleteEntry(index); }; editItem.Click += delegate { EditEntryAsync(index); }; @@ -1034,6 +1036,7 @@ private ContextMenu GenerateAccountContextMenu(Account account, int index) clearTimeoutItem.Click += delegate { AccountButtonClearTimeout_Click(index); }; copyUsernameItem.Click += delegate { CopyUsernameToClipboard(index); }; copyPasswordItem.Click += delegate { CopyPasswordToClipboard(index); }; + copyProfileUrlItem.Click += delegate { CopyProfileUrlToClipboard(index); }; accountContext.Items.Add(editItem); accountContext.Items.Add(deleteItem); @@ -1043,6 +1046,7 @@ private ContextMenu GenerateAccountContextMenu(Account account, int index) accountContext.Items.Add(clearTimeoutItem); accountContext.Items.Add(copyUsernameItem); accountContext.Items.Add(copyPasswordItem); + accountContext.Items.Add(copyProfileUrlItem); return accountContext; } @@ -1928,7 +1932,14 @@ private void ShowWindowButton_Click(object sender, RoutedEventArgs e) private void CopyUsernameToClipboard(int index) { - Clipboard.SetText(decryptedAccounts[index].Name); + try + { + Clipboard.SetText(decryptedAccounts[index].Name); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } } @@ -1944,6 +1955,18 @@ private void CopyPasswordToClipboard(int index) } } + private void CopyProfileUrlToClipboard(int index) + { + try + { + Clipboard.SetText(decryptedAccounts[index].ProfUrl); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } + #endregion private void ContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e) diff --git a/SAM/SettingsWindow.xaml b/SAM/SettingsWindow.xaml index aae87b0..adc419f 100644 --- a/SAM/SettingsWindow.xaml +++ b/SAM/SettingsWindow.xaml @@ -57,7 +57,7 @@ - +