public PhotoViewController1(ImageEntity image, List<ImageEntity> images) { _images = images; _currentImageIndex = GetImageIndex(image); var tabButton = new UIBarButtonItem("Tag", UIBarButtonItemStyle.Plain, OnTagClicked); NavigationItem.RightBarButtonItem = tabButton; _btShare = new UIBarButtonItem(UIBarButtonSystemItem.Action, OnShareClicked); var btTrash = new UIBarButtonItem(UIBarButtonSystemItem.Trash, OnTrashClicked); var deleteSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); ToolbarItems = new[] { _btShare, deleteSpace, btTrash }; }
public PhotoViewController4(ImageEntity image, List<ImageEntity> images) : base(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal, UIPageViewControllerSpineLocation.None, 20f) { FullScreen = false; _image = image; _images = images; var tabButton = new UIBarButtonItem("Tag", UIBarButtonItemStyle.Plain, OnTagClicked); NavigationItem.RightBarButtonItem = tabButton; _btShare = new UIBarButtonItem(UIBarButtonSystemItem.Action, OnShareClicked); var btTrash = new UIBarButtonItem(UIBarButtonSystemItem.Trash, OnTrashClicked); var deleteSpace = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace); ToolbarItems = new[] { _btShare, deleteSpace, btTrash }; DataSource = _pageVewDataSource; AutomaticallyAdjustsScrollViewInsets = false; }
public TagSelectorViewController(ImageEntity image) : base("TagSelectorViewController", null) { _images.Add(image.CloneDeep()); }
public ImageEntity CloneDeep() { var result = new ImageEntity { EntityId = EntityId, LocalIdentifier = LocalIdentifier, TagsInternal = TagsInternal, CreateTime = CreateTime }; return result; }
public void Update(ImageEntity value) { _tags.Clear(); _tags.AddRange(value.Tags); EntityId = value.EntityId; _tagsInternal = TagsToString(); }
public List<TagEntity> GetRemovedTags(ImageEntity entity) { IEnumerable<TagEntity> result = Tags.Except(entity.Tags, new FuncComparer<TagEntity>((x, y) => x.Equals(y))); return result.ToList(); }
public bool Equals(ImageEntity value) { if (ReferenceEquals(null, value)) { return false; } if (ReferenceEquals(this, value)) { return true; } return value.EntityId == EntityId && string.Equals(value.LocalIdentifier, LocalIdentifier, StringComparison.OrdinalIgnoreCase); }
private static int GetImageIndex(ImageEntity image) { return _images.FindIndex(x => x.Equals(image)); }
private void OnTagSelectorDone(object sender, EventArgsOf<List<ImageEntity>> ea) { _imageCache.SaveOrUpdate(ea.Data); _image = ea.Data.First(); }
private void OnDeleteAssetsCompleted(ImageEntity removedImage, bool result, NSError error) { if (result == false) { return; } int imageIndex = GetImageIndex(removedImage); _images.Remove(removedImage); _imageCache.Remove(removedImage); InvokeOnMainThread(() => { ResetDataSource(); if (_images.IsNullOrEmpty()) { NavigationController.PopViewController(true); return; } imageIndex--; if (imageIndex < 0) { imageIndex = 0; } PhotoViewPage1 page = PhotoViewPage1.ImageViewControllerForPageIndex(_images[imageIndex]); SetViewControllers(new UIViewController[] { page }, UIPageViewControllerNavigationDirection.Forward, false, null); }); }
public PhotoViewController2(ImageEntity image, List<ImageEntity> images) { Title = "Image"; _image = image; }
public static PhotoViewPage1 ImageViewControllerForPageIndex(ImageEntity image) { return new PhotoViewPage1(image); }
private PhotoViewPage1(ImageEntity image) { ImageEntity = image; Title = "Image"; }
private void OnDeleteAssetsCompleted(ImageEntity removedImage, bool result, NSError error) { if (result == false) { return; } else { Console.WriteLine(error); } int imageIndex = GetImageIndex(removedImage); _images.Remove(removedImage); _imageCache.Remove(removedImage); InvokeOnMainThread(() => { _pageViewController.ResetDataSource(); if (_images.IsNullOrEmpty()) { NavigationController.PopViewController(true); return; } var page = new PhotoPage(this, _currentImageIndex, _images); imageIndex--; if (imageIndex < 0) { imageIndex = 0; } _pageViewController.SetViewControllers(new UIViewController[] { page }, UIPageViewControllerNavigationDirection.Forward, false, null); }); }
private void SwipeImage() { _image = _images[_currentImageIndex]; PHAsset asset = _imageCache.GetAsset(_image.LocalIdentifier); InvokeOnMainThread(() => UpdateImage(asset)); }
public void Remove(ImageEntity image) { Remove(new List<ImageEntity> { image }); }
private ImageEntity CreateImage(PHAsset asset) { try { var result = new ImageEntity { LocalIdentifier = asset.LocalIdentifier, CreateTime = asset.CreationDate.ToDateTime() }; return result; } catch (Exception ex) { Console.WriteLine(ex); return new ImageEntity { LocalIdentifier = asset.LocalIdentifier, CreateTime = DateTime.MinValue }; } }
private void OnDeleteAssetsCompleted(ImageEntity removedImage, bool result, NSError error) { if (result) { _images.Remove(removedImage); _imageCache.Remove(removedImage); _currentImageIndex--; if (_images.IsNullOrEmpty()) { InvokeOnMainThread(() => NavigationController.PopViewController(true)); return; } else if (_currentImageIndex < 0) { _currentImageIndex = 0; } SwipeImage(); } else { Console.WriteLine(error); } }