public void Clear()
        {
            int count = Root.Children.Count;

            if (AllowWatchExpressions)
            {
                count--;
            }

            if (count <= 0)
            {
                return;
            }

            var removed = new List <MacObjectValueNode> ();

            for (int i = count - 1; i >= 0; i--)
            {
                var child = Root.Children[i];
                Root.Children.RemoveAt(i);
                Remove(child, removed);
            }

            var range   = new NSRange(0, count);
            var indexes = NSIndexSet.FromNSRange(range);

            treeView.RemoveItems(indexes, null, NSTableViewAnimation.None);

            for (int i = 0; i < removed.Count; i++)
            {
                removed[i].Dispose();
            }
        }
Пример #2
0
        public virtual void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            this.source = source;

            RowHeights = new List <nfloat> ();
            for (int i = 0; i < source.RowCount; i++)
            {
                RowHeights.Add(-1);
            }

            tsource          = new ListSource(source);
            Table.DataSource = tsource;

            //TODO: Reloading single rows would be slightly more efficient.
            //      According to NSTableView.ReloadData() documentation,
            //      only the visible rows are reloaded.
            source.RowInserted += (sender, e) => {
                RowHeights.Insert(e.Row, -1);
                Table.ReloadData();
            };
            source.RowDeleted += (sender, e) => {
                RowHeights.RemoveAt(e.Row);
                Table.ReloadData();
            };
            source.RowChanged += (sender, e) => {
                UpdateRowHeight(e.Row);
                Table.ReloadData(NSIndexSet.FromIndex(e.Row), NSIndexSet.FromNSRange(new NSRange(0, Table.ColumnCount)));
            };
            source.RowsReordered += (sender, e) => { RowHeights.Clear(); Table.ReloadData(); };
        }
        public void Clear()
        {
            int count = Root.Children.Count;

            if (AllowWatchExpressions)
            {
                count--;
            }

            for (int i = count - 1; i >= 0; i--)
            {
                var child = Root.Children[i];
                Root.Children.RemoveAt(i);
                Remove(child);
            }

            if (count <= 0)
            {
                return;
            }

            var range   = new NSRange(0, count);
            var indexes = NSIndexSet.FromNSRange(range);

            treeView.RemoveItems(indexes, null, NSTableViewAnimation.None);
        }
Пример #4
0
        public void FetchResultObjectsAt()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8 or later");
            }

            if (ALAssetsLibrary.AuthorizationStatus != ALAuthorizationStatus.Authorized)
            {
                Assert.Inconclusive("Requires access to the photo library");
            }

            var collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);

            if (collection.Count == 0)
            {
                XamagramImage.Image.SaveToPhotosAlbum(null);
                collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);
            }

            // Actual Test
            var obj = collection.ObjectsAt <NSObject> (NSIndexSet.FromNSRange(new NSRange(0, 1)));

            Assert.That(obj != null && obj.Count() > 0);
        }
Пример #5
0
            public override void SelectionDidChange(NSNotification notification)
            {
                var h = Handler;

                if (h == null)
                {
                    return;
                }

                // didn't start a drag (when this was set), so clear this out when the selection changes
                h.CustomSelectedRows = null;

                if (h.SuppressSelectionChanged == 0)
                {
                    h.Callback.OnSelectionChanged(h.Widget, EventArgs.Empty);
                    var columns = NSIndexSet.FromNSRange(new NSRange(0, h.Control.TableColumns().Length));
                    if (previouslySelected?.Count > 0)
                    {
                        h.Control.ReloadData(previouslySelected, columns);
                    }
                    var selected = h.Control.SelectedRows;
                    if (selected?.Count > 0)
                    {
                        h.Control.ReloadData(selected, columns);
                    }
                    previouslySelected = selected;
                }
            }
        private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewStartingIndex < 0 || e.NewItems == null || e.NewItems.Count == 0)
                {
                    goto default;
                }

                this.table.InsertRows(NSIndexSet.FromNSRange(new NSRange(e.NewStartingIndex, e.NewItems.Count)), NSTableViewAnimation.SlideDown);
                break;

            case NotifyCollectionChangedAction.Remove:
                if (e.OldStartingIndex < 0 || e.OldItems == null || e.OldItems.Count == 0)
                {
                    goto default;
                }

                this.table.RemoveRows(NSIndexSet.FromNSRange(new NSRange(e.OldStartingIndex, e.OldItems.Count)), NSTableViewAnimation.SlideDown);
                break;

            default:
                this.table.ReloadData();
                break;
            }
        }
        public void Append(IList <ObjectValueNode> nodes)
        {
            int index;

            if (AllowWatchExpressions)
            {
                index = Root.Children.Count - 1;
                for (int i = 0; i < nodes.Count; i++)
                {
                    Insert(Root, index + i, nodes[i]);
                }
            }
            else
            {
                index = Root.Children.Count;
                for (int i = 0; i < nodes.Count; i++)
                {
                    Add(Root, nodes[i]);
                }
            }

            treeView.BeginUpdates();

            try {
                var range   = new NSRange(index, nodes.Count);
                var indexes = NSIndexSet.FromNSRange(range);

                treeView.InsertItems(indexes, null, NSTableViewAnimation.None);
                RestoreExpandedState(nodes);
            } finally {
                treeView.EndUpdates();
            }
        }
