Public Class ColrForm
  Inherits System.Windows.Forms.Form
  Implements Observer
  Private colname As String
  Dim fnt As Font
  Dim bBrush As SolidBrush

#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

  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 Pic As System.Windows.Forms.PictureBox

  '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.Pic = New System.Windows.Forms.PictureBox()
    Me.SuspendLayout()
    '
    'Pic
    '
    Me.Pic.BackColor = System.Drawing.SystemColors.ActiveCaptionText
    Me.Pic.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.Pic.Location = New System.Drawing.Point(16, 24)
    Me.Pic.Name = "Pic"
    Me.Pic.Size = New System.Drawing.Size(232, 200)
    Me.Pic.TabIndex = 0
    Me.Pic.TabStop = False
    '
    'ColrForm
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Pic})
    Me.Name = "ColrForm"
    Me.Text = "ColrForm"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Public Sub New(ByVal subj As Subject)
    Me.New()                      'Wywołaj konstruktora klasy bazowej
    subj.registerInterest(Me)
    fnt = New Font("arial", 18, Drawing.FontStyle.Bold)
    bBrush = New SolidBrush(Color.Black)
    AddHandler Pic.Paint, _
        New PaintEventHandler(AddressOf paintHandler)
  End Sub

  Public Sub sendNotify(ByVal mesg As String) Implements vbnetObserver.Observer.sendNotify
    colname = mesg
    Select Case mesg.ToLower
      Case "red"
        Pic.BackColor = Color.Red '
      Case "blue"
        Pic.BackColor = Color.Blue
      Case "green"
        Pic.BackColor = Color.Green
    End Select
  End Sub
  '-----
  Private Sub paintHandler(ByVal sender As Object, ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics
    g.DrawString(colname, fnt, bBrush, 20, 40)
  End Sub
End Class
