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 10, 2023
1 parent 1eb7fd7 commit 503980f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pass-winmenu/src/Windows/EditWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
Title="" Height="350" Width="350" MinHeight="250" MinWidth="350" ResizeMode="CanResizeWithGrip"
Title="" Height="350" Width="430" MinHeight="250" MinWidth="350" ResizeMode="CanResizeWithGrip"
KeyUp="Window_KeyUp">
<Grid>
<DockPanel>
<GroupBox Header="Password generator" DockPanel.Dock="Top" VerticalAlignment="Top" Margin="5,15,5,0">
<StackPanel>
<Grid>
<TextBox x:Name="Password" Height="23" Margin="5,5,90,0" Padding="3,3,3,3" TextWrapping="Wrap" Text=""
<TextBox x:Name="Password" Height="23" Margin="5,5,175,0" Padding="3,3,3,3" TextWrapping="Wrap" Text=""
VerticalAlignment="Top" FontFamily="Consolas" />
<Button x:Name="Btn_Generate" Content="Generate" Margin="0,5,5,0" Click="Btn_Generate_Click"
<Button x:Name="Btn_Generate" Content="Generate" Margin="0,5,90,0" Click="Btn_Generate_Click"
HorizontalAlignment="Right" Width="80" Height="23" VerticalAlignment="Top" />
<Button x:Name="Btn_Replace" Content="Replace" Margin="0,5,5,0" Click="Btn_Replace_Click"
Width="80" Height="23" HorizontalAlignment="Right" />
</Grid>
<Grid Name="CharacterGroups" Margin="5,10,0,0" />
</StackPanel>
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.Replace(Environment.NewLine, "\n");
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 503980f

Please sign in to comment.