Example #1
0
 private void addNextItems(VirtualizingIEnumerable <T> sourceToAdd, int nItems)
 {
     sourceToAdd.AddNextItems(nItems);
     if (!sourceToAdd.HasNext)
     {
         // all items from IEnumerable have been added
         this.itemsSourceTotalCount = sourceToAdd.Count;
     }
 }
        public void SetItemsSource(IEnumerable <ITreeNode> value)
        {
            if (value == null)
            {
                return;
            }

            this.itemsSource = value;
            this.lazyGrid    = new LazyItemsControl <ITreeNode>(this.dataGrid, InitialItemsCount);

//			// HACK for updating the pins in tooltip
//			var observable = new List<ITreeNode>();
//			this.itemsSource.ForEach(item => observable.Add(item));
//
//			// verify if at the line of the root there's a pin bookmark
//			ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
//			var editor = provider.TextEditor;
//			if (editor != null) {
//				var pin = BookmarkManager.Bookmarks.Find(
//					b => b is PinBookmark &&
//					b.Location.Line == logicalPosition.Line &&
//					b.FileName == editor.FileName) as PinBookmark;
//
//				if (pin != null) {
//					observable.ForEach(item => { // TODO: find a way not to use "observable"
//					                    if (pin.ContainsNode(item))
//					                        item.IsPinned = true;
//					                   });
//				}
//			}

            var source = new VirtualizingIEnumerable <ITreeNode>(value);

            lazyGrid.ItemsSource = source;
            this.dataGrid.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(handleScroll));

            if (this.lazyGrid.ItemsSourceTotalCount != null)
            {
                // hide up/down buttons if too few items
                btnUp.Visibility = btnDown.Visibility =
                    this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible;
            }
        }
        public void SetItemsSource(IEnumerable <ITreeNode> value)
        {
            if (value == null)
            {
                return;
            }

            this.itemsSource = value;
            this.lazyGrid    = new LazyItemsControl <ITreeNode>(this.dataGrid, InitialItemsCount);

            var source = new VirtualizingIEnumerable <ITreeNode>(value);

            lazyGrid.ItemsSource = source;
            this.dataGrid.AddHandler(ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(handleScroll));

            if (this.lazyGrid.ItemsSourceTotalCount != null)
            {
                // hide up/down buttons if too few items
                btnUp.Visibility = btnDown.Visibility =
                    this.lazyGrid.ItemsSourceTotalCount.Value <= VisibleItemsCount ? Visibility.Collapsed : Visibility.Visible;
            }
        }