Skip to content

Commit

Permalink
Add a password replacing button to EditWindow (issue #84)
Browse files Browse the repository at this point in the history
  • Loading branch information
scerzh committed Apr 6, 2023
1 parent c3924fa commit 611ce64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pass-winmenu/src/Windows/EditWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
<Grid Name="CharacterGroups" Margin="5,10,0,0" />
</StackPanel>
</GroupBox>
<Label x:Name="Lbl_ExtraContent" DockPanel.Dock="Top" Content="Password file contents" Margin="10,0,10,0"
VerticalAlignment="Top" />
<Grid DockPanel.Dock="Top">
<Label x:Name="Lbl_ExtraContent" Content="Password file contents" Margin="10,3,10,3"
HorizontalAlignment="Left" />
<Button x:Name="Btn_Replace" Content="Replace" Margin="10,3,16,3" Click="Btn_Replace_Click"
Width="80" Height="23" HorizontalAlignment="Right" />
</Grid>
<Grid DockPanel.Dock="Top">
<TextBox x:Name="PasswordContent" Margin="10,10,10,45" Padding="3,3,3,3" TextWrapping="Wrap" AcceptsReturn="True"
AcceptsTab="True" CaretIndex="10" FontFamily="Consolas" GotFocus="HandlePasswordContentFocus"
Expand Down
7 changes: 7 additions & 0 deletions pass-winmenu/src/Windows/EditWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ private void Btn_Generate_Click(object sender, RoutedEventArgs e)
Password.Text = passwordGenerator.GeneratePassword();
}

private void Btn_Replace_Click(object sender, RoutedEventArgs e)
{
var content = PasswordContent.Text;
var index = content.IndexOf('\n');
PasswordContent.Text = index == -1 ? Password.Text : Password.Text + content.Remove(0, index);
}

private void Btn_OK_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
Expand Down

0 comments on commit 611ce64

Please sign in to comment.