using Avalonia.Controls;
using DTLib.Demystifier;
using Mlaumcherb.Client.Avalonia.зримое;
using MsBox.Avalonia;
using MsBox.Avalonia.Dto;
using MsBox.Avalonia.Enums;
using MsBox.Avalonia.Models;

namespace Mlaumcherb.Client.Avalonia.холопы;

public static class ErrorHelper
{
    internal static void ShowMessageBox(string context, Exception err) 
        => ShowMessageBox(context, err.ToStringDemystified());

    internal static async void ShowMessageBox(string context, string err)
    {
        LauncherApp.Logger.LogError(context, err);
        var box = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams
            {
                ButtonDefinitions = new List<ButtonDefinition> { new() { Name = "пон" } },
                ContentTitle = "ОШИБКА",
                ContentMessage = err,
                Icon = Icon.Error,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                CanResize = true,
                MaxWidth = 1000,
                MaxHeight = 1000,
                SizeToContent = SizeToContent.WidthAndHeight,
                ShowInCenter = true,
                Topmost = true
            }
        );
        await box.ShowAsync().ConfigureAwait(false);
    }
}