Пример #8
0
        internal void Reload()
        {
            var range    = new NSRange(0, TimeEntriesLogTableView.NumberOfSections());
            var indexSet = NSIndexSet.FromNSRange(range);

            TimeEntriesLogTableView.ReloadSections(indexSet, UITableViewRowAnimation.None);
        }
Пример #9
0
        private NSIndexSet MakeIndexSet(int start, int count)
        {
            NSRange range;

            range.Location = start;
            range.Length   = count;
            return(NSIndexSet.FromNSRange(range));
        }
        // Reloads the BeforeOrAfter and Value section.
        void ReloadDynamicSections()
        {
            if (timeType == TimeConditionType.Sun && order == TimeConditionOrder.At)
            {
                order = TimeConditionOrder.Before;
            }
            var reloadIndexSet = NSIndexSet.FromNSRange(new NSRange((int)TimeConditionTableViewSection.BeforeOrAfter, 2));

            TableView.ReloadSections(reloadIndexSet, UITableViewRowAnimation.Automatic);
        }
Пример #11
0
        protected virtual void ReloadColumnData()
        {
            var handler = ColumnHandler?.DataViewHandler;

            if (handler?.Loaded == true)
            {
                var column = handler.Widget.Columns.IndexOf(ColumnHandler.Widget);
                var rows   = NSIndexSet.FromNSRange(new NSRange(0, (nnuint)handler.Table.RowCount));
                handler.Table.ReloadData(rows, new NSIndexSet(column));
            }
        }
Пример #12
0
        void OnTestSessionChanged(TestSession session)
        {
            var newCategoriesArray = new NSMutableArray();

            newCategoriesArray.Add(allCategory);
            newCategoriesArray.Add(globalCategory);
            newCategoriesArray.Add(martinCategory);
            var newCurrentCategory = allCategory;

            if (session != null)
            {
                Configuration = session.Configuration;
                foreach (var category in Configuration.Categories)
                {
                    var model = new TestCategoryModel(category);
                    newCategoriesArray.Add(model);
                    if (category == Configuration.CurrentCategory)
                    {
                        newCurrentCategory = model;
                    }
                }

                if (fullyLoaded)
                {
                    foreach (var feature in Configuration.Features)
                    {
                        var model = new TestFeatureModel(feature);
                        FeaturesController.AddObject(model);
                    }
                }
            }
            else
            {
                Configuration = null;

                if (fullyLoaded)
                {
                    var featureRange = new NSRange(0, FeaturesController.ArrangedObjects().Length);
                    FeaturesController.Remove(NSIndexSet.FromNSRange(featureRange));
                }
            }

            WillChangeValue(CurrentCategoryKey);
            WillChangeValue(TestCategoriesArrayKey);
            currentCategory     = newCurrentCategory;
            testCategoriesArray = newCategoriesArray;
            DidChangeValue(TestCategoriesArrayKey);
            DidChangeValue(CurrentCategoryKey);

            if (SessionChangedEvent != null)
            {
                SessionChangedEvent(this, session);
            }
        }
