⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdirpicker.cs

📁 LLBLGen 1.21 Sourcecode
💻 CS
📖 第 1 页 / 共 2 页
字号:
		/// <returns>reference to the searched TreeNode object if found, otherwise null.</returns>
		private TreeNode FindNodeInNodes(string sNodeText, TreeNodeCollection tncNodes)
		{
			foreach(TreeNode tnNode in tncNodes)
			{
				if(tnNode.Text == sNodeText)
				{
					// found it
					return tnNode;
				}
			}
			// not found
			return null;
		}


		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.lblDescription = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.tvMain = new System.Windows.Forms.TreeView();
			this.ilMain = new System.Windows.Forms.ImageList(this.components);
			this.label1 = new System.Windows.Forms.Label();
			this.tbxCurrentPath = new System.Windows.Forms.TextBox();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnOK = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// lblDescription
			// 
			this.lblDescription.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.lblDescription.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.lblDescription.Location = new System.Drawing.Point(6, 9);
			this.lblDescription.Name = "lblDescription";
			this.lblDescription.Size = new System.Drawing.Size(390, 18);
			this.lblDescription.TabIndex = 0;
			// 
			// groupBox1
			// 
			this.groupBox1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.tvMain});
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(3, 30);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(393, 351);
			this.groupBox1.TabIndex = 1;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Directory structure";
			// 
			// tvMain
			// 
			this.tvMain.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tvMain.HideSelection = false;
			this.tvMain.ImageList = this.ilMain;
			this.tvMain.Indent = 19;
			this.tvMain.Location = new System.Drawing.Point(6, 15);
			this.tvMain.Name = "tvMain";
			this.tvMain.Size = new System.Drawing.Size(381, 321);
			this.tvMain.Sorted = true;
			this.tvMain.TabIndex = 0;
			this.tvMain.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.tvMain_AfterExpand);
			this.tvMain.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.tvMain_AfterCollapse);
			this.tvMain.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvMain_AfterSelect);
			this.tvMain.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvMain_BeforeExpand);
			// 
			// ilMain
			// 
			this.ilMain.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
			this.ilMain.ImageSize = new System.Drawing.Size(16, 16);
			this.ilMain.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// label1
			// 
			this.label1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label1.Location = new System.Drawing.Point(6, 390);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 18);
			this.label1.TabIndex = 2;
			this.label1.Text = "Current path:";
			// 
			// tbxCurrentPath
			// 
			this.tbxCurrentPath.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tbxCurrentPath.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.tbxCurrentPath.Location = new System.Drawing.Point(75, 387);
			this.tbxCurrentPath.Name = "tbxCurrentPath";
			this.tbxCurrentPath.ReadOnly = true;
			this.tbxCurrentPath.Size = new System.Drawing.Size(318, 20);
			this.tbxCurrentPath.TabIndex = 3;
			this.tbxCurrentPath.Text = "";
			// 
			// btnCancel
			// 
			this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnCancel.Location = new System.Drawing.Point(321, 414);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(72, 24);
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnOK
			// 
			this.btnOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnOK.Location = new System.Drawing.Point(243, 414);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(72, 24);
			this.btnOK.TabIndex = 5;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// frmDirPicker
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(400, 447);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnOK,
																		  this.btnCancel,
																		  this.tbxCurrentPath,
																		  this.label1,
																		  this.groupBox1,
																		  this.lblDescription});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
			this.Name = "frmDirPicker";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Select a directory";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			m_bCancelClicked = true;
			this.Close();
		}

		private void tvMain_AfterCollapse(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			// change image of collapsed node
			if(e.Node.Parent!=null)
			{
				e.Node.ImageIndex = 0;
				e.Node.SelectedImageIndex = 0;
			}
		}


		private void tvMain_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			// Mirror full path in textbox
			tbxCurrentPath.Text = e.Node.FullPath;
		}

		private void tvMain_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
		{
			// get the subdirectories if needed.
			GetSubDirectoryNodes(e.Node);

			Application.DoEvents();
		}

		private void tvMain_AfterExpand(object sender, System.Windows.Forms.TreeViewEventArgs e)
		{
			// change image of expanded node.
			if(e.Node.Parent!=null)
			{
				e.Node.ImageIndex = 1;
				e.Node.SelectedImageIndex = 1;
			}
		}

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

		
		#region Class Property Declarations
		public string Description
		{
			get
			{
				return lblDescription.Text;
			}
			set
			{
				if(value!=null)
				{
					lblDescription.Text = value;
				}
				else
				{
					// invalid, throw exception.
					throw new ArgumentNullException("Description","Description can't be NULL");
				}
			}
		}
		public string CurrentPath
		{
			get
			{
				return tbxCurrentPath.Text;
			}
			set
			{
				if(value!=null)
				{
					tbxCurrentPath.Text = value;
					if(value.Length > 0)
					{
						ReflectCurrentPathInTree();
					}
				}
				else
				{
					// invalid, throw exception.
					throw new ArgumentNullException("CurrentPath","CurrentPath can't be NULL");
				}
			}
		}
		public bool CancelClicked
		{
			get
			{
				return m_bCancelClicked;
			}
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -