added first part of persistence to locally save a new login and got 2 or 3 buttons working - no errors in this build
This commit is contained in:
parent
7c5e88071f
commit
bb901f23af
15
Project.Model/CreateLogin.cs
Normal file
15
Project.Model/CreateLogin.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace Project.Model;
|
||||
|
||||
public class CreateLogin
|
||||
{
|
||||
public string newLoginname { get; set; }
|
||||
public string newMasterpassword { get; set; }
|
||||
public string newEmail { get; set; }
|
||||
|
||||
public CreateLogin(string username, string password, string email)
|
||||
{
|
||||
newLoginname = username;
|
||||
newMasterpassword = password;
|
||||
newEmail = email;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Project.Model;
|
||||
|
||||
public class entry
|
||||
public class Entry
|
||||
{
|
||||
public string? entryname;
|
||||
public string? username;
|
||||
9
Project.Model/LoginCredentials.cs
Normal file
9
Project.Model/LoginCredentials.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Project.Model;
|
||||
|
||||
public class LoginCredentials
|
||||
{
|
||||
public string? loginname { get; set; }
|
||||
public string? masterpassword { get; set; }
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
namespace Project.Model;
|
||||
|
||||
public class loginCredentials
|
||||
{
|
||||
public string? loginname;
|
||||
public string? masterpassword;
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace Project.Persistence;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
12
Project.Persistence/UserStorage.cs
Normal file
12
Project.Persistence/UserStorage.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Project.Model;
|
||||
namespace Project.Persistence;
|
||||
|
||||
public static class UserStorage
|
||||
{
|
||||
private static readonly string FilePath = "C:/Users/lowns/desktop/users.txt";
|
||||
public static void SaveUser(CreateLogin user)
|
||||
{
|
||||
var line = $"{user.newLoginname}:{user.newMasterpassword}:{user.newEmail}";
|
||||
File.AppendAllLines(FilePath, new[] { line });
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,46 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
x:Class="Project.View.LoginPage"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<UserControl
|
||||
x:Class="Project.View.LoginPage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid Background="SandyBrown">
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Image Source="avares://Project.View/Images/keywi_logo_2.png" Height="400" Width="400"/>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Image
|
||||
Height="400"
|
||||
Source="avares://Project.View/Images/keywi_logo_2.png"
|
||||
Width="400" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Vertical"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock>Your Login Name:</TextBlock>
|
||||
<TextBox Watermark="Login-Name" TextWrapping="Wrap"/>
|
||||
<TextBox TextWrapping="Wrap" Watermark="Login-Name" />
|
||||
|
||||
<TextBlock>Password:</TextBlock>
|
||||
|
||||
<TextBlock>Password:</TextBlock>
|
||||
|
||||
<TextBox Watermark="Password" TextWrapping="Wrap" PasswordChar="*"/>
|
||||
<Button Name="ConfirmButton" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Center" Margin="20"> LOGIN </Button>
|
||||
|
||||
<TextBox
|
||||
PasswordChar="*"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Password" />
|
||||
<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>
|
||||
</Grid>
|
||||
|
||||
|
||||
@ -17,4 +17,13 @@ public partial class LoginPage : UserControl
|
||||
InitializeComponent();
|
||||
_controller = controller;
|
||||
}
|
||||
private async void LoginButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private async void NewUserButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
var newLoginWindow = new NewLogin();
|
||||
newLoginWindow.Show();
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,6 @@ public partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
_controller = new();
|
||||
MainGrid.Children.Add(new MenuView());
|
||||
MainGrid.Children.Add(new LoginPage());
|
||||
}
|
||||
}
|
||||
@ -48,6 +48,11 @@
|
||||
HorizontalAlignment="Left"
|
||||
Margin="23"
|
||||
Text="Name:" />
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="23"
|
||||
Text="Login-Name:" />
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Left"
|
||||
@ -71,6 +76,11 @@
|
||||
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"
|
||||
|
||||
@ -20,9 +20,10 @@ public partial class MenuView : UserControl
|
||||
}
|
||||
|
||||
|
||||
private void NewEntryButton_OnClick(object? sender, RoutedEventArgs e)
|
||||
private async void NewEntryButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
var newEntry = new NewEntry(_controller);
|
||||
NewEntry.Show(newEntry);
|
||||
var newEntryWindow = new NewEntry();
|
||||
newEntryWindow.Show();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
<UserControl
|
||||
Height="500"
|
||||
Width="350"
|
||||
x:Class="Project.View.NewEntry"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
@ -5,7 +5,7 @@ using Project.Controller;
|
||||
|
||||
namespace Project.View;
|
||||
|
||||
public partial class NewEntry : UserControl
|
||||
public partial class NewEntry : Window
|
||||
{
|
||||
readonly AppController? _controller;
|
||||
public NewEntry()
|
||||
@ -18,4 +18,5 @@ public partial class NewEntry : UserControl
|
||||
InitializeComponent();
|
||||
_controller = controller;
|
||||
}
|
||||
|
||||
}
|
||||
57
Project.View/NewLogin/NewLogin.axaml
Normal file
57
Project.View/NewLogin/NewLogin.axaml
Normal file
@ -0,0 +1,57 @@
|
||||
<UserControl
|
||||
Height="500"
|
||||
Width="350"
|
||||
x:Class="Project.View.NewLogin"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid>
|
||||
|
||||
<Border Background="SaddleBrown">
|
||||
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Left"
|
||||
Text="Username:" />
|
||||
<TextBox
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Username"
|
||||
x:Name="NewLoginUsernameBox" />
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="23"
|
||||
Text="Password:" />
|
||||
<TextBox
|
||||
PasswordChar="*"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Password:"
|
||||
x:Name="NewLoginPasswordBox" />
|
||||
<TextBlock
|
||||
FontSize="20"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="23"
|
||||
Text="Email:" />
|
||||
<TextBox
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Email:"
|
||||
x:Name="NewLoginEmailBox" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1"
|
||||
Click="NewLoginSaveOnClick"
|
||||
Content="Save" />
|
||||
<Button
|
||||
BorderBrush="Black"
|
||||
BorderThickness="1"
|
||||
Click="NewLoginCancelOnClick"
|
||||
Content="Cancel" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
44
Project.View/NewLogin/NewLogin.axaml.cs
Normal file
44
Project.View/NewLogin/NewLogin.axaml.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Project.Controller;
|
||||
using Project.Model;
|
||||
using Project.Persistence;
|
||||
|
||||
namespace Project.View;
|
||||
|
||||
public partial class NewLogin : Window
|
||||
{
|
||||
readonly AppController? _controller;
|
||||
public NewLogin()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public NewLogin(AppController controller)
|
||||
{
|
||||
InitializeComponent();
|
||||
_controller = controller;
|
||||
}
|
||||
|
||||
private void NewLoginSaveOnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
string username = NewLoginUsernameBox.Text?.Trim();
|
||||
string password = NewLoginPasswordBox.Text?.Trim();
|
||||
string email = NewLoginEmailBox.Text?.Trim();
|
||||
|
||||
var user = new CreateLogin(username, password, email);
|
||||
UserStorage.SaveUser(user);
|
||||
|
||||
|
||||
NewLoginUsernameBox.Text = "";
|
||||
NewLoginPasswordBox.Text = "";
|
||||
NewLoginEmailBox.Text = "";
|
||||
|
||||
|
||||
}
|
||||
private void NewLoginCancelOnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -25,4 +25,19 @@
|
||||
<ProjectReference Include="..\Project.Model\Project.Model.csproj" />
|
||||
<AvaloniaResource Include="Images\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="NewLogin\NewLogin.axaml.cs">
|
||||
<DependentUpon>NewLogin.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="NewLogin\NewLogin.axaml.cs">
|
||||
<DependentUpon>NewEntry.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="NewLogin\NewLogin.axaml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user