Exemplo n.º 1
0
        private void btnDo_Click(object sender, EventArgs e)
        {
            if (sender == btnDo)
            {
                var tileRange = txtZoomLevels.Text.Trim();
                if (string.IsNullOrEmpty(tileRange))
                {
                    return;
                }

                var parts = tileRange.Split(';');
                using (var cts = new Samples.CreateTilesSample(Map, chkMercator.Checked, lblFolder.Text))
                {
                    cts.Opacity = (float)tbOpacity.Value / 100f;

                    foreach (var part in parts)
                    {
                        var subParts = part.Split('-');
                        if (subParts.Length == 2)
                        {
                            int fromLevel;
                            if (!int.TryParse(subParts[0], out fromLevel))
                            {
                                return;
                            }
                            int toLevel;
                            if (!int.TryParse(subParts[1], out toLevel))
                            {
                                return;
                            }
                            for (var i = fromLevel; i <= toLevel; i++)
                            {
                                cts.SaveImagesAtLevel(i);
                            }
                        }
                        else
                        {
                            int level;
                            if (int.TryParse(part, out level))
                            {
                                cts.SaveImagesAtLevel(level);
                            }
                        }
                    }
                }

                if (chkSampleWebPage.Checked)
                {
                    var htmlPath = System.IO.Path.Combine(lblFolder.Text, "SharpMapTileDemo.html");
                    Samples.CreateTilesSample.CreateHtmlSamplePage(htmlPath, txtGoogleMapsApiKey.Text);
                    Process.Start(new Uri(htmlPath).AbsolutePath);
                }
            }
            Close();
        }
Exemplo n.º 2
0
        private void btnDo_Click(object sender, EventArgs e)
        {
            if (sender == btnDo)
            {
                var tileRange = txtZoomLevels.Text.Trim();
                if (string.IsNullOrEmpty(tileRange))
                    return;

                var parts = tileRange.Split(';');
                using (var cts = new Samples.CreateTilesSample(Map, chkMercator.Checked, lblFolder.Text))
                {
                    cts.Opacity = (float)tbOpacity.Value / 100f;

                    foreach (var part in parts)
                    {
                        var subParts = part.Split('-');
                        if (subParts.Length == 2)
                        {
                            int fromLevel;
                            if (!int.TryParse(subParts[0], out fromLevel))
                                return;
                            int toLevel;
                            if (!int.TryParse(subParts[1], out toLevel))
                                return;
                            for (var i = fromLevel; i <= toLevel; i++)
                                cts.SaveImagesAtLevel(i);
                        }
                        else
                        {
                            int level;
                            if (int.TryParse(part, out level))
                                cts.SaveImagesAtLevel(level);

                        }
                    }
                }

                if (chkSampleWebPage.Checked)
                {
                    var htmlPath = System.IO.Path.Combine(lblFolder.Text, "SharpMapTileDemo.html");
                    Samples.CreateTilesSample.CreateHtmlSamplePage(htmlPath, txtGoogleMapsApiKey.Text);
                    Process.Start(new Uri(htmlPath).AbsolutePath);
                }
            }
            Close();
        }