added SSCLI 1.0
[windows-sources.git] / sdk / samples / WPFSamples / ImageView / vb / default.xaml.vb
blob53c6f23bb2909db985d8564a8cac67811fdd7cff
1 'This is a list of commonly used namespaces for a window.
2 Imports System
3 Imports System.Windows
4 Imports System.Windows.Controls
5 Imports System.Windows.Media
6 Imports System.Windows.Media.Imaging
7 Imports System.IO
8 Imports System.Collections
10 Namespace ImageView
12 '/ <summary>
13 '/ Interaction logic for Window1.xaml
14 '/ </summary>
16 Partial Class ImageViewExample
17 Inherits Window '
18 Private imageFiles As ArrayList
20 Public Sub New()
21 InitializeComponent()
23 End Sub 'New
26 Private Sub WindowLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
27 imageFiles = GetImageFileInfo()
28 imageListBox.DataContext = imageFiles
30 End Sub 'WindowLoaded
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
37 If index >= 0 Then
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
47 'Setup Info Text
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"
51 End If
52 End If
53 End If
55 End Sub 'showImage
58 Private Function GetImageFileInfo() As ArrayList
59 Dim imageFiles As New ArrayList()
60 Dim files() As String
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")
67 Dim image As String
68 For Each image In files
69 Dim info As New FileInfo(image)
70 imageFiles.Add(info)
71 Next image
73 'imageFiles.Sort();
74 Return imageFiles
76 End Function 'GetImageFileInfo
77 End Class 'ImageViewExample
78 End Namespace 'ImageView