Imports Microsoft.VisualStudio.DebuggerVisualizers
Imports System.Runtime.Serialization.Formatters.Binary

Public Class PicViewer

    Private _objectProvider As IVisualizerObjectProvider
    Private _info As PictureViewerInfo

    Public Sub SetObjectProvider(ByVal objectProvider As IVisualizerObjectProvider)
        _objectProvider = objectProvider
        Me.GetObjectData()
    End Sub

    Private Sub GetObjectData()
        Dim output As IO.Stream = New IO.MemoryStream()
        Dim formatter As BinaryFormatter = New BinaryFormatter()

        Try
            output = _objectProvider.GetData()
            _info = CType(formatter.Deserialize(output, Nothing), PictureViewerInfo)
            pic.Image = _info.PicImage
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        Finally
            CType(output, IDisposable).Dispose()
        End Try
    End Sub

    Private Sub pic_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic.MouseEnter
        Me.Opacity = 50
    End Sub

    Private Sub pic_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic.MouseHover
        Me.Opacity = 100
    End Sub

    Private Sub pic_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic.MouseLeave

    End Sub

    Private Sub PicViewer_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
        Me.Opacity = 20
    End Sub
End Class