Public Class Form1
  Inherits System.Windows.Forms.Form
  Private contxt As Context

  Private Sub init()
    Dim evh As EventHandler = New EventHandler(AddressOf ButClick)
    AddHandler btLine.Click, evh
    AddHandler btBar.Click, evh
    contxt = New Context()
    btBar.setContext(contxt)
    btLine.setContext(contxt)
  End Sub

  Public Sub ButClick(ByVal Sender As Object, ByVal e As EventArgs)
    Dim cmd As Command
    cmd = CType(Sender, Command)
    cmd.Execute()
  End Sub

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()
  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents btBar As vbnetStrategy.BarBtn
  Friend WithEvents btLine As vbnetStrategy.LineBtn

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.btBar = New vbnetStrategy.BarBtn()
    Me.btLine = New vbnetStrategy.LineBtn()
    Me.SuspendLayout()
    '
    'btBar
    '
    Me.btBar.Location = New System.Drawing.Point(48, 32)
    Me.btBar.Name = "btBar"
    Me.btBar.TabIndex = 0
    Me.btBar.Text = "Bar plot"
    '
    'btLine
    '
    Me.btLine.Location = New System.Drawing.Point(160, 32)
    Me.btLine.Name = "btLine"
    Me.btLine.TabIndex = 1
    Me.btLine.Text = "Line plot"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(272, 157)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btLine, Me.btBar})
    Me.Name = "Form1"
    Me.Text = "Strategy demo"
    Me.ResumeLayout(False)

  End Sub

#End Region

End Class
