using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace Sonex.Pages;

/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class TableSample : Page
{
    public List<Person> people1 = new();
    public TableSample()
    {
        InitializeComponent();
        people1 = PersonGenerator.Generate(10);
        tableView.ItemsSource = people1;
        Unloaded += TableSample_Unloaded;
    }

    private void TableSample_Unloaded(object sender, RoutedEventArgs e)
    {
        tableView.ItemsSource = null;
    }
}
public class Person
{
    public int Id { get; set; }
    public string FirstName { get; set; } = string.Empty;
    public string LastName { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;
    public int Age { get; set; }
    public DateTime BirthDate { get; set; }
    public bool IsActive { get; set; }
    public Status Status { get; set; }
}
public enum Status
{
    Bezrobotny, Robotny, Troche_robotny, brak
}
public static class PersonGenerator
{
    private static readonly string[] FirstNames = { "Jan", "Anna", "Piotr", "Katarzyna", "Michał", "Agnieszka" };
    private static readonly string[] LastNames = { "Kowalski", "Nowak", "Wiśniewski", "Wójcik", "Kaczmarek" };
    private static readonly Random Rng = new();

    public static List<Person> Generate(int count)
    {
        return Enumerable.Range(1, count)
            .Select(i =>
            {
                var first = FirstNames[Rng.Next(FirstNames.Length)];
                var last = LastNames[Rng.Next(LastNames.Length)];
                var age = Rng.Next(18, 65);
                var birthDate = DateTime.Today.AddYears(-age).AddDays(Rng.Next(0, 365));

                return new Person
                {
                    Id = i,
                    FirstName = first,
                    LastName = last,
                    Age = age,
                    BirthDate = birthDate,
                    Email = $"{first.ToLower()}.{last.ToLower()}{i}@test.pl",
                    IsActive = Rng.NextDouble() > 0.3
                };
            })
            .ToList();
    }
}