-
Notifications
You must be signed in to change notification settings - Fork 6
/
FormMain.cs
105 lines (88 loc) · 2.98 KB
/
FormMain.cs
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
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
using MbJsonToYaml.Utils;
namespace MbJsonToYaml
{
public partial class FormMain : Form
{
private readonly Converter _converter = Converter.GetInstance();
private string _style;
public FormMain()
{
InitializeComponent();
}
private string BrightFile = "bright-v9";
private string BasicFile = "basic-v9";
private string LibertyFile = "osm-liberty";
private void Form1_Load(object sender, EventArgs e)
{
comboBoxInput.SelectedIndex = 2;
}
private void ReadFile(string style)
{
_style = style;
var lines = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"\Styles\" + _style + "\\" + _style + ".json");
textBoxIn.Lines = lines;
Process();
}
private void Process()
{
string debugLines = null;
string inText = textBoxIn.Text;
textBoxOut.Text = _converter.Convert(_style, inText, out debugLines);
textBoxDebug.Text = debugLines;
}
static string ConvertStringArrayToString(string[] array)
{
StringBuilder builder = new StringBuilder();
foreach (string value in array)
{
builder.AppendLine(value);
}
return builder.ToString();
}
private void buttonCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBoxOut.Text);
}
private void buttonConvert_Click(object sender, EventArgs e)
{
Process();
}
private void checkBoxForceUrl_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxForceUrl.Checked)
_converter.ForcedUrl = "http://localhost:8765/{x}/{y}/{z}.mvt";
else
_converter.ForcedUrl = null;
Process();
}
private void checkBoxExcludeCommonParts_CheckedChanged(object sender, EventArgs e)
{
// I have some of these things defined in a common import yaml
_converter.ExcludeCommon = checkBoxExcludeCommonParts.Checked;
Process();
}
private void checkBoxIncludeSprites_CheckedChanged(object sender, EventArgs e)
{
_converter.IncludeSprites = checkBoxIncludeSprites.Checked;
}
private void comboBoxInput_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxInput.SelectedIndex)
{
case 0:
ReadFile(BasicFile);
break;
case 1:
ReadFile(BrightFile);
break;
case 2:
ReadFile(LibertyFile);
break;
}
}
}
}