http://www.reflectionit.nl/Splash.aspx

解决方案 »

  1.   

    you can use From(Start from) and a timer!
      

  2.   

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Threading;namespace YourNameSpace
    {
    public sealed class SplashScreen
    {
        static SplashForm m_SplashForm;
        static Thread m_WorkerThread;    
        private SplashScreen()
        {
        }    static SplashScreen()
        {
            m_SplashForm = new SplashForm();
            m_SplashForm.SplashImage = Resources.bmpEffortechSplash;
        }    public static Image SplashImage
        {
            get
            {
                return m_SplashForm.SplashImage;
            }
            set 
            {
                m_SplashForm.SplashImage = value;
            }
        }    public static string InfoText 
        {
            get 
            {
                return m_SplashForm.InfoText;
            }
            set 
            {
                m_SplashForm.InfoText = value;
            }
        }    public static void Show(Bitmap splashImage)
        {
            if (splashImage == null)
                throw new ArgumentNullException();        m_SplashForm.SplashImage = splashImage;
            Show();
        }    public static void Show()
        {
            ThreadStart threadStart = new ThreadStart(ShowForm);
    m_SplashForm.HideSplash = false;
            m_WorkerThread = new Thread(threadStart);
            m_WorkerThread.Start();
        }    private static void ShowForm()
        {
            m_SplashForm.ShowDialog();
        }    public static void Close()
        {
    if (m_SplashForm != null && !m_SplashForm.IsDisposed)
    m_SplashForm.HideSplash = true;
            //m_WorkerThread.Join();
        }
        public static void Dispose()
        {
    if (m_SplashForm != null)
    m_SplashForm.Dispose();
    m_SplashForm = null;
        }
    }internal class SplashForm : Form
    {
        private System.Windows.Forms.Timer timer1;
        private PictureBox m_SplashPictureBox;
        private System.ComponentModel.IContainer components;
        private bool m_HideSplash = false;
        private System.Windows.Forms.Timer timer2;
    private Point orgPoint;    internal System.Windows.Forms.Label InfoLabel;
        
        public SplashForm()
        {
            InitializeComponent();
            this.timer1.Start();
        }
    #region Windows Form Designer generated code
        private void InitializeComponent()
        {
    this.components = new System.ComponentModel.Container();
    this.m_SplashPictureBox = new System.Windows.Forms.PictureBox();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.InfoLabel = new System.Windows.Forms.Label();
    this.timer2 = new System.Windows.Forms.Timer(this.components);
    this.SuspendLayout();
    // 
    // m_SplashPictureBox
    // 
    this.m_SplashPictureBox.Cursor = System.Windows.Forms.Cursors.AppStarting;
    this.m_SplashPictureBox.Name = "m_SplashPictureBox";
    this.m_SplashPictureBox.Size = new System.Drawing.Size(112, 80);
    this.m_SplashPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
    this.m_SplashPictureBox.TabIndex = 0;
    this.m_SplashPictureBox.TabStop = false;
    this.m_SplashPictureBox.Click += new System.EventHandler(this.m_SplashPictureBox_Click);
    this.m_SplashPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
    this.m_SplashPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
    this.m_SplashPictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
    // 
    // timer1
    // 
    this.timer1.Enabled = true;
    this.timer1.Interval = 500;
    this.timer1.Tick += new System.EventHandler(this.OnTick);
    // 
    // InfoLabel
    // 
    this.InfoLabel.BackColor = System.Drawing.Color.Aqua;
    this.InfoLabel.Cursor = System.Windows.Forms.Cursors.Default;
    this.InfoLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
    this.InfoLabel.Location = new System.Drawing.Point(0, 286);
    this.InfoLabel.Name = "InfoLabel";
    this.InfoLabel.Size = new System.Drawing.Size(415, 19);
    this.InfoLabel.TabIndex = 1;
    this.InfoLabel.Text = "正在启动 ...";
    this.InfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
    this.InfoLabel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
    this.InfoLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
    this.InfoLabel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
    // 
    // timer2
    // 
    this.timer2.Interval = 5000;
    this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
    // 
    // SplashForm
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(415, 305);
    this.ControlBox = false;
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.m_SplashPictureBox,
      this.InfoLabel});
    this.Cursor = System.Windows.Forms.Cursors.Cross;
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Name = "SplashForm";
    this.ShowInTaskbar = false;
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.TopMost = true;
    this.ResumeLayout(false); }
    #endregion    private void OnTick(object sender,EventArgs e)
        {
            if(HideSplash == true)
            {
                this.timer1.Enabled = false;
                this.timer2.Enabled = true;
            }
        }    private void m_SplashPictureBox_Click(object sender, System.EventArgs e)
        {
            if (this.timer1.Enabled == false)
            {
                this.timer2.Stop();
                this.timer1.Dispose();
                this.timer2.Dispose();
                this.m_SplashPictureBox.Dispose();
            
                this.Close();
            }
        } private void OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    this.Cursor = Cursors.SizeAll;
    orgPoint = new Point(e.X,e.Y);
    orgPoint = this.PointToScreen(orgPoint);
    } private void OnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    this.Cursor = Cursors.Default;
    } private void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if(e.Button==MouseButtons.Left)
    {
    Point tp = new Point(e.X,e.Y);
    tp = this.PointToScreen(tp);
    this.Top += tp.Y -orgPoint.Y;
    this.Left += tp.X-orgPoint.X;
    this.orgPoint = tp;
    }
    }
        private void timer2_Tick(object sender, System.EventArgs e)
        {
            this.timer2.Stop();
            this.timer1.Dispose();
            this.timer2.Dispose();
            this.m_SplashPictureBox.Dispose();
            this.Close();
        }    public bool HideSplash
        {
            get
            {
                return m_HideSplash;
            }
            set
            {
                lock(this)
                {
                    m_HideSplash = value;   
                }
            }
        }    public string InfoText
        {
            get
            {
                lock(this)
                {
                    return this.InfoLabel.Text;
                }
            }
            set
            {
                lock(this)
                {
                    this.InfoLabel.Text = value;   
                }
            }
        }    public Image SplashImage
        {
            get
            {
                return this.m_SplashPictureBox.Image;
            }
            set 
            {
                if (m_SplashPictureBox.Image == value)
                    return;
                m_SplashPictureBox.Image = value;
                this.ClientSize = new Size(m_SplashPictureBox.Size.Width, 
                    m_SplashPictureBox.Size.Height + this.InfoLabel.Height);
            }
        }}
    }
      

  3.   

    http://www.codeproject.com/csharp/apploadingarticle.asp?target=splash