/// <devdoc>
        /// Copies the tree node and the  entire subtree rooted at this tree node.
        /// </devdoc>
        public override object Clone()
        {
            ConfigurationTreeNode clone = (ConfigurationTreeNode)base.Clone();

            clone.configurationNode = configurationNode;
            clone.children          = children;
            return(clone);
        }
        private void AddChildeNode(ConfigurationNodeChangedEventArgs e)
        {
            ConfigurationTreeNode newNode = CreateChildNode(e.Node);

            if (newNode.ConfigurationNode.Parent.SortChildren)
            {
                AddSorted(newNode);
            }
            else
            {
                this.Nodes.Add(newNode);
            }
            foreach (ConfigurationNode child in e.Node.Nodes)
            {
                newNode.OnChildAdded(newNode, new ConfigurationNodeChangedEventArgs(child, e.Node));
            }
        }
        /// <devdoc>
        /// Creates a new intance of a ConfigurationTreeNode class and sets its ImageIndex and SelectedImageIndex property values.
        /// </devdoc>
        public static ConfigurationTreeNode Create(ConfigurationNode node)
        {
            Type nodeType     = node.GetType();
            Type treeNodeType = GetTreeNodeType(nodeType);
            ConfigurationTreeNode treeNode = (ConfigurationTreeNode)Activator.CreateInstance(treeNodeType, new object[] { node });

            if (Current.imageContainer != null)
            {
                treeNode.ImageIndex         = Current.imageContainer.GetImageIndex(nodeType);
                treeNode.SelectedImageIndex = Current.imageContainer.GetSelectedImageIndex(nodeType);
            }
            if (Current.treeNodeContainer != null)
            {
                Current.treeNodeContainer.AddTreeNode(treeNode);
            }
            return(treeNode);
        }
        private int AddSorted(ConfigurationTreeNode node)
        {
            int    index           = 0;
            string nodeDisplayName = node.Text;
            int    childCount      = Nodes.Count;

            if (childCount > 0)
            {
                CompareInfo compare = CultureInfo.CurrentCulture.CompareInfo;
                if (compare.Compare(Nodes[childCount - 1].Text, nodeDisplayName) <= 0)
                {
                    index = childCount;
                }
                else
                {
                    int firstNode   = 0;
                    int lastNode    = 0;
                    int compareNode = 0;
                    for (firstNode = 0, lastNode = childCount; firstNode < lastNode;)
                    {
                        compareNode = (firstNode + lastNode) / 2;
                        if (compare.Compare(Nodes[compareNode].Text, nodeDisplayName) <= 0)
                        {
                            firstNode = compareNode + 1;
                        }
                        else
                        {
                            lastNode = compareNode;
                        }
                    }
                    index = firstNode;
                }
            }
            Nodes.Insert(index, node);
            return(index);
        }
        /// <devdoc>
        /// Creates a ConfigurationTreeNode using the TreeNodeFactory of the current ConfigurationTreeView.
        /// </devdoc>
        protected ConfigurationTreeNode CreateChildNode(ConfigurationNode node)
        {
            ConfigurationTreeNode treeNode = TreeNodeFactory.Create(node);

            return(treeNode);
        }
Пример #6
0
 /// <devdoc>
 /// Adds the specified ConfigurationTreeNode to the container.
 /// </devdoc>
 public void AddTreeNode(ConfigurationTreeNode treeNode)
 {
     treeNodes[treeNode.ConfigurationNode.Id] = treeNode;
 }
Пример #7
0
 /// <devdoc>
 /// Adds the specified ConfigurationTreeNode to the container.
 /// </devdoc>
 public void AddTreeNode(ConfigurationTreeNode treeNode)
 {
     treeNodes[treeNode.ConfigurationNode.Id] = treeNode;
 }
Пример #8
0
 private void LoadMenuItemsFromNode(ConfigurationTreeNode node, MenuItem[] menuItems)
 {
     AddMenus(node.ConfigurationNode, menuItems);
 }
Пример #9
0
 //private void AddServices()
 //{
 //    designHost.AddService(typeof(IUIService), this);
 //}
 private void InitializeHierarchy()
 {
     TreeNodeFactory.SetImageContainer(new ConfigurationNodeImageContainer(treeViewImageList));
     solutionNode = new SolutionConfigurationNode();
     //IConfigurationUIHierarchy hierarchy = new ConfigurationUIHierarchy(solutionNode, designHost);
     IConfigurationUIHierarchyService service = designHost.GetService(typeof(IConfigurationUIHierarchyService)) as IConfigurationUIHierarchyService;
     //service.AddHierarchy(hierarchy);
     service.HierarchyAdded += new EventHandler<HierarchyAddedEventArgs>(OnHierarchyAdded);
     service.HierarchyRemoved += new EventHandler<HierarchyRemovedEventArgs>(OnHierarchyRemoved);
     solutionTreeNode = TreeNodeFactory.Create(solutionNode);
     treeView.Nodes.Add(solutionTreeNode);
     SetSelectedNode(solutionTreeNode);
 }
Пример #10
0
 private void UpdateSelection(ConfigurationTreeNode treeNode)
 {
     using (new WaitCursor())
     {
         object[] objects = new object[] {treeNode.ConfigurationNode};
         propertyGrid.SelectedObjects = objects;
     }
 }
Пример #11
0
 private void SetSelectedNode(ConfigurationTreeNode selectedNode)
 {
     treeView.SelectedNode = null;
     treeView.SelectedNode = selectedNode;
 }
Пример #12
0
 private void SetSelectedHierarchy(ConfigurationTreeNode node)
 {
     IConfigurationUIHierarchyService hierarchyService = (IConfigurationUIHierarchyService)designHost.GetService(typeof(IConfigurationUIHierarchyService));
     hierarchyService.SelectedHierarchy = node.ConfigurationNode.Hierarchy;
 }
Пример #13
0
 private int AddSorted(ConfigurationTreeNode node)
 {
     int index = 0;
     string nodeDisplayName = node.Text;
     int childCount = Nodes.Count;
     if (childCount > 0)
     {
         CompareInfo compare = CultureInfo.CurrentCulture.CompareInfo;
         if (compare.Compare(Nodes[childCount-1].Text, nodeDisplayName) <= 0)
         {
             index = childCount;
         }
         else
         {
             int firstNode = 0;
             int lastNode = 0;
             int compareNode = 0;
             for (firstNode = 0, lastNode = childCount; firstNode < lastNode;)
             {
                 compareNode = (firstNode + lastNode) / 2;
                 if (compare.Compare(Nodes[compareNode].Text, nodeDisplayName) <= 0)
                 {
                     firstNode = compareNode + 1;
                 }
                 else
                 {
                     lastNode = compareNode;
                 }
             }
             index = firstNode;
         }
     }
     Nodes.Insert(index, node);
     return index;
 }