コード例 #1
0
        void ShowActualPhotoPermissionAlert()
        {
            ALAssetsLibrary library = new ALAssetsLibrary();

            library.Enumerate(ALAssetsGroupType.SavedPhotos, HandleALAssetsLibraryGroupsEnumerationResults, delegate(NSError obj)
            {
                FirePhotoPermissionCompletionHandler();
            });
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "All Asset Groups";

            // instantiate a reference to the shared assets library
            assetsLibrary = new ALAssetsLibrary();
            // enumerate the photo albums
            assetsLibrary.Enumerate(ALAssetsGroupType.All, GroupsEnumerator,
                        (NSError e) => { Console.WriteLine ("Could not enumerate albums: " + e.LocalizedDescription); });
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "All Asset Groups";

            // instantiate a reference to the shared assets library
            assetsLibrary = new ALAssetsLibrary();
            // enumerate the photo albums
            assetsLibrary.Enumerate(ALAssetsGroupType.All, GroupsEnumerator,
                                    (NSError e) => { Console.WriteLine("Could not enumerate albums: " + e.LocalizedDescription); });
        }
コード例 #4
0
        static NSUrl fetchMovieUrl()
        {
            NSUrl movieURL   = null;
            var   waitHandle = new AutoResetEvent(false);

            ThreadPool.QueueUserWorkItem(_ => {
                ALAssetsLibrary assetsLibrary = new ALAssetsLibrary();
                assetsLibrary.Enumerate(ALAssetsGroupType.All, (ALAssetsGroup group, ref bool stop) => {
                    if (group == null)
                    {
                        waitHandle.Set();
                        return;
                    }

                    NSDate latest = NSDate.FromTimeIntervalSince1970(0);
                    group.Enumerate((ALAsset result, nint index, ref bool stopGroup) => {
                        if (result == null || result.AssetType != ALAssetType.Video)
                        {
                            return;
                        }

                        NSUrl url = result.DefaultRepresentation.Url;
                        if (url == null)
                        {
                            return;
                        }

                        var diff = result.Date.SecondsSinceReferenceDate - latest.SecondsSinceReferenceDate;
                        if (diff > 0)
                        {
                            latest   = result.Date;
                            movieURL = url;
                        }
                    });

                    stop = movieURL != null;
                }, (error) => {
                    waitHandle.Set();
                });
            });

            waitHandle.WaitOne();

            if (movieURL == null)
            {
                UIAlertView alertView = new UIAlertView(null, "Could not find any movies in assets library to use as sample content.", null, "OK", null);
                alertView.Show();
            }

            return(movieURL);
        }
コード例 #5
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                NavigationItem.Title = NSBundle.MainBundle.LocalizedString("Loading", "Loading...");
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear();

                Library = new ALAssetsLibrary();
                Library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
コード例 #6
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();

                NavigationItem.Title = "Loading...";
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel /*, cancelImagePicker*/);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear();

                Library = new ALAssetsLibrary();
                Library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
コード例 #7
0
        public Task <IList <Picture> > LoadImagesAsync()
        {
            taskCompletionSource = new TaskCompletionSource <IList <Picture> >();
            //Clean the mess
            pictures.Clear();
            var library = new ALAssetsLibrary();

            library.Enumerate(ALAssetsGroupType.All, GroupEnumerator,
                              (NSError e) => {
                Console.WriteLine("Could not enumerate albums: " + e.LocalizedDescription);
            }
                              );


            return(taskCompletionSource.Task);
        }
