Exemplo n.º 1
0
        public WaterfallStreamViewer()
        {
            this.DefaultStyleKey = typeof(WaterfallStreamViewer);
            CollectionView       = new DependencyCollectionView()
            {
            };
            CollectionView.GroupingManager = new ContentHeightGroupingManager(this);

            var b = new Binding()
            {
                Source = this,
                Path   = new PropertyPath(nameof(Loader)),
                Mode   = BindingMode.TwoWay
            };

            BindingOperations.SetBinding(CollectionView, DependencyCollectionView.IncrementalLoaderProperty, b);

            this.Loaded += (o, e) =>
            {
                var b2 = new Binding()
                {
                    Source = this,
                    Path   = new PropertyPath(nameof(CollectionView.GroupingManager.GroupCount)),
                };
                BindingOperations.SetBinding(CollectionView.GroupingManager, DependencyCollectionViewGroupingManagerBase.GroupCountProperty, b2);


                //CollectionView.GroupingManager.GroupCount = GroupCount;
            };
        }
Exemplo n.º 2
0
        public void AutoGroupTest()
        {
            var cw = new DependencyCollectionView();
            CreateGroups(cw);

            Enumerable.Range(0, 100)
                .ToList()
                .ForEach(i => cw.Add(i));

            Assert.AreEqual(cw.CollectionGroups.Count, 5);
            foreach (ICollectionViewGroup item in cw.CollectionGroups)
            {
                Assert.AreEqual(20, item.GroupItems.Count);
            }

            cw.Remove(13);
            Assert.AreEqual(
                19,
                cw
                    .CollectionGroups
                    .OfType<SelfServiceDependencyCollectionViewGroupBase>()
                    .Where(g => (int)g.Group == 3)
                    .Select(g => g.GroupItems.Count).First());


            Assert.AreEqual(
                99,
                cw.Count);


            var incFac = new DependencyCollectionViewDelegateIncrementalLoader(
                (v, inc) => true,
                async (v, inc, c) =>
                {
                    Enumerable.Range((int)v[v.Count - 1] + 1, c)
                    .ToList().ForEach(val =>
                        v.Add(val));
                    await Task.Yield();
                    return new LoadMoreItemsResult { Count = (uint)c };
                }
                );

            cw.IncrementalLoader = incFac;

var t=            cw.LoadMoreItemsAsync(10);
          
            Assert.AreEqual(
                 109,
                 cw.Count);

            Assert.AreEqual(
                21,
                cw
                    .CollectionGroups
                    .OfType<SelfServiceDependencyCollectionViewGroupBase>()
                    .Where(g => (int)g.Group == 3)
                    .Select(g => g.GroupItems.Count).First());

        }
Exemplo n.º 3
0
        public void AddTest()
        {
            var cw = new DependencyCollectionView();
            cw.Add("a");
            cw.Add("b");
            Assert.AreEqual(cw.Count, 2);

        }
Exemplo n.º 4
0
        public void AddTest()
        {
            var cw = new DependencyCollectionView();

            cw.Add("a");
            cw.Add("b");
            Assert.AreEqual(cw.Count, 2);
        }
        public DependencyCollectionViewGroupingManagerBase(DependencyCollectionView collectionView)
        {
            CollectionView = collectionView;

            var binding = new Binding
            {
                Path = new PropertyPath(nameof(collectionView.IncrementalLoader)),
                Source = CollectionView
            };

            BindingOperations.SetBinding(this, IncrementalLoaderProperty, binding);
        }
        public DependencyCollectionViewGroup(object groupObject, DependencyCollectionView parentView)
        {
            Group = groupObject;
            var groupItems = new DependencyCollectionView();
            GroupItems = groupItems;
            ParentView = parentView;
            var loader = new DependencyCollectionViewProxyIncrementalLoader()
            {
                InnerLoader = parentView.IncrementalLoader
            };
            
            groupItems.IncrementalLoader = loader;



        }
