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

namespace GFATask
{
    public partial class FormInfo : FormEx
    {
        LoadingPanel panel = XObjects.LoadingPanel.Clone();
     
        public FormInfo()
        {
            InitializeComponent();

            this.SetDefaultDesign();
            picLOGO.Image = Image.FromStream(File.OpenRead(Paths.Icons.Directory + @"\System\GFA.png"));
            lText.Text = $"{InfoClass.Program} [Codename {InfoClass.ProgramCodeName}]";
            lComputer.Text = $"{InfoClass.Computer } [{InfoClass.IPAdress}]";
            lOS.Text = InfoClass.OperatingSystem;
            lCopyright.Text = InfoClass.Copyright;

            label1.Paint += Designer.DrawHeaderLabel;
            label2.Paint += Designer.DrawHeaderLabel;
            label4.Paint += Designer.DrawHeaderLabel;
            label5.Paint += Designer.DrawHeaderLabel;

            lWebBrowser.Text = InfoClass.Browsers;
        }

        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);
            if(this.Visible)
            {
                panel = XObjects.LoadingPanel.Clone();
                panel.Loading = true;
                this.tableLayoutPanel1.Controls.Add(panel, 1, this.tableLayoutPanel1.RowCount -2);
                this.tableLayoutPanel1.SetColumnSpan(panel, this.tableLayoutPanel1.ColumnCount - 1);
            }
            else
            {
                panel.Loading = this.Visible;
            }
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if(e.CloseReason == CloseReason.UserClosing)
            {
                this.Visible = false;
                e.Cancel = true;
            }
            base.OnFormClosing(e);
        }
    }
}
