forked from SharpMap/SharpMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormCreateTilesSample.cs
More file actions
93 lines (82 loc) · 3.15 KB
/
FormCreateTilesSample.cs
File metadata and controls
93 lines (82 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinFormSamples
{
public partial class FormCreateTilesSample : Form
{
public FormCreateTilesSample()
{
InitializeComponent();
}
public SharpMap.Map Map { get; set; }
protected override void OnLoad(EventArgs e)
{
lblFolder.Text = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "tiles");
var asr = new AppSettingsReader();
txtGoogleMapsApiKey.Text = (string) asr.GetValue("GoogleMapsApiKey", typeof(string));
base.OnLoad(e);
}
private void btnFolder_Click(object sender, EventArgs e)
{
fbdFolder.SelectedPath = lblFolder.Text;
if (fbdFolder.ShowDialog() == DialogResult.OK)
{
lblFolder.Text = fbdFolder.SelectedPath;
}
}
private void chkSampleWebPage_CheckedChanged(object sender, EventArgs e)
{
txtGoogleMapsApiKey.Enabled = chkSampleWebPage.Checked;
}
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();
}
}
}