Beispiel #1
0
        private static void TestImage(MyUser user, Album myAlbumTitleOnly)
        {
            // Get all the images from the current album
            List <Image> myImageList  = new List <Image>();
            Watermark    myWatermark1 = null;
            Watermark    myWatermark2 = null;
            Image        myImage2     = null;
            Image        myImage3     = null;

            try
            {
                myImageList = myAlbumTitleOnly.GetImages(true);
                foreach (var x in myImageList)
                {
                    Console.WriteLine("{0} - {1}", x.FileName, x.Date);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Comments
            try
            {
                myImageList[0].AddComment("Comment on image");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();



            Console.WriteLine("Test the image functions:");

            try
            {
                Image myImage = myImageList[0];
                myImage2 = myImageList[1];
                myImage3 = myImageList[2];
                // Change position
                myImage.ChangePosition(2);
                myImageList = myAlbumTitleOnly.GetImages(true);
                foreach (var x in myImageList)
                {
                    Console.WriteLine(x.FileName);
                }
                // Crop the picture
                myImage2.Crop(300, 300, 0, 10);
                // Change settings
                myImage.Caption = "Test image";
                myImage.ChangeSettings();
                Console.WriteLine("The new image caption is: " + myImage.Caption);
                // Get EXIF info from site
                myImage = myImage.GetEXIF();

                var imageWithStats = myImage.GetStats(12, 2011);

                myImage2.PopulateImageWithEXIFFromSite();
                Console.WriteLine("EXIF info: " + myImage.Model);
                Console.WriteLine("EXIF info: " + myImage2.Model);
                // Get info from site
                myImage = myImage.GetInfo();
                myImage2.PopulateImageWithInfoFromSite();
                Console.WriteLine("Info: " + myImage.FileName);
                Console.WriteLine("Info: " + myImage2.FileName);
                // Get the URLs
                myImage = myImage.GetURLs();
                myImage2.PopulateImageWithURLsFromSite();
                Console.WriteLine(myImage2.OriginalURL);
                // Rotate an image
                myImage.Rotate(DegreesEnum.Left, false);
                // Zoom the thumbnail
                myImage3.ZoomThumbnail(100, 100, 1, 1);
                myImage.Delete();
                Console.WriteLine("The remaining pictures after delete: ");
                myImageList = myAlbumTitleOnly.GetImages(true);
                foreach (var x in myImageList)
                {
                    Console.WriteLine(x.FileName);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();


            // Comments
            try
            {
                myImageList[0].GetComments();
                if (myImage2.Comments != null)
                {
                    Console.WriteLine(myImage2.Comments[0].Text);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();


            Console.WriteLine("Test the watermarking functions:");
            // Create a watermark
            try
            {
                myWatermark1 = myImage2.CreateWatermark("TestWatermark1");
                myImage3.ApplyWatermark(myWatermark1);
                myWatermark2 = myImage3.CreateWatermark("TestWatermark2");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Display the existing watermarks
            try
            {
                var myWatermarksList = user.GetWatermarks(true);
                foreach (var x in myWatermarksList)
                {
                    Console.WriteLine(x.Name);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            // Change settings
            try
            {
                myWatermark1.Name     = "TestWatermarkNameChanged";
                myWatermark1.Dissolve = 50;
                // Get info
                myWatermark1 = myWatermark1.GetInfo();
                Console.WriteLine(myWatermark1.Name);
                myWatermark2.PopulateWatermarkWithInfoFromSite();
                Console.WriteLine(myWatermark2.Name);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();

            try
            {
                myImage3.RemoveWatermark();
                myWatermark1.Delete();
                myWatermark2.Delete();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.WriteLine();
        }