Exemple #1
0
        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;
            }
        }