Imports PaxScript.Net Public Class Form1 Inherits System.Windows.Forms.Form Friend WithEvents Button1 As System.Windows.Forms.Button Friend scripter As PaxScripter = New PaxScripter #Region " Windows Form Designer generated code " '................................................................ #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click scripter.Reset() scripter.RegisterType(GetType(Form)) scripter.RegisterType(GetType(Button)) scripter.RegisterType(GetType(MessageBox)) scripter.AddModule("1", "VB") scripter.AddCodeLine("1", "Imports System.Windows.Forms") scripter.AddCodeLine("1", "Public Class TestClass") scripter.AddCodeLine("1", "Public Shared Sub OnClickHandler(ByRef Sender As Object, ByRef e As EventArgs)") scripter.AddCodeLine("1", "MessageBox.Show(sender.ToString())") scripter.AddCodeLine("1", "MessageBox.Show(e.ToString())") scripter.AddCodeLine("1", "End Sub") scripter.AddCodeLine("1", "End Class") scripter.AddCodeLine("1", "Dim f As Form = New Form()") scripter.AddCodeLine("1", "f.Text = ""Script-defined application""") scripter.AddCodeLine("1", "Dim b As Button = new Button()") scripter.AddCodeLine("1", "b.Text = ""Click me""") scripter.AddCodeLine("1", "AddHandler b.Click, AddressOf TestClass.OnClickHandler") scripter.AddCodeLine("1", "f.Controls.Add(b)") scripter.AddCodeLine("1", "f.ShowDialog()") scripter.Run(RunMode.Run) If (scripter.HasErrors) Then MessageBox.Show(scripter.Error_List(0).Message) End If End Sub End Class
where Helper is a host-defined method which calls script-defined delegate. For example:scripter.RegisterEventHandler(typeof(MyEventHandler), "MyEvent", new MyEventHandler(Helper));
The following events of System.Windows.Forms.Control class are already registered:void Helper(object sender, MyEventArgs x) { scripter.ApplyDelegate("MyEvent", sender, x); // the first 2 arguments will determine the script-defined delegate }
so, the demo application presented at this page will work correctly under .NET CF without any changes.Click CursorChanged DockChanged DoubleClick EnabledChanged Enter Leave MouseEnter MouseLeave Resize TextChanged