Private Sub Load1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length = 1 Then
Me.lblPatientid1.Text = "No command line arguments passed."
Else
Me.lblPatientid1.Text = cla(1)
End If
If Directory.Exists("C:\" & cla(1)) Then
tvwDirectories.Nodes.Add("C:\" & cla(1))
'load the treeview with file contents
RefreshTreeView("C:\" & cla(1), tvwDirectories.Nodes(0))
Else
MessageBox.Show("No file found for this ID", "No File Found", MessageBoxButtons.OK)
End If
Catch ex As Exception
MessageBox.Show("An error has occured please try again", "Error", MessageBoxButtons.OK)
End Try
End Sub
Private Sub tvwDirectories_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwDirectories.AfterSelect
Try
' load the treeview with subdirectories of current selection
RefreshTreeView(e.Node.Text, e.Node)
'Load the list view with files of current selection
RefreshListView(e.Node.Text)
Catch ex As Exception
MessageBox.Show("An error has occured please try again", "Error", MessageBoxButtons.OK)
End Try
End Sub
Sub RefreshTreeView(ByVal strDir As String, ByVal tnRoot As TreeNode)
Try
'Get Directory Information
Dim StrDirArray() As String = Directory.GetDirectories(strDir)
If StrDirArray.Length <> 0 Then
'Populate the treeview control with all subdirectories in the current directory
Dim d As String
Dim tnNode As TreeNode
For Each d In StrDirArray
tnNode = New TreeNode(d)
tnRoot.Nodes.Add(tnNode)
Next
End If
Catch ex As Exception
MessageBox.Show("An error has occured please try again", "Error", MessageBoxButtons.OK)
End Try
End Sub
Sub RefreshListView(ByVal strDir As String)
Try
lvwfiles.Items.Clear()
'Get File information
Dim Files() As FileInfo = New DirectoryInfo(strDir).GetFiles()
'Populate the listview with all files in the current directory
Dim f As FileInfo
Dim newfile As ListViewItem
For Each f In Files
newfile = lvwfiles.Items.Add(f.FullName)
newfile.ImageIndex = 0
Next
Catch ex As Exception
MessageBox.Show("An error has occured please try again", "Error", MessageBoxButtons.OK)
End Try
End Sub
Private Sub lvwfiles_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvwfiles.DoubleClick
'If File.Exists(lvwfiles.SelectedItems(0).Text) = True Then MessageBox.Show("Yes it exists")
' If Not DirectCast(Me.Owner, Form1).PicImage.Image Is Nothing Then
Dim File As FileInfo = New FileInfo(lvwfiles.SelectedItems(0).Text)
DirectCast(Me.Owner, Form1).PicImage.Image = Image.FromFile(lvwfiles.SelectedItems(0).Text)
DirectCast(Me.Owner, Form1).lblScanDate1.Text = String.Format("File Date: {0}", File.LastWriteTime.ToLongDateString())
DirectCast(Me.Owner, Form1).lblfilename1.Text = String.Format("File Name: {0}", File.Name.ToString)
DirectCast(Me.Owner, Form1).lblimageno1.Show()
'picimage.Image = Image.FromFile(lvwfiles.SelectedItems(0).Text)
'MessageBox.Show(String.Format(lvwfiles.SelectedItems(0).Text))
Me.Close()
End Sub