Ejemplo n.º 1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            var openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter           = "map files (*.map)|*.map|All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _mapTileDownloadManager.Stop();
                    GC.Collect();
                    string fileName = openFileDialog1.FileName;
                    var    localMapTileFileReader = new MapTileStoredDataSource(fileName);

                    _mapTileDownloadManager = new MapTileDownloadManager(this, localMapTileFileReader);
                    _mapTileDownloadManager.Start();
                    GeoLatLng center = _rasterMap.GetScreenCenter();
                    int       zoom   = _rasterMap.GetZoom();

                    _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
                    _rasterMap.SetCenter(center, zoom);
                    _rasterMap.SetMapDrawingListener(this);
                    _rasterMap.SetGeocodingListener(this);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private void ProcessTileIndex()
        {
            while (!stopThread)
            {
                int newX = 0;
                int newY = 0;
                int newZ = 0;
                lock (_tileIndexList)
                {
                    if (_tileIndexList.Count > 0)
                    {
                        MapTileIndex mapTileIndex = _tileIndexList[_tileIndexList.Count - 1];
                        newX = mapTileIndex.XIndex;
                        newY = mapTileIndex.YIndex;
                        newZ = mapTileIndex.ZoomLevel;
                        _tileIndexList.Clear();
                    }
                    else
                    {
                        Thread.Sleep(5000);
                    }
                }
                if (newZ != 0)
                {
                    int       oldZoom = _rasterMap.GetZoom();
                    GeoLatLng latLng  = MapLayer.FromPixelToLatLng(new GeoPoint(newX * 256 + 128, newY * 256 + 128), newZ);
                    if (newZ != oldZoom)
                    {
                        _rasterMap.SetCenter(latLng, newZ);
                    }
                    else
                    {
                        GeoLatLng center = _rasterMap.GetCenter();
                        GeoPoint  pt1    = _rasterMap.FromLatLngToScreenPixel(center);

                        GeoPoint pt2 = _rasterMap.FromLatLngToScreenPixel(latLng);

                        _rasterMap.PanDirection((int)(pt1.X - pt2.X), (int)(pt1.Y - pt2.Y));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void btnServer_Click(object sender, EventArgs e)
        {
            _mapTileDownloadManager.Stop();
            _mapTileDownloadManager = new MapTileDownloadManager(this);
            _mapTileDownloadManager.Start();
            GeoLatLng center = _rasterMap.GetScreenCenter();
            int       zoom   = _rasterMap.GetZoom();

            _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
            _rasterMap.SetCenter(center, zoom);
            _rasterMap.SetMapDrawingListener(this);
            _rasterMap.SetGeocodingListener(this);
        }
Ejemplo n.º 4
0
        private void btnServer_Click(object sender, EventArgs e)
        {
            _mapTileDownloadManager.Stop();
            _mapTileDownloadManager = new MapTileDownloadManager(this);
            _mapTileDownloadManager.Start();
            GeoLatLng center = _rasterMap.GetScreenCenter();
            int zoom = _rasterMap.GetZoom();

            _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
            _rasterMap.SetCenter(center, zoom);
            _rasterMap.SetMapDrawingListener(this);
            _rasterMap.SetGeocodingListener(this);
        }
Ejemplo n.º 5
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            var openFileDialog1 = new OpenFileDialog
                                                 {
                                                     InitialDirectory = "c:\\",
                                                     Filter = "map files (*.map)|*.map|All files (*.*)|*.*",
                                                     FilterIndex = 2,
                                                     RestoreDirectory = true
                                                 };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _mapTileDownloadManager.Stop();
                    GC.Collect();
                    string fileName = openFileDialog1.FileName;
                    var localMapTileFileReader = new MapTileStoredDataSource(fileName);

                    _mapTileDownloadManager = new MapTileDownloadManager(this, localMapTileFileReader);
                    _mapTileDownloadManager.Start();
                    GeoLatLng center = _rasterMap.GetScreenCenter();
                    int zoom = _rasterMap.GetZoom();

                    _rasterMap = new RasterMap(768, 768, _mapType, _mapTileDownloadManager);
                    _rasterMap.SetCenter(center, zoom);
                    _rasterMap.SetMapDrawingListener(this);
                    _rasterMap.SetGeocodingListener(this);

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }