Ejemplo n.º 1
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
            }

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            _flickr = new FlickrNet.Flickr("076a4a9c54b18678c5ad367dc21b1d94", "8b9ef74b0d6a16d0");

            settings = new AppSettings();
        }
Ejemplo n.º 2
0
        public PhotoAdapter()
        {
            var apiKey = ConfigurationManager.AppSettings["PhotoApiKey"] ?? "b2247ed8cfe512cbbf381a5c0907c8cb";
            var apiSecret = ConfigurationManager.AppSettings["PhotoApiSecret"] ?? "ce369460c3b90d24";

            _flickr = new FlickrNet.Flickr(apiKey, apiSecret);
        }
Ejemplo n.º 3
0
        public PhotoAdapter()
        {
            var apiKey    = ConfigurationManager.AppSettings["PhotoApiKey"] ?? "b2247ed8cfe512cbbf381a5c0907c8cb";
            var apiSecret = ConfigurationManager.AppSettings["PhotoApiSecret"] ?? "ce369460c3b90d24";

            _flickr = new FlickrNet.Flickr(apiKey, apiSecret);
        }
        public IFlickrApiClient Create()
        {
            var apiKey    = ConfigurationManager.AppSettings[ApiKeySettingsKey];
            var apiSecret = ConfigurationManager.AppSettings[ApiSecretSettingsKey];
            var flicrApi  = new FlickrApi(apiKey, apiSecret);

            return(new FlickrApiClient(flicrApi));
        }
Ejemplo n.º 5
0
        public static void Authorize(this FlickrNet.Flickr flickr, OAuthAccessToken accessToken)
        {
            if (!IsComplete(accessToken))
            {
                throw new AuthorizationException();
            }

            flickr.OAuthAccessToken       = accessToken.Token;
            flickr.OAuthAccessTokenSecret = accessToken.TokenSecret;
        }
