コード例 #1
0
        /// <summary>
        /// Initialize all UI components
        /// </summary>
        private void InitializeUIComponentValues()
        {
            cmdBuildPlan.Enabled = false;

            imgList            = new ImageList();
            imgList.ImageSize  = new System.Drawing.Size(128, 128);
            imgList.ColorDepth = ColorDepth.Depth24Bit;

            cboIdentities.Items.Insert(0, "New Identity...");
            cboIdentities.Items.AddRange(IdentityManager.GetIdentities(TokenManager.GetTokenFiles(ConfigInfo.ApplicationDataFolder)));

            cboContentType.Items.AddRange(Enum.GetNames(typeof(FlickrNet.ContentType)));
            cboPrivacy.Items.AddRange(Enum.GetNames(typeof(FlickrNet.PrivacyFilter)));
            cboHidePublic.Items.AddRange(Enum.GetNames(typeof(FlickrNet.HiddenFromSearch)));
            cboSafety.Items.AddRange(Enum.GetNames(typeof(FlickrNet.SafetyLevel)));
        }
コード例 #2
0
        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.");
        }