コード例 #1
0
        public async Task CheckDownloadStatusAsync(IReadOnlyList <DownloadOperation> operations)
        {
            ImageItem.Init();
            var task = ImageItem.TryLoadBitmapAsync();

            var folder = await AppSettings.Instance.GetSavingFolderAsync();

            var item = await folder.TryGetItemAsync(ImageItem.GetFileNameForDownloading());

            if (item != null)
            {
                if (item is StorageFile file)
                {
                    _resultFile = file;
                    var prop = await _resultFile.GetBasicPropertiesAsync();

                    if (prop.Size > 0)
                    {
                        Progress = 100;
                    }
                }
            }
            if (Progress != 100)
            {
                var downloadOperation = operations.Where(s => s.Guid == DownloadOperationGUID).FirstOrDefault();
                if (downloadOperation != null)
                {
                    var progress = new Progress <DownloadOperation>();
                    progress.ProgressChanged += Progress_ProgressChanged;
                    _cts = new CancellationTokenSource();
                    await downloadOperation.StartAsync().AsTask(_cts.Token, progress);
                }
                else
                {
                    DisplayIndex = (int)DisplayMenu.Retry;
                }
            }
        }