mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-06 06:46:36 +03:00
add window for creating passwords
This commit is contained in:
@@ -23,4 +23,12 @@ public class UnlockedRepositoryViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
passStore = store;
|
passStore = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddEntry(PassStoreEntry entry)
|
||||||
|
{
|
||||||
|
if (entry is PassStoreEntryPassword)
|
||||||
|
{
|
||||||
|
(passStore.GetRootDirectory() as PassStoreEntryGroup)!.ChildEntries.Add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
48
src/KeyKeeper/Views/EntryEditWindow.axaml
Normal file
48
src/KeyKeeper/Views/EntryEditWindow.axaml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:KeyKeeper.ViewModels"
|
||||||
|
x:Class="KeyKeeper.Views.EntryEditWindow"
|
||||||
|
Title="Add Entry"
|
||||||
|
CanResize="False"
|
||||||
|
Width="540"
|
||||||
|
Height="270"
|
||||||
|
Background="White">
|
||||||
|
|
||||||
|
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto" ColumnDefinitions="*,*" Margin="5">
|
||||||
|
<TextBlock Text="Add New Password Entry" FontSize="20" HorizontalAlignment="Center"
|
||||||
|
Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
|
||||||
|
|
||||||
|
<TextBlock Text="Entry name:" HorizontalAlignment="Right"
|
||||||
|
Grid.Row="1" Grid.Column="0" Margin="5" />
|
||||||
|
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" />
|
||||||
|
|
||||||
|
<TextBlock Text="Username:" HorizontalAlignment="Right"
|
||||||
|
Grid.Row="2" Grid.Column="0" Margin="5" />
|
||||||
|
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" />
|
||||||
|
|
||||||
|
<TextBlock Text="Password:" HorizontalAlignment="Right"
|
||||||
|
Grid.Row="3" Grid.Column="0" Margin="5" />
|
||||||
|
<TextBox Grid.Row="3" Grid.Column="1" Margin="5" PasswordChar="*" />
|
||||||
|
|
||||||
|
<Button Content="Add!" HorizontalAlignment="Center"
|
||||||
|
Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2"
|
||||||
|
Background="#aaa" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Window.Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBox">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button /template/ ContentPresenter">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button:pointerover /template/ ContentPresenter">
|
||||||
|
<Setter Property="Foreground" Value="Black" />
|
||||||
|
<Setter Property="Background" Value="#ccc" />
|
||||||
|
</Style>
|
||||||
|
</Window.Styles>
|
||||||
|
</Window>
|
||||||
15
src/KeyKeeper/Views/EntryEditWindow.axaml.cs
Normal file
15
src/KeyKeeper/Views/EntryEditWindow.axaml.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using KeyKeeper.PasswordStore;
|
||||||
|
|
||||||
|
namespace KeyKeeper.Views;
|
||||||
|
|
||||||
|
public partial class EntryEditWindow: Window
|
||||||
|
{
|
||||||
|
public PassStoreEntryPassword? EditedEntry;
|
||||||
|
|
||||||
|
public EntryEditWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,13 @@
|
|||||||
Foreground="White"
|
Foreground="White"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Margin="0,20,0,0"/>
|
Margin="0,20,0,0"/>
|
||||||
|
|
||||||
|
<Button Content="New Entry"
|
||||||
|
Click="AddEntryButton_Click"
|
||||||
|
Height="30"
|
||||||
|
Foreground="White"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="0,20,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ListBox Width="580"
|
<ListBox Width="580"
|
||||||
Margin="210 10 10 10"
|
Margin="210 10 10 10"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
using KeyKeeper.ViewModels;
|
using KeyKeeper.ViewModels;
|
||||||
|
|
||||||
namespace KeyKeeper.Views;
|
namespace KeyKeeper.Views;
|
||||||
@@ -15,9 +17,21 @@ public partial class RepositoryWindow: Window
|
|||||||
await new ErrorDialog(message).ShowDialog(this);
|
await new ErrorDialog(message).ShowDialog(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnOpened(EventArgs e)
|
protected override void OnOpened(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnOpened(e);
|
base.OnOpened(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void AddEntryButton_Click(object sender, RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
if (DataContext is RepositoryWindowViewModel vm_ && vm_.CurrentPage is UnlockedRepositoryViewModel vm)
|
||||||
|
{
|
||||||
|
EntryEditWindow dialog = new();
|
||||||
|
await dialog.ShowDialog(this);
|
||||||
|
|
||||||
|
if (dialog.EditedEntry != null)
|
||||||
|
vm.AddEntry(dialog.EditedEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user