Ejemplo n.º 6
0
 private void AuthenticateButton_Click(object sender, EventArgs e)
 {
     FlickrNet.Flickr f = FlickrManager.GetFlickrInstance();
     try
     {
         // Request a token. The parameter "oob" basically means Flickr shows the user the
         // verification code on their own web page.
         requestToken = f.OAuthGetRequestToken("oob");
         string url = f.OAuthCalculateAuthorizationUrl(requestToken.Token, FlickrNet.AuthLevel.Read);
         System.Diagnostics.Process.Start(url);
         Step2GroupBox.Enabled = true;
         labelResult.Visible   = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 7
0
        List <Models.FlickrPhoto> GetPhotosFromFlickr(int pageindex = 0)
        {
            List <Models.FlickrPhoto> retVal = null;

            FlickrNet.Flickr flickr = new FlickrNet.Flickr(Manager.Settings.Current.FlickrAPIKey);
            flickr.InstanceCacheDisabled = true;

            FlickrNet.FoundUser userInfo = flickr.PeopleFindByUserName(Manager.Settings.Current.FlickrUserName);
            string flickrUserId          = userInfo.UserId;

            ViewBag.FlickrFullName = userInfo.FullName;

            FlickrNet.Person user = flickr.PeopleGetInfo(flickrUserId);
            ViewBag.FlickrFullName = user.RealName;

            FlickrNet.PhotoSearchOptions option = new FlickrNet.PhotoSearchOptions();
            option.UserId = flickrUserId;
            option.Page   = pageindex;

            FlickrNet.PhotoCollection photosets = flickr.PhotosSearch(option);
            if (photosets != null && photosets.Count > 0)
            {
                DataTable photos = UnigateObject.Query(Manager.Settings.Current.PhotoListTableName)
                                   .Column("Slug")
                                   .SortDesc("CreateDate")
                                   .ToDataTable();

                List <string> slugs = new List <string>();
                if (photos != null && photos.Rows.Count > 0)
                {
                    slugs = photos.AsEnumerable().Select(p => p.Field <string>("Slug")).ToList();
                }

                retVal = photosets.Where(p => !slugs.Any(s => s == p.PhotoId)).Select(p => new Models.FlickrPhoto()
                {
                    DownloadUrl = !string.IsNullOrEmpty(p.LargeUrl) ? p.LargeUrl : (!string.IsNullOrEmpty(p.MediumUrl) ? p.MediumUrl : p.SmallUrl),
                    ViewUrl     = p.SmallUrl,
                    Title       = p.Title,
                    PhotoId     = p.PhotoId
                }).ToList <Models.FlickrPhoto>();
            }

            return(retVal);
        }
Ejemplo n.º 8
0
 public void PostToFlickr()
 {
     if (Settings.FlickrToken != "")
     {
         FlickrNet.Flickr flckr = new FlickrNet.Flickr(Program.FlickrAPIKey, Program.FlickrSharedSecretKey);
         flckr.AuthToken = Settings.FlickrToken;
         string c = this.Comments;
         if (c == null)
         {
             c = "";
         }
         using (System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open)) {
             flckr.UploadPicture(fs, System.IO.Path.GetFileName(FilePath), c, "screenshot Terminals", 1, 1, 1, FlickrNet.ContentType.Screenshot, FlickrNet.SafetyLevel.Safe, FlickrNet.HiddenFromSearch.Visible);
         }
     }
     else
     {
         throw new Exception("You must authorize with Flickr prior to posting.  In Terminals, go to Tools, Options and then select the Flickr tab.");
     }
 }
Ejemplo n.º 9
0
        internal static string Authenticate(System.Windows.Forms.IWin32Window dialogOwner, FlickrContext context)
        {
            string frob;

            FlickrNet.Flickr.CacheDisabled = true;
            FlickrNet.Flickr flickrProxy = null;

            System.Resources.ResourceManager mgr = new System.Resources.ResourceManager(typeof(SmilingGoat.WindowsLiveWriter.Flickr.Properties.Resources));
            flickrProxy = new FlickrNet.Flickr(mgr.GetString("ApiKey"), mgr.GetString("SharedSecret"));

            // Leverage proxy settings if they are there.
            System.Net.WebProxy proxySettings = (System.Net.WebProxy)WindowsLive.Writer.Api.PluginHttpRequest.GetWriterProxy();
            if (proxySettings != null)
            {
                flickrProxy.Proxy = proxySettings;
            }

            using (AuthForm authf = new AuthForm(flickrProxy))
            {
                if (authf.ShowDialog(dialogOwner) != System.Windows.Forms.DialogResult.OK)
                {
                    return(null);
                }

                frob = authf.Frob;
            }

            using (CompletedAuth complete = new CompletedAuth(flickrProxy, frob))
            {
                if (complete.ShowDialog(dialogOwner) != System.Windows.Forms.DialogResult.OK)
                {
                    // auth failed
                    MessageBox.Show("Authorization has failed.  Please try again", "Authorization Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }

                context.FlickrAuthToken = complete.AuthToken;

                return(complete.AuthToken);
            }
        }
Ejemplo n.º 10
0
        internal static string Authenticate(IWin32Window dialogOwner, FlickrContext context)
        {
            object frob;

            FlickrNet.Flickr.CacheDisabled = true;

            System.Resources.ResourceManager mgr = new System.Resources.ResourceManager(typeof(Properties.Resources));
            FlickrNet.Flickr flickrProxy = new FlickrNet.Flickr(mgr.GetString("ApiKey"), mgr.GetString("SharedSecret"));

            // Leverage proxy settings if they are there.
            System.Net.WebProxy proxySettings = (System.Net.WebProxy)WindowsLive.Writer.Api.PluginHttpRequest.GetWriterProxy();
            if (proxySettings != null)
            {
                flickrProxy.Proxy = proxySettings;
            }

            using (AuthForm authf = new AuthForm(flickrProxy))
            {
                if (authf.ShowDialog(dialogOwner) != DialogResult.OK)
                {
                    return null;
                }

                frob = authf.Frob;
            }

            using (CompletedAuth complete = new CompletedAuth(flickrProxy, frob))
            {
                if (complete.ShowDialog(dialogOwner) != DialogResult.OK)
                {
                    // auth failed
                    MessageBox.Show(@"Authorization has failed.  Please try again", @"Authorization Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return null;
                }

                context.FlickrAuthToken = complete.AuthToken;
                context.FlickrAuthTokenSecret = complete.AuthTokenSecret;

                return complete.AuthToken;
            }
        }
Ejemplo n.º 11
0
        public Photo[] GetPhotos(string apiKey, string tags)
        {
            FlickrNet.Flickr.CacheDisabled = true;
            FlickrNet.Flickr flickr = new FlickrNet.Flickr(apiKey);

            FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
            options.Tags    = tags;
            options.Extras  = FlickrNet.PhotoSearchExtras.DateTaken | FlickrNet.PhotoSearchExtras.Geo | FlickrNet.PhotoSearchExtras.OwnerName;
            options.PerPage = 1000;
            options.Text    = tags;
            options.TagMode = FlickrNet.TagMode.AllTags;

            List <Photo> photos = new List <Photo>();

            foreach (FlickrNet.Photo photo in flickr.PhotosSearch(options).PhotoCollection)
            {
                try { photos.Add(new Photo(photo, "{0}")); }
                catch { }
            }

            return(photos.ToArray());
        }
Ejemplo n.º 12
0
        public Photo[] GetPhotos( string apiKey, string tags )
        {
            FlickrNet.Flickr.CacheDisabled = true;
            FlickrNet.Flickr flickr = new FlickrNet.Flickr( apiKey );

            FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
            options.Tags = tags;
            options.Extras = FlickrNet.PhotoSearchExtras.DateTaken | FlickrNet.PhotoSearchExtras.Geo | FlickrNet.PhotoSearchExtras.OwnerName;
			options.PerPage = 1000;
			options.Text = tags;
			options.TagMode = FlickrNet.TagMode.AllTags;

            List<Photo> photos = new List<Photo>();

            foreach ( FlickrNet.Photo photo in flickr.PhotosSearch( options ).PhotoCollection )
            {
				try { photos.Add( new Photo( photo, "{0}" ) ); }
				catch { }
            }

            return photos.ToArray();
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            var key = ConfigurationManager.AppSettings["APIKey"];
            var secret = ConfigurationManager.AppSettings["APISecret"];
            FlickrNet.Flickr f = new FlickrNet.Flickr(key, secret);

            if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["accesstoken"]))
            {
                var requesttoken = f.OAuthGetRequestToken("oob");
                var url = f.OAuthCalculateAuthorizationUrl(requesttoken.Token, FlickrNet.AuthLevel.Write);
                Process.Start(url);
                Console.Write("Please enter the 9 digit code Flickr gave you");
                var code = Console.ReadLine();
                var settings = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var accesstoken = f.OAuthGetAccessToken(requesttoken.Token, requesttoken.TokenSecret, code);
                //settings.
                settings.AppSettings.Settings.Add("accesstoken", accesstoken.Token);
                settings.AppSettings.Settings.Add("accesstokensecret", accesstoken.TokenSecret);
                settings.Save();
            }

            else
            {
                f.OAuthAccessToken = ConfigurationManager.AppSettings["accesstoken"];
                f.OAuthAccessTokenSecret = ConfigurationManager.AppSettings["accesstokensecret"];
                var searchoptions = new FlickrNet.PhotoSearchOptions() { UserId = "me", MinUploadDate = DateTime.Parse("2013-10-01"), Extras=FlickrNet.PhotoSearchExtras.Tags,Page=2 };

                var collection = f.PhotosSearch(searchoptions);

                var filteredcollection = collection.Where(photo => photo.Title.StartsWith("DSC") && !HasFileNameTag(photo));
                foreach (FlickrNet.Photo photo in filteredcollection)
                {
                    f.PhotosAddTags(photo.PhotoId, "filename:" + photo.Title);
                }

            }
        }
        public FlickrFixture()
        {
            var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";

            Console.WriteLine("ENV:" + env);

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env}.json", optional: true)
                          .AddEnvironmentVariables()
                          .Build();

            ApiKey = builder.GetSection("flickrSettings:apiKey").Value;
            Secret = builder.GetSection("flickrSettings:secret").Value;

            this.Flickr = new FlickrNet.Flickr(ApiKey, Secret);

            var serviceProvider = new ServiceCollection()
                                  .AddScoped <ISearchService>(s => new SearchService(ApiKey, Secret))
                                  .BuildServiceProvider();

            SearchService = serviceProvider.GetRequiredService <ISearchService>();
        }
Ejemplo n.º 15
0
        private void CompleteAuthButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(VerifierTextBox.Text))
            {
                MessageBox.Show("You must paste the verifier code into the text box above.");
                return;
            }

            FlickrNet.Flickr f = FlickrManager.GetFlickrInstance();
            try
            {
                var accessToken = f.OAuthGetAccessToken(requestToken, VerifierTextBox.Text);
                NewUser = new User(accessToken.Username);
                if (!string.IsNullOrWhiteSpace(accessToken.FullName))
                {
                    NewUser.RealName = accessToken.FullName;
                }
                NewUser.UserId           = accessToken.UserId;
                NewUser.OAuthToken       = accessToken.Token;
                NewUser.OAuthTokenSecret = accessToken.TokenSecret;

                // Add or replace the account in the account list.
                Settings.AddReplaceFlickrLoginAccountName(NewUser);

                // Also add this user to the search list
                Settings.AddReplaceFlickrSearchAccountName(NewUser);

                labelResult.Visible    = true;
                btnCancel.Text         = "Close";
                btnCancel.DialogResult = DialogResult.OK;
            }
            catch (FlickrNet.FlickrApiException ex)
            {
                MessageBox.Show("Failed to get access token./r/n" + ex.Message);
            }
        }
