Beispiel #1
0
        public override TreePath PathFromNode(object aNode)
        {
            TreePath tp = new TreePath();

            if ((aNode == null) || (Items == null) || (Items.Count == 0))
            {
                return(tp);
            }

            if (RespectHierarchy == false)
            {
                int i = Items.IndexOf(aNode);
                if (i > -1)
                {
                    tp.AppendIndex(i);
                }
                return(tp);
            }
            int[] idx = HierarchicalList.IndexOf(Items, aNode);
            if (idx != null)
            {
                foreach (int j in idx)
                {
                    tp.AppendIndex(j);
                }
            }
            return(tp);
        }
        public override TreePath PathFromNode(object aNode)
        {
            TreePath tp = new TreePath();

            if ((aNode == null) || (DataSource == null) || (GetMasterItemChildCount() == 0))
            {
                return(tp);
            }

            if (RespectHierarchy == false)
            {
                int i = GetMasterItemIndex(aNode);
                if (i > -1)
                {
                    tp.AppendIndex(i);
                }
                return(tp);
            }
            int[] idx = GetItemIndex(aNode, true);
            if (idx != null)
            {
                foreach (int j in idx)
                {
                    tp.AppendIndex(j);
                }
            }
            return(tp);
        }
		/// <summary>
		/// Searches for node in Items
		/// </summary>
		public override TreePath PathFromNode (object aNode)
		{
			TreePath tp = new TreePath();
			if ((aNode == null) || (Items == null) || (Items.Rows.Count == 0))
				return (tp);

			int idx = Items.Rows.IndexOf(aNode as DataRow);
			if (idx >= 0)
				tp.AppendIndex (idx);
			return (tp);
		}
Beispiel #4
0
        private void HandleNodeRemoved(Node parent, Node child, int wasAtIndex)
        {
            TreePath path = parent.Path;

            path.AppendIndex(wasAtIndex);

            Disconnect(child);

            RemoveChildren(child, path);

            //Console.WriteLine("Row deleted: {0}, {1}, {2}", path, child, Environment.StackTrace);
            d_adapter.EmitRowDeleted(path);
        }
        public TreePath GetPath(TreeIter iter)
        {
            var gch = (GCHandle)iter.UserData;
            var o   = gch.Target;

            if (o == null)
            {
                throw new ArgumentException("iter");
            }
            TreePath path = new TreePath();

            path.AppendIndex((int)o);
            return(path);
        }
Beispiel #6
0
        /// <summary>
        /// Searches for node in Items
        /// </summary>
        public override TreePath PathFromNode(object aNode)
        {
            TreePath tp = new TreePath();

            if ((aNode == null) || (Items == null) || (Items.Rows.Count == 0))
            {
                return(tp);
            }

            int idx = Items.Rows.IndexOf(aNode as DataRow);

            if (idx >= 0)
            {
                tp.AppendIndex(idx);
            }
            return(tp);
        }
Beispiel #7
0
        public TreePath PathFromNode(object aNode)
        {
            TreePath tp = new TreePath();

            if ((aNode == null) || (sourceList == null) || (sourceList.Count == 0))
            {
                return(tp);
            }

            int i = sourceList.IndexOf(aNode);

            if (i > -1)
            {
                tp.AppendIndex(i);
            }
            return(tp);
        }
Beispiel #8
0
        /// <summary>
        /// Searches for node in Items
        /// </summary>
        public override TreePath PathFromNode(object aNode)
        {
            TreePath tp = new TreePath();

            if ((aNode == null) || (DataSource == null) || (GetItemCount() == 0))
            {
                return(tp);
            }

            int idx = GetItemIndex(aNode);

            if (idx >= 0)
            {
                tp.AppendIndex(idx);
            }
            return(tp);
        }
Beispiel #9
0
        /// <summary>
        /// Gets the path to the node pointed to by <paramref name="nodePath"/>. If the path doesn't point to a specific
        /// node, it will be set to the deepest possible node.
        /// </summary>
        /// <param name="nodePath">The path to the node. Expected to have '\' as its separator character.</param>
        /// <returns>The path to the node.</returns>
        public TreePath GetPath(string nodePath)
        {
            if (string.IsNullOrEmpty(nodePath))
            {
                throw new ArgumentNullException(nameof(nodePath));
            }

            var parentNode = this.Tree.Root;

            string[] pathParts = nodePath.Split('\\');

            var result = new TreePath();

            foreach (var part in pathParts)
            {
                bool foundNode = false;
                foreach (var nodeOffset in parentNode.ChildOffsets)
                {
                    var node = this.Tree.GetNode(nodeOffset);
                    if (!string.Equals(this.Tree.GetNodeName(node), part, StringComparison.OrdinalIgnoreCase))
                    {
                        // Skip descendant nodes that are not part of the path
                        continue;
                    }

                    var childIndex = parentNode.ChildOffsets.IndexOf(nodeOffset);
                    result.AppendIndex(childIndex);

                    parentNode = node;

                    foundNode = true;
                    break;
                }

                if (!foundNode)
                {
                    // If we reach this point, we did not find a matching node on this level. Therefore, the path is
                    // invalid.
                    return(null);
                }
            }

            return(result);
        }
Beispiel #10
0
        protected void RowExpanded(object o, RowExpandedArgs args)
        {
            TreeIter it;

            GtkStore.GetIter(out it, args.Path);
            int childCount = GtkStore.IterNChildren(it);

            for (int i = 0; i < childCount; i++)
            {
                TreePath childPath = args.Path.Copy();
                childPath.AppendIndex(i);

                TreeIter childIter;
                GtkStore.GetIter(out childIter, childPath);
                string childFullName = (string)GtkStore.GetValue(childIter, LocalsStore.ColumnFullName);
                // This node was expanded in the past - expand it
                if (childFullName != null && expandedNodes.ContainsKey(childFullName))
                {
                    GtkTree.ExpandRow(childPath, false);
                }
            }
        }
            private void OnCursorChanged(object o,
						      System.EventArgs args)
            {
                TreePath path;
                TreeViewColumn col;
                view.GetCursor (out path, out col);
                ArrayList moves = new ArrayList ();

                TreePath tmppath = new TreePath ();
                foreach (int i in path.Indices)
                {
                    tmppath.AppendIndex (i);
                    TreeIter iter;
                    store.GetIter (out iter, tmppath);
                    moves.Add (store.GetValue (iter, 0));
                }

                boardWidget.PlayMoves (moves);
            }
		/// <summary>
		/// Searches for node in Items
		/// </summary>
		public override TreePath PathFromNode (object aNode)
		{
			TreePath tp = new TreePath();
			if ((aNode == null) || (DataSource == null) || (GetItemCount() == 0))
				return (tp);

			int idx = GetItemIndex (aNode);
			if (idx >= 0)
				tp.AppendIndex (idx);
			return (tp);
		}