using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;

namespace kursovaya;

public partial class EditAttestWindow : Window
{
    public int MaxAttestNumber { get; set; }
    public int outputAttestNumber;
    public EditAttestWindow()
    {
        InitializeComponent();
    }
    
    public EditAttestWindow(int number) : this()
    {
        switch(number) 
        {
            case 1:
                MaxAttestNumber = 20;
                break;
            case 2:
                MaxAttestNumber = 30;
                break;
            case 3:
                MaxAttestNumber = 50;
                break;
            default:
                // code block
                break;
        }
        DataContext = this;
    }

    private void Button_OnClick(object? sender, RoutedEventArgs e)
    {
        if (!int.TryParse(AttestTextBox.Text, out int output)) return;
        if (output > MaxAttestNumber || output == null)
        {
            outputAttestNumber = 0;
        }
        else
        {
            outputAttestNumber = output;
        }
        Close(outputAttestNumber);
    }
}