private void cmdBuildPlan_Click(object sender, EventArgs e) { FlickrPlan plan = new FlickrPlan(); plan.User = (Identity)cboIdentities.SelectedItem; foreach (FlickrImage image in photoCollection.Values) { plan.Images.Add(image); } foreach (string s in lstSets.SelectedItems) { plan.Sets.Add(photoSetCollection[s]); } plan.HideFromSearch = (HiddenFromSearch)Enum.Parse(typeof(HiddenFromSearch), cboHidePublic.Text); plan.Privacy = (PrivacyFilter)Enum.Parse(typeof(PrivacyFilter), cboPrivacy.Text); plan.Safety = (SafetyLevel)Enum.Parse(typeof(SafetyLevel), cboSafety.Text); plan.Type = (ContentType)Enum.Parse(typeof(ContentType), cboContentType.Text); SaveFileDialog dlgSave = new SaveFileDialog(); dlgSave.Filter = "XML Plan File (*.xplan)|*.xplan|All Files (*.*)|*.*"; dlgSave.ShowDialog(); plan.WriteToFile(dlgSave.FileName); }
public FlickrPlan(string Filename) { XmlSerializer xSer = new XmlSerializer(typeof(FlickrPlan)); FlickrPlan plan = (FlickrPlan)xSer.Deserialize(new StreamReader(Filename).BaseStream); //HACK: There has to be a better way to map these properties back... Images = plan.Images; Sets = plan.Sets; User = plan.User; HideFromSearch = plan.HideFromSearch; Safety = plan.Safety; Type = plan.Type; Privacy = plan.Privacy; }
static void ProcessPlan(string Filename) { float pctComplete = 0; FlickrPlan plan = new FlickrPlan(Filename); ConfigInfo.FlickrApiToken = IdentityManager.GetUserToken(plan.User.TokenFile); flickr = new Flickr(ConfigInfo.FlickrApiKey, ConfigInfo.FlickrApiSecret, ConfigInfo.FlickrApiToken); bool isPublic; bool isFriends; bool isFamily; switch (plan.Privacy) { case PrivacyFilter.CompletelyPrivate: isPublic = false; isFriends = false; isFamily = false; break; case PrivacyFilter.PrivateVisibleToFamily: isPublic = false; isFriends = false; isFamily = true; break; case PrivacyFilter.PrivateVisibleToFriends: isPublic = false; isFriends = true; isFamily = false; break; case PrivacyFilter.PrivateVisibleToFriendsFamily: isPublic = false; isFriends = true; isFamily = true; break; case PrivacyFilter.PublicPhotos: isPublic = true; isFriends = true; isFamily = true; break; default: isPublic = false; isFriends = false; isFamily = false; break; } Console.WriteLine("\nBeginning Upload..."); pctComplete = 0; Console.Write(String.Format("{0:F2} %".PadLeft(8), pctComplete)); for (int i = 0; i < plan.Images.Count; i++) { try { FlickrImage image = plan.Images[i]; string imageID = flickr.UploadPicture(new StreamReader(image.ImagePath).BaseStream, image.ImagePath, image.Title, image.Description, image.Tags, isPublic, isFamily, isFriends, plan.Type, plan.Safety, plan.HideFromSearch); foreach (FlickrSet set in plan.Sets) { if (!allSets.Keys.Contains(set.Title)) { allSets.Add(set.Title, flickr.PhotosetsCreate(set.Title, set.Description, imageID)); } else { flickr.PhotosetsAddPhoto(allSets[set.Title].PhotosetId, imageID); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } pctComplete = (((i + 1) / (float)plan.Images.Count) * 100); Console.SetCursorPosition(0, Console.CursorTop); Console.Write(String.Format("{0:F2} %".PadLeft(8), pctComplete)); } Console.WriteLine("Upload complete."); }