Ejemplo n.º 1
0
 public void Upload(Action<Status> callback, UploadFile image, string status, string source = null,
                    string location = null, string mode = null, string format = null)
 {
     if (string.IsNullOrEmpty(status)) throw new ArgumentException("status不能为空");
     UpdateStatusCallBack = callback;
     var parameters = new Parameters();
     parameters.Add("status", status);
     if (!string.IsNullOrEmpty(source)) parameters.Add("source", source);
     if (!string.IsNullOrEmpty(mode)) parameters.Add("mode", mode);
     if (!string.IsNullOrEmpty(format)) parameters.Add("format", format);
     if (!string.IsNullOrEmpty(location)) parameters.Add("location", location);
     var file = new Files();
     file.Add("photo", image);
     PostData("http://api.fanfou.com/photos/upload.json", parameters, file, UpdateStatusEnd);
 }
Ejemplo n.º 2
0
        private void PhotoChooserTask_Completed(object sender, PhotoResult e)
        {
            try
            {
                if (e.ChosenPhoto != null)
                {
                    ((ApplicationBarMenuItem)ApplicationBar.MenuItems[1]).IsEnabled = true; //清空图片
                    imageIcon.Visibility = Visibility.Visible;
                    if (string.IsNullOrWhiteSpace(editContent.Text))
                        editContent.Text = "#分享照片#";

                    uploadFile = new UploadFile(e.OriginalFileName, ImageHelper.Compression(e.ChosenPhoto));

                    //保存缩略图
                    ImageSource imageSource = ImageHelper.SaveThumbnail(Const.TempThumbnailFileName, e.ChosenPhoto);

                    //保存原图
                    ImageHelper.SaveImage(Const.TempImageFileName, e.ChosenPhoto);

                    imageIcon.Source = imageSource;
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 添加文件
 /// </summary>
 /// <param name="name"></param>
 /// <param name="file"></param>
 public void Add(string name, UploadFile file)
 {
     this.Items.Add(new KeyValuePair<string, UploadFile>(name, file));
 }