int GetInsertionIndex(TreeNodeCollection nodes, TreeView treeView)
        {
            if (treeView == null)
            {
                return(nodes.Count);
            }

            Comparison <TreeNode> comparison = null;

            ExtTreeView etv = treeView as ExtTreeView;

            if (etv == null)
            {
                if (!treeView.Sorted)
                {
                    return(nodes.Count);
                }
                if (treeView.TreeViewNodeSorter != null)
                {
                    comparison = treeView.TreeViewNodeSorter.Compare;
                }
            }
            else
            {
                if (!etv.IsSorted)
                {
                    return(nodes.Count);
                }
                if (etv.NodeSorter != null)
                {
                    comparison = etv.NodeSorter.Compare;
                }
            }

            if (comparison == null)
            {
                return(nodes.Count);
            }

            for (int i = 0; i < nodes.Count; ++i)
            {
                if (comparison(this, nodes[i]) < 0)
                {
                    return(i);
                }
            }

            return(nodes.Count);
        }
Exemple #2
0
		public void SetIcon(string iconName)
		{
			if (iconName == null) {
				return;
			}
			this.image = iconName;
			
			ExtTreeView tree = TreeView as ExtTreeView;
			if (tree != null) {
				int index = tree.GetImageIndexForImage(iconName, DoPerformCut);
				if (ImageIndex != index) {
					ImageIndex = SelectedImageIndex = index;
				}
			}
		}
		/// <summary>
		/// This method is required for Windows Forms designer support.
		/// Do not change the method contents inside the source code editor. The Forms designer might
		/// not be able to load this method if it was changed manually.
		/// </summary>
		private void InitializeComponent()
		{
			this.treeView = new ExtTreeView();
			this.SuspendLayout();
			// 
			// treeView
			// 
			this.treeView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.treeView.ImageIndex = -1;
			this.treeView.Location = new System.Drawing.Point(0, 0);
			this.treeView.Name = "treeView";
			this.treeView.SelectedImageIndex = -1;
			this.treeView.Size = new System.Drawing.Size(292, 266);
			this.treeView.TabIndex = 0;
			
			// 
			// ProjectBrowserControl
			// 
			this.Controls.Add(this.treeView);
			this.Name = "ProjectBrowserControl";
			this.Size = new System.Drawing.Size(292, 266);
			this.ResumeLayout(false);
		}
		/// <summary>
		/// Adds a new tree node to the tree view.
		/// </summary>
		public static ExtTreeNode AddNode(ExtTreeView treeView, XmlElement element)
		{
			ExtTreeNode node = CreateNode(element);
			node.AddTo(treeView);
			return node;
		}