FrmWelcom.cs 2.3 KB
using Dolen.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using UIControl.Forms;

namespace AGVDispatch
{
    public partial class FrmWelcom : FrmBase
    {
        public bool Loading { get; set; } = true;
        ImageList imageList;
        FormMain formMain;
        public FrmWelcom()
        {
            InitializeComponent();
            label1.Text = $"Copyright © {DateTime.Now.ToString("yyyy")}";
            loadImages();
            thread = new Thread(loading);
            thread.IsBackground = true;
            thread.Start();
        }
        void loadImages()
        {
            imageList = new ImageList();
            imageList.Images.Add(Properties.Resources._1);
            imageList.Images.Add(Properties.Resources._2);
            imageList.Images.Add(Properties.Resources._3);
            imageList.Images.Add(Properties.Resources._4);
            imageList.Images.Add(Properties.Resources._5);
            imageList.Images.Add(Properties.Resources._6);
            imageList.Images.Add(Properties.Resources._7);
            imageList.Images.Add(Properties.Resources.ok);
        }
        Thread thread;
        private void loading()
        {
            int idx = 0;
            while (!this.IsHandleCreated)
                Thread.Sleep(300);
            this.Invoke(new Action(() =>
            {

                formMain = new FormMain("AGV任务调度系统");
            })
       );
            pictureBox1.Invoke(new Action(() =>
            {
                while (!formMain.IsLoad)
                {
                    pictureBox1.Image = imageList.Images[idx];
                    idx++;
                    if (idx == 6)
                        idx = 0;
                    Thread.Sleep(300);
                }

            }));
            pictureBox1.Invoke(new Action(() =>
            {
                pictureBox1.Image = imageList.Images[7];
            }));
            Thread.Sleep(2000);
            this.Invoke(new Action(() =>
            {

                this.Hide();
                formMain.Show();

            })
         );

        }
    }
}