new ui and added another error window for wrong login

This commit is contained in:
Taarly 2025-06-30 16:32:06 +02:00
parent d29e6b8767
commit ad25e8c849
12 changed files with 458 additions and 237 deletions

View File

@ -5,9 +5,9 @@ namespace Project.Persistence;
public partial class SQLite
{
//filepath for home-pc:
private static string _dbPath = "C:/Users/Soi/Desktop/keywi.db";
//private static string _dbPath = "C:/Users/Soi/Desktop/keywi.db";
//filepath for work-laptop:
//private static string _dbPath = "C:/Users/lowns/Desktop/keywi.db";
private static string _dbPath = "C:/Users/lowns/Desktop/keywi.db";
//KLASSENVARIABLEN ERSTELLEN
//private static string loginname;

View File

@ -2,50 +2,74 @@
x:Class="Project.View.LoginPage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Background="SandyBrown">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Image
Height="400"
Source="avares://Project.View/Images/keywi_logo_2.png"
Width="400" />
</StackPanel>
<StackPanel
HorizontalAlignment="Center"
Orientation="Vertical"
VerticalAlignment="Center">
<TextBlock>Your Login Name:</TextBlock>
<TextBox
TextWrapping="Wrap"
Watermark="Login-Name"
x:Name="LoginNameBox" />
<TextBlock>Password:</TextBlock>
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="Width" Value="200" />
<Setter Property="Height" Value="40" />
<Setter Property="CornerRadius" Value="20" />
<Setter Property="Margin" Value="0,8" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#4CAF50" />
<Setter Property="Foreground" Value="White" />
</Style>
</UserControl.Styles>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="LightGray" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<TextBox
PasswordChar="*"
TextWrapping="Wrap"
Watermark="Password"
x:Name="LoginPasswordBox" />
<Button
BorderBrush="Black"
BorderThickness="1"
Click="LoginButtonOnClick"
HorizontalAlignment="Center"
Margin="20"
Name="ConfirmButton">
LOGIN
</Button>
<Button
BorderBrush="Black"
BorderThickness="1"
Click="NewUserButtonOnClick"
HorizontalAlignment="Center"
Margin="20"
Name="NewUserButton">
Create New User
</Button>
</StackPanel>
<Border
Background="White"
BoxShadow="0 4 8 0 #40000000"
CornerRadius="8"
Padding="20"
Width="400">
<StackPanel>
<Image
Height="150"
Margin="0,0,0,20"
Source="avares://Project.View/Images/keywi_logo_2.png"
Width="150" />
<TextBlock
FontSize="24"
FontWeight="Bold"
HorizontalAlignment="Center"
Margin="0,0,0,20"
Text="Login-Page" />
<TextBlock Text="Username:" />
<TextBox
TextWrapping="Wrap"
Watermark="Your Username"
x:Name="LoginNameBox" />
<TextBlock Text="Password:" />
<TextBox
PasswordChar="•"
TextWrapping="Wrap"
Watermark="Enter password"
x:Name="LoginPasswordBox" />
<Button Click="LoginButtonOnClick" Name="ConfirmButton">
Login
</Button>
<Button
Background="#FF9800"
Click="NewUserButtonOnClick"
Name="NewUserButton">
New User
</Button>
</StackPanel>
</Border>
</Grid>
</UserControl>

View File

@ -25,7 +25,7 @@ public partial class LoginPage : UserControl
string? loginName = LoginNameBox.Text ?? string.Empty;
string? loginPassword = LoginPasswordBox.Text ?? string.Empty;
bool allowLogin = AppController.CompareLogin(loginName, loginPassword);
var newPopUp = new PopUp();
var newPopUp = new LoginErrorPopUp();
if (allowLogin)
{
//show menuview

View File

@ -0,0 +1,56 @@
<Window
SizeToContent="Height"
Title="WARNING"
Width="500"
WindowStartupLocation="CenterOwner"
x:Class="Project.View.LoginErrorPopUp"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Styles>
<Style Selector="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="Gray" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="0,5" />
</Style>
<Style Selector="Button">
<Setter Property="Width" Value="120" />
<Setter Property="Height" Value="40" />
<Setter Property="CornerRadius" Value="20" />
<Setter Property="Margin" Value="0,15,0,0" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#4CAF50" />
<Setter Property="Foreground" Value="White" />
</Style>
</Window.Styles>
<Grid Background="#F5F5F5">
<Border
Background="White"
BoxShadow="0 4 8 0 #40000000"
CornerRadius="8"
Margin="15">
<ScrollViewer>
<StackPanel Margin="20" MaxWidth="450">
<TextBlock
FontSize="24"
FontWeight="Bold"
Margin="0,0,0,15"
Text="⚠️ Warning" />
<TextBlock Text="One or more entries are wrong or missing." />
<TextBlock Text="Your username and password do not match." />
<Button
Click="LoginError_Click"
Content="OK"
Margin="0,15,0,5" />
</StackPanel>
</ScrollViewer>
</Border>
</Grid>
</Window>

View File

@ -0,0 +1,22 @@
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media;
using Project.Controller;
using Project.Model;
using Project.Persistence;
namespace Project.View;
public partial class LoginErrorPopUp : Window
{
public LoginErrorPopUp()
{
InitializeComponent();
}
private void LoginError_Click(object? sender, RoutedEventArgs e)
{
Close();
}
}

View File

@ -2,103 +2,114 @@
x:Class="Project.View.MenuView"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="16" />
<Setter Property="Margin" Value="0,10" />
</Style>
<Style Selector="TextBox">
<Setter Property="Height" Value="35" />
<Setter Property="Margin" Value="0,5,0,10" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
<Style Selector="Button.icon">
<Setter Property="Width" Value="35" />
<Setter Property="Height" Value="35" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Margin" Value="5,0" />
</Style>
</UserControl.Styles>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="250" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ScrollViewer
Grid.Column="0"
Margin="0,0,0,40"
VerticalScrollBarVisibility="Auto">
<!-- left column -->
<Border Background="#F5F5F5" BoxShadow="2 0 10 0 #20000000">
<Grid>
<ScrollViewer Margin="0,0,0,60" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="10" x:Name="entriesContainer" />
</ScrollViewer>
<StackPanel x:Name="entriesContainer">
</StackPanel>
</ScrollViewer>
<Button
Click="NewEntryButton_OnClick"
Content="+"
HorizontalAlignment="Left"
Name="NewEntryButton"
VerticalAlignment="Bottom" />
<Border Background="RosyBrown" Grid.Column="1">
<StackPanel Orientation="Horizontal" x:Name="ShowEntryDetails">
<StackPanel Margin="20,20,100,20" Orientation="Vertical">
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Name:" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Login-Name:" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="URL:" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Password:" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Note:" />
</StackPanel>
<StackPanel Margin="20,20,20,20" Orientation="Vertical">
<TextBox
Height="30"
Margin="20"
Text="THE NAME OF YOUR SAVED LOGIN"
TextWrapping="Wrap" />
<TextBox
Height="30"
Margin="20"
Text="YOUR LOGIN NAME ON THIS PAGE"
TextWrapping="Wrap" />
<TextBox
Height="30"
Margin="20"
Text="THE URL TO YOUR PAGE"
TextWrapping="Wrap" />
<StackPanel Orientation="Horizontal">
<TextBox
Height="30"
Margin="20"
PasswordChar="*"
Text="PASSWORT"
TextWrapping="Wrap" />
<Button
BorderBrush="Black"
BorderThickness="1"
Content="X"
Name="copyPassword" />
<Button
BorderBrush="Black"
BorderThickness="1"
Content="X"
Name="showPassword" />
</StackPanel>
<TextBox
Height="150"
Margin="20"
Text="YOUR NOTES"
TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
<Button
Background="Red"
Content="-"
CornerRadius="22"
FontSize="24"
Foreground="White"
Height="45"
HorizontalAlignment="Center"
IsEnabled="False"
Margin="0,0,-50,20"
VerticalAlignment="Bottom"
Width="45"
x:Name="DeleteButton" />
<Button
Background="#4CAF50"
Click="NewEntryButton_OnClick"
Content="+"
CornerRadius="22"
FontSize="24"
Foreground="White"
Height="45"
HorizontalAlignment="Right"
Margin="0,0,20,20"
VerticalAlignment="Bottom"
Width="45"
x:Name="NewEntryButton" />
</Grid>
</Border>
<!-- Right column -->
<Border Background="White" Grid.Column="1">
<StackPanel Margin="40" x:Name="ShowEntryDetails">
<Grid ColumnDefinitions="150,*">
<!-- Labels -->
<StackPanel Grid.Column="0">
<TextBlock FontWeight="SemiBold" Text="Name:" />
<TextBlock FontWeight="SemiBold" Text="Login-Name:" />
<TextBlock FontWeight="SemiBold" Text="URL:" />
<TextBlock FontWeight="SemiBold" Text="Password:" />
<TextBlock FontWeight="SemiBold" Text="Note:" />
</StackPanel>
<!-- entry fields -->
<StackPanel Grid.Column="1">
<TextBox Text="THE NAME OF YOUR SAVED LOGIN" />
<TextBox Text="YOUR LOGIN NAME ON THIS PAGE" />
<TextBox Text="THE URL TO YOUR PAGE" />
<StackPanel Orientation="Horizontal">
<TextBox
PasswordChar="•"
Text="PASSWORT"
Width="250" />
<Button
Classes="icon"
Content="📋"
ToolTip.Tip="Passwort kopieren"
x:Name="copyPassword" />
<Button
Classes="icon"
Content="👁"
ToolTip.Tip="Passwort anzeigen"
x:Name="showPassword" />
</StackPanel>
<TextBox
AcceptsReturn="True"
Height="150"
Text="YOUR NOTES" />
</StackPanel>
</Grid>
</StackPanel>
</Border>
</Grid>
</UserControl>

View File

@ -45,7 +45,8 @@ public partial class MenuView : Window
Content = entry.Name, // Display the entry name on the button
Margin = new Thickness(5),
Padding = new Thickness(10),
Width = 200
Width = 200,
Background = Brushes.SlateGray,
};
// add click handler for the button
button.Click += (object? sender, Avalonia.Interactivity.RoutedEventArgs e) => EntryDetails(entry);

View File

@ -4,73 +4,110 @@
x:Class="Project.View.NewEntry"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Border Background="SaddleBrown">
<UserControl.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="14" />
<Setter Property="FontWeight" Value="Medium" />
<Setter Property="Margin" Value="0,10,0,5" />
</Style>
<Style Selector="TextBox">
<Setter Property="Height" Value="40" />
<Setter Property="Margin" Value="0,0,0,10" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<StackPanel Orientation="Vertical">
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Text="Name:" />
<TextBox TextWrapping="Wrap" Watermark="Name:" x:Name="NameBox"/>
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Text="Username/Email:" />
<TextBox TextWrapping="Wrap" Watermark="Username/Email" x:Name="UsernameMailBox"/>
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="URL:" />
<TextBox TextWrapping="Wrap" Watermark="E-Mail" x:Name="URLBox"/>
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Password:" />
<StackPanel Orientation="Horizontal">
</Style>
<Style Selector="Button">
<Setter Property="Height" Value="35" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Margin" Value="5" />
<Setter Property="Padding" Value="15,0" />
</Style>
</UserControl.Styles>
<Border
Background="White"
BoxShadow="0 4 8 0 #40000000"
CornerRadius="8"
Margin="10">
<Grid Margin="20">
<StackPanel>
<TextBlock
FontSize="24"
FontWeight="Bold"
Foreground="Gray"
HorizontalAlignment="Center"
Margin="0,0,0,20"
Text="New Entry" />
<TextBlock Text="Name:" />
<TextBox Watermark="Enter Name" x:Name="NameBox" />
<TextBlock Text="Username/E-Mail:" />
<TextBox Watermark="Enter username or email" x:Name="UsernameMailBox" />
<TextBlock Text="URL:" />
<TextBox Watermark="Enter URL" x:Name="URLBox" />
<TextBlock Text="Password:" />
<Grid ColumnDefinitions="*, Auto, Auto">
<TextBox
Grid.Column="0"
Name="NewentryPW"
PasswordChar="*"
Watermark="Password" x:Name="PassBox"/>
PasswordChar="•"
Watermark="Enter password"
x:Name="PassBox" />
<Button
BorderBrush="Black"
BorderThickness="1"
Content="Generate Secure Password (WIP)"
Name="newentry_generate_password" />
Background="#4CAF50"
Foreground="White"
Grid.Column="1"
IsEnabled="False"
Name="newentry_generate_password"
ToolTip.Tip="Generate secure password (WORK IN PROGRESS)">
🔒
</Button>
<Button
BorderBrush="Black"
BorderThickness="1"
Background="#607D8B"
Click="NewEntry_ShowPW_Click"
Content="👁"
Foreground="White"
Grid.Column="2"
Name="newentry_show_password" />
</StackPanel>
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Text="Note:" />
<TextBox TextWrapping="Wrap" Watermark="Note" x:Name="NoteBox"/>
<StackPanel Orientation="Horizontal">
</Grid>
<TextBlock Text="Note:" />
<TextBox
AcceptsReturn="True"
Height="80"
Watermark="Your note:"
x:Name="NoteBox" />
<StackPanel
HorizontalAlignment="Center"
Margin="0,20,0,0"
Orientation="Horizontal">
<Button
BorderBrush="Black"
BorderThickness="1"
Click="NewEntry_Cancel_Click"
Content="X"
Name="newentry_cancel_button" />
<Button
BorderBrush="Black"
BorderThickness="1"
Background="#4CAF50"
Click="NewEntry_Save_Click"
Content="✓"
Content="Save"
Foreground="White"
Name="newentry_save_button" />
<Button
Background="#FF5722"
Click="NewEntry_Cancel_Click"
Content="Cancel"
Foreground="White"
Name="newentry_cancel_button" />
</StackPanel>
</StackPanel>
</Border>
</Grid>
</Grid>
</Border>
</UserControl>

View File

@ -1,57 +1,85 @@
<UserControl
Height="500"
Width="350"
Height="600"
Width="400"
x:Class="Project.View.NewLogin"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Styles>
<Style Selector="TextBlock">
<Setter Property="Margin" Value="0,5" />
<Setter Property="FontSize" Value="14" />
<Setter Property="FontWeight" Value="Medium" />
</Style>
<Style Selector="TextBox">
<Setter Property="Width" Value="250" />
<Setter Property="Margin" Value="0,5,0,15" />
<Setter Property="CornerRadius" Value="4" />
</Style>
<Style Selector="Button">
<Setter Property="Width" Value="120" />
<Setter Property="Height" Value="40" />
<Setter Property="CornerRadius" Value="20" />
<Setter Property="Margin" Value="10,8" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#4CAF50" />
<Setter Property="Foreground" Value="White" />
</Style>
</UserControl.Styles>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#FFE0B2" Offset="0" />
<GradientStop Color="#FFCC80" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Border Background="SandyBrown">
<Border
Background="White"
BoxShadow="0 4 8 0 #40000000"
CornerRadius="8"
Margin="20">
<StackPanel Orientation="Vertical">
<StackPanel Margin="20">
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Text="Username:" />
FontSize="24"
FontWeight="Bold"
HorizontalAlignment="Center"
Margin="0,0,0,20"
Text="Neuer Benutzer" />
<TextBlock Text="Benutzername:" />
<TextBox
TextWrapping="Wrap"
Watermark="Username"
Watermark="Benutzername eingeben"
x:Name="NewLoginUsernameBox" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Password:" />
<TextBlock Text="Passwort:" />
<TextBox
PasswordChar="*"
PasswordChar="•"
TextWrapping="Wrap"
Watermark="Password:"
Watermark="Passwort eingeben"
x:Name="NewLoginPasswordBox" />
<TextBlock
FontSize="20"
HorizontalAlignment="Left"
Margin="23"
Text="Email:" />
<TextBlock Text="E-Mail:" />
<TextBox
TextWrapping="Wrap"
Watermark="Email:"
Watermark="E-Mail-Adresse eingeben"
x:Name="NewLoginEmailBox" />
<StackPanel Orientation="Horizontal">
<StackPanel
HorizontalAlignment="Center"
Margin="0,20,0,0"
Orientation="Horizontal">
<Button Click="NewLoginSaveOnClick" Content="Speichern" />
<Button
BorderBrush="Black"
BorderThickness="1"
Click="NewLoginSaveOnClick"
Content="Save" />
<Button
BorderBrush="Black"
BorderThickness="1"
Background="#FF5722"
Click="NewLoginCancelOnClick"
Content="Cancel" />
Content="Abbrechen" />
</StackPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>

View File

@ -1,5 +1,5 @@
<Window
Height="250"
SizeToContent="Height"
Title="WARNING"
Width="500"
WindowStartupLocation="CenterOwner"
@ -7,16 +7,53 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Margin="20" Spacing="10">
<TextBlock HorizontalAlignment="Center" Text="One or more of your inputs are missing or wrong." />
<TextBlock HorizontalAlignment="Center" Text="All fields must be filled." />
<TextBlock HorizontalAlignment="Center" Text="Your username needs at least 4 characters." />
<TextBlock HorizontalAlignment="Center" Text="Your password needs at least 8 characters." />
<TextBlock HorizontalAlignment="Center" Text="Make sure your email is correct." />
<Button
Click="OkButton_Click"
Content="OK"
HorizontalAlignment="Center"
Width="80" />
</StackPanel>
<Window.Styles>
<Style Selector="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="Gray" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="0,5" />
</Style>
<Style Selector="Button">
<Setter Property="Width" Value="120" />
<Setter Property="Height" Value="40" />
<Setter Property="CornerRadius" Value="20" />
<Setter Property="Margin" Value="0,15,0,0" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#4CAF50" />
<Setter Property="Foreground" Value="White" />
</Style>
</Window.Styles>
<Grid Background="#F5F5F5">
<Border
Background="White"
BoxShadow="0 4 8 0 #40000000"
CornerRadius="8"
Margin="15">
<ScrollViewer>
<StackPanel Margin="20" MaxWidth="450">
<TextBlock
FontSize="24"
FontWeight="Bold"
Margin="0,0,0,15"
Text="⚠️ Warning" />
<TextBlock Text="One or more entries are wrong or missing." />
<TextBlock Text="All boxes must be filled in." />
<TextBlock Text="Your username needs to be at least 4 characters." />
<TextBlock Text="Your password needs to be at least 8 characters." />
<TextBlock Text="Make sure your e-mail is correct." />
<Button
Click="OkButton_Click"
Content="OK"
Margin="0,15,0,5" />
</StackPanel>
</ScrollViewer>
</Border>
</Grid>
</Window>

View File

@ -9,7 +9,8 @@ using Project.Persistence;
namespace Project.View;
public partial class PopUp : Window
{ public PopUp()
{
public PopUp()
{
InitializeComponent();
}

View File

@ -36,6 +36,10 @@
<DependentUpon>NewEntry.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="LoginErrorPopup\LoginErrorPopup.axaml.cs">
<DependentUpon>PopUp.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>