private void FireUpFileChooserForDownloading() { if (uploadbutton.Active) return; FileChooserDialog chooser = new FileChooserDialog( "Select a folder", null, FileChooserAction.SelectFolder, Stock.Open, ResponseType.Ok, Stock.Cancel, ResponseType.Cancel); chooser.SetIconFromFile(DeskFlickrUI.ICON_PATH); chooser.SetFilename(PersistentInformation.GetInstance().DownloadFoldername); ResponseType choice = (ResponseType) chooser.Run(); string foldername = ""; if (choice == ResponseType.Ok) { foldername = chooser.Filename; // Set the default path to be opened next time file chooser runs. PersistentInformation.GetInstance().DownloadFoldername = foldername; } chooser.Destroy(); if (foldername.Equals("")) return; // Selected folder for downloading. ArrayList photoids = new ArrayList(); ArrayList selectedphotos = new ArrayList(); bool refreshview = false; if (treeview2.Selection.GetSelectedRows().Length > 0) { foreach (TreePath path in treeview2.Selection.GetSelectedRows()) { Photo p = new Photo(GetPhoto(path)); TreePath childpath = filter.ConvertPathToChildPath(path); SelectedPhoto sel = new SelectedPhoto(p, childpath.ToString()); selectedphotos.Add(sel); photoids.Add(p.Id); } } else if (treeview1.Selection.GetSelectedRows().Length > 0) { // Going through the complex way of figuring out photos for the // different tab modes. Easier way would be to just copy contents // of _photos, as it already takes care of left tree selection. However, // when the view is locked to 'downloads', _photos wouldn't be updated. // Hence the need to figure out photoids. TreePath path = treeview1.Selection.GetSelectedRows()[0]; if (selectedtab == 0) { // albums Album album = new Album((Album) _albums[path.Indices[0]]); photoids = PersistentInformation.GetInstance().GetPhotoIdsForAlbum(album.SetId); //foldername = String.Format("{0}/{1}", foldername, album.Title); } else if (selectedtab == 1) { // tags string tag = (string) _tags[path.Indices[0]]; photoids = PersistentInformation.GetInstance().GetPhotoIdsForTag(tag); //foldername = String.Format("{0}/{1}", foldername, tag); } else if (selectedtab == 2) { PersistentInformation.Entry poolentry = (PersistentInformation.Entry) _pools[path.Indices[0]]; string poolid = poolentry.entry1; //string pooltitle = poolentry.entry2; photoids = PersistentInformation.GetInstance().GetPhotoidsForPool(poolid); //foldername = String.Format("{0}/{1}", foldername, pooltitle); } else if (selectedtab == 3) { PersistentInformation.Entry blog = (PersistentInformation.Entry) _blogs[path.Indices[0]]; foreach (BlogEntry blogentry in PersistentInformation.GetInstance().GetEntriesForBlog(blog.entry1)) { photoids.Add(blogentry.Photoid); } //foldername = String.Format("{0}/{1}", foldername, blog.entry2); } refreshview = true; } Utils.EnsureDirectoryExists(foldername); foreach (string id in photoids) { if (PersistentInformation.GetInstance().IsDownloadEntryExists(id)) { PersistentInformation.GetInstance().DeleteEntryFromDownload(id); } PersistentInformation.GetInstance().InsertEntryToDownload(id, foldername); } UpdateToolBarButtons(); if (downloadbutton.Active) RefreshDownloadPhotos(); else if (refreshview) RefreshLeftTreeView(); else UpdatePhotos(selectedphotos); }