Imports Microsoft.WindowsMobile.Forms
Public Class Foto
    Private _row As SmartEstateDataSet.ImmobiliRow

    Public Property Row() As SmartEstateDataSet.ImmobiliRow
        Get
            Return _row
        End Get
        Set(ByVal value As SmartEstateDataSet.ImmobiliRow)
            _row = value
        End Set
    End Property


    Private Sub Foto_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load


        Dim ms As IO.MemoryStream = New IO.MemoryStream(Row.Foto, 0, Row.Foto.Length)
        Dim bitmap As New Bitmap(ms)

        pic.Image = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap)

    End Sub

    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
        Me.Close()
    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

        Dim picd As New SelectPictureDialog

        If (picd.ShowDialog() = Windows.Forms.DialogResult.OK) Then

            Try
                Dim bm As New Bitmap(picd.FileName)
                Dim imgStream As New IO.MemoryStream

                pic.Image = Image.FromHbitmap(bm.GetHbitmap)

                bm.Save(imgStream, Imaging.ImageFormat.Jpeg)

                Row.Foto = imgStream.ToArray()
            Catch ex As Exception

            End Try

        End If

    End Sub
End Class