void BuildTreeChildren(Gtk.TreeStore store, Gtk.TreeIter parent, ParentNode p, IList <Block> blocks)
        {
            foreach (Node node in p)
            {
                if (!(node is TagNode))
                {
                    var startLoc = new TextLocation(node.Location.BeginLine, node.Location.BeginColumn);
                    var endLoc   = new TextLocation(node.Location.EndLine, node.Location.EndColumn);
                    var doc      = defaultDocument.Editor.Document;

                    var blocksBetween = blocks.Where(n => n.Start.AbsoluteIndex >= doc.GetOffset(startLoc) &&
                                                     n.Start.AbsoluteIndex <= doc.GetOffset(endLoc));

                    foreach (var block in blocksBetween)
                    {
                        var outlineNode = new OutlineNode(block)
                        {
                            Location = new DomRegion(doc.OffsetToLocation(block.Start.AbsoluteIndex),
                                                     doc.OffsetToLocation(block.Start.AbsoluteIndex + block.Length))
                        };
                        if (!parent.Equals(Gtk.TreeIter.Zero))
                        {
                            store.AppendValues(parent, outlineNode);
                        }
                        else
                        {
                            store.AppendValues(outlineNode);
                        }
                    }
                    continue;
                }

                Gtk.TreeIter childIter;
                if (!parent.Equals(Gtk.TreeIter.Zero))
                {
                    childIter = store.AppendValues(parent, new OutlineNode(node as TagNode));
                }
                else
                {
                    childIter = store.AppendValues(new OutlineNode(node as TagNode));
                }

                ParentNode pChild = node as ParentNode;
                if (pChild != null)
                {
                    BuildTreeChildren(store, childIter, pChild, blocks);
                }
            }
        }
Пример #2
0
        private static bool GetTreeIterForItem(out Gtk.TreeIter itemIter, Gtk.TreeIter parentIter, Gtk.TreeStore treeStore, FileNodeViewModel item, int index)
        {
            // if item is null, just get iterator at index
            itemIter = Gtk.TreeIter.Zero;
            var validIter  = false;
            var putAtFront = (index < 0) && (item == null);

            if (parentIter.Equals(Gtk.TreeIter.Zero))
            {
                if (putAtFront)
                {
                    validIter = treeStore.IterChildren(out itemIter);
                }
                else
                {
                    validIter = (treeStore.IterNChildren() > index) && treeStore.IterNthChild(out itemIter, index);
                }
            }
            else
            {
                if (putAtFront)
                {
                    validIter = treeStore.IterChildren(out itemIter, parentIter);
                }
                else
                {
                    validIter = (treeStore.IterNChildren(parentIter) > index) && treeStore.IterNthChild(out itemIter, parentIter, index);
                }
            }
            var node    = validIter ? treeStore.GetValue(itemIter, 0) as FileNodeViewModel : null;
            var foundIt = (node == null) || (item == null) || object.ReferenceEquals(node, item);

            return(foundIt && !itemIter.Equals(Gtk.TreeIter.Zero));
        }
Пример #3
0
        void BuildTreeChildren(Gtk.TreeStore store, Gtk.TreeIter parent, XContainer p, IList <Block> blocks)
        {
            foreach (XNode node in p.Nodes)
            {
                var el = node as XElement;
                if (el == null)
                {
                    var startLoc = node.Region.Begin;
                    var endLoc   = node.Region.End;
                    var doc      = defaultDocument.Editor.Document;

                    var blocksBetween = blocks.Where(n => n.Start.AbsoluteIndex >= doc.GetOffset(startLoc) &&
                                                     n.Start.AbsoluteIndex <= doc.GetOffset(endLoc));

                    foreach (var block in blocksBetween)
                    {
                        var outlineNode = new OutlineNode(block)
                        {
                            Location = new DomRegion(doc.OffsetToLocation(block.Start.AbsoluteIndex),
                                                     doc.OffsetToLocation(block.Start.AbsoluteIndex + block.Length))
                        };
                        if (!parent.Equals(Gtk.TreeIter.Zero))
                        {
                            store.AppendValues(parent, outlineNode);
                        }
                        else
                        {
                            store.AppendValues(outlineNode);
                        }
                    }
                    continue;
                }

                Gtk.TreeIter childIter;
                if (!parent.Equals(Gtk.TreeIter.Zero))
                {
                    childIter = store.AppendValues(parent, new OutlineNode(el));
                }
                else
                {
                    childIter = store.AppendValues(new OutlineNode(el));
                }

                BuildTreeChildren(store, childIter, el, blocks);
            }
        }