Exemplo n.º 7
0
        private static void CreateGroups(DependencyCollectionView cw)
        {
            Func <int, SelfServiceDependencyDelegateCollectionViewGroup> fac =
                n =>
            {
                return(new SelfServiceDependencyDelegateCollectionViewGroup(n, cw,
                                                                            (c, o) =>
                {
                    if (o is int)
                    {
                        var v = (int)o;
                        var moded = v % 5;
                        if (moded == n)
                        {
                            c.GroupItems.Add(o);
                            return true;
                        }
                    }
                    return false;
                },
                                                                            (c, o) =>
                {
                    if (o is int)
                    {
                        return c.GroupItems.Remove(o);
                    }
                    return false;
                }));
            };


            cw.CollectionGroups.Add(fac(0));
            cw.CollectionGroups.Add(fac(1));
            cw.CollectionGroups.Add(fac(2));
            cw.CollectionGroups.Add(fac(3));
            cw.CollectionGroups.Add(fac(4));
        }
Exemplo n.º 8
0
        private static void CreateGroups(DependencyCollectionView cw)
        {
            Func<int, SelfServiceDependencyDelegateCollectionViewGroup> fac =
                n =>
                {
                    return new SelfServiceDependencyDelegateCollectionViewGroup(n, cw,
                    (c, o) =>
                    {
                        if (o is int)
                        {
                            var v = (int)o;
                            var moded = v % 5;
                            if (moded == n)
                            {
                                c.GroupItems.Add(o);
                                return true;
                            }

                        }
                        return false;
                    },
                    (c, o) =>
                    {
                        if (o is int)
                        {
                            return c.GroupItems.Remove(o);
                        }
                        return false;

                    });
                };


            cw.CollectionGroups.Add(fac(0));
            cw.CollectionGroups.Add(fac(1));
            cw.CollectionGroups.Add(fac(2));
            cw.CollectionGroups.Add(fac(3));
            cw.CollectionGroups.Add(fac(4));
        }
Exemplo n.º 9
0
        public void AutoGroupTest()
        {
            var cw = new DependencyCollectionView();

            CreateGroups(cw);

            Enumerable.Range(0, 100)
            .ToList()
            .ForEach(i => cw.Add(i));

            Assert.AreEqual(cw.CollectionGroups.Count, 5);
            foreach (ICollectionViewGroup item in cw.CollectionGroups)
            {
                Assert.AreEqual(20, item.GroupItems.Count);
            }

            cw.Remove(13);
            Assert.AreEqual(
                19,
                cw
                .CollectionGroups
                .OfType <SelfServiceDependencyCollectionViewGroupBase>()
                .Where(g => (int)g.Group == 3)
                .Select(g => g.GroupItems.Count).First());


            Assert.AreEqual(
                99,
                cw.Count);


            var incFac = new DependencyCollectionViewDelegateIncrementalLoader(
                (v, inc) => true,
                async(v, inc, c) =>
            {
                Enumerable.Range((int)v[v.Count - 1] + 1, c)
                .ToList().ForEach(val =>
                                  v.Add(val));
                await Task.Yield();
                return(new LoadMoreItemsResult {
                    Count = (uint)c
                });
            }
                );

            cw.IncrementalLoader = incFac;

            var t = cw.LoadMoreItemsAsync(10);

            Assert.AreEqual(
                109,
                cw.Count);

            Assert.AreEqual(
                21,
                cw
                .CollectionGroups
                .OfType <SelfServiceDependencyCollectionViewGroupBase>()
                .Where(g => (int)g.Group == 3)
                .Select(g => g.GroupItems.Count).First());
        }
        private void InitCollectionViewGroup(DependencyCollectionView view, int count)
        {
            if (view.CollectionGroups?.Count != count)
            {
                view.CollectionGroups.Clear();
                for (int i = 0; i < count; i++)
                {
                    var g = new DependencyCollectionViewGroup(i, view);

                    view.CollectionGroups.Add(g);
                }


                if ((view.CollectionGroups?.Count ?? 0) != 0)
                {


                    foreach (var item in view)
                    {
                        this.TryAddItemToGroup(item);
                    }
                }
            }
        }
        public SelfServiceDependencyCollectionViewGroupBase(object groupObject, DependencyCollectionView parentView)
            : base(groupObject, parentView)
        {

        }
   public SelfServiceDependencyDelegateCollectionViewGroup(object groupObject, DependencyCollectionView parentView, Func<ICollectionViewGroup, object, bool> tryAddItemToGroup, Func<ICollectionViewGroup, object, bool> tryRemoveItemFromGroup)
 : base(groupObject, parentView)
   {
       _OnAddingItemToGroup = tryAddItemToGroup;
       _OnRemovingingItemRemoveGroup = tryRemoveItemFromGroup;
   }