Public Class ChainForm
  Inherits System.Windows.Forms.Form
  Private chn As Chain
  Private Sub init()
    Dim clrchain As New ColorChain(pnlColor)
    Dim flchain As New FileChain(lsFiles)
    Dim nochain As New NoCmd(lsNoCmd)

    chn = New ImageChain(picImage)
    chn.addChain(clrchain)
    clrchain.addChain(flchain)
    flchain.addChain(nochain)
  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 lsFiles As System.Windows.Forms.ListBox
  Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  Friend WithEvents btSend As System.Windows.Forms.Button
  Friend WithEvents txCommand As System.Windows.Forms.TextBox
  Friend WithEvents lsNoCmd As System.Windows.Forms.ListBox
  Friend WithEvents picImage As System.Windows.Forms.PictureBox
  Friend WithEvents pnlColor As System.Windows.Forms.Panel

  '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.lsFiles = New System.Windows.Forms.ListBox()
    Me.GroupBox1 = New System.Windows.Forms.GroupBox()
    Me.btSend = New System.Windows.Forms.Button()
    Me.txCommand = New System.Windows.Forms.TextBox()
    Me.lsNoCmd = New System.Windows.Forms.ListBox()
    Me.picImage = New System.Windows.Forms.PictureBox()
    Me.pnlColor = New System.Windows.Forms.Panel()
    Me.GroupBox1.SuspendLayout()
    Me.SuspendLayout()
    '
    'lsFiles
    '
    Me.lsFiles.Location = New System.Drawing.Point(208, 8)
    Me.lsFiles.Name = "lsFiles"
    Me.lsFiles.Size = New System.Drawing.Size(176, 121)
    Me.lsFiles.TabIndex = 2
    '
    'GroupBox1
    '
    Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btSend, Me.txCommand})
    Me.GroupBox1.Location = New System.Drawing.Point(16, 184)
    Me.GroupBox1.Name = "GroupBox1"
    Me.GroupBox1.Size = New System.Drawing.Size(160, 104)
    Me.GroupBox1.TabIndex = 1
    Me.GroupBox1.TabStop = False
    Me.GroupBox1.Text = "Send commands"
    '
    'btSend
    '
    Me.btSend.Location = New System.Drawing.Point(48, 72)
    Me.btSend.Name = "btSend"
    Me.btSend.Size = New System.Drawing.Size(48, 24)
    Me.btSend.TabIndex = 1
    Me.btSend.Text = "Send"
    '
    'txCommand
    '
    Me.txCommand.Location = New System.Drawing.Point(16, 24)
    Me.txCommand.Name = "txCommand"
    Me.txCommand.Size = New System.Drawing.Size(128, 20)
    Me.txCommand.TabIndex = 0
    Me.txCommand.Text = ""
    '
    'lsNoCmd
    '
    Me.lsNoCmd.Location = New System.Drawing.Point(400, 8)
    Me.lsNoCmd.Name = "lsNoCmd"
    Me.lsNoCmd.Size = New System.Drawing.Size(96, 121)
    Me.lsNoCmd.TabIndex = 3
    '
    'picImage
    '
    Me.picImage.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.picImage.Location = New System.Drawing.Point(16, 8)
    Me.picImage.Name = "picImage"
    Me.picImage.Size = New System.Drawing.Size(160, 128)
    Me.picImage.TabIndex = 0
    Me.picImage.TabStop = False
    '
    'pnlColor
    '
    Me.pnlColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.pnlColor.Location = New System.Drawing.Point(216, 184)
    Me.pnlColor.Name = "pnlColor"
    Me.pnlColor.Size = New System.Drawing.Size(112, 104)
    Me.pnlColor.TabIndex = 4
    '
    'ChainForm
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(512, 309)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lsFiles, Me.GroupBox1, Me.lsNoCmd, Me.picImage, Me.pnlColor})
    Me.Name = "ChainForm"
    Me.Text = "Chain demo"
    Me.GroupBox1.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSend.Click
    chn.sendToChain(txCommand.Text)
    txCommand.Text = ""
  End Sub
End Class
