Пример #1
0
 private void SelectNode(NodeCollection nodes, string strNodeText)
 {
     foreach (Node node in nodes)
     {
         if (node.Nodes.Count == 0 && node.Tag.ToString() == strNodeText)
         {
             Node tnode = new Node();
             node.Nodes.Add(tnode);
             advTree1.SelectedNode = node;
             tnode.EnsureVisible();
             node.Nodes.Clear();
         }
         else
         {
             SelectNode(node.Nodes, strNodeText);
         }
     }
 }
Пример #2
0
 private Node FindOrCreateNamespaceNodeSplit(string ns, NodeCollection collection)
 {
     int index = ns.IndexOf(".");
     if (index > -1)
     {
         string @namespace = ns.Substring(0, index);
         var parent = FindOrCreateNamespaceNode(@namespace, collection);
         return FindOrCreateNamespaceNodeSplit(ns.Substring(index + 1), parent.Nodes);
     }
     return FindOrCreateNamespaceNode(ns, collection);
 }
Пример #3
0
        private Node FindOrCreateNamespaceNode(string ns, NodeCollection collection)
        {
            var node = FindFirstNodeNamed(ns, collection);

            if (node == null)
            {
                node = new Node { Text = ns, Name = ns };
                collection.Add(node);
            }

            return node;
        }
Пример #4
0
 private Node FindFirstNodeNamed(string nodeName, NodeCollection collection)
 {
     Node[] nodes = collection.Find(nodeName, false);
     return nodes.Length > 0 ? nodes[0] : null;
 }
Пример #5
0
        /// <summary>
        /// Creates a new node for the data item.
        /// </summary>
        /// <param name="item">Item to create node for.</param>
        /// <returns>New instance of the node.</returns>
        private Node CreateNode(NodeCollection parentCollection, object item, int itemIndex, List<string> fieldNames)
        {
            Node node = new Node();
            parentCollection.Add(node);

            SetNodeData(node, item, fieldNames, itemIndex);

            DataNodeEventArgs eventArgs = new DataNodeEventArgs(node, item);

            OnDataNodeCreated(eventArgs);

            return eventArgs.Node;
        }
Пример #6
0
 private Node CreateGroupNode(NodeCollection parentCollection, string text)
 {
     Node node = new Node();
     node.Text = text;
     node.Style = _GroupNodeStyle;
     node.Expanded = true;
     node.Selectable = false;
     parentCollection.Add(node);
     DataNodeEventArgs eventArgs = new DataNodeEventArgs(node, null);
     OnGroupNodeCreated(eventArgs);
     return node;
 }
Пример #7
0
 private void FilterNodes(NodeCollection nodeCollection, List<Node> hiddenNodes, string searchText)
 {
     searchText = searchText.ToUpper();
     foreach (Node item in nodeCollection)
     {
         PropertyNode propertyNode = item as PropertyNode;
         if (propertyNode != null && !propertyNode.Text.ToUpper().Contains(searchText))
         {
             propertyNode.Visible = false;
             hiddenNodes.Add(propertyNode);
         }
         if (item.HasChildNodes)
             FilterNodes(item.Nodes, hiddenNodes, searchText);
     }
 }
Пример #8
0
 public static Node FindNodeByBindingIndex(NodeCollection col, int bindingIndex)
 {
     foreach (Node node in col)
     {
         if (node.BindingIndex == bindingIndex)
             return node;
         if (node.HasChildNodes)
         {
             Node n2 = FindNodeByBindingIndex(node.Nodes, bindingIndex);
             if (n2 != null) return n2;
         }
     }
     return null;
 }
Пример #9
0
 public static Node FindNodeByDataKey(NodeCollection col, object key)
 {
     foreach (Node node in col)
     {
         if (object.Equals(node.DataKey, key))
             return node;
         if (node.HasChildNodes)
         {
             Node n2 = FindNodeByDataKey(node.Nodes, key);
             if (n2 != null) return n2;
         }
     }
     return null;
 }
Пример #10
0
 public static void FindNodesByName(NodeCollection col, string name, bool searchAllChildren, ArrayList listToPopulate)
 {
     foreach (Node node in col)
     {
         if (node.Name == name)
             listToPopulate.Add(node);
         if (searchAllChildren && node.HasChildNodes)
         {
             FindNodesByName(node.Nodes, name, true, listToPopulate);
         }
     }
 }
Пример #11
0
 public static Node FindNodeByName(NodeCollection col, string name)
 {
     foreach (Node node in col)
     {
         if (node.Name == name)
             return node;
         if (node.HasChildNodes)
         {
             Node n2 = FindNodeByName(node.Nodes, name);
             if (n2 != null) return n2;
         }
     }
     return null;
 }
