public MapTileDownloadWorker(MapTileDownloadManager mapTileDownloadManager, MapTileIndex mapTileIndex)
 {
     this.mapTileIndex = mapTileIndex;
     this.mapTileDownloadManager = mapTileDownloadManager;
     localMapTileFileReader = frmMain.localMapTileFileReader;
 }
Esempio n. 2
0
        //addDownloadTaskThread
        private void AddDownloadTask()
        {
            try
            {
                int minX = int.Parse(txtStartX.Text) % 3;
                int minY = int.Parse(txtStartY.Text) % 3;
                int maxX = int.Parse(txtEndX.Text) % 3;
                int maxY = int.Parse(txtEndY.Text) % 3;

                int startX = Math.Min(minX, maxX);
                int startY = Math.Min(minY, maxY);
                int endX = Math.Max(minX, maxX);
                int endY = Math.Max(minY, maxY);

                for (int zoom = mapZoomLevel; zoom < 18; zoom++)
                {
                    if (MapZoomLevelSelected[zoom])
                    {

                        int zoomPower = (int)Math.Pow(2, zoom - mapZoomLevel);

                        for (int indexX = startX * zoomPower; indexX < (endX + 1) * zoomPower; indexX++)
                        {
                            for (int indexY = startY * zoomPower; indexY < (endY + 1) * zoomPower; indexY++)
                            {
                                MapTileIndex mapTileIndex = new MapTileIndex();
                                mapTileIndex.MapType = mapType;
                                mapTileIndex.ZoomLevel = 17 - zoom;
                                mapTileIndex.XIndex = indexX + mapIndexX * zoomPower;
                                mapTileIndex.YIndex = indexY + mapIndexY * zoomPower;
                                mapTileDownloadManager.AddToTaskList(mapTileIndex);
                                Thread.Sleep(1000);
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {

            }
        }