Пример #4
0
        /**
         * Gets both iters from the provided ListStore obj based on the passed TreePath object(the selected row)
         */
        private bool getPrevIterFromSelection(out Gtk.TreeIter selectedIter, out Gtk.TreeIter prevIter,
                                              Gtk.TreePath selectedRow, Gtk.ListStore listModel)
        {
            listModel.GetIter(out selectedIter, selectedRow);
            selectedRow.Prev();
            listModel.GetIter(out prevIter, selectedRow);

            return(prevIter.Stamp != 0 && !prevIter.Equals(selectedIter));
        }
Пример #5
0
        /**
         * Gets both iters from the provided ListStore obj based on the passed TreePath object(the selected row)
         */

        private bool getNextIterFromSelection(out Gtk.TreeIter selectedIter, out Gtk.TreeIter nextIter,
                                              Gtk.TreePath selectedRow, Gtk.ListStore listModel)
        {
            listModel.GetIter(out selectedIter, selectedRow);
            selectedRow.Next();
            listModel.GetIter(out nextIter, selectedRow);

            return(nextIter.Stamp != 0 && !nextIter.Equals(selectedIter));
        }
 void AssertIsValid()
 {
     if (!pad.sorting && !currentIter.Equals(Gtk.TreeIter.Zero) && !store.IterIsValid(currentIter))
     {
         if (dataItem == null || !MoveToObject(dataItem))
         {
             throw new InvalidOperationException("Tree iterator has been invalidated.");
         }
     }
 }
Пример #7
0
 public int IterNChildren(Gtk.TreeIter iter)
 {
     if (iter.Equals(TreeIter.Zero))
     {
         return(Nodes.Count);
     }
     else
     {
         return(GetNode(iter).ChildCount);
     }
 }
Пример #8
0
 public int IterNChildren(Gtk.TreeIter iter)
 {
     if (iter.Equals(Gtk.TreeIter.Zero))
     {
         return(source.RowCount);
     }
     else
     {
         return(0);
     }
 }
 internal void MoveToIter(Gtk.TreeIter iter)
 {
     currentNavIter = iter;
     if (!iter.Equals(Gtk.TreeIter.Zero))
     {
         dataItem = GetStoreValue(ExtensibleTreeView.DataItemColumn);
     }
     else
     {
         dataItem = null;
     }
 }
Пример #10
0
            public void Remove()
            {
                pad.RemoveChildren(currentIter);
                object data = store.GetValue(currentIter, ExtensibleTreeView.DataItemColumn);

                pad.UnregisterNode(data, currentIter, null, true);
                Gtk.TreeIter it = currentIter;
                if (store.Remove(ref it) && !it.Equals(Gtk.TreeIter.Zero))
                {
                    MoveToIter(it);
                }
            }
Пример #11
0
 public bool IterNthChild(out Gtk.TreeIter iter, Gtk.TreeIter parent, int n)
 {
     if (parent.Equals(Gtk.TreeIter.Zero))
     {
         iter = IterFromNode(n);
         return(true);
     }
     else
     {
         iter = Gtk.TreeIter.Zero;
         return(false);
     }
 }
