using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using ImGuiNET;

namespace SDL2Demo.Forms
{
    internal class MessageWindow : IRenderable
    {
        public string Message { get; }
        private string WindowUuid;

        public MessageWindow(string message)
        {
            Message = message;
            WindowUuid = Guid.NewGuid().ToString();
        }

        private bool sizeSet;
        public void Render()
        {
            bool closeMe = true;
            if (!sizeSet)
            {
                ImGui.SetNextWindowSize(new Vector2(300, 160));
                sizeSet = true;
            }
            
            ImGui.Begin(String.Format("Information ##{0}",WindowUuid), ref closeMe);
            ImGui.TextWrapped(Message);
            if (ImGui.Button("OK"))
                closeMe = false;
            ImGui.End();
            if (!closeMe)
            {
                Closed = true;
                if (OnClose != null)
                    OnClose();
            }
        }

        public bool Closed { get; private set; }

        public Action OnClose { get; set; }
    }
}