Ejemplo n.º 16
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Add is the accept button, because I want it to be clicked when the user hits enter.
            // That means the DialogResult is set to OK by the framework.
            // Set it to none, so that if errors occur, we don't exit this dialog.
            // If we successfully add, we will set it back to OK.
            this.DialogResult = DialogResult.None;

            string newUserName = txtUserName.Text;

            newUserName = newUserName.Trim();
            if (string.IsNullOrWhiteSpace(newUserName))
            {
                MessageBox.Show("Please enter a Flickr account name or email address.");
                return;
            }
            int index = Settings.FlickrSearchAccountList.ToList <User>().FindIndex(x => x.UserName == newUserName);

            if (index >= 0)
            {
                MessageBox.Show("That account is already in the search account list.");
                return;
            }

            FlickrNet.Flickr    f        = null;
            FlickrNet.FoundUser userInfo = null;
            try
            {
                f = FlickrManager.GetFlickrAuthInstance();
                if (f == null)
                {
                    MessageBox.Show("Could not connect with Flickr.");
                    return;
                }

                // Look for the user by name.
                Cursor.Current = Cursors.WaitCursor;
                userInfo       = f?.PeopleFindByUserName(newUserName);
            }
            catch (FlickrNet.FlickrException)
            {
                try
                {
                    userInfo = f?.PeopleFindByEmail(newUserName);
                }
                catch (FlickrNet.FlickrException)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("Could not find user " + newUserName + ".");
                    return;
                }
                catch (Exception exc)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(exc.Message);
                    return;
                }
            }
            catch (Exception exc)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exc.Message);
                return;
            }

            if (userInfo == null)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("Could not find user " + newUserName + ".");
                return;
            }

            // Check if this user is already in the account list. We checked before, but this
            // could still happen if they searched by email.
            index = Settings.FlickrSearchAccountList.ToList <User>().FindIndex(x => x.UserName == userInfo.UserName);
            if (index >= 0)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("That account is already in the account list.");
                return;
            }

            // Create a new user.
            NewUser        = new User(userInfo.UserName);
            NewUser.UserId = userInfo.UserId;

            // Get the users real name.
            FlickrNet.Person person = null;
            try
            {
                person = f.PeopleGetInfo(NewUser.UserId);
            }
            catch (Exception exc)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exc.Message);
                return;
            }

            if (!string.IsNullOrWhiteSpace(person.RealName))
            {
                NewUser.RealName = person.RealName;
            }

            // Add the user to the search account list.
            Settings.AddReplaceFlickrSearchAccountName(NewUser);

            Cursor.Current    = Cursors.Default;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 17
