www.pudn.com > PlanBoard.rar > Form1.cs


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using System.Data; 
 
namespace PlanBoard 
{ 
	///  
	/// Form1 的摘要说明。 
	///  
	public class Form1 : System.Windows.Forms.Form 
	{ 
 
		private System.Windows.Forms.Panel panel_top; 
		private System.Windows.Forms.Button btn_Remove; 
		private System.Windows.Forms.Button btn_Add; 
		private System.Windows.Forms.Label label4; 
		private System.Windows.Forms.Label label3; 
		private System.Windows.Forms.Label label2; 
		private System.Windows.Forms.Label label1; 
		private System.Windows.Forms.ListBox lst_11; 
		private System.Windows.Forms.ListBox lst_10; 
		private System.Windows.Forms.ListBox lst_01; 
		private System.Windows.Forms.ListBox lst_00; 
 
		private UC_AddPlan uc_AddPlan = null; 
		private UC_UpdatePlan uc_UpdatePlan = null; 
		public static PlanInfo planInfo = null; 
		private ListBox curFocusListBox = null; 
 
		///  
		/// 必需的设计器变量。 
		///  
		private System.ComponentModel.Container components = null; 
 
		public Form1() 
		{ 
			// 
			// Windows 窗体设计器支持所必需的 
			// 
			InitializeComponent(); 
 
			ShowList(); 
		} 
 
		public void ReturnParent(Control c) 
		{ 
			this.Controls.Remove(c); 
			c.Dispose(); 
			uc_AddPlan = null; 
			panel_top.Visible = true; 
			ShowList(); 
		} 
 
