DNAPhotoViewController NewPhotoViewController(NSPhoto photo)
        {
            if (photo != null)
            {
                UIView loadingView = null;

                if (((NSObject)Delegate).RespondsToSelector(new Selector("photosViewController:loadingViewForPhoto:")))
                {
                    loadingView = Delegate.LoadingViewForPhoto(this, photo);
                }

                var photoViewController = new DNAPhotoViewController(photo, loadingView, _notificationCenter);
                photoViewController.Delegate = this;

                SingleTapGestureRecognizer.RequireGestureRecognizerToFail(photoViewController.DoubleTapGestureRecognizer);

                if (((NSObject)Delegate).RespondsToSelector(new Selector("photosViewController:maximumZoomScaleForPhoto:")))
                {
                    var maximumZoomScale = Delegate.MaximumZoomScaleForPhoto(this, photo);
                    photoViewController.ScalingImageView.MaximumZoomScale = maximumZoomScale;
                }
                return(photoViewController);
            }
            return(null);
        }
        void DidNavigateToPhoto(NSPhoto photo)
        {
            if (((NSObject)Delegate).RespondsToSelector(new Selector("photosViewController:didNavigateToPhoto:atIndex:")))
            {
                Delegate.DidNavigateToPhotoAtIndex(this, photo, DataSource.IndexOfPhoto(photo));
            }

            NSNotificationCenter.DefaultCenter.PostNotificationName(PhotosViewControllerDidNavigateToPhotoNotification, this);
        }
        public DNAPhotosViewController(IDNAPhotoViewerDataSource dataSource, NSPhoto initialPhoto = null, IDNAPhotosViewControllerDelegate _delegate = null)
        {
            if (initialPhoto == null)
            {
                initialPhoto = dataSource.PhotoAtIndex(0);
            }

            Initialize(dataSource, initialPhoto, _delegate);
        }
        void DisplayPhoto(NSPhoto photo, bool animated)
        {
            if (DataSource.IndexOfPhoto(photo) == -1)
            {
                return;
            }

            var photoViewController = NewPhotoViewController(photo);

            SetCurrentlyDisplayedViewController(photoViewController, animated);
            UpdateOverlayInformation();
        }
        void UpdatePhoto(NSPhoto photo)
        {
            if (DataSource.IndexOfPhoto(photo) == -1)
            {
                return;
            }

            _notificationCenter.PostNotificationName(Constants.DNAPhotoViewControllerPhotoImageUpdatedNotification, photo);

            if (CurrentlyDisplayedPhoto.Equals(photo))
            {
                UpdateOverlayInformation();
            }
        }
        void ReloadPhotos(bool animated)
        {
            NSPhoto newCurrentPhoto = null;

            if (DataSource.IndexOfPhoto(CurrentlyDisplayedPhoto) != -1)
            {
                newCurrentPhoto = CurrentlyDisplayedPhoto;
            }
            else
            {
                newCurrentPhoto = DataSource.PhotoAtIndex(0);
            }

            DisplayPhoto(newCurrentPhoto, animated);

            if (OverlayView.Hidden)
            {
                SetOverlayViewHidden(false, animated);
            }
        }
        void Initialize(IDNAPhotoViewerDataSource dataSource, NSPhoto initialPhoto, IDNAPhotosViewControllerDelegate _delegate = null)
        {
            DataSource   = dataSource;
            Delegate     = _delegate;
            InitialPhoto = initialPhoto;

            PanGestureRecognizer       = new UIPanGestureRecognizer(this, new Selector("didPanWithGestureRecognizer:"));
            SingleTapGestureRecognizer = new UITapGestureRecognizer(this, new Selector("didSingleTapWithGestureRecognizer:"));

            TransitionController   = new DNAPhotoTransitionController();
            ModalPresentationStyle = UIModalPresentationStyle.Custom;
            TransitioningDelegate  = TransitionController;
            ModalPresentationCapturesStatusBarAppearance = true;

            OverlayView = SetUpOverlayView();

            _notificationCenter           = new NSNotificationCenter();
            PageViewController            = new UIPageViewController(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal, new NSDictionary());
            PageViewController.Delegate   = this;
            PageViewController.DataSource = this;
        }
        void Initialize(NSPhoto photo, UIView loadingView, NSNotificationCenter notificationCenter)
        {
            _photo = photo;

            if (photo.ImageData != null)
            {
                ScalingImageView = new DNAScalingImageView(photo.ImageData, CGRect.Empty);
            }
            else
            {
                var photoImage = (photo.Image != null) ? photo.Image : photo.PlaceholderImage;
                ScalingImageView = new DNAScalingImageView(photoImage, CGRect.Empty);

                if (photoImage == null)
                {
                    SetUpLoadingView(loadingView);
                }
            }

            ScalingImageView.Delegate = this;
            _notificationCenter       = notificationCenter;

            SetUpGestureRecognizers();
        }
Ejemplo n.º 9
0
 public nint IndexOfPhoto(NSPhoto photo)
 {
     return(Photos.IndexOf(photo));
 }
 public DNAPhotoViewController(NSPhoto photo, UIView loadingView, NSNotificationCenter notificationCenter) : base(null, null)
 {
     Initialize(photo, loadingView, notificationCenter);
 }
Ejemplo n.º 11
0
 public DNAPhotoViewerSinglePhotoDataSource(NSPhoto photo)
 {
     Photo = photo;
 }
Ejemplo n.º 12
0
 public nint IndexOfPhoto(NSPhoto photo)
 {
     return(0);
 }