概要
cscの作法、調べてみた。
Neo.IronLua、見つけたので、やってみた。
luaでformを生成する。
サンプルコード
using System;
using System.Windows.Forms;
using Neo.IronLua;
class Program {
[STAThread]
static void Main() {
using (Lua lua = new Lua())
{
LuaGlobal global = lua.CreateEnvironment();
Form mainForm = new Form {
Text = "NeoLua GUI App",
Width = 400,
Height = 250,
StartPosition = FormStartPosition.CenterScreen
};
global["AddButton"] = new Action<string, string>((buttonText, messageToShow) => {
Button btn = new Button {
Text = buttonText,
Dock = DockStyle.Fill
};
btn.Click += (sender, e) => {
MessageBox.Show(messageToShow, "通知");
};
mainForm.Controls.Add(btn);
});
global["ShowForm"] = new Action(() => {
mainForm.ShowDialog();
});
try
{
global.DoChunk("wnd.lua");
}
catch (Exception ex)
{
Console.WriteLine("エラーが発生しました: " + ex.Message);
}
}
}
}
luaコード
print("シンプルなGUI画面を表示します...")
AddButton("ここをクリックして挨拶", "こんにちは!NeoLuaからForms画面が動いています!")
ShowForm()
写真
以上。
