forked from zhangqi-ulua/XlsxToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
68 lines (62 loc) · 2.54 KB
/
MainForm.cs
File metadata and controls
68 lines (62 loc) · 2.54 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace TableStringChecker
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
tbFormat.Text = "tableString[在这里填写格式定义]";
// 导入lang文件内容
if (File.Exists("lang.txt"))
{
string errorString = null;
AppValues.LangData = TxtConfigReader.ParseTxtConfigFile("lang.txt", ":", out errorString);
if (!string.IsNullOrEmpty(errorString))
{
errorString = "lang.txt文件中存在错误,请修正后重新运行,程序被迫退出" + System.Environment.NewLine + errorString;
MessageBox.Show(errorString, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
}
else
MessageBox.Show("未找到本程序所在目录下的lang.txt文件,将无法使用lang数据类型", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
private void btnAnalyze_Click(object sender, EventArgs e)
{
string inputFormatString = tbFormat.Text.Trim();
string inputDataString = tbData.Text;
if (string.IsNullOrEmpty(inputFormatString))
{
MessageBox.Show("未输入格式定义", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(inputDataString))
{
MessageBox.Show("未输入数据", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// 解析格式定义
string errorString = null;
TableStringFormatDefine formatDefine = TableAnalyzeHelper.GetTableStringFormatDefine(inputFormatString, out errorString);
if (errorString != null)
{
tbOutput.Text = "格式声明错误," + errorString;
return;
}
// 生成lua table
string exportString = TableExportToLuaHelper.GetTableStringValue(formatDefine, inputDataString, 0, out errorString);
if (errorString != null)
tbOutput.Text = "输入数据错误," + errorString;
else
tbOutput.Text = exportString;
}
}
}