Skip to content

Commit

Permalink
Copy profile url context menu item
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rex706 committed Apr 8, 2020
1 parent ee6d2da commit 69f14ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions SAM/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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))
{
Expand All @@ -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); };
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
}


Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SAM/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<CheckBox x:Name="HandleImeCheckBox" Content="Handle Microsoft IME" HorizontalAlignment="Left" Margin="17,153,0,0" VerticalAlignment="Top" ToolTip="Toggle Caps-Lock when automatically entering characters to handle IME for international keyboard settings." Checked="HandleImeCheckBox_Checked" Unchecked="HandleImeCheckBox_Unchecked"/>
<ComboBox x:Name="InputMethodSelectBox" HorizontalAlignment="Left" Margin="159,118,0,0" VerticalAlignment="Top" Width="154"/>
<Rectangle HorizontalAlignment="Left" Height="1" Margin="10,102,0,0" VerticalAlignment="Top" Width="318" Fill="{DynamicResource xctkForegoundBrush}"/>
<CheckBox x:Name="SteamGuardOnlyCheckBox" Content="2FA Only" HorizontalAlignment="Left" Margin="184,153,0,0" VerticalAlignment="Top" ToolTip="Only toggle Caps-Lock for the Steam Guard 2FA window." IsEnabled="False"/>
<CheckBox x:Name="SteamGuardOnlyCheckBox" Content="Steam Guard Only" HorizontalAlignment="Left" Margin="193,153,0,0" VerticalAlignment="Top" ToolTip="Only toggle Caps-Lock for the Steam Guard 2FA window." IsEnabled="False"/>
</Grid>
</TabItem>
<TabItem Header="Customize" mah:ControlsHelper.HeaderFontSize="{DynamicResource TabItemFontSize}">
Expand Down

0 comments on commit 69f14ac

Please sign in to comment.