using Quik;
using Quik.CommandMachine;
using Quik.Controls;
using Quik.OpenTK;
using Quik.Media.Defaults;
using Quik.Media;
using Quik.PAL;

namespace QuikDemo
{
    public static class Program
    {
        public static readonly QuikApplication Application = new QuikApplication(new OpenTKPlatform());

        public static void Main(string[] args)
        {
            Application.Run(new EmptyView());
        }
    }

    public class EmptyView : View
    {
        private QFont? font;
        private readonly Label Label = new Label() { Text = "Hello world!", Position = new QVec2(300, 300) };

        protected override void PaintBegin(CommandList cmd)
        {
            base.PaintBegin(cmd);

            if (font == null)
            {
                IFontDataBase db = FontDataBaseProvider.Instance;
                font = new QFontFreeType(db.FontFileInfo(db.Sans).OpenRead());

                Label.Font = font;
                Label.TextSize = 12;
                Label.InvalidateVisual();
            }

            cmd.Rectangle(new QRectangle(16, 16, 0, 0));
            Label.Paint(cmd);
        }
    }
}