Creating a .NET Form, handling Events in Smalltalk

f := DotNet newWithEvents: 'LSW.ST_Form'.
f Text: 'Play with me!'.
f Height: 80.

"---------------------"
b := DotNet newWithEvents: 'LSW.ST_Button'.
b Name: 'Button1'.

b Left: 175.
b Top: 20.

s := b Size.
s Height: 25.
s Width: 100.
b Size: s.

b Text: 'Close'.

b when: #Click evaluate: [:p | f Close].

f Controls Add: b.

"---------------------"
t := DotNet newWithEvents: 'LSW.ST_TextBox'.
t Left: 10.
t Top: 20.
t Width: 120.
t when: #TextChanged evaluate: [:p |
t Text = 'red' ifTrue: [t ForeColor: 16r0000FF].
t Text = 'green' ifTrue: [t ForeColor: 16r00FF00].
t Text = 'blue' ifTrue: [t ForeColor: 16rFF0000].
t Text = 'cyan' ifTrue: [t ForeColor: 16rFFFF00].
t Text = 'magenta' ifTrue: [t ForeColor: 16rFF00FF].
t Text = 'yellow' ifTrue: [t ForeColor: 16r00FFFF].
t Text = 'black' ifTrue: [t ForeColor: 16r000000].
].

f Controls Add: t.

"---------------------"

f Show.

"---------------------"