How To Win Forms
Print Hello World
Write Basic Syntax
Use Properties
Make An If Else Ladder
Make A Branch Statement
Declare Inits
Use Lists
Use Arrays
Make A Class Hierarchy
Use Nil And Nilable Types
Use Dynamic Typing
Declare Variable Number Of Args
Read And Write Files
Check Inheritance And Implementation
Customize Object Equality
Pass References To Methods
Translate Pseudo Code To Cobra 1
Translate Pseudo Code To Cobra 2
Implement IEnumerable 1
Implement IEnumerable 2
Iterate Through Recursive Data With Yield
Make A Collection Class
Declare Contracts
Threads
Win Forms
WPF
GTK
Qyoto
Access MySQL
XNA
Open TK
 
"""
To compile:
cobra -c -t:winexe 380-WinForms.cobra

To run:
winforms

Or leave out the "-c" to compile and run in one shot.

Also, leave out -t:winexe and run from the command line to see the output of
`print` and `trace` statements.

Note that you don't have to explicitly reference the System.Windows.Forms.dll in
the command line because the `use` clause below will automatically locate it.

Recommended reading:

    Programming Microsoft Windows Forms
    by Charles Petzold

    Pro .NET 2.0 Windows Forms
    by Matthew MacDonald

Cobra tips:
    * Combine enums: AnchorStyle(Left, Right)
    * Hook up events: listen someObj.someEvent, ref .myMethod
    * In event handlers, leave out the type of the sender and you can use
      dynamic typing to easily access the senders properties and methods.

There is more substantial WinForms code in the source code for Cobra under
Source/ObjectExplorer-WinForms.cobra.
"""

@args -t:winexe

use System.Windows.Forms


class MyForm inherits Form

    cue init
        base.init
        .text = 'Sample Form'
        flp = FlowLayoutPanel(parent=this, dock=DockStyle.Fill, flowDirection=FlowDirection.TopDown)
        b = Button(parent=flp, autoSize=true, text='One', tag=1)
        listen b.click, ref .handleClick
        b = Button(parent=flp, autoSize=true, text='Two', tag=2)
        listen b.click, ref .handleClick

    def handleClick(sender, args as EventArgs)
        MessageBox.show(this, 'You clicked [sender.text]/[sender.tag]', 'Click')


class Program

    def main has STAThread
        Application.run(MyForm())