1 'This is a list of commonly used namespaces for a window.
4 Imports System
.Windows
.Controls
5 Imports System
.Windows
.Media
6 Imports System
.Windows
.Media
.Imaging
8 Imports System
.Collections
13 '/ Interaction logic for Window1.xaml
16 Partial Class ImageViewExample
18 Private imageFiles
As ArrayList
26 Private Sub WindowLoaded(ByVal sender
As Object, ByVal e
As RoutedEventArgs
)
27 imageFiles
= GetImageFileInfo()
28 imageListBox
.DataContext
= imageFiles
33 Private Sub showImage(ByVal sender
As Object, ByVal args
As SelectionChangedEventArgs
)
34 Dim list
As ListBox
= CType(sender
, ListBox
)
35 If Not (list Is
Nothing) Then
36 Dim index
As Integer = list
.SelectedIndex
'Save the selected index
38 Dim selection
As String = list
.SelectedItem
.ToString()
40 If Not (selection Is
Nothing) AndAlso selection
.Length
<> 0 Then
41 'Set currentImage to selected Image
42 Dim selLoc
As New Uri(selection
)
43 Dim id
As New BitmapImage(selLoc
)
44 Dim currFileInfo
As New FileInfo(selection
)
45 currentImage
.Source
= id
48 imageSize
.Text
= id
.PixelWidth
.ToString() + " x " + id
.PixelHeight
.ToString()
49 imageFormat
.Text
= id
.Format
.ToString()
50 fileSize
.Text
= ((currFileInfo
.Length
+ 512) / 1024).ToString() + "k"
58 Private Function GetImageFileInfo() As ArrayList
59 Dim imageFiles
As New ArrayList()
62 'Get directory path of myData (down two directory levels)
63 Dim currDir
As String = Directory
.GetCurrentDirectory()
64 Dim temp
As String = currDir
+ "\..\..\myData"
65 files
= Directory
.GetFiles(temp
, "*.jpg")
68 For Each image
In files
69 Dim info
As New FileInfo(image
)
76 End Function 'GetImageFileInfo
77 End Class
'ImageViewExample
78 End Namespace
'ImageView