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); }
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); }
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); } } }
protected void NotifyOnSizeChanged(object sender, CollectionSizeChangedResult data) { // TODO... implement this... }