Exemplo n.º 1
0
        private void SelectScreenLoadedHandler(object sender, RoutedEventArgs e)
        {
            CheckDisposedState();
            ThumbnailList list = _selectScreen.ListControl.List;

            if (ExecutionEngine.Context.Contains(Constants.PhotosToRemove))
            {
                System.Collections.Generic.List <string> filesToRemove = (System.Collections.Generic.List <string>)ExecutionEngine.Context[Constants.PhotosToRemove];

                list.Items.
                Where(item => filesToRemove.Contains(item.Photo.SourceFileName)).
                ToList().
                ForEach(item => list.RemoveItem(item, false));

                ExecutionEngine.Context.Remove(Constants.PhotosToRemove);
            }

            if (ExecutionEngine.Context.Contains(Constants.FoundPhotos))
            {
                var foundPhotos         = (System.Collections.ObjectModel.Collection <PhotoItem>)ExecutionEngine.Context[Constants.FoundPhotos];
                var newPhotosList       = foundPhotos.Where(photo => !list.Items.Any(item => photo.SourceFileName.Equals(item.Photo.SourceFileName))).ToList <PhotoItem>();
                var newPhotosCollection = new System.Collections.ObjectModel.Collection <PhotoItem>(newPhotosList);
                list.LoadItems(newPhotosCollection);
                ExecutionEngine.Context.Remove(Constants.FoundPhotos);
            }
        }