/// <summary> /// OnChange event is fired when an item is added or removed from the gallery /// </summary> /// <param name="arg"></param> private void OnChanged(GalleryItemsChangedEvent.Args arg) { if (arg.GalleryItem == null) { return; } else { if ((this.ID == "Reviewer_BatchJob_Gallery_Advanced" && arg.GalleryItem.TypeId == "file_datareviewer_batchjob") || (this.ID == "Reviewer_Sessions_Gallery_Advanced" && arg.GalleryItem.TypeId == "SessionResources")) { if (arg.Adding) { if (!ItemCollection.Any(p => (p as GalleryItem).Path == arg.GalleryItem.Path)) { Add(arg.GalleryItem); } } else { GalleryItem itemToRemove = ItemCollection.Where(p => (p as GalleryItem).Path == arg.GalleryItem.Path).FirstOrDefault() as GalleryItem; if (null != itemToRemove) { Remove(itemToRemove); } } } } }
// <param name="adding"> true == add operation, false == remove operation</param> public Args(GalleryItem galleryItem, bool adding) { GalleryItem = galleryItem; Adding = adding; }
static public void Publish(GalleryItem galleryItem, bool adding) { GalleryItemsChangedEvent.Publish(new Args(galleryItem, adding)); }