using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Test_Merge
{
    public partial class Form1 : Form
    {
        Reader Reader = null;
        F1TVEmulator Emulator = null;
        public Form1()
        {
            InitializeComponent();
        }
        public async void RefreshUI()
        {
            if(Emulator != null && Reader != null)
            {
                Bitmap screen = Emulator.Screenshot();
                screen.Save("SCREEEEEEEEN.png");
                Reader.ChangeImage(screen);
                tbxResult.Text = await Reader.Decode(Reader.MainZones,Reader.Drivers);
            }
        }
        private void btnSettings_Click(object sender, EventArgs e)
        {
            Settings settingsForm = new Settings();
            settingsForm.ShowDialog();
            MessageBox.Show(settingsForm.GrandPrixUrl + Environment.NewLine + settingsForm.GrandPrixName + Environment.NewLine + settingsForm.GrandPrixYear);
        }

        private async void Form1_Load(object sender, EventArgs e)
        {
            string configFile = "./Presets/Clean_2023.json";
            string gpUrl = "https://f1tv.formula1.com/detail/1000006688/2023-azerbaijan-grand-prix?action=play";

            //Emulator = new F1TVEmulator(gpUrl);
            //await Emulator.Start();
            //Reader = new Reader(configFile,Emulator.Screenshot(),true);
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            btnUpdate.Enabled = false;
            RefreshUI();
            btnUpdate.Enabled = true;
        }
    }
}