コード例 #8
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad();
                var loading = string.IsNullOrWhiteSpace(LoadingTitle) ? NSBundle.MainBundle.GetLocalizedString("Loading", "Loading...") : LoadingTitle;

                NavigationItem.Title = loading;
                var cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel);

                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                assetGroups.Clear();

                library = new ALAssetsLibrary();
                library.Enumerate(ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
コード例 #9
0
        //AlAssetsGroupSavedPhotos
        public void InitializePhotos()
        {
            assetsLibrary     = new ALAssetsLibrary();
            currentPhotoIndex = -1;
            photoAssets       = new List <ALAsset> (PHOTO_ASSETS_CAPACITY);
            int  photoIndex            = 0;
            bool syncContentController = true;

            assetsLibrary.Enumerate(ALAssetsGroupType.Album, (ALAssetsGroup group, ref bool stop) => {
                if (group != null)
                {
                    string groupName = group.Name;
                    if (groupName.StartsWith(PNALBUM_PREFIX))
                    {
                        group.SetAssetsFilter(ALAssetsFilter.AllPhotos);
                        group.Enumerate((ALAsset asset, int index, ref bool st) => {
                            int notfound = Int32.MaxValue;
                            if (asset != null && index != notfound)
                            {
                                photoAssets.Add(asset);
                                photoIndex++;
                                currentPhotoIndex = 0;
                            }
                            if (photoIndex == PHOTO_ASSETS_CAPACITY)
                            {
                                st = true;
                            }
                        });
                    }
                }

                if (syncContentController)
                {
                    syncContentController = false;
                    DispatchQueue.MainQueue.DispatchAsync(() => {
                        if (currentPhotoIndex == 0)
                        {
                            setCurrentPhotoToIndex(0);
                        }
                        ((PhotoViewController)(ViewController.contentController)).Synchronize(currentPhotoIndex >= 0);
                    });
                }
            },
                                    (NSError error) => {
                Console.WriteLine("User denied access to photo Library... {0}", error);
            });
        }
コード例 #10
0
        public void RequestPhotoAccess(bool useImagePicker)
        {
            if (useImagePicker)
            {
                UIImagePickerController picker = new UIImagePickerController();
                picker.Delegate = this;
                PresentViewController(picker, true, null);
            }
            else
            {
                if (assetLibrary == null)
                {
                    assetLibrary = new ALAssetsLibrary();
                }

                assetLibrary.Enumerate(ALAssetsGroupType.All,
                                       delegate { }, delegate { });
            }
        }
コード例 #11
0
        private void GetAllAssets()
        {
            var assetsLibrary = new ALAssetsLibrary();

            assetsLibrary.Enumerate(ALAssetsGroupType.All,
                                    (ALAssetsGroup group, ref bool stop) =>
            {
                group?.SetAssetsFilter(ALAssetsFilter.AllPhotos);
                group?.Enumerate((ALAsset asset, nint index, ref bool st) =>
                {
                    int notfound = Int32.MaxValue;
                    if (asset != null && index != notfound)
                    {
                        Images.Add(new AssetImage(asset));
                    }
                });
                ReloadData();
            },
                                    (NSError obj) =>
            {
            });
        }
コード例 #12
0
            public override void ViewDidLoad()
            {
                base.ViewDidLoad ();

                NavigationItem.Title = NSBundle.MainBundle.LocalizedString ("Loading", "Loading...");
                var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);
                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear ();

                Library = new ALAssetsLibrary ();
                Library.Enumerate (ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
コード例 #13
0
		//AlAssetsGroupSavedPhotos
		public void InitializePhotos ()
		{
			assetsLibrary = new ALAssetsLibrary ();
			currentPhotoIndex = -1;
			photoAssets = new List<ALAsset> (PHOTO_ASSETS_CAPACITY);
			int photoIndex = 0;
			bool syncContentController = true;
			assetsLibrary.Enumerate (ALAssetsGroupType.Album, ( ALAssetsGroup group, ref bool stop) => {

				if (group != null) {

					string groupName = group.Name;
					if (groupName.StartsWith (PNALBUM_PREFIX)) {
						group.SetAssetsFilter (ALAssetsFilter.AllPhotos);
						group.Enumerate ((ALAsset asset, nint index, ref bool st) => {
							int notfound = Int32.MaxValue;
							if (asset != null && index != notfound) {
								photoAssets.Add (asset);
								photoIndex++;
								currentPhotoIndex = 0;
							}
							if (photoIndex == PHOTO_ASSETS_CAPACITY) {
								st = true;
							}
						});
					}
				}

				if (syncContentController) {
					syncContentController = false;
					DispatchQueue.MainQueue.DispatchAsync (() => {
						if (currentPhotoIndex == 0) {
							setCurrentPhotoToIndex (0);
						}
						((PhotoViewController)(ViewController.contentController)).Synchronize (currentPhotoIndex >= 0);
					});
				}
			},
			(NSError error) => {
				Console.WriteLine ("User denied access to photo Library... {0}", error);
			});
		}
            public override void ViewDidLoad()
            {
                base.ViewDidLoad ();

                NavigationItem.Title = Catalog.GetString ("Loading...");
                var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel/*, cancelImagePicker*/);
                cancelButton.Clicked += CancelClicked;
                NavigationItem.RightBarButtonItem = cancelButton;

                AssetGroups.Clear ();

                Library = new ALAssetsLibrary ();
                Library.Enumerate (ALAssetsGroupType.All, GroupsEnumerator, GroupsEnumeratorFailed);
            }
コード例 #15
0
		static NSUrl fetchMovieUrl ()
		{
			NSUrl movieURL = null;
			var waitHandle = new AutoResetEvent (false);

			ThreadPool.QueueUserWorkItem (_ => {
				ALAssetsLibrary assetsLibrary = new ALAssetsLibrary ();
				assetsLibrary.Enumerate (ALAssetsGroupType.All, (ALAssetsGroup group, ref bool stop) => {
					if (group == null) {
						waitHandle.Set ();
						return;
					}

					NSDate latest = NSDate.FromTimeIntervalSince1970(0);
					group.Enumerate ((ALAsset result, nint index, ref bool stopGroup) => {
						if(result == null || result.AssetType != ALAssetType.Video)
							return;

						NSUrl url = result.DefaultRepresentation.Url;
						if (url == null)
							return;

						var diff = result.Date.SecondsSinceReferenceDate - latest.SecondsSinceReferenceDate;
						if(diff > 0) {
							latest = result.Date;
							movieURL = url;
						}
					});

					stop = movieURL != null;
				}, (error) => {
					waitHandle.Set ();
				});
			});

			waitHandle.WaitOne ();

			if (movieURL == null) {
				UIAlertView alertView = new UIAlertView (null, "Could not find any movies in assets library to use as sample content.", null, "OK", null);
				alertView.Show ();
			}

			return movieURL;
		}
コード例 #16
0
 void ShowActualPhotoPermissionAlert()
 {
     ALAssetsLibrary library = new ALAssetsLibrary ();
     library.Enumerate (ALAssetsGroupType.SavedPhotos, HandleALAssetsLibraryGroupsEnumerationResults, delegate (NSError obj)
     {
         FirePhotoPermissionCompletionHandler ();
     });
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Gallery.iOS.ImageHandler"/> class.
 /// </summary>
 public ImageHandler()
 {
     _assetLibrary = new ALAssetsLibrary();
     _assets       = new List <string> ();
     _assetLibrary.Enumerate(ALAssetsGroupType.SavedPhotos, GroupEnumerator, Console.WriteLine);
 }