PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/Source Code/FileArchiveEditor/frmMain.vb

#
Visual Basic | 75 lines | 54 code | 20 blank | 1 comment | 1 complexity | 228acf1759883c0c7733264df8389cf7 MD5 | raw file
  1. Imports System.IO.Path
  2. Imports PowerSong.FileArchive
  3. Public Class frmMain
  4. Private Sub btnSelectArchiveFilename_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectArchiveFilename.Click
  5. If dlgSaveArchive.ShowDialog = Windows.Forms.DialogResult.OK Then
  6. txtArchiveFilename.Text = dlgSaveArchive.FileName
  7. End If
  8. End Sub
  9. Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
  10. If dlgAddFile.ShowDialog = Windows.Forms.DialogResult.OK Then
  11. For Each Filename As String In dlgAddFile.FileNames
  12. Dim Item As ListViewItem = lvFiles.Items.Add(GetFileName(Filename))
  13. Item.SubItems.Add(Filename)
  14. Next
  15. End If
  16. End Sub
  17. Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
  18. Dim Table As New FileTable
  19. For Each Item As ListViewItem In lvFiles.Items
  20. Table.AddFile(Item.Text, Item.SubItems(1).Text)
  21. Next
  22. ArchiveFile.Create(txtArchiveFilename.Text, Table)
  23. MsgBox("The archive has been created.", MsgBoxStyle.Information)
  24. End Sub
  25. Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
  26. If lvFiles.SelectedItems.Count = 0 Then
  27. MsgBox("Please select a file to remove first.", MsgBoxStyle.Information)
  28. Exit Sub
  29. End If
  30. If MsgBox("Are you sure you wish to remove the selected files?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  31. For Each Item As ListViewItem In lvFiles.SelectedItems
  32. Item.Remove()
  33. Next
  34. End If
  35. End Sub
  36. Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
  37. If lvFiles.SelectedItems.Count = 0 Then
  38. MsgBox("Please select a file to edit first.", MsgBoxStyle.Information)
  39. Exit Sub
  40. End If
  41. ' Change the file name of the selected file
  42. Dim SelectedFile As String = lvFiles.SelectedItems(0).Text
  43. SelectedFile = InputBox("Please enter the new virtual file name for this file:", "Change Filename", SelectedFile)
  44. lvFiles.SelectedItems(0).Text = SelectedFile
  45. End Sub
  46. Private Sub btnAddFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFolder.Click
  47. If dlgAddFolder.ShowDialog = Windows.Forms.DialogResult.OK Then
  48. For Each Filename As String In IO.Directory.GetFiles(dlgAddFolder.SelectedPath, "*.*", IO.SearchOption.AllDirectories)
  49. Dim NewFilename As String = Filename.Remove(0, dlgAddFolder.SelectedPath.Length + 1)
  50. Dim Item As ListViewItem = lvFiles.Items.Add(NewFilename)
  51. Item.SubItems.Add(Filename)
  52. Next
  53. End If
  54. End Sub
  55. End Class