コード例 #1
0
ファイル: MultiItemReplacer.cs プロジェクト: sung-su/maui
        protected override void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes)
        {
            if (indexes.Length < 2)
            {
                return;
            }

            var index1 = indexes[0];
            var index2 = indexes[1];

            if (index1 > -1 && index2 < observableCollection.Count && index1 <= index2)
            {
                var newItems = new List <CollectionViewGalleryTestItem>();

                for (int n = 0; n < 4; n++)
                {
                    newItems.Add(new CollectionViewGalleryTestItem(DateTime.Now.AddDays(n),
                                                                   $"Added", "coffee.png", n));
                }

                if (_withIndex)
                {
                    observableCollection.TestReplaceWithListAndIndex(index1, index2 - index1 + 1, newItems);
                }
                else
                {
                    observableCollection.TestReplaceWithList(index1, index2 - index1 + 1, newItems);
                }
            }
        }
コード例 #2
0
ファイル: MultiItemMover.cs プロジェクト: sung-su/maui
        protected override void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes)
        {
            if (indexes.Length < 3)
            {
                return;
            }

            var startIndex       = indexes[0];
            var endIndex         = indexes[1];
            var destinationIndex = indexes[2];

            var count = observableCollection.Count;

            // -1 < startIndex < endIndex < count
            if (startIndex < 0 || endIndex >= count || endIndex <= startIndex)
            {
                return;
            }

            var itemsToMove = endIndex - startIndex;

            // Can't move the items past the end of the list
            if (destinationIndex > (count - itemsToMove))
            {
                return;
            }

            observableCollection.TestMoveWithList(startIndex, (endIndex - startIndex) + 1, destinationIndex);
        }
コード例 #3
0
ファイル: ItemsSourceGenerator.cs プロジェクト: hevey/maui
        void GenerateMultiTestObservableCollection()
        {
            if (int.TryParse(_entry.Text, out int count))
            {
                var items = new MultiTestObservableCollection <CollectionViewGalleryTestItem>();

                for (int n = 0; n < count; n++)
                {
                    items.Add(new CollectionViewGalleryTestItem(DateTime.Now.AddDays(n),
                                                                $"{_images[n % _images.Length]}, {n}", _images[n % _images.Length], n));
                }

                _cv.ItemsSource = items;
            }
        }
コード例 #4
0
        protected override void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes)
        {
            if (indexes.Length < 2)
            {
                return;
            }

            var index1 = indexes[0];
            var index2 = indexes[1];

            if (index1 > -1 && index2 < observableCollection.Count && index1 <= index2)
            {
                if (_withIndex)
                {
                    observableCollection.TestRemoveWithListAndIndex(index1, (index2 - index1) + 1);
                }
                else
                {
                    observableCollection.TestRemoveWithList(index1, (index2 - index1) + 1);
                }
            }
        }
コード例 #5
0
        protected override void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes)
        {
            var index1 = indexes[0];

            if (index1 > -1 && index1 < observableCollection.Count)
            {
                var newItems = new List <CollectionViewGalleryTestItem>();

                for (int n = 0; n < 4; n++)
                {
                    newItems.Add(new CollectionViewGalleryTestItem(DateTime.Now.AddDays(n),
                                                                   $"Added", "coffee.png", n));
                }

                if (_withIndex)
                {
                    observableCollection.TestAddWithListAndIndex(newItems, index1);
                }
                else
                {
                    observableCollection.TestAddWithList(newItems, index1);
                }
            }
        }
コード例 #6
0
ファイル: Resetter.cs プロジェクト: sung-su/maui
 protected override void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes)
 {
     observableCollection.TestReset();
 }
コード例 #7
0
 protected abstract void ModifyObservableCollection(MultiTestObservableCollection <CollectionViewGalleryTestItem> observableCollection, params int[] indexes);