using Noctalk.UI.Components.Button;
using Noctalk.UI.Components.Label;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace Noctalk.UI.Components.Confirmation;

public static class Noctalk_message
{
    public static void Show(Window? The_owner, string The_title, string The_message)
    {
        Window dialog = new()
        {
            Title = The_title,
            Width = 520,
            Height = 170,
            WindowStartupLocation = WindowStartupLocation.CenterOwner,
            Owner = The_owner,
            ResizeMode = ResizeMode.NoResize,
            Background = UI__brush(5, 9, 18),
            Foreground = UI__brush(73, 217, 255)
        };

        Grid grid = new() { Margin = new Thickness(14) };
        grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

        Noctalk_label messageLabel = new()
        {
            Text = The_message,
            Size = Noctalk_label_size.medium,
            TextWrapping = TextWrapping.Wrap,
            Foreground = UI__brush(185, 243, 255)
        };

        Noctalk_button okButton = new() { Content = "OK", Width = 92, Color = Noctalk_button_color.Blue_O__Blue_O, HorizontalAlignment = HorizontalAlignment.Right };
        okButton.Click += (_, _) => dialog.Close();

        Grid.SetRow(messageLabel, 0);
        Grid.SetRow(okButton, 1);
        grid.Children.Add(messageLabel);
        grid.Children.Add(okButton);
        dialog.Content = grid;
        dialog.ShowDialog();
    }

    private static SolidColorBrush UI__brush(byte Red, byte Green, byte Blue)
    {
        return new SolidColorBrush(Color.FromRgb(Red, Green, Blue));
    }
}
