Example #1
0
 private void ChangeImage(CaptionedImage ci)
 {
     if (ci != null)
     {
         picCurrentImage.Image = Image.FromFile(ci.Path);
     }
 }
Example #2
0
 /// <summary>
 /// Posts a photo with the provided path and caption
 /// </summary>
 /// <param name="path"></param>
 /// <param name="caption"></param>
 public void PostPhoto(CaptionedImage captionedImage, string albumID)
 {
     if (!string.IsNullOrEmpty(AccessToken))
     {
         _client = new FacebookClient(AccessToken);
         try
         {
             string  apiPath = string.Format("/{0}/photos", albumID);
             dynamic request = _client.Post(apiPath, new
             {
                 message = captionedImage.Caption,
                 file    = new FacebookMediaObject
                 {
                     ContentType = "image/jpeg",
                     FileName    = Path.GetFileName(captionedImage.Path)
                 }.SetValue(File.ReadAllBytes(captionedImage.Path))
             });
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
             Application.Exit();
         }
     }
 }
Example #3
0
        private void lstCaptionedImages_SelectedIndexChanged(object sender, EventArgs e)
        {
            CaptionedImage ci = lstCaptionedImages.SelectedItem as CaptionedImage;

            if (ci != null)
            {
                ChangeImage(ci);
                txtCaption.Text = ci.Caption;
            }
        }
Example #4
0
 private void btnSaveCaption_Click(object sender, EventArgs e)
 {
     if (lstCaptionedImages.Items.Count > 0)
     {
         if (lstCaptionedImages.SelectedIndex > -1)
         {
             int            index          = lstCaptionedImages.SelectedIndex;
             CaptionedImage captionedImage = lstCaptionedImages.SelectedItem as CaptionedImage;
             captionedImage.Caption = txtCaption.Text;
             lstCaptionedImages.Items.RemoveAt(index);
             lstCaptionedImages.Items.Insert(index, captionedImage);
             lstCaptionedImages.SelectedIndex = index;
         }
     }
 }
Example #5
0
        private void LoadImagesFromDirectory(string path)
        {
            lstCaptionedImages.Items.Clear();
            string[] files    = Directory.GetFiles(path);
            Captions _caption = new Captions();

            foreach (var file in files)
            {
                string extension = Path.GetExtension(file);
                if (extension.Equals(".jpg") || extension.Equals(".jpeg"))
                {
                    string         caption = _caption.GetNextCaption();
                    CaptionedImage ci      = new CaptionedImage(file, caption);
                    lstCaptionedImages.Items.Add(ci);
                }
            }
        }