First commit

This commit is contained in:
2025-09-26 17:32:32 +02:00
commit 6c5579809d
14 changed files with 417 additions and 0 deletions

24
Feladat1/Feladat1.csproj Normal file
View File

@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GirCore.Adw-1" Version="0.6.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="UI/MainWindow/MainWindow.ui.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../Logic/Logic.csproj" />
<ProjectReference Include="../Repository/Repository.csproj" />
</ItemGroup>
</Project>

30
Feladat1/Program.cs Normal file
View File

@@ -0,0 +1,30 @@
using Feladat1.UI.MainWindow;
using Logic;
using Microsoft.Extensions.DependencyInjection;
using Repository;
namespace Feladat1;
class Program
{
static int Main()
{
var application = Adw.Application.New("org.piper.feladat1", Gio.ApplicationFlags.FlagsNone);
application.OnActivate += (sender, args) =>
{
var window = new MainWindow().Window;
window.Application = (Adw.Application)sender;
window.Show();
};
return application.RunWithSynchronizationContext(null);
}
private static ServiceProvider SetupServices()
{
var services = new ServiceCollection();
services.AddSingleton<IRepository, JsonRepository>();
services.AddSingleton<IUserService, UserService>();
return services.BuildServiceProvider();
}
}

View File

@@ -0,0 +1,85 @@
using Adw;
using Logic;
namespace Feladat1.UI.MainWindow;
public class MainWindow
{
private IUserService userService;
private const string windowId = "main_window";
public Window Window;
private Gtk.Button saveBtn;
private const string saveBtnId = "save_btn";
private EntryRow emailField;
private const string emailFieldId = "email";
private EntryRow userNameField;
private const string userNameFieldId = "username";
private PasswordEntryRow passwordField;
private const string passwordFieldId = "password";
public MainWindow()
{
var builder = new Gtk.Builder("Feladat1.UI.MainWindow.MainWindow.ui.xml");
Window = builder.GetObject(windowId) as Window;
if (Window == null)
{
throw new Exception("Failed to load embedded resource MainWindow.ui.xml");
}
try
{
saveBtn = builder.GetObject(saveBtnId) as Gtk.Button;
if (saveBtn == null)
{
throw new NullReferenceException(saveBtnId);
}
saveBtn.OnClicked += (sender, args) => Save();
emailField = builder.GetObject(emailFieldId) as EntryRow;
if (emailField == null)
{
throw new NullReferenceException(emailFieldId);
}
userNameField = builder.GetObject(userNameFieldId) as EntryRow;
if (userNameField == null)
{
throw new NullReferenceException(userNameFieldId);
}
passwordField = builder.GetObject(passwordFieldId) as PasswordEntryRow;
if (passwordField == null)
{
throw new NullReferenceException(passwordFieldId);
}
}
catch (NullReferenceException e)
{
Console.WriteLine($"Failed to load UI element with ID: {e.Message}");
Window.Close();
}
}
private bool ValidateFields()
{
if (userNameField.Text_ != null && emailField.Text_ != null && passwordField.Text_ != null)
{
return true;
}
return false;
}
private void Save()
{
if (ValidateFields())
{
userService.Create(userNameField.GetText(), emailField.GetText(), passwordField.GetText());
}
}
}

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="AdwWindow" id="main_window">
<property name="width-request">300</property>
<property name="height-request">300</property>
<property name="default-width">500</property>
<property name="default-height">600</property>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<property name="title-widget">
<object class="AdwViewSwitcher">
<property name="stack">stack</property>
<property name="policy">wide</property>
</object>
</property>
</object>
</child>
<property name="content">
<object class="AdwViewStack" id="stack">
<property name="enable-transitions">True</property>
<child>
<object class="AdwViewStackPage">
<property name="name">save</property>
<property name="title">Save</property>
<property name="child">
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwEntryRow" id="email">
<property name="title">Email</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="username">
<property name="title">Felhasználónév</property>
</object>
</child>
<child>
<object class="AdwPasswordEntryRow" id="password">
<property name="title">Jelszó</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="save_btn">
<style>
<class name="suggested-action" />
</style>
<property name="label">Exportálás</property>
<property name="valign">center</property>
<property name="halign">center</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="AdwViewStackPage">
<property name="name">load</property>
<property name="title">Load</property>
<property name="child">
<object class="AdwStatusPage">
<property name="title">Load</property>
</object>
</property>
</object>
</child>
</object>
</property>
<child type="bottom">
<object class="AdwViewSwitcherBar" id="switcher_bar">
<property name="stack">stack</property>
</object>
</child>
</object>
</property>
</object>
</interface>