DemoService/MainWindow.axaml.cs
2024-09-09 16:26:07 +03:00

51 lines
1.4 KiB
C#

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