This commit is contained in:
parent
024570f0ed
commit
1f964b3148
6 changed files with 93 additions and 30 deletions
|
@ -7,7 +7,7 @@
|
|||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
<AssemblyVersion>1.0</AssemblyVersion>
|
||||
<FileVersion>1.0</FileVersion>
|
||||
<FileVersion>1.2</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
Background="Transparent"
|
||||
Height="400"
|
||||
Width="520"
|
||||
MinHeight="340"
|
||||
MinWidth="340"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="Cryptura">
|
||||
<!--ExtendClientAreaToDecorationsHint="True"-->
|
||||
|
@ -24,8 +26,10 @@
|
|||
</ExperimentalAcrylicBorder>
|
||||
|
||||
<Grid>
|
||||
<Border Grid.Row="0" Background="#80000000" CornerRadius="10" Margin="10" Name="ContentBorder">
|
||||
<ListBox Name="PasswordList" Background="Transparent" SelectionChanged="PasswordList_OnSelectionChanged">
|
||||
<Border Width="1" Background="#80000000" Margin="5,10" HorizontalAlignment="Center" ZIndex="1"/>
|
||||
<Border Background="#80000000" CornerRadius="10" Margin="10" Name="ContentBorder">
|
||||
<ListBox Name="PasswordList" Background="Transparent" SelectionChanged="PasswordList_OnSelectionChanged"
|
||||
Margin="10">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="local:Password">
|
||||
<Border Background="Transparent" Padding="10">
|
||||
|
@ -33,11 +37,22 @@
|
|||
<ContextMenu>
|
||||
<MenuItem Header="Add New Password" Click="CreatePassword_OnClick"/>
|
||||
<MenuItem Header="Remove Password" Click="DeletePassword_OnClick"/>
|
||||
<MenuItem Header="Hide/Unhide Passwords" Click="ToggleHide_OnClick"/>
|
||||
</ContextMenu>
|
||||
</Border.ContextMenu>
|
||||
<Grid ColumnDefinitions="*, *">
|
||||
<TextBlock Grid.Column="0" Foreground="White" Text="{Binding Name}" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="1" Foreground="White" Text="{Binding DisplayValue}" VerticalAlignment="Center"/>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Foreground="White"
|
||||
Text="{Binding Name}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0"/>
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Foreground="White"
|
||||
Text="{Binding DisplayValue}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="20,0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
@ -45,12 +60,15 @@
|
|||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Add New Password" Click="CreatePassword_OnClick"/>
|
||||
<MenuItem Header="Remove Password" Click="DeletePassword_OnClick"/>
|
||||
<MenuItem Header="Hide/Unhide Passwords" Click="ToggleHide_OnClick"/>
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#35313d"/>
|
||||
<Setter Property="Background" Value="#40000000"/>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem:pointerover /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="#20000000"></Setter>
|
||||
</Style>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
|
@ -58,23 +76,39 @@
|
|||
</Style>
|
||||
</ListBox.Styles>
|
||||
</ListBox>
|
||||
|
||||
</Border>
|
||||
<Border Background="#80000000" Name="AddPasswordContainer" IsVisible="False">
|
||||
<Border Margin="50" Background="#2b2f36" CornerRadius="10">
|
||||
<Border Background="#80000000" Name="AddPasswordContainer" IsVisible="False" PointerPressed="OuterBorder_OnPointerPressed" ZIndex="11">
|
||||
<Border Background="#2b2f36" CornerRadius="10" PointerPressed="InnerBorder_OnPointerPressed"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<StackPanel Spacing="10" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="20">
|
||||
<TextBlock Text="Name:" Margin="20,0"/>
|
||||
<TextBox Name="PasswordName" Margin="20,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" KeyDown="DialogKeyDown"/>
|
||||
<TextBox Name="PasswordName"
|
||||
Margin="20,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
KeyDown="DialogKeyDown"/>
|
||||
<TextBlock Text="Password:" Margin="20,0"/>
|
||||
<TextBox Name="PasswordValue" Margin="20,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" KeyDown="DialogKeyDown"/>
|
||||
<TextBox Name="PasswordValue"
|
||||
Margin="20,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
KeyDown="DialogKeyDown"
|
||||
PasswordChar="*"/>
|
||||
<TextBlock Text="Repeat Password:" Margin="20,0"/>
|
||||
<TextBox Name="PasswordRepeat" Margin="20,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" KeyDown="DialogKeyDown"/>
|
||||
<TextBox Name="PasswordRepeat"
|
||||
Margin="20,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
KeyDown="DialogKeyDown"
|
||||
PasswordChar="*"/>
|
||||
<TextBlock Name="ErrorTextBlock" IsVisible="False" HorizontalAlignment="Center" Foreground="Crimson"/>
|
||||
<Button Name="PasswordSave" Click="PasswordSave_OnClick" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Content="Confirm"/>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
</Border>
|
||||
</Grid>
|
||||
</Panel>
|
||||
|
|
|
@ -45,7 +45,8 @@ public partial class MainWindow : Window
|
|||
if (Path.GetExtension(file).ToLower() == ".wx")
|
||||
{
|
||||
Password pw = new Password(file);
|
||||
passwords.Add(pw);
|
||||
if(!String.IsNullOrEmpty(pw.Value))
|
||||
passwords.Add(pw);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -65,11 +66,7 @@ public partial class MainWindow : Window
|
|||
}
|
||||
}
|
||||
|
||||
private void Button_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
censorPasswords = !censorPasswords;
|
||||
FetchPasswords();
|
||||
}
|
||||
|
||||
|
||||
private void PasswordList_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
@ -83,12 +80,23 @@ public partial class MainWindow : Window
|
|||
|
||||
private void DeletePassword_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (PasswordList.SelectedItem is Password password)
|
||||
{
|
||||
File.Delete(password.WxFile.Path);
|
||||
FetchPasswords();
|
||||
}
|
||||
|
||||
}
|
||||
private void ToggleHide_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
censorPasswords = !censorPasswords;
|
||||
FetchPasswords();
|
||||
}
|
||||
|
||||
private void ErrorMessage(string message)
|
||||
{
|
||||
//TODO: Show Error in GUI
|
||||
ErrorTextBlock.Text = message;
|
||||
ErrorTextBlock.IsVisible = true;
|
||||
}
|
||||
|
||||
private void SavePassword()
|
||||
|
@ -110,7 +118,17 @@ public partial class MainWindow : Window
|
|||
}
|
||||
Password newPassword = new Password(PasswordName.Text, PasswordValue.Text);
|
||||
FetchPasswords();
|
||||
ResetPasswordModal();
|
||||
}
|
||||
|
||||
private void ResetPasswordModal()
|
||||
{
|
||||
AddPasswordContainer.IsVisible = false;
|
||||
PasswordName.Text = "";
|
||||
PasswordValue.Text = "";
|
||||
PasswordRepeat.Text = "";
|
||||
ErrorTextBlock.IsVisible = false;
|
||||
|
||||
}
|
||||
|
||||
private void PasswordSave_OnClick(object? sender, RoutedEventArgs e)
|
||||
|
@ -125,4 +143,13 @@ public partial class MainWindow : Window
|
|||
SavePassword();
|
||||
}
|
||||
}
|
||||
|
||||
private void OuterBorder_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
ResetPasswordModal();
|
||||
}
|
||||
private void InnerBorder_OnPointerPressed(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class Password
|
|||
|
||||
public string DisplayValue
|
||||
{
|
||||
get => MainWindow.censorPasswords ? Value : CensoredValue;
|
||||
get => MainWindow.censorPasswords ? CensoredValue : Value;
|
||||
}
|
||||
|
||||
public Password(string name, string value)
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
Title="Cryptura"
|
||||
CanResize="False"
|
||||
Width="430"
|
||||
Height="170">
|
||||
Height="170"
|
||||
Loaded="Control_OnLoaded"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Panel>
|
||||
<ExperimentalAcrylicBorder IsHitTestVisible="False" Name="AcrylicBorderObject">
|
||||
<ExperimentalAcrylicBorder.Material>
|
||||
|
@ -22,7 +24,6 @@
|
|||
</ExperimentalAcrylicBorder>
|
||||
<Border Background="#80000000" CornerRadius="10" Margin="10" Name="ContentBorder">
|
||||
<StackPanel Spacing="10" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="20">
|
||||
|
||||
<TextBlock Text="Enter Master password" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBox Name="MasterPasswordBox" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" PasswordChar="*" KeyDown="MasterPasswordBox_OnKeyDown"/>
|
||||
<Button Name="MasterPasswordConfirm" Content="Confirm" Click="MasterPasswordConfirm_OnClick" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
|
|
|
@ -32,10 +32,6 @@ public partial class PasswordWindow : Window
|
|||
AdjustThemeToPlatform();
|
||||
}
|
||||
|
||||
private void WindowBase_OnResized(object? sender, WindowResizedEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.ClientSize);
|
||||
}
|
||||
|
||||
private void ConfirmPassword()
|
||||
{
|
||||
|
@ -54,4 +50,9 @@ public partial class PasswordWindow : Window
|
|||
ConfirmPassword();
|
||||
}
|
||||
}
|
||||
|
||||
private void Control_OnLoaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
MasterPasswordBox.Focus();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue