Пример #1
0
        /// <summary>
        /// Selects the specified object in the tree.
        /// </summary>
        /// <param name="o">The object to be selected.</param>
        /// <param name="node">The node at which to start.</param>
        /// <param name="expand">Expand the node when it's found.</param>
        /// <param name="cancelled">if set to <c>true</c> then the node for the
        /// specified object was not allowed to be selected.</param>
        /// <returns>A value indicating whether selection was successful.</returns>
        public bool SelectObject(IXenObject o, VirtualTreeNode node, bool expand, ref bool cancelled)
        {
            IXenObject candidate = node.Tag as IXenObject;

            if (o == null || (candidate != null && candidate.opaque_ref == o.opaque_ref))
            {
                if (!CanSelectNode(node))
                {
                    cancelled = true;
                    return(false);
                }

                SelectedNode = node;

                if (expand)
                {
                    node.Expand();
                }

                return(true);
            }

            foreach (VirtualTreeNode child in node.Nodes)
            {
                if (SelectObject(o, child, expand, ref cancelled))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
 /// <summary>
 /// Ensures that the tree node is visible, expanding tree nodes and scrolling the tree view control as necessary.
 /// </summary>
 public new void EnsureVisible()
 {
     if (((TreeNode)this).TreeView == null)
     {
         VirtualTreeNode n = Parent;
         while (n != null)
         {
             n.Expand();
             n = n.Parent;
         }
     }
     base.EnsureVisible();
 }
Пример #3
0
        /// <summary>
        /// Selects the specified object in the tree.
        /// </summary>
        /// <param name="o">The object to be selected.</param>
        /// <param name="node">The node at which to start.</param>
        /// <param name="expand">Expand the node when it's found.</param>
        /// <param name="cancelled">if set to <c>true</c> then the node for the
        /// specified object was not allowed to be selected.</param>
        /// <returns>A value indicating whether selection was successful.</returns>
        public bool SelectObject(IXenObject o, VirtualTreeNode node, bool expand, ref bool cancelled)
        {
            IXenObject candidate = node.Tag as IXenObject;

            if (o == null || (candidate != null && candidate.opaque_ref == o.opaque_ref))
            {
                if (!CanSelectNode(node))
                {
                    cancelled = true;
                    return false;
                }

                SelectedNode = node;

                if (expand)
                    node.Expand();

                return true;
            }

            foreach (VirtualTreeNode child in node.Nodes)
            {
                if (SelectObject(o, child, expand, ref cancelled))
                    return true;
            }

            return false;
        }