Пример #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            standardUserDefaults = NSUserDefaults.StandardUserDefaults;

            selectedType   = (VisionType)(int)standardUserDefaults.IntForKey(nameof(VisionType));
            selectedScript = (TextRecognitionScript)(int)standardUserDefaults.IntForKey(nameof(TextRecognitionScript));

            SettingsTable.ReloadSections(NSIndexSet.FromNSRange(new NSRange(0, 2)), UITableViewRowAnimation.Automatic);
        }
Пример #14
0
        public void FetchResultObjectsAt()
        {
            var collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);

            if (collection.Count == 0)
            {
                XamagramImage.Image.SaveToPhotosAlbum(null);
                collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);
            }

            // Actual Test
            var obj = collection.ObjectsAt <NSObject> (NSIndexSet.FromNSRange(new NSRange(0, 1)));

            Assert.That(obj != null && obj.Count() > 0);
        }
Пример #15
0
 public override void SelectionDidChange(NSNotification notification)
 {
     if (Handler.SuppressSelectionChanged == 0)
     {
         Handler.Callback.OnSelectionChanged(Handler.Widget, EventArgs.Empty);
         var columns = NSIndexSet.FromNSRange(new NSRange(0, Handler.Control.TableColumns().Length));
         if (previouslySelected != null)
         {
             Handler.Control.ReloadData(previouslySelected, columns);
         }
         var selected = Handler.Control.SelectedRows;
         Handler.Control.ReloadData(selected, columns);
         previouslySelected = selected;
     }
 }
        public void ReplaceObjectsTest()
        {
            var str1 = (NSString)"1";
            var str2 = (NSString)"2";
            var str3 = (NSString)"3";
            var str4 = (NSString)"4";

            var oSet = new NSMutableOrderedSet <NSString> (str1, str2);

            Assert.AreEqual((nint)2, oSet.Count, "ReplaceObjectsTest Count");
            Assert.AreSame(str1, oSet[0], "ReplaceObjectsTest 1 == 1");
            Assert.AreSame(str2, oSet[1], "ReplaceObjectsTest 2 == 2");

            oSet.ReplaceObjects(NSIndexSet.FromNSRange(new NSRange(0, 2)), str3, str4);
            Assert.AreSame(str3, oSet[0], "ReplaceObjectsTest 3 == 3");
            Assert.AreSame(str4, oSet[1], "ReplaceObjectsTest 4 == 4");
        }
        public void InsertObjectsTest()
        {
            var str1 = (NSString)"1";
            var str2 = (NSString)"2";
            var str3 = (NSString)"3";
            var str4 = (NSString)"4";
            var oSet = new NSMutableOrderedSet <NSString> (str4);

            oSet.InsertObjects(new[] { str1, str2, str3 }, NSIndexSet.FromNSRange(new NSRange(0, 3)));

            Assert.AreEqual((nint)4, oSet.Count, "InsertObjectsTest Count");
            Assert.IsTrue(oSet.Contains(str1), "InsertObjectsTest Contains 1");
            Assert.IsTrue(oSet.Contains(str2), "InsertObjectsTest Contains 2");
            Assert.IsTrue(oSet.Contains(str3), "InsertObjectsTest Contains 3");
            Assert.IsTrue(oSet.Contains(str4), "InsertObjectsTest Contains 4");
            Assert.AreSame(str1, oSet[0], "InsertObjectsTest 1 == 1");
            Assert.AreSame(str4, oSet[3], "InsertObjectsTest 4 == 4");
        }
Пример #18
0
        public override void DidSelectRow(WKInterfaceTable table, nint rowIndex)
        {
            var newCityNames = new [] { "Saratoga", "San Jose" };

            var newCityIndexes = NSIndexSet.FromNSRange(new NSRange(rowIndex + 1, newCityNames.Length));

            // Insert new rows into the table.
            interfaceTable.InsertRows(newCityIndexes, "default");

            // Update the rows that were just inserted with the appropriate data.
            var newCityNumber = 0;

            newCityIndexes.EnumerateIndexes((nuint idx, ref bool stop) => {
                var newCityName = newCityNames [newCityNumber];
                var row         = (TableRowController)interfaceTable.GetRowController((nint)idx);
                row.RowLabel.SetText(newCityName);
                newCityNumber++;
            });
        }
