예제 #1
0
        private async void btnTest_Click(object sender, RoutedEventArgs e)
        {
            btnTest.IsEnabled = false;

            var tiles = TileModel.GetTiles(ViewModel.ZoomLevel);

            await tiles[0].DownloadTileAsync();

            img.Source = tiles[0].Image;

            btnTest.IsEnabled = true;
        }
예제 #2
0
        public async Task DownloadTiles()
        {
            await Task.Run(() =>
            {
                var tiles = TileModel.GetTiles(this.ZoomLevel);
                var count = tiles.Count;
                int index = 1;


                Parallel.ForEach(tiles, (item, loopState) =>
                {
                    if (IsCancelDownload)
                    {
                        loopState.Stop();
                    }

                    item.DownloadTile();

                    if (SaveAsPbf)
                    {
                        item.SaveTileAsfdb();
                    }
                    else
                    {
                        item.SaveTile();
                    }

                    ProgressStatus = (index * 100) / count;

                    NotifyPropertyChanged(nameof(ProgressStatus));

                    index++;
                });

                ProgressStatus = 0;
                NotifyPropertyChanged(nameof(ProgressStatus));

                this.IsCancelDownload = false;
            });
        }