Beispiel #1
0
        static void DeleteAll()
        {
            List <Album> myAlbums = user.GetAlbums();

            foreach (Album a in myAlbums)
            {
                a.Delete();
            }
        }
Beispiel #2
0
        private static Album TestAlbum(MyUser user)
        {
            Console.WriteLine("Test the album functions: ");
            Album myAlbumTitleOnly = null;

            try
            {
                // Create an album only with title (if the category isn't specified, the default one is "Other")
                myAlbumTitleOnly = user.CreateAlbum("TestAlbumTitleOnly");
                Console.WriteLine("Created album {0}", myAlbumTitleOnly.Title);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            // Get all the albums from the site
            try
            {
                List <Album> myAlbumList = user.GetAlbums(true);
                foreach (var x in myAlbumList)
                {
                    Console.WriteLine("{0}-{1}-{2}", x.Title, x.Category, (x.SubCategory == null) ? "None" : x.SubCategory.Name);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Get info for an album from the site and return it in a new album (here I use the same object)
            try
            {
                var testAlbum = myAlbumTitleOnly.GetInfo();
                Console.WriteLine(testAlbum.Protected);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Populate the current album with info from the site
            try
            {
                myAlbumTitleOnly.PopulateAlbumWithInfoFromSite();
                Console.WriteLine(myAlbumTitleOnly.Protected);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Change the settings for an album
            try
            {
                Console.WriteLine(myAlbumTitleOnly.Protected);
                myAlbumTitleOnly.Protected = true;
                myAlbumTitleOnly.ChangeSettings();

                myAlbumTitleOnly.PopulateAlbumWithInfoFromSite();
                Console.WriteLine(myAlbumTitleOnly.Protected);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Comments
            try
            {
                myAlbumTitleOnly.AddComment("Comment for album");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Comments
            try
            {
                myAlbumTitleOnly.GetComments();
                if ((myAlbumTitleOnly.CommentsList != null) && (myAlbumTitleOnly.CommentsList.Count > 0))
                {
                    Console.WriteLine(myAlbumTitleOnly.CommentsList[0].Text);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Upload piture to the album from an URL
            try
            {
                myAlbumTitleOnly.UploadImageFromURL("http://www.socialseo.com/files/images/best-free.jpg");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Upload pictures to the album
            try
            {
                var up = myAlbumTitleOnly.CreateUploader();
                up.UploadCompleted += new EventHandler <UploadEventArgs>(img_UploadCompleted);
                up.UploadProgress  += new EventHandler <UploadEventArgs>(img_UploadProgress);
                Console.Write("Give picture with whole path (eg: " + @"C:\Users\Username\Pictures\IMG_1234.jpg): ");
                String img1 = "images\\1.jpg"; //  Console.ReadLine();
                Console.Write("Give picture with whole path (eg: " + @"C:\Users\Username\Pictures\IMG_1234.jpg): ");
                String img2 = "images\\2.jpg"; //Console.ReadLine();
                Console.Write("Give picture with whole path (eg: " + @"C:\Users\Username\Pictures\IMG_1234.jpg): ");
                String img3 = "images\\3.jpg"; //Console.ReadLine();
                up.UploadImage(img1);
                up.UploadImage(img2);
                up.UploadImage(img3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Resort the album
            try
            {
                Console.WriteLine("Images before the sort");
                foreach (var x in myAlbumTitleOnly.GetImages(true))
                {
                    Console.WriteLine("{0} - {1}", x.FileName, x.Aperture);
                }
                myAlbumTitleOnly.ReSort(By.FileName, Direction.DESC);
                Console.WriteLine("Images after the sort");
                foreach (var x in myAlbumTitleOnly.GetImages(true))
                {
                    Console.WriteLine("{0} - {1}", x.FileName, x.Aperture);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            TestImage(user, myAlbumTitleOnly);

            return(myAlbumTitleOnly);
        }