DemoService/MainWindow.axaml.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2024-09-04 07:09:08 +00:00
using Avalonia.Controls;
2024-09-04 09:08:53 +00:00
using Avalonia.Interactivity;
2024-09-09 13:26:07 +00:00
using Avalonia.Media.Imaging;
using System;
2024-09-04 07:09:08 +00:00
namespace DemoService
{
public partial class MainWindow : Window
{
2024-09-04 09:08:53 +00:00
private readonly string adminCode = "0000";
2024-09-04 07:09:08 +00:00
public MainWindow()
{
InitializeComponent();
2024-09-04 09:08:53 +00:00
Background = Colors.white;
UserButton.Background = Colors.orange;
PasswordError.Foreground = Colors.white;
AdminButton.Background = Colors.orange;
2024-09-09 13:26:07 +00:00
Icon = new WindowIcon(new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "/Assets/service_logo.ico"));
2024-09-04 09:08:53 +00:00
}
2024-09-05 13:11:39 +00:00
private void UserLogIn(object sender, RoutedEventArgs args)
2024-09-04 09:08:53 +00:00
{
ServiceWindow serviceWindow = new(false);
serviceWindow.Show();
Close();
}
2024-09-05 13:11:39 +00:00
private void AdminLogIn(object sender, RoutedEventArgs args)
2024-09-04 09:08:53 +00:00
{
if (PasswordCheck(Password.Text))
{
ServiceWindow serviceWindow = new(true);
serviceWindow.Show();
Close();
}
else
{
PasswordError.Foreground = Colors.red;
}
}
2024-09-05 13:11:39 +00:00
private bool PasswordCheck(string? password)
2024-09-04 09:08:53 +00:00
{
if (password == adminCode)
{
return true;
}
else
{
return false;
}
2024-09-04 07:09:08 +00:00
}
}
}