using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading ;

namespace Test
{
	/// <summary>
	/// Form4 的摘要说明。
	/// </summary>
	public class frmLoadProgress : System.Windows.Forms.Form
	{
		private System.ComponentModel.IContainer components;
		// Create a MainMenu object and a MenuItem object.
		int lngTime1;
		int lngTime2;
		int lngTime3;
		private System.Windows.Forms.ProgressBar pbr;
		private System.Windows.Forms.Timer timer1;
		private System.Windows.Forms.StatusBar s;
		private System.Windows.Forms.StatusBarPanel s1;
		private System.Windows.Forms.StatusBarPanel s2;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.StatusBarPanel s3;
		public frmLoadProgress()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			AppStartMenu();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmLoadProgress));
			this.pbr = new System.Windows.Forms.ProgressBar();
			this.s = new System.Windows.Forms.StatusBar();
			this.s1 = new System.Windows.Forms.StatusBarPanel();
			this.s2 = new System.Windows.Forms.StatusBarPanel();
			this.s3 = new System.Windows.Forms.StatusBarPanel();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			((System.ComponentModel.ISupportInitialize)(this.s1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.s2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.s3)).BeginInit();
			this.SuspendLayout();
			// 
			// pbr
			// 
			this.pbr.Cursor = System.Windows.Forms.Cursors.WaitCursor;
			this.pbr.Location = new System.Drawing.Point(56, 16);
			this.pbr.Name = "pbr";
			this.pbr.Size = new System.Drawing.Size(412, 22);
			this.pbr.TabIndex = 0;
			// 
			// s
			// 
			this.s.Location = new System.Drawing.Point(0, 45);
			this.s.Name = "s";
			this.s.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																				 this.s1,
																				 this.s2,
																				 this.s3});
			this.s.ShowPanels = true;
			this.s.Size = new System.Drawing.Size(472, 26);
			this.s.TabIndex = 2;
			// 
			// s2
			// 
			this.s2.Width = 500;
			// 
			// s3
			// 
			this.s3.Width = 1000;
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Interval = 1000;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(12, 10);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(32, 34);
			this.pictureBox1.TabIndex = 26;
			this.pictureBox1.TabStop = false;
			// 
			// frmLoadProgress
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.White;
			this.ClientSize = new System.Drawing.Size(472, 71);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.s);
			this.Controls.Add(this.pbr);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmLoadProgress";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "正在处理数据，请稍后...";
			this.Load += new System.EventHandler(this.Form4_Load);
			((System.ComponentModel.ISupportInitialize)(this.s1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.s2)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.s3)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void Form4_Load(object sender, System.EventArgs e)
		{

			Thread t2=new Thread(new ThreadStart(this.Show));
			t2.Start() ;
			Thread t=new Thread(new ThreadStart(TakeTime));
			t.Start() ;
			Thread t1=new Thread(new ThreadStart(PbrShow));
			t1.Start() ;
//			Thread t3=new Thread(new ThreadStart(TakeTime1));
//			t3.Start() ;


		}
		public void TakeTime()
		{
			for(int i=0;i<3200;i++)

			{
				s.Panels[0].Text =i.ToString();
			}
		}
		public void TakeTime1()
		{
			TimerCallback callback = new TimerCallback (TimeShow); 
			System.Threading.Timer timer = new System.Threading.Timer(callback, null, 1000, 1000); 

		}
		public void PbrShow()
		{
			pbr.Maximum =12000;
			pbr.Minimum =0;

			for(int i=0;i<12000;i++)

			{
				pbr.Value  =i;
			}
		}
		public void TimeShow(object state)
		{
				s.Panels[1].Text = "正在加载数据，请您稍后 ...";
				lngTime1 = lngTime1 + 1;
				if (lngTime1 == 60)
			{
				lngTime2 = lngTime2 + 1;
				lngTime1 = 0;
			}
			if (lngTime2 == 60)
		{
			lngTime3 = lngTime3 + 1;
			lngTime2 = 0;
		}


			string h;
			string t;
			string c;
			if (lngTime3.ToString().Length==2 )
		{
			h=lngTime3.ToString() ;
		}
			else
		{
			h="0" +lngTime3.ToString() ;
		}
			if (lngTime2.ToString().Length==2 )
		{
			t=lngTime2.ToString() ;
		}
			else
		{
			t="0" +lngTime2.ToString() ;
		}		
			if (lngTime1.ToString().Length==2 )
		{
			c=lngTime1.ToString() ;
		}
			else
		{
			c="0" +lngTime1.ToString() ;
		}
			s.Panels[1].Text  = "Time [" + h+ ":" + t + ":" +c;
		}
		public void AppStartMenu()
		{
//			// Create an instance of the MainMenu object.
//			mmAppStart = new MainMenu();
//
//			// Create a top-level menu item and two menu items. Use this
//			// overloaded constructor that takes an event handler
//			// (MenuSelect) so that later, you can cause the menu selection
//			// to change the application state.
//			miFile = new MenuItem("&File", new EventHandler(MenuSelect));
//			miFile.MenuItems.Add("&New", new EventHandler(MenuSelect));
//			miFile.MenuItems.Add("&Open", new EventHandler(MenuSelect));
//			miFile.MenuItems.Add("&Exit");
//
//			// Add the top-level menu item to the MainMenu component 
//			// and set the MainMenu component to be the form's menu.
//			mmAppStart.MenuItems.Add(miFile);
//
//			// Set the form's menu to the menu you have just created.
//			this.Menu = mmAppStart;
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
//			string strMsg;
////''If Timer1.Enabled = False Then Exit Sub
				s.Panels[1].Text = "正在加载数据，请您稍后 ...";
			lngTime1 = lngTime1 + 1;
			if (lngTime1 == 60)
			{
				lngTime2 = lngTime2 + 1;
				lngTime1 = 0;
			}
			if (lngTime2 == 60)
			{
				lngTime3 = lngTime3 + 1;
				lngTime2 = 0;
			}

//if PBar.Value < 4000 Then
//''     PBar.Value = PBar.Value + 60;
//''  End If
//''
//''  If PBar.Value <= 5000 And PBar.Value >= 4000 Then
//''     PBar.Value = PBar.Value + 30
//''  End If
//''
//''   If PBar.Value <= 5500 And PBar.Value >= 5000 Then
//''     PBar.Value = PBar.Value + 15
//''  End If
//''    If PBar.Value <= 6800 And PBar.Value >= 5500 Then
//''     PBar.Value = PBar.Value + 5
//''  End If
//''
		string h;
			string t;
			string c;
			if (lngTime3.ToString().Length==2 )
			{
				h=lngTime3.ToString() ;
			}
			else
			{
				h="0" +lngTime3.ToString() ;
			}
			if (lngTime2.ToString().Length==2 )
			{
				t=lngTime2.ToString() ;
			}
			else
			{
				t="0" +lngTime2.ToString() ;
			}		
			if (lngTime1.ToString().Length==2 )
						{
							c=lngTime1.ToString() ;
						}
						else
						{
							c="0" +lngTime1.ToString() ;
						}
			s.Panels[1].Text  = "时间[" + h+ ":" + t + ":" +c+"]";


		}

	}
}
