private void DeleteSectionsFromDataSource() { // store intermediary sections and indices to be deleted, than delete using (var sectionIndicesToBeDeleted = new NSMutableIndexSet()) { var sectionsToBeDeleted = new List <int>(); foreach (var indexElementPair in GalleryDataSource.ImageCollection.Select((pair, index) => new { index, pair })) { if (indexElementPair.pair.Value.Count != 0) { continue; } sectionsToBeDeleted.Add(indexElementPair.index); sectionIndicesToBeDeleted.Add((nuint)indexElementPair.index); } var sortedSectionsToBeDeleted = sectionsToBeDeleted.OrderByDescending(x => x); foreach (var section in sortedSectionsToBeDeleted) { GalleryDataSource.ImageCollection.Remove(GalleryDataSource.ImageCollection.Keys[section]); } GalleryCollectionView.DeleteSections(sectionIndicesToBeDeleted); } }
private IEnumerable <int> DeleteImagesFromDataSource() { //store intermediary images and indices to be deleted, than delete var imageIndicesToBeDeleted = new List <NSIndexPath>(); var imagesToBeDeleted = new List <(int section, int item)>(); var imageIdsToBeDeleted = new HashSet <int>(); foreach (var indexPath in GalleryDataSource.SelectedImageIndexPaths) { imagesToBeDeleted.Add((indexPath.Section, (int)indexPath.Item)); imageIndicesToBeDeleted.Add(indexPath); imageIdsToBeDeleted.Add(GalleryDataSource.ImageCollection.Values[indexPath.Section] .Values[(int)indexPath.Item].Id ?? 0); } var sortedImagesToBeDeleted = imagesToBeDeleted.OrderByDescending(pair => pair.item); foreach (var image in sortedImagesToBeDeleted) { var row = GalleryDataSource.ImageCollection.Values[image.section]; row.Remove(row.Keys[image.item]); } GalleryCollectionView.DeleteItems(imageIndicesToBeDeleted.ToArray()); return(imageIdsToBeDeleted); }
public override void ViewDidLoad() { base.ViewDidLoad(); GalleryDataSource.LoadImages(); GalleryCollectionView.RegisterClassForSupplementaryView(typeof(Header), UICollectionElementKindSection.Header, Constants.GalleryHeaderKey); GalleryCollectionView.Source = new GalleryCollectionViewSource(this); var layout = new UICollectionViewFlowLayout { SectionInset = new UIEdgeInsets( Constants.GallerySectionVerticalSpacing, Constants.GallerySectionSize, Constants.GallerySectionSize, Constants.GallerySectionSize), ItemSize = new CGSize(Constants.GalleryTileWidth, Constants.GalleryTileHeight), ScrollDirection = UICollectionViewScrollDirection.Vertical, MinimumLineSpacing = Constants.GalleryLayoutMinLinSpacing, MinimumInteritemSpacing = Constants.GalleryLayoutMinIterItemSpacing, HeaderReferenceSize = new CGSize(GalleryCollectionView.Frame.Size.Width, Constants.GalleryHeaderHeight) }; GalleryCollectionView.SetCollectionViewLayout(layout, true); GenerateNavBarButtons(); GenerateToolBar(); ResetGalleryTitle(); }
void ReleaseDesignerOutlets() { if (AddPictureButton != null) { AddPictureButton.Dispose(); AddPictureButton = null; } if (AddPostButton != null) { AddPostButton.Dispose(); AddPostButton = null; } if (CreatePostButton != null) { CreatePostButton.Dispose(); CreatePostButton = null; } if (DescriptionTextField != null) { DescriptionTextField.Dispose(); DescriptionTextField = null; } if (FriendsButton != null) { FriendsButton.Dispose(); FriendsButton = null; } if (GalleryCollectionView != null) { GalleryCollectionView.Dispose(); GalleryCollectionView = null; } if (HomeButton != null) { HomeButton.Dispose(); HomeButton = null; } if (PostImageView != null) { PostImageView.Dispose(); PostImageView = null; } if (ProfileButton != null) { ProfileButton.Dispose(); ProfileButton = null; } }
private void UncheckSelectedImages(object sender, EventArgs e) { foreach (var indexPath in GalleryDataSource.SelectedImageIndexPaths) { var galleryImageCell = (GalleryImageCell)GalleryCollectionView.DequeueReusableCell(GalleryImageCell.Key, indexPath); galleryImageCell.SetGalleryCheckmark(); } GalleryCollectionView.ReloadData(); ClearSelectedImages(); ResetGalleryTitle(); ToggleToolBarVisibility(false); }
void ReleaseDesignerOutlets() { if (GalleryCollectionView != null) { GalleryCollectionView.Dispose(); GalleryCollectionView = null; } if (GalleryMainView != null) { GalleryMainView.Dispose(); GalleryMainView = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); source = new GalleryCollectionViewSource(PostImageView); source.LoadData(dataContext.GaleryImagePaths); SetBindings(); SetCommands(); BaseStyling(); EventStyling(); NavigationBar.Set(this, HomeButton, FriendsButton, AddPostButton, ProfileButton); GalleryCollectionView.RegisterNibForCell(GalleryCollectionViewCell.Nib, GalleryCollectionViewCell.Key); var layout = new UICollectionViewFlowLayout { ItemSize = new CoreGraphics.CGSize(90, 90) }; GalleryCollectionView.SetCollectionViewLayout(layout, true); GalleryCollectionView.Source = source; GalleryCollectionView.ReloadData(); source.OnImageSelect += (o, e) => { if (GalleryCollectionViewSource.SelectedImagePath != null) { dataContext.SelectedImagePath = GalleryCollectionViewSource.SelectedImagePath; GalleryCollectionViewSource.SelectedImagePath = null; } }; CreatePostButton.TouchUpInside += (o, e) => { Navigator.Navigate(this, CtrConst.FeedController); }; }
public override void ViewWillAppear(bool animated) { GalleryDataSource.LoadImages(); GalleryCollectionView.ReloadData(); }