Пример #19
0
        private void HandleProgramsChangedCore(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            DebugItemChange("ROMS COLLECTION CHANGED");
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                AddObjectsToArrayController(e.NewItems.OfType <NSObject>());
                break;

            case NotifyCollectionChangedAction.Remove:
                RemoveObjectsFromArrayController(e.OldItems.OfType <NSObject>());
                break;

            case NotifyCollectionChangedAction.Reset:
                var itemsToDelete = NSIndexSet.FromNSRange(new NSRange(0, RomsArrayController.ArrangedObjects().Length));
                RomsArrayController.Remove(itemsToDelete);
                HandleRomListSelectionChanged(null, null);     // ensure we show 'drop stuff here' text
                break;
            }
        }
Пример #20
0
        public void FetchResultObjectsAt()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false);

            if (ALAssetsLibrary.AuthorizationStatus != ALAuthorizationStatus.Authorized)
            {
                Assert.Inconclusive("Requires access to the photo library");
            }

            var collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);

            if (collection.Count == 0)
            {
                XamagramImage.Image.SaveToPhotosAlbum(null);
                collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null);
            }

            // Actual Test
            var obj = collection.ObjectsAt <NSObject> (NSIndexSet.FromNSRange(new NSRange(0, 1)));

            Assert.That(obj != null && obj.Count() > 0);
        }
        public void Append(IList <ObjectValueNode> nodes)
        {
            int index;

            if (AllowWatchExpressions)
            {
                index = Root.Children.Count - 1;
                for (int i = 0; i < nodes.Count; i++)
                {
                    Insert(Root, index + i, nodes[i]);
                }
            }
            else
            {
                index = Root.Children.Count;
                for (int i = 0; i < nodes.Count; i++)
                {
                    Add(Root, nodes[i]);
                }
            }

            var range   = new NSRange(index, nodes.Count);
            var indexes = NSIndexSet.FromNSRange(range);

            treeView.InsertItems(indexes, null, NSTableViewAnimation.None);

            foreach (var node in nodes)
            {
                if (treeView.Controller.GetNodeWasExpandedAtLastCheckpoint(node))
                {
                    if (TryGetValue(node, out MacObjectValueNode x))
                    {
                        treeView.ExpandItem(x);
                    }
                }
            }
        }
        public void ReloadChildren(ObjectValueNode node)
        {
            if (!TryGetValue(node, out var parent))
            {
                return;
            }

            treeView.BeginUpdates();

            try {
                NSIndexSet indexes;
                NSRange    range;

                if (parent.Children.Count > 0)
                {
                    range   = new NSRange(0, parent.Children.Count);
                    indexes = NSIndexSet.FromNSRange(range);

                    var removed = new List <MacObjectValueNode> ();
                    foreach (var child in parent.Children)
                    {
                        Remove(child, removed);
                    }

                    parent.Children.Clear();

                    if (parent.Target is RootObjectValueNode)
                    {
                        treeView.RemoveItems(indexes, null, NSTableViewAnimation.None);
                    }
                    else
                    {
                        treeView.RemoveItems(indexes, parent, NSTableViewAnimation.None);
                    }

                    for (int i = 0; i < removed.Count; i++)
                    {
                        removed[i].Dispose();
                    }
                }

                for (int i = 0; i < node.Children.Count; i++)
                {
                    Add(parent, node.Children[i]);
                }

                // if we did not load all the children, add a Show More node
                if (!node.ChildrenLoaded)
                {
                    Add(parent, new ShowMoreValuesObjectValueNode(node));
                }

                range   = new NSRange(0, parent.Children.Count);
                indexes = NSIndexSet.FromNSRange(range);

                if (parent.Target is RootObjectValueNode)
                {
                    treeView.InsertItems(indexes, null, NSTableViewAnimation.None);
                }
                else
                {
                    treeView.InsertItems(indexes, parent, NSTableViewAnimation.None);
                }

                // if we loaded children and discovered that the node does not actually have any children,
                // update the node and reload the data.
                // TOOD: it would be nice to know this before the node is expanded so we don't see the "loading" node flash
                if (!node.HasChildren)
                {
                    treeView.ReloadItem(parent);
                }
                else
                {
                    RestoreExpandedState(node.Children);
                }
            } finally {
                treeView.EndUpdates();
            }
        }