Пример #12
0
        private void RenderNodes(KeyCatalog catalog, NodeCollection nodes, int restoreLevel)
        {
            restoreLevel--;
            foreach (KeyCatalog sub in catalog.Subcatalogs.SortedValues)
            {
                KeyNode n = new KeyNode(sub.ToString()) { Catalog = sub };
                nodes.Add(n);

                if (restoreLevel < 0)
                {
                    if (SelectionNodeName == sub.Name)
                        ATree.SelectedNode = n;
                }

                if (!sub.IsLeaf)
                    RenderNodes(sub, n.Nodes, restoreLevel);
            }
        }
Пример #13
0
        internal void Parse(NodeCollection nodeCollection, ePropertySort propertySort, SuperTooltip helpTooltip)
        {
            PropertyDescriptorCollection propertyCollection = GetProperties();
            bool hasIgnoredProperties = _IgnoredProperties.Count > 0;
            bool hasIgnoredCategories = _IgnoredCategories.Count > 0;

            if (propertySort == ePropertySort.Categorized || propertySort == ePropertySort.CategorizedAlphabetical)
            {
                Dictionary<string, Node> table = new Dictionary<string, Node>();
                foreach (PropertyDescriptor item in propertyCollection)
                {
                    if (item == null || hasIgnoredProperties && _IgnoredProperties.Contains(item.Name)) continue;

                    string category = GetCategory(item);
                    PropertySettings settings = _PropertySettings[item, item.Name];
                    if (settings != null && settings.Category != null)
                        category = settings.Category;
                        
                    if (hasIgnoredCategories && !string.IsNullOrEmpty(category) && _IgnoredCategories.Contains(category)) continue;

                    Node categoryNode = null;
                    if (!table.TryGetValue(category, out categoryNode))
                    {
                        categoryNode = _PropertyNodeFactory.CreateCategoryNode(category, _Localizer);
                        nodeCollection.Add(categoryNode);
                        table.Add(category, categoryNode);
                    }
                    PropertyNode node = _PropertyNodeFactory.CreatePropertyNode(item, _SelectedObject ?? _SelectedObjects, _Localizer, settings, _SelectedObjects != null);
                    categoryNode.Nodes.Add(node);
                    node.OnLoaded();
                    if (_HelpType == ePropertyGridHelpType.SuperTooltip && helpTooltip != null)
                        node.SetHelpTooltip(helpTooltip);
                    node.UpdateDisplayedValue();
                }

                if (propertySort == ePropertySort.CategorizedAlphabetical)
                {
                    foreach (Node item in table.Values)
                    {
                        item.Nodes.Sort();
                    }

                    nodeCollection.Sort();
                }
            }
            else
            {
                foreach (PropertyDescriptor item in propertyCollection)
                {
                    if (item == null || _IgnoredProperties.Contains(item.Name)) continue;

                    PropertyNode node = _PropertyNodeFactory.CreatePropertyNode(item, _SelectedObject ?? _SelectedObjects, _Localizer, _PropertySettings, _SelectedObjects != null);
                    nodeCollection.Add(node);
                    node.OnLoaded();
                    if (_HelpType == ePropertyGridHelpType.SuperTooltip && helpTooltip != null)
                        node.SetHelpTooltip(helpTooltip);
                    node.UpdateDisplayedValue();
                }
                if (propertySort == ePropertySort.Alphabetical)
                    nodeCollection.Sort();
            }
        }
Пример #14
0
 private void ClearNodes(NodeCollection nodes)
 {
     foreach(Node node in nodes)
     {
         node.Tag = null;
         foreach(Cell cell in node.Cells)
         {
             cell.Tag = null;
         }
         ClearNodes(node.Nodes);
     }
     nodes.Clear();
 }
Пример #15
0
        private void ProcessTreeValidity(NodeCollection nodesToProcess)
        {
            for (int i = nodesToProcess.Count - 1; i >= 0; i--)
            {
                Node node = nodesToProcess[i];

                if (GetNodeCheckState(node) == CheckState.Unchecked && node.ImageIndex == GreenBulletValue)
                {
                    continue;
                }
                ValidateNode(node);
                ProcessTreeValidity(node.Nodes);
            }
        }
Пример #16
0
 private Node FindFirstNamed(string name, NodeCollection nodes)
 {
     Node[] found = nodes.Find(name, false);
     return found.Length > 0 ? found[0] : null;
 }