		///  
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if (components != null)  
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows 窗体设计器生成的代码 
		///  
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改 
		/// 此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
			this.panel_top = new System.Windows.Forms.Panel(); 
			this.btn_Remove = new System.Windows.Forms.Button(); 
			this.btn_Add = new System.Windows.Forms.Button(); 
			this.label4 = new System.Windows.Forms.Label(); 
			this.label3 = new System.Windows.Forms.Label(); 
			this.label2 = new System.Windows.Forms.Label(); 
			this.label1 = new System.Windows.Forms.Label(); 
			this.lst_11 = new System.Windows.Forms.ListBox(); 
			this.lst_10 = new System.Windows.Forms.ListBox(); 
			this.lst_01 = new System.Windows.Forms.ListBox(); 
			this.lst_00 = new System.Windows.Forms.ListBox(); 
			this.panel_top.SuspendLayout(); 
			this.SuspendLayout(); 
			//  
			// panel_top 
			//  
			this.panel_top.Controls.Add(this.btn_Remove); 
			this.panel_top.Controls.Add(this.btn_Add); 
			this.panel_top.Controls.Add(this.label4); 
			this.panel_top.Controls.Add(this.label3); 
			this.panel_top.Controls.Add(this.label2); 
			this.panel_top.Controls.Add(this.label1); 
			this.panel_top.Controls.Add(this.lst_11); 
			this.panel_top.Controls.Add(this.lst_10); 
			this.panel_top.Controls.Add(this.lst_01); 
			this.panel_top.Controls.Add(this.lst_00); 
			this.panel_top.Location = new System.Drawing.Point(8, 24); 
			this.panel_top.Name = "panel_top"; 
			this.panel_top.Size = new System.Drawing.Size(672, 512); 
			this.panel_top.TabIndex = 21; 
			//  
			// btn_Remove 
			//  
			this.btn_Remove.Location = new System.Drawing.Point(624, 0); 
			this.btn_Remove.Name = "btn_Remove"; 
			this.btn_Remove.Size = new System.Drawing.Size(16, 16); 
			this.btn_Remove.TabIndex = 30; 
			this.btn_Remove.Text = "-"; 
			this.btn_Remove.Click += new System.EventHandler(this.btn_Remove_Click); 
			//  
			// btn_Add 
			//  
			this.btn_Add.Location = new System.Drawing.Point(608, 0); 
			this.btn_Add.Name = "btn_Add"; 
			this.btn_Add.Size = new System.Drawing.Size(16, 16); 
			this.btn_Add.TabIndex = 29; 
			this.btn_Add.Text = "+"; 
			this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click); 
			//  
			// label4 
			//  
			this.label4.Location = new System.Drawing.Point(344, 262); 
			this.label4.Name = "label4"; 
			this.label4.Size = new System.Drawing.Size(100, 16); 
			this.label4.TabIndex = 28; 
			this.label4.Text = "不重要不紧急"; 
			//  
			// label3 
			//  
			this.label3.Location = new System.Drawing.Point(16, 262); 
			this.label3.Name = "label3"; 
			this.label3.Size = new System.Drawing.Size(100, 16); 
			this.label3.TabIndex = 27; 
			this.label3.Text = "不重要紧急"; 
			//  
			// label2 
			//  
			this.label2.Location = new System.Drawing.Point(344, 22); 
			this.label2.Name = "label2"; 
			this.label2.Size = new System.Drawing.Size(100, 16); 
			this.label2.TabIndex = 26; 
			this.label2.Text = "重要不紧急"; 
			//  
			// label1 
			//  
			this.label1.Location = new System.Drawing.Point(16, 22); 
			this.label1.Name = "label1"; 
			this.label1.Size = new System.Drawing.Size(100, 16); 
			this.label1.TabIndex = 25; 
			this.label1.Text = "重要紧急"; 
			//  
			// lst_11 
			//  
			this.lst_11.DisplayMember = "Item"; 
			this.lst_11.ItemHeight = 12; 
			this.lst_11.Location = new System.Drawing.Point(344, 278); 
			this.lst_11.Name = "lst_11"; 
			this.lst_11.Size = new System.Drawing.Size(312, 220); 
			this.lst_11.TabIndex = 24; 
			this.lst_11.DoubleClick += new System.EventHandler(this.lst_DoubleClick); 
			this.lst_11.SelectedIndexChanged += new System.EventHandler(this.lst_SelectedIndexChanged); 
			//  
			// lst_10 
			//  
			this.lst_10.DisplayMember = "Item"; 
			this.lst_10.ItemHeight = 12; 
			this.lst_10.Location = new System.Drawing.Point(16, 278); 
			this.lst_10.Name = "lst_10"; 
			this.lst_10.Size = new System.Drawing.Size(312, 220); 
			this.lst_10.TabIndex = 23; 
			this.lst_10.DoubleClick += new System.EventHandler(this.lst_DoubleClick); 
			this.lst_10.SelectedIndexChanged += new System.EventHandler(this.lst_SelectedIndexChanged); 
			//  
			// lst_01 
			//  
			this.lst_01.DisplayMember = "Item"; 
			this.lst_01.ItemHeight = 12; 
			this.lst_01.Location = new System.Drawing.Point(344, 38); 
			this.lst_01.Name = "lst_01"; 
			this.lst_01.Size = new System.Drawing.Size(312, 220); 
			this.lst_01.TabIndex = 22; 
			this.lst_01.DoubleClick += new System.EventHandler(this.lst_DoubleClick); 
			this.lst_01.SelectedIndexChanged += new System.EventHandler(this.lst_SelectedIndexChanged); 
			//  
			// lst_00 
			//  
			this.lst_00.DisplayMember = "Item"; 
			this.lst_00.ItemHeight = 12; 
			this.lst_00.Location = new System.Drawing.Point(16, 38); 
			this.lst_00.Name = "lst_00"; 
			this.lst_00.Size = new System.Drawing.Size(312, 220); 
			this.lst_00.TabIndex = 21; 
			this.lst_00.DoubleClick += new System.EventHandler(this.lst_DoubleClick); 
			this.lst_00.SelectedIndexChanged += new System.EventHandler(this.lst_SelectedIndexChanged); 
			//  
			// Form1 
			//  
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); 
			this.ClientSize = new System.Drawing.Size(688, 542); 
			this.Controls.Add(this.panel_top); 
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 
			this.MaximizeBox = false; 
			this.Name = "Form1"; 
			this.Opacity = 0.8; 
			this.Text = "Form1"; 
			this.panel_top.ResumeLayout(false); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		///  
		/// 应用程序的主入口点。 
		///  
		[STAThread] 
		static void Main()  
		{ 
			Application.Run(new Form1()); 
		} 
 
		private void ShowList() 
		{ 
			/*lst_00.DisplayMember = "Item"; 
			lst_01.DisplayMember = "Item"; 
			lst_10.DisplayMember = "Item"; 
			lst_11.DisplayMember = "Item"; 
			lst_00.DataSource = Global.PLAN_LIST[0]; 
			lst_01.DataSource = Global.PLAN_LIST[1]; 
			lst_10.DataSource = Global.PLAN_LIST[2]; 
			lst_11.DataSource = Global.PLAN_LIST[3];*/ 
 
			lst_00.Items.Clear(); 
			lst_01.Items.Clear(); 
			lst_10.Items.Clear(); 
			lst_11.Items.Clear(); 
			foreach(PlanInfo info in Global.PLAN_LIST.Plan_List) 
			{ 
				/*Label lbl = new Label(); 
				lbl.Width = 312; 
				lbl.Text = info.Item + "(" + info.DateEnd.ToString("yyyy-MM-dd") + ")"; 
				if(info.DateEnd <= DateTime.Today.AddDays(10)) 
				{ 
					lbl.ForeColor = Color.Red; 
				}*/ 
				switch(info.Level) 
				{ 
					case 0: 
						lst_00.Items.Add((info.Finished ? "√" : "") + info.Item + "(" + info.DateEnd.ToString("yyyy-MM-dd") + ")"); 
						break; 
					case 1: 
						//lst_01.Controls.Add(lbl); 
						lst_01.Items.Add((info.Finished ? "√" : "") + info.Item + "(" + info.DateEnd.ToString("yyyy-MM-dd") + ")"); 
						break; 
					case 2: 
						lst_10.Items.Add((info.Finished ? "√" : "") + info.Item + "(" + info.DateEnd.ToString("yyyy-MM-dd") + ")"); 
						break; 
					case 3: 
						lst_11.Items.Add((info.Finished ? "√" : "") + info.Item + "(" + info.DateEnd.ToString("yyyy-MM-dd") + ")"); 
						break; 
					default: 
						break; 
				} 
			} 
		} 
 
		private void btn_Add_Click(object sender, System.EventArgs e) 
		{ 
			panel_top.Visible = false; 
 
			uc_AddPlan = new UC_AddPlan(); 
			uc_AddPlan.Parent_Form = this; 
			this.Controls.Add(uc_AddPlan); 
		} 
 
		private void btn_Remove_Click(object sender, System.EventArgs e) 
		{ 
			if(Global.YesNoMessage("是否要删除计划项:" + curFocusListBox.Text)) 
			{ 
				Global.PLAN_LIST.Plan_List.Remove(Global.PLAN_LIST[curFocusListBox.Text.Split('(')[0]]); 
				Global.SaveConfig(); 
				ShowList(); 
			} 
		} 
 
		private void lst_DoubleClick(object sender, System.EventArgs e) 
		{ 
			panel_top.Visible = false; 
 
			//uc_UpdatePlan = new UC_UpdatePlan(lst_00.SelectedItem as PlanInfo); 
			uc_UpdatePlan = new UC_UpdatePlan(Global.PLAN_LIST[(sender as ListBox).Text.Split('(')[0]]); 
			uc_UpdatePlan.Parent_Form = this; 
			this.Controls.Add(uc_UpdatePlan); 
		} 
 
		private void lst_SelectedIndexChanged(object sender, System.EventArgs e) 
		{ 
			curFocusListBox = sender as ListBox; 
			/*if(sender.Equals(lst_00)) 
			{ 
				lst_01.SelectedIndex = -1; 
				lst_10.SelectedIndex = -1; 
				lst_11.SelectedIndex = -1; 
				lst_00.Select(); 
			} 
			else if(sender.Equals(lst_01)) 
			{ 
				lst_00.SelectedIndex = -1; 
				lst_10.SelectedIndex = -1; 
				lst_11.SelectedIndex = -1; 
				lst_01.Select(); 
			} 
			else if(sender.Equals(lst_10)) 
			{ 
				lst_00.SelectedIndex = -1; 
				lst_01.SelectedIndex = -1; 
				lst_11.SelectedIndex = -1; 
				lst_10.Select(); 
			} 
			else if(sender.Equals(lst_11)) 
			{ 
				lst_00.SelectedIndex = -1; 
				lst_01.SelectedIndex = -1; 
				lst_10.SelectedIndex = -1; 
			} 
			(sender as ListBox).Select(); 
			(sender as ListBox).Focus();*/ 
//			lst_00.SelectedIndex = sender.Equals(lst_00) ? lst_00.SelectedIndex : -1; 
//			lst_01.SelectedIndex = sender.Equals(lst_01) ? lst_01.SelectedIndex : -1; 
//			lst_10.SelectedIndex = sender.Equals(lst_10) ? lst_10.SelectedIndex : -1; 
//			lst_11.SelectedIndex = sender.Equals(lst_11) ? lst_11.SelectedIndex : -1; 
		} 
	} 
}