Exemplo n.º 1
0
        private void GenerateTileMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_tileMapGeneratorForm == null || _tileMapGeneratorForm.IsDisposed)
            {
                _tileMapGeneratorForm = new TileMapGeneratorForm(_appSettings.LastTileMapPath, _renderFlags);
            }
            _tileMapGeneratorForm.Show();
            _tileMapGeneratorForm.BringToFront();

            _tileMapGeneratorForm.GenerateTileMap += (exportPath, startZoomLevel, endZoomLevel, createTiles, exportFlags, renderFlags) => // Called when export button is pressed in TileMapGeneratorForm
            {
                _tileMapGeneratorForm.Close();
                _appSettings.LastTileMapPath = exportPath;
                JsonHelper.SaveSettings(_appSettings);
                _mapper.ExportInfo(exportFlags, exportPath);

                if (startZoomLevel < 0 || endZoomLevel < 0)
                {
                    return;
                }
                if (startZoomLevel > endZoomLevel)
                {
                    var tmp = startZoomLevel;
                    startZoomLevel = endZoomLevel;
                    endZoomLevel   = tmp;
                }

                GenerateTileMap(startZoomLevel, endZoomLevel, exportPath, createTiles, (exportFlags & ExportFlags.TileMapInfo) == ExportFlags.TileMapInfo, renderFlags);
                MessageBox.Show("Tile map has been generated!", "TsMap - Tile Map Generation Finished", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Focus();
            };
        }
Exemplo n.º 2
0
        private void GenerateTileMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_tileMapGeneratorForm == null || _tileMapGeneratorForm.IsDisposed)
            {
                _tileMapGeneratorForm = new TileMapGeneratorForm();
            }
            _tileMapGeneratorForm.Show();
            _tileMapGeneratorForm.BringToFront();

            _tileMapGeneratorForm.GenerateTileMap += (zoomLevel) => // Called when export button is pressed in TileMapGeneratorForm
            {
                if (zoomLevel < 0)
                {
                    return;
                }
                folderBrowserDialog1.Description = "Select where you want the tile map files to be placed";
                if (_appSettings.LastTileMapPath != null)
                {
                    folderBrowserDialog1.SelectedPath = _appSettings.LastTileMapPath;
                }
                _tileMapGeneratorForm.Hide();
                var res = folderBrowserDialog1.ShowDialog();
                if (res == DialogResult.OK)
                {
                    if (!Directory.Exists(folderBrowserDialog1.SelectedPath))
                    {
                        return;
                    }
                    GenerateTileMap(zoomLevel, folderBrowserDialog1.SelectedPath);
                    MessageBox.Show("Tile map has been generated!", "TsMap - Tile Map Generation Finished", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                Focus();
            };
        }
Exemplo n.º 3
0
        private void GenerateTileMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_tileMapGeneratorForm == null || _tileMapGeneratorForm.IsDisposed)
            {
                _tileMapGeneratorForm = new TileMapGeneratorForm();
            }
            _tileMapGeneratorForm.Show();
            _tileMapGeneratorForm.BringToFront();

            _tileMapGeneratorForm.GenerateTileMap += () => // Called when export button is pressed in TileMapGeneratorForm
            {
                _tileMapGeneratorForm.Close();

                MapPanel.Enabled = false;

                //Task.Run(() =>
                //{
                UpdateProgress("Loading map...", true);

                _tilesGeneratorMapper = this.CreateMapper();

                _tilesGeneratorMapper.Parse();

                UpdateProgress("Loading renderer...", true);

                _tilesGeneratorRenderer = this.CreateRenderer(_tilesGeneratorMapper);

                UpdateProgress("Generating tiles...", true);

                _tilesGeneratorMapper.ExportInfo(SettingsManager.Current.Settings.TileGenerator.ExportFlags, SettingsManager.Current.Settings.TileGenerator.LastTileMapPath);

                GenerateTileMap(SettingsManager.Current.Settings.TileGenerator.StartZoomLevel,
                                SettingsManager.Current.Settings.TileGenerator.EndZoomLevel, SettingsManager.Current.Settings.TileGenerator.LastTileMapPath,
                                SettingsManager.Current.Settings.TileGenerator.GenerateTiles,
                                (SettingsManager.Current.Settings.TileGenerator.ExportFlags & ExportFlags.TileMapInfo) == ExportFlags.TileMapInfo, SettingsManager.Current.Settings.TileGenerator.RenderFlags);

                MessageBox.Show("Tile map has been generated!", "TsMap - Tile Map Generation Finished", MessageBoxButtons.OK, MessageBoxIcon.Information);

                UpdateProgress("Ready.", false);

                Invoke(new Action(() =>
                {
                    Focus();
                    MapPanel.Enabled = true;
                }));
                //});
            };
        }