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

namespace SixGroup_Knowledge.OtherView
{
    public partial class MaskForm : Form
    {
        public MaskForm()
        {
            InitializeComponent();
        }
        //获得屏幕的宽和高
        private int winWidth = Screen.PrimaryScreen.Bounds.Width;
        private int winHeight = Screen.PrimaryScreen.Bounds.Height;

        private Point tar1Position = new Point(0, 0);
        private Point tar2Postion = new Point(0, 0);
        private Label[] labelList = null;

        private void MaskForm_Load(object sender, EventArgs e)
        {
            this.Location = new Point(0, 0);
            this.Width = winWidth;
            this.Height = winHeight;
            this.loadTimer.Enabled = true;
            labelList = new Label[] {
                l_t1,l_t2,l_t3,l_t4,l_t5,l_t6,l_t7,l_t8
            };
            foreach (Label item in labelList)
            {
                item.Visible = false;
            }
            int tarX = ((int)(winWidth / 2)) - ((int)(this.panel1.Width / 2));
            tar1Position = new Point(tarX, 100);
            tarX = ((int)winWidth / 2) - ((int)(this.panel2.Width / 2));
            int tarY = ((int)(winHeight / 2)) - ((int)(this.panel2.Height / 2));
            tar2Postion = new Point(tarX, tarY);

            title_timer.Enabled = true;
        }

        private void MaskForm_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void loadTimerTick(object sender, EventArgs e)
        {
            if (this.Opacity <= 0.7)
            {
                this.loadTimer.Enabled = false;
                loadPostionTimer();
            }
            else
            {
                this.Opacity -= 0.02;
            }
        }
        private void loadPostionTimer()
        {
            move_lt_timer.Enabled = true;
            this.ltTimer.Enabled = true;
            this.ltTimer.Tag = 0;
        }

        private void ltTimer_Tick(object sender, EventArgs e)
        {
            int labelIndex = Convert.ToInt32(ltTimer.Tag);
            if (labelIndex < labelList.Length)
                ltTimer.Tag = labelIndex + 1;
            else
            {
                this.pictureBox1.Visible = true;
                ltTimer.Enabled = false;
                labelList[labelList.Length - 1].ForeColor = Color.FromArgb(255, 255, 255);
                return;
            }
            Label label = labelList[labelIndex];
            label.ForeColor = Color.Red;
            if (labelIndex > 0)
                labelList[labelIndex - 1].ForeColor = Color.FromArgb(255, 255, 255);
            label.Visible = true;
        }

        private void move_lt_timer_Tick(object sender, EventArgs e)
        {
            if (panel2.Location.X >= tar2Postion.X)
            {
                move_lt_timer.Enabled = false;
            }
            else
            {
                panel2.Location = new Point(panel2.Location.X + 5, tar2Postion.Y);
            }
        }

        private void title_timer_Tick(object sender, EventArgs e)
        {
            if (panel1.Location.X>=tar1Position.X)
            {
                title_timer.Enabled = false;
            }
            else
            {
                panel1.Location = new Point(panel1.Location.X + 5, tar1Position.Y);
            }
        }
    }
}
