67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using System;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Media;
|
|
using Project.Controller;
|
|
|
|
namespace Project.View;
|
|
|
|
public partial class NewEntry : Window
|
|
{
|
|
readonly AppController? _controller;
|
|
public NewEntry()
|
|
{
|
|
InitializeComponent();
|
|
this.SizeToContent = SizeToContent.Height;
|
|
}
|
|
|
|
public NewEntry(AppController controller)
|
|
{
|
|
InitializeComponent();
|
|
_controller = controller;
|
|
}
|
|
private void NewEntry_Cancel_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void NewEntry_Save_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
string? name = NameBox.Text;
|
|
string? username = UsernameMailBox.Text;
|
|
string? url = URLBox.Text;
|
|
string? pass = PassBox.Text;
|
|
string? note = NoteBox.Text;
|
|
if (InputSanitizer.EntryName(name) && InputSanitizer.Password(pass) && InputSanitizer.Userormail(username))
|
|
{
|
|
AppController.NewEntrySave(name, username, url, pass, note);
|
|
var newMenuView = new MenuView();
|
|
newMenuView.AfterSavingNewEntry();
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
var newPopUp = new EntryErrorPopUp();
|
|
NameBox.Text = string.Empty;
|
|
UsernameMailBox.Text = string.Empty;
|
|
URLBox.Text = String.Empty;
|
|
PassBox.Text = String.Empty;
|
|
NoteBox.Text = String.Empty;
|
|
newPopUp.Show();
|
|
}
|
|
|
|
}
|
|
|
|
private void NewEntry_ShowPW_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (NewentryPW.PasswordChar == '•')
|
|
{
|
|
NewentryPW.PasswordChar = '\0';
|
|
}
|
|
else
|
|
{
|
|
NewentryPW.PasswordChar = '•';
|
|
}
|
|
}
|
|
|
|
} |