Skip to content

Commit

Permalink
增加脚本文件打开功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazi199 committed Jun 11, 2015
1 parent 95e90dc commit 25674e7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
40 changes: 27 additions & 13 deletions KanScript/forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion KanScript/forms/MainForm.cs
Expand Up @@ -4,6 +4,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
Expand All @@ -24,6 +25,7 @@ public MainForm()
private void MainForm_Load(object sender, EventArgs e)
{
formHandlerTextBox.Text = Handle.ToString();
scriptInitButton_Click(sender, e);
}

private void kcvHandlerFindButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -60,7 +62,7 @@ public IntPtr getKcvHandler()
return gameHandler;
}

private void button1_Click(object sender, EventArgs e)
private void scriptRunButton_Click(object sender, EventArgs e)
{
new Thread(runScript).Start();
}
Expand All @@ -77,5 +79,23 @@ private void runScript()
scriptRunner.runScript(luaScriptTextBox.Text);
}
}

private void scriptOpenButtion_Click(object sender, EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
fd.Title = "打开脚本文件";
fd.Filter = "脚本文件(*.lua)|*.lua|所有文件(*.*)|*.*";
if (fd.ShowDialog() == DialogResult.OK)
{
StringBuilder sb = new StringBuilder();
FileInfo file = new FileInfo(fd.FileName);
StreamReader sr = file.OpenText();
while (sr.Peek() > 0)
{
sb.AppendLine(sr.ReadLine());
}
luaScriptTextBox.Text = sb.ToString();
}
}
}
}

0 comments on commit 25674e7

Please sign in to comment.