Пример #23
0
        public virtual void SetSource(IListDataSource source, IBackend sourceBackend)
        {
            this.source      = source;
            tsource          = new ListSource(source);
            Table.DataSource = tsource;

            //TODO: Reloading single rows would be slightly more efficient.
            //      According to NSTableView.ReloadData() documentation,
            //      only the visible rows are reloaded.
            source.RowInserted   += (sender, e) => Table.ReloadData();
            source.RowDeleted    += (sender, e) => Table.ReloadData();
            source.RowChanged    += (sender, e) => Table.ReloadData(NSIndexSet.FromIndex(e.Row), NSIndexSet.FromNSRange(new NSRange(0, Table.ColumnCount - 1)));
            source.RowsReordered += (sender, e) => Table.ReloadData();
        }
Пример #24
0
 NSIndexSet CreateIndexSetFrom(int startIndex, int count)
 {
     return(NSIndexSet.FromNSRange(new NSRange(startIndex, count)));
 }
Пример #25
0
 public void ReloadData(IEnumerable <int> rows)
 {
     Control.ReloadData(NSIndexSet.FromArray(rows.Select(r => (nuint)r).ToArray()), NSIndexSet.FromNSRange(new NSRange(0, Control.TableColumns().Length)));
     if (Widget.Columns.Any(r => r.AutoSize))
     {
         AutoSizeColumns(true);
     }
 }
 internal static NSIndexSet ToNewIndexSet([NotNull] this NotifyCollectionChangedEventArgs args)
 {
     return(NSIndexSet.FromNSRange(new NSRange(args.NewStartingIndex, args.NewItems.NotNull().Count)).NotNull());
 }
