di class C#
--// Ini di class c#
-- SomeClass obj = new SomeClass ("Param");
-- state ["obj"] = obj; // Create a global value 'obj' of .NET type SomeClass
Di NLUA nya
--// Disini starting NLUA scriptnya
local res1 = obj:Text()
obj:MessageBoxing(res1)
local res3 = obj:DownloadStringText('http://nlua.org')
-- obj:MessageBoxing(res3)
Paint the form via LUA ( di gambar dulu biar popout lebih native c# daripada sekedar MessageBox.
NLUA
-- //////////////////////////=====================
-- kevinh - the following lines are part of our standard init
-- require("compat-5.1")
import("System.Windows.Forms")
import("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
import("System.Drawing")
local EnumToObject, WinFormsAnchorStylesType =
luanet.get_method_bysig(luanet.System.Enum, "ToObject",
"System.Type", "System.Int32"),
luanet.System.Windows.Forms.AnchorStyles.Top:GetType()
AnchorTop, AnchorLeft, AnchorRight, AnchorBottom = 1, 4, 8, 2
function Anchor(flags)
return EnumToObject(WinFormsAnchorStylesType, flags)
end
form1=Form()
button1=Button()
richtext1=RichTextBox()
button2=Button()
function handleClick(sender,data)
if sender.Text=="OK" then
sender.Text="Clicked"
else
sender.Text="OK"
end
button1.MouseUp:Remove(handler)
MessageBox.Show (sender:ToString())
end
button1.Text = "OK"
button1.Location=Point(10,10)
button2.Text = "Cancel"
button2.Location=Point(button1.Left, button1.Height + button1.Top + 10)
richtext1.Location = Point(button2.Left,button2.Height + button2.Top + 10)
richtext1.Size = Size(form1.Width-30, form1.Height - 120)
richtext1.Text = res3
richtext1.Anchor = Anchor(AnchorLeft + AnchorTop + AnchorRight + AnchorBottom)
handler=button1.MouseUp:Add(handleClick)
form1.Text = "My Dialog Box"
form1.HelpButton = true
form1.MaximizeBox=false
form1.MinimizeBox=false
form1.AcceptButton = button1
form1.CancelButton = button2
form1.Controls:Add(button1)
form1.Controls:Add(button2)
form1.Controls:Add(richtext1)
form1:ShowDialog()
FULL Scriptnya
--// Ini di class c# -- SomeClass obj = new SomeClass ("Param"); -- state ["obj"] = obj; // Create a global value 'obj' of .NET type SomeClass --// Disini starting NLUA scriptnya local res1 = obj:Text() obj:MessageBoxing(res1) local res3 = obj:DownloadStringText('http://nlua.org') -- obj:MessageBoxing(res3) -- //////////////////////////===================== -- kevinh - the following lines are part of our standard init -- require("compat-5.1") import("System.Windows.Forms") import("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") import("System.Drawing") local EnumToObject, WinFormsAnchorStylesType = luanet.get_method_bysig(luanet.System.Enum, "ToObject", "System.Type", "System.Int32"), luanet.System.Windows.Forms.AnchorStyles.Top:GetType() AnchorTop, AnchorLeft, AnchorRight, AnchorBottom = 1, 4, 8, 2 function Anchor(flags) return EnumToObject(WinFormsAnchorStylesType, flags) end form1=Form() button1=Button() richtext1=RichTextBox() button2=Button() function handleClick(sender,data) if sender.Text=="OK" then sender.Text="Clicked" else sender.Text="OK" end button1.MouseUp:Remove(handler) MessageBox.Show (sender:ToString()) end button1.Text = "OK" button1.Location=Point(10,10) button2.Text = "Cancel" button2.Location=Point(button1.Left, button1.Height + button1.Top + 10) richtext1.Location = Point(button2.Left,button2.Height + button2.Top + 10) richtext1.Size = Size(form1.Width-30, form1.Height - 120) richtext1.Text = res3 richtext1.Anchor = Anchor(AnchorLeft + AnchorTop + AnchorRight + AnchorBottom) handler=button1.MouseUp:Add(handleClick) form1.Text = "My Dialog Box" form1.HelpButton = true form1.MaximizeBox=false form1.MinimizeBox=false form1.AcceptButton = button1 form1.CancelButton = button2 form1.Controls:Add(button1) form1.Controls:Add(button2) form1.Controls:Add(richtext1) form1:ShowDialog()