Пример #12
0
        static void BuildTreeChildren(Gtk.TreeStore store, Gtk.TreeIter parent, XContainer p)
        {
            foreach (XNode n in p.Nodes)
            {
            Gtk.TreeIter childIter;
            if (!parent.Equals (Gtk.TreeIter.Zero))
                childIter = store.AppendValues (parent, n);
            else
                childIter = store.AppendValues (n);

            XContainer c = n as XContainer;
            if (c != null && c.FirstChild != null)
                BuildTreeChildren (store, childIter, c);
            }
        }
Пример #13
0
 /// <summary>
 /// Inserts the given child FileNodeViewModels into the given Gtk.TreeStore using the supplied Gtk.TreeIter as the point of insertion.
 /// </summary>
 /// <param name="treeStore">The Gtk.TreeStore to add child objects to.</param>
 /// <param name="children">The child ViewModels.</param>
 /// <param name="iter">The Gtk.TreeIter of the parent to which children are added.</param>
 protected static void InsertChildren(Gtk.TreeStore treeStore, ObservableCollection <FileNodeViewModel> children, Gtk.TreeIter iter)
 {
     foreach (var child in children)
     {
         Gtk.TreeIter childIter;
         if (iter.Equals(Gtk.TreeIter.Zero))
         {
             childIter = treeStore.AppendValues(child);
         }
         else
         {
             childIter = treeStore.AppendValues(iter, child);
         }
         var folder = child as FolderViewModel;
         if (folder != null)
         {
             // Ensure the child folder has properly initialized Gtk.TreeStore.
             folder.InitializeGtkModel(treeStore);
             InsertChildren(treeStore, folder.Items, childIter);
         }
     }
 }
Пример #14
0
            public bool IterNthChild(out Gtk.TreeIter child, Gtk.TreeIter parent, int n)
            {
                child = TreeIter.Zero;

                if (parent.Equals(TreeIter.Zero))
                {
                    if (Nodes.Count <= n)
                    {
                        return(false);
                    }
                    child = GetIter(Nodes [n] as ITreeNode);
                }
                else
                {
                    ITreeNode parent_node = GetNode(parent);
                    if (parent_node.ChildCount <= n)
                    {
                        return(false);
                    }
                    child = GetIter(parent_node [n]);
                }
                return(true);
            }
Пример #15
0
        bool FindChildByName(string name, ref Gtk.TreeIter iter)
        {
            if (iter.Equals(Gtk.TreeIter.Zero))
            {
                if (!store.GetIterFirst(out iter))
                {
                    return(false);
                }
            }
            else if (!store.IterChildren(out iter, iter))
            {
                return(false);
            }

            do
            {
                if (name == (string)store.GetValue(iter, ColSignal))
                {
                    return(true);
                }
            }while (store.IterNext(ref iter));

            return(false);
        }
Пример #16
0
 static void BuildTreeChildren(Gtk.TreeStore store, Gtk.TreeIter parent, ParentNode p)
 {
     foreach (Node n in p)
     {
         if (!(n is TagNode || n is DirectiveNode || n is ExpressionNode))
         {
             continue;
         }
         Gtk.TreeIter childIter;
         if (!parent.Equals(Gtk.TreeIter.Zero))
         {
             childIter = store.AppendValues(parent, n);
         }
         else
         {
             childIter = store.AppendValues(n);
         }
         ParentNode pChild = n as ParentNode;
         if (pChild != null)
         {
             BuildTreeChildren(store, childIter, pChild);
         }
     }
 }
Пример #17
0
            public bool IterChildren(out Gtk.TreeIter first_child, Gtk.TreeIter parent)
            {
                first_child = Gtk.TreeIter.Zero;

                if (parent.Equals(TreeIter.Zero))
                {
                    if (Nodes.Count <= 0)
                    {
                        return(false);
                    }
                    first_child = GetIter(Nodes [0] as ITreeNode);
                }
                else
                {
                    ITreeNode node = GetNode(parent);
                    if (node.ChildCount <= 0)
                    {
                        return(false);
                    }

                    first_child = GetIter(node [0]);
                }
                return(true);
            }