Пример #27
0
        private void UpdateItems(NotifyCollectionChangedEventArgs e, int section, bool resetWhenGrouped)
        {
            NotifyCollectionChangedEventArgsEx changedEventArgsEx = e as NotifyCollectionChangedEventArgsEx;

            if (changedEventArgsEx != null)
            {
                this.dataSource.Counts [section] = changedEventArgsEx.Count;
            }
            bool flag = resetWhenGrouped && this.Element.IsGroupingEnabled;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                //this.UpdateEstimatedRowHeight ();
                if (!(e.NewStartingIndex == -1 | flag))
                {
                    this.Control.BeginUpdates();

                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.NewStartingIndex, e.NewItems.Count));

                    this.Control.InsertRows(indexSet, NSTableViewAnimation.SlideUp);
                    this.Control.EndUpdates();
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Remove:
                if (!(e.OldStartingIndex == -1 | flag))
                {
                    this.Control.BeginUpdates();

                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.OldStartingIndex, e.OldItems.Count));

                    Control.RemoveRows(indexSet, NSTableViewAnimation.SlideDown);
                    this.Control.EndUpdates();

                    if (!this.estimatedRowHeight || this.Element.TemplatedItems.Count != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Replace:
                if (!(e.OldStartingIndex == -1 | flag))
                {
                    Control.BeginUpdates();
                    var indexSet = NSIndexSet.FromNSRange(new NSRange(e.OldStartingIndex, e.OldItems.Count));
                    Control.ReloadData(indexSet, null);
                    this.Control.EndUpdates();

                    if (!this.estimatedRowHeight || e.OldStartingIndex != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Move:
                if (((e.OldStartingIndex == -1 ? 1 : (e.NewStartingIndex == -1 ? 1 : 0)) | (flag ? 1 : 0)) == 0)
                {
                    this.Control.BeginUpdates();
                    for (int index = 0; index < e.OldItems.Count; ++index)
                    {
                        int oldStartingIndex = e.OldStartingIndex;
                        int newStartingIndex = e.NewStartingIndex;
                        if (e.NewStartingIndex < e.OldStartingIndex)
                        {
                            oldStartingIndex += index;
                            newStartingIndex += index;
                        }

                        this.Control.MoveRow(oldStartingIndex, newStartingIndex);
                    }
                    this.Control.EndUpdates();
                    if (!this.estimatedRowHeight || e.OldStartingIndex != 0)
                    {
                        break;
                    }
                    this.estimatedRowHeight = false;
                    break;
                }
                goto case NotifyCollectionChangedAction.Reset;

            case NotifyCollectionChangedAction.Reset:
                this.estimatedRowHeight = false;
                this.Control.ReloadData();
                break;
            }
        }
        public void Replace(ObjectValueNode node, ObjectValueNode[] replacementNodes)
        {
            if (!TryGetValue(node, out var item))
            {
                return;
            }

            var parent = item.Parent;
            int index  = -1;

            if (parent == null)
            {
                return;
            }

            for (int i = 0; i < parent.Children.Count; i++)
            {
                if (parent.Children[i] == item)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)
            {
                return;
            }

            parent.Children.RemoveAt(index);
            mapping.Remove(item.Target);
            item.Dispose();

            treeView.BeginUpdates();

            var indexes = new NSIndexSet(index);

            if (parent.Target is RootObjectValueNode)
            {
                treeView.RemoveItems(indexes, null, NSTableViewAnimation.None);
            }
            else
            {
                treeView.RemoveItems(indexes, parent, NSTableViewAnimation.None);
            }

            if (replacementNodes.Length > 0)
            {
                for (int i = 0; i < replacementNodes.Length; i++)
                {
                    Insert(parent, index + i, replacementNodes [i]);
                }

                var range = new NSRange(index, replacementNodes.Length);
                indexes = NSIndexSet.FromNSRange(range);

                if (parent.Target is RootObjectValueNode)
                {
                    treeView.InsertItems(indexes, null, NSTableViewAnimation.None);
                }
                else
                {
                    treeView.InsertItems(indexes, parent, NSTableViewAnimation.None);
                }

                foreach (var n in replacementNodes)
                {
                    if (treeView.Controller.GetNodeWasExpandedAtLastCheckpoint(n))
                    {
                        if (TryGetValue(n, out MacObjectValueNode x))
                        {
                            treeView.ExpandItem(x);
                        }
                    }
                }
            }

            treeView.EndUpdates();
        }
        public void ReloadChildren(ObjectValueNode node)
        {
            if (!TryGetValue(node, out var parent))
            {
                return;
            }

            treeView.BeginUpdates();

            NSIndexSet indexes;
            NSRange    range;

            if (parent.Children.Count > 0)
            {
                range   = new NSRange(0, parent.Children.Count);
                indexes = NSIndexSet.FromNSRange(range);

                foreach (var child in parent.Children)
                {
                    mapping.Remove(child.Target);
                    child.Dispose();
                }

                parent.Children.Clear();

                if (parent.Target is RootObjectValueNode)
                {
                    treeView.RemoveItems(indexes, null, NSTableViewAnimation.None);
                }
                else
                {
                    treeView.RemoveItems(indexes, parent, NSTableViewAnimation.None);
                }
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                Add(parent, node.Children[i]);
            }

            // if we did not load all the children, add a Show More node
            if (!node.ChildrenLoaded)
            {
                Add(parent, new ShowMoreValuesObjectValueNode(node));
            }

            range   = new NSRange(0, parent.Children.Count);
            indexes = NSIndexSet.FromNSRange(range);

            if (parent.Target is RootObjectValueNode)
            {
                treeView.InsertItems(indexes, null, NSTableViewAnimation.None);
            }
            else
            {
                treeView.InsertItems(indexes, parent, NSTableViewAnimation.None);
            }

            // if we loaded children and discovered that the node does not actually have any children,
            // update the node and reload the data.
            // TOOD: it would be nice to know this before the node is expanded so we don't see the "loading" node flash
            if (!node.HasChildren)
            {
                treeView.ReloadItem(parent);
            }
            else
            {
                // expand any items that we loaded that were expanded previously

                foreach (var n in node.Children)
                {
                    if (treeView.Controller.GetNodeWasExpandedAtLastCheckpoint(n))
                    {
                        if (TryGetValue(n, out MacObjectValueNode x))
                        {
                            treeView.ExpandItem(x);
                        }
                    }
                }
            }

            treeView.EndUpdates();
        }
Пример #30
0
 public void ReloadData(IEnumerable <int> rows)
 {
     Control.ReloadData(NSIndexSet.FromArray(rows.Select(r => (nuint)r).ToArray()), NSIndexSet.FromNSRange(new NSRange(0, Control.TableColumns().Length)));
 }