private List <DownloadLevelTile> GetDownloadLevelTiles(DownloadLevelCfg downloadLevelCfg)
        {
            int count = downloadLevelCfg.TileGPoints.Count;
            List <DownloadLevelTile> downloadLevelTiles = new List <DownloadLevelTile>(count);

            for (int i = 0; i < count; ++i)
            {
                DownloadLevelTile downloadLevel = new DownloadLevelTile(downloadLevelCfg.TileGPoints[i], downloadLevelCfg.ZoomLevel);
                downloadLevelTiles.Add(downloadLevel);
            }

            return(downloadLevelTiles);
        }
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker worker = sender as BackgroundWorker;
                int minzoom             = this.mapProvider.MinZoom;
                int maxzoom             = this.mapProvider.MaxZoom.Value;

                for (int z = minzoom; z <= maxzoom; ++z)
                {
                    GPoint topLeft     = mapProvider.Projection.FromPixelToTileXY(mapProvider.Projection.FromLatLngToPixel(rectLatLng.LocationTopLeft, z));
                    GPoint rightBottom = mapProvider.Projection.FromPixelToTileXY(mapProvider.Projection.FromLatLngToPixel(rectLatLng.LocationRightBottom, z));

                    long begin_x          = topLeft.X;
                    long end_x            = rightBottom.X;
                    long begin_y          = topLeft.Y;
                    long end_y            = rightBottom.Y;
                    long levelRow         = (end_x - begin_x + 1);
                    long levelCol         = (end_y - begin_y + 1);
                    long currentZoomTiles = levelRow * levelCol;

                    DownloadLevelCfg downloadLevelCfg = new DownloadLevelCfg();
                    downloadLevelCfg.TopLeft      = topLeft;
                    downloadLevelCfg.RightBottom  = rightBottom;
                    downloadLevelCfg.IsChecked    = false;
                    downloadLevelCfg.ZoomLevel    = z;
                    downloadLevelCfg.ZoomLevelCol = levelCol;
                    downloadLevelCfg.ZoomLevelRow = levelRow;
                    downloadLevelCfg.PreCount     = currentZoomTiles;
                    long sizeMb = currentZoomTiles * 20 / 1024;
                    if (sizeMb > 0)
                    {
                        downloadLevelCfg.PreSize = string.Format("{0}MB", sizeMb);
                    }
                    else
                    {
                        downloadLevelCfg.PreSize = string.Format("{0}KB", currentZoomTiles * 20);
                    }

                    downloadLevelCfgs.Add(downloadLevelCfg);

                    //int progress = (z - minzoom + 1) * 100 / (maxzoom - minzoom + 1);
                    //worker.ReportProgress(progress);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }