コード例 #1
0
        public void ShrinkEventTest()
        {
            CollectionSizeChangedResult changedResult = null;
            int changedEventCount = 0;

            _collection.OnSizeChanged += (sender, e) =>
            {
                changedResult = e;
                changedEventCount++;
            };

            _collection.Shrink(5);

            Assert.AreEqual(1, changedEventCount);

            Assert.AreEqual(10, changedResult.sizeBefore);
            Assert.AreEqual(5, changedResult.sizeAfter);
        }
コード例 #2
0
        public void ExpandEventTest()
        {
            CollectionSizeChangedResult changedResult = null;
            int changedEventCount = 0;

            _collection.OnSizeChanged += (sender, e) =>
            {
                changedResult = e;
                changedEventCount++;
            };

            _collection.Expand <CollectionSlot <IItemInstance> >(5);

            Assert.AreEqual(1, changedEventCount);

            Assert.AreEqual(10, changedResult.sizeBefore);
            Assert.AreEqual(15, changedResult.sizeAfter);
        }
コード例 #3
0
        protected virtual void OnCollectionSizeChanged(object sender, CollectionSizeChangedResult e)
        {
            logger.LogVerbose($"Collection {_collectionName} changed size from {e.sizeBefore} to {e.sizeAfter}. Resizing UI elements array...");
            Array.Resize(ref repaintableElements, e.sizeAfter);

            if (e.sizeAfter > e.sizeBefore)
            {
                // Generate new UI slots
                for (int i = e.sizeBefore; i < e.sizeAfter; i++)
                {
                    repaintableElements[i] = CreateUIElement(i);
                    RepaintOrQueue(i);
                }
            }
            else if (e.sizeBefore > e.sizeAfter)
            {
                // Remove some ui slots
                for (int i = e.sizeAfter; i < e.sizeBefore; i++)
                {
                    DestroyUISlot(i);
                }
            }
        }
コード例 #4
0
 protected void NotifyOnSizeChanged(object sender, CollectionSizeChangedResult data)
 {
     // TODO... implement this...
 }