0
        private void GetImageUrlsForSentence(string query)
        {
            if (rdoFlickr.Checked)
            {
                FlickrNet.Flickr flickr = new FlickrNet.Flickr("580162ba802ed95a92fc92494dcdecbf", "a6b6d63a6ce977c5");
                FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
                options.Tags = query;
                options.PerPage = 10;
                //options.IsCommons = true;
                options.Licenses.Add(FlickrNet.LicenseType.NoKnownCopyrightRestrictions);
                options.Licenses.Add(FlickrNet.LicenseType.AttributionCC);
                options.Licenses.Add(FlickrNet.LicenseType.AttributionNoDerivativesCC);
                options.Licenses.Add(FlickrNet.LicenseType.AttributionShareAlikeCC);

                var result = flickr.PhotosSearch(options);
                SearchCompleted(result);

                flickr.PhotosSearchAsync(options, asyncResult =>
                    {
                        if (asyncResult.HasError)
                        {
                            TextBox txtError = new TextBox();
                            txtError.Multiline = true;
                            txtError.Dock = DockStyle.Fill;
                            txtError.Text = asyncResult.Error.ToString();
                            flowLayoutPanel1.Controls.Add(txtError);

                            return;
                        }

                        var photos = asyncResult.Result;

                        SearchCompleted(photos);
                    });
            }

            else if (rdoBing.Checked)
            {
                using (BingPortTypeClient client = new BingPortTypeClient())
                {
                    client.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(client_SearchCompleted);
                    var searchRequest = new SearchRequest();
                    searchRequest.Adult = BingSearchService.AdultOption.Strict;
                    searchRequest.AdultSpecified = true;
                    searchRequest.Market = "en-US";
                    searchRequest.Version = "2.2";
                    searchRequest.AppId = "C208A7E582F635C7768950E74C8FDC274A0EA7B4";
                    searchRequest.Sources = new BingSearchService.SourceType[] { SourceType.Image };
                    searchRequest.Query = query;

                    searchRequest.Image = new ImageRequest();
                    searchRequest.Image.Count = 10;
                    progressBar1.Step = (int)100 / (int)searchRequest.Image.Count;
                    searchRequest.Image.CountSpecified = true;

                    searchRequest.Image.Offset = 0;
                    searchRequest.Image.OffsetSpecified = true;

                    client.SearchAsync(searchRequest);
                }
            }
        }
Ejemplo n.º 18
0
 static JobFlickrUploader()
 {
     g_FR = new FlickrNet.Flickr("1d39fd2053d23729f64981fd2dcd3cdb", "3dd5b228858000ed", g_AuthToken);
     g_Auth = g_FR.AuthCheckToken(g_AuthToken);
     g_FR.OnUploadProgress += new FlickrNet.Flickr.UploadProgressHandler(OffThreadOnUploadProgress);
 }
Ejemplo n.º 19
0
 public AuthForm(FlickrNet.Flickr flickrProxy)
 {
     InitializeComponent();
     _proxy = flickrProxy;
 }
Ejemplo n.º 20
0
 public AuthForm(FlickrNet.Flickr flickrProxy)
 {
     InitializeComponent();
     _proxy = flickrProxy;
 }
Ejemplo n.º 21
0
        public void GetNewWallpaper()
        {
            NotifyIconText = "Retrieving next picture...";
            NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrwait;
            IsNotifyFail   = false;

            if (ApiKey.Equals(string.Empty))
            {
                NotifyIconText = "API key missing";
                NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad;
                IsNotifyFail   = true;
                return;
            }

            FlickrNet.Flickr flickr = new FlickrNet.Flickr();
            flickr.ApiKey = ApiKey;

            FlickrNet.PhotoCollection photos = null;

            switch (_settings.SearchOrFaves)
            {
            case 0:
                FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions();
                if (!Tags.Trim().Equals(string.Empty))
                {
                    options.Tags    = Tags;
                    options.TagMode = GetTagMode();
                }
                if (!UserId.Trim().Equals(string.Empty))
                {
                    FlickrNet.FoundUser fuser;
                    string   UserName     = "";
                    string[] AllUserNames = UserId.Split(',');
                    UserName = AllUserNames[new Random().Next(0, AllUserNames.GetUpperBound(0) + 1)];
                    try
                    {     // Exception handler added by CLR 2010-06-11
                        fuser = flickr.PeopleFindByUserName(UserName.Trim());
                    }
                    catch (Exception ex)
                    {
                        FailWithError(ex);
                        return;
                    }
                    if (!fuser.UserId.Equals(string.Empty))
                    {
                        options.UserId = fuser.UserId;
                    }
                }
                options.PrivacyFilter = FlickrNet.PrivacyFilter.PublicPhotos;
                options.SortOrder     = GetSortOrder();
                options.PerPage       = 365;

                try
                {
                    photos = flickr.PhotosSearch(options);
                    //photos = flickr.PhotosGetRecent(); // this was me trying to do Explore stuff, but failed
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    FailWithError(ex);
                    return;
                }
                options = null;
                break;

            case 1:
                try
                {
                    FlickrNet.FoundUser fuser;
                    fuser  = flickr.PeopleFindByUserName(FaveUserId);
                    photos = flickr.FavoritesGetPublicList(fuser.UserId);
                }
                catch (Exception ex)
                {
                    FailWithError(ex);
                    return;
                }
                break;

            case 2:
                // do explore
                try
                {
                    photos = flickr.InterestingnessGetList();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                    FailWithError(ex);
                    return;
                }
                break;

            default:
                break;
            }


            clsWallpaper wallpaper = new clsWallpaper();

            Random pn = new Random();

            if (photos.Count == 0)
            {
                NotifyIconText = "Specified parameters return no photographs from Flickr";
                NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad;
                IsNotifyFail   = true;
                return;
            }
            else
            {
                int chosePhoto = pn.Next(0, photos.Count);
                //FlickrNet.Sizes fs = flickr.PhotosGetSizes("4570943273");
                FlickrNet.SizeCollection fs;
                bool LoadedWallpaper = false;
                try
                {
                    fs = flickr.PhotosGetSizes(photos[chosePhoto].PhotoId);
                    // Load the last size (which should be "Original"). Doing all this
                    // because photo.OriginalURL just causes an exception
                    LoadedWallpaper = wallpaper.Load(fs[fs.Count - 1].Source, _settings,
                                                     getDisplayStyle(), Application.ExecutablePath, photos[chosePhoto].WebUrl);
                }
                catch (Exception ex) // load failed with an exception
                {
                    FailWithError(ex);
                    return;
                }

                if (!LoadedWallpaper) // load failed, but didn't cause an exception
                {
                    NotifyIconText = "Failed to load wallpaper";
                    NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad;
                    IsNotifyFail   = true;
                    return;
                }

                // Get further info about the photo to display in the tooltip
                FlickrNet.PhotoInfo fi;
                try
                {
                    fi = flickr.PhotosGetInfo(photos[chosePhoto].PhotoId);
                }
                catch (Exception ex)
                {
                    FailWithError(ex);
                    return;
                }

                // Set thumbnail
                NotifyIconIcon = TinyPictureVersion(FileSystem.MyPath() + "\\wallpaper\\_CurrentPaper.bmp");

                FlickrNet.Person fuser;
                string           notifyText = "";
                fuser      = flickr.PeopleGetInfo(photos[chosePhoto].UserId);
                notifyText = fuser.UserName + ": " + photos[chosePhoto].Title;
                string description = fi.Description;
                string location    = "\n";
                if (fi.Location != null)
                {
                    if (fi.Location.County != null)
                    {
                        location += fi.Location.County.Description + ", " + fi.Location.Country.Description;
                    }
                    else
                    {
                        location += fi.Location.Country.Description;
                    }
                }
                description = System.Web.HttpUtility.HtmlDecode(Regex.Replace(description, "<[^>]*>", ""));

                NotifyIconText           = notifyText.Substring(0, Math.Min(63, notifyText.Length));
                NotifyIconBalloonTipText = fi.DateTaken.ToLongDateString() +
                                           location + "\n" + description;
                NotifyIconBalloonTipTitle = photos[chosePhoto].Title;

                if (ShowBubbles)
                {
                    NotifyPropertyChanged("PopupBalloon");
                }
            }

            wallpaper = null;
            flickr    = null;
            photos    = null;
            //notifyIcon1.Icon = WallpaperFlickr.Properties.Resources.flickr;
        }