예제 #1
0
        public bool UpdateUIForComplete(LocalImage image, ImgurImage image2)
        {
            if (!Uploads.Remove(image))
            {
                return(false);
            }

            CompleteUploads.Add(image2);

            return(true);
        }
예제 #2
0
        private async void btn_Upload_Click(object sender, RoutedEventArgs e)
        {
            btn_SelectImages.IsEnabled = false;
            btn_Upload.IsEnabled       = false;

            Request.AnonState = (bool)cb_Anon.IsChecked;

            if (!AppGlobal.IsAuth)
            {
                Request.AnonState = true;
            }

            var uploads = MyViewModel.Uploads.ToList();
            int count   = 0;

            foreach (LocalImage image in uploads)
            {
                lbl_Status.Content = string.Format("Uploading image {0}/{1}", ++count, uploads.Count);
                ImgurWrapper result = await Imgur.UploadImage(image.LocalPath);

                if (result.success)
                {
                    ImgurImage uploaded = JsonConvert.DeserializeObject <ImgurImage>(result.data.ToString());
                    uploaded.LocalPath = image.LocalPath;
                    uploaded.Init();

                    MyViewModel.UpdateUIForComplete(image, uploaded);

                    GoToSite(uploaded.Link);
                }

                pb_Progress.Value = ((double)count / uploads.Count) * 100;
            }

            btn_SelectImages.IsEnabled = true;
        }