public void CatImageButtonTapped(object sender, EventArgs e) { JTSImageInfo imageInfo = new JTSImageInfo (); //imageInfo.Image = UIImage.FromBundle ("banecat.jpg"); imageInfo.PlaceholderImage = UIImage.FromBundle ("banecat.jpg"); imageInfo.ImageURL = new NSUrl ("http://www.phillipheath.com/images/homephotos-left/phil-heath-mr-olympia01.png"); imageInfo.ReferenceRect = catImageButton.Frame; imageInfo.ReferenceView = catImageButton.Superview; var imageViewer = new JTSImageViewController.JTSImageViewController (imageInfo, JTSImageViewController.JTSImageViewController.JTSImageViewControllerMode.Image, JTSImageViewController.JTSImageViewController.JTSImageViewControllerBackgroundStyle.ScaledDimmed); imageViewer.ShowFromViewController (this, JTSImageViewController.JTSImageViewController.JTSImageViewControllerTransition.FromOriginalPosition); }
// TODO: COMPLETE THIS METHOD LATER private Task<UIImage> SetupImageAndDownloadIfNecessary(JTSImageInfo imageInfo) { var tcs = new TaskCompletionSource<UIImage> (); if (imageInfo.Image != null) { tcs.SetResult (imageInfo.Image); } else { // Image = imageInfo.PlaceholderImage; RectangleF referenceFrameInWindow = ImageInfo.ReferenceView.ConvertRectToView (ImageInfo.ReferenceRect, null); StartingInfo.StartingReferenceFrameForThumbnailInPresentingViewControllersOriginalOrientation = View.ConvertRectFromView (referenceFrameInWindow, null); // RUN TASK TO DOWNLOAD IMAGE HERE SDWebImageDownloader.SharedDownloader.DownloadImage ( url: imageInfo.ImageURL, options: SDWebImageDownloaderOptions.HighPriority, progressHandler: (receivedSize, expectedSize) => { //Console.WriteLine("Downloaded " + (float)receivedSize / (float)expectedSize + "%"); }, completedHandler: (image, data, error, finished) => { if (image != null && finished) { tcs.SetResult(image); } } ); } return tcs.Task; }
public JTSImageViewController (JTSImageInfo imageInfo, JTSImageViewControllerMode imageMode, JTSImageViewControllerBackgroundStyle backgroundStyle) { ImageInfo = imageInfo; CurrentSnapshotRotationTransform = CGAffineTransform.MakeIdentity(); Mode = imageMode; BackgroundStyle = backgroundStyle; // if (Mode == JTSImageViewControllerMode.Image) { // SetupImageAndDownloadIfNecessary (imageInfo); // } Flags = new JTSImageViewControllerFlags (); StartingInfo = new JTSImageViewControllerStartingInfo (); DismissalDelegate = new JTSImageViewControllerDismissalDelegate (); OptionsDelegate = new JTSImageViewControllerOptionsDelegate (); InteractionDelegate = new JTSImageViewControllerInteractionsDelegate (); AccessibilityDelegate = new JTSImageViewControllerAccessibilityDelegate (); }