Exemplo n.º 1
0
        public async Task LoadPicturesAsync()
        {
            // TODO: yield iterator
            var pictures = await PicturesRepository.GetPictures();

            Pictures.Clear();

            foreach (var picture in pictures)
            {
                Pictures.Add(picture);
            }
        }
Exemplo n.º 2
0
        private void PictureDownload_Completed(object sender,
                                               AsyncCompletedEventArgs e)
        {
            while (!DownloadCompleted)
            {
                ;
            }

            if (e.Cancelled)
            {
                lock (WebTools.LockDownload)
                {
                    MyProgressBar.Value += (Picture.Size - Picture.ReceiveBytes);
                }
                File.Delete(Picture.Adress);
            }
            else
            {
                Picture.IsDownloaded = true;
                Picture.Adress       = Picture.Adress;
            }

            if (_picturesRepository.GetPictures().Where(x => x.BegunDownload).All(x => x.IsDownloaded))
            {
                lock (WebTools.LockDownload)
                {
                    _progress.Report(0);
                    MyProgressBar.Maximum = 0;
                    MyProgressBar.Value   = 0;
                }
            }

            Picture.ReadyDownload = true;
            Picture.BegunDownload = false;
            WebTools.Tokens[Picture.Id - 1].Dispose();
            Picture.ReceiveBytes = 0;
            Picture.Size         = 0;
        }