Accepts a score passed to it in the RenderRating function. It
will take that score and use its own technique to render that score into a
graphical image equivalent to the score. When the end-user clicks on each
group box (which contains a picture box) it creates a graphical image.
Listing 2
' Equivalent to Implementation in the Bridge pattern
Public MustInherit Class RatingRenderer
Protected RatingPictureBox As PictureBox
Protected RenderableImagesList As ImageList
Protected RenderingGraphics As Graphics
Public Sub New(ByVal RatingPicture As PictureBox, ByVal
ImageListToUse As ImageList)
RatingPictureBox = RatingPicture
RenderableImagesList = ImageListToUse
End Sub
Public Function ClearGraphicSurface()
RenderingGraphics = RatingPictureBox.CreateGraphics
RenderingGraphics.Clear(Color.FromKwnClr(KnownClr.Control))
End Function
' Equivalent to Implement in the Bridge pattern
Public MustOverride Function RenderRating(ByVal ScoreToRender
As Integer)
End Class
' Equivalent to Concrete Implementation in the Bridge pattern
Public Class FaceRenderer
Inherits RatingRenderer
Public Sub New(ByVal RatingPicture As PictureBox, ByVal
ImageListToUse As ImageList)
MyBase.New(RatingPicture, ImageListToUse)
End Sub
Public Overrides Function RenderRating(ByVal ScoreToRender As
Integer)
' Equivalent to Implement in the Bridge pattern
ClearGraphicSurface()
Dim GraphicWidth As Integer = 25
Dim GraphicHeight As Integer = 25
If ScoreToRender <> 0 Then
RenderableImagesList.Draw(RenderingGraphics, 50, 0,
GraphicWidth, GraphicHeight, ScoreToRender - 1)
End If
End Function
End Class