/Source Code/FileArchiveEditor/frmMain.vb
Visual Basic | 75 lines | 54 code | 20 blank | 1 comment | 1 complexity | 228acf1759883c0c7733264df8389cf7 MD5 | raw file
- Imports System.IO.Path
- Imports PowerSong.FileArchive
-
- Public Class frmMain
-
- Private Sub btnSelectArchiveFilename_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectArchiveFilename.Click
- If dlgSaveArchive.ShowDialog = Windows.Forms.DialogResult.OK Then
- txtArchiveFilename.Text = dlgSaveArchive.FileName
- End If
- End Sub
-
- Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
-
- If dlgAddFile.ShowDialog = Windows.Forms.DialogResult.OK Then
- For Each Filename As String In dlgAddFile.FileNames
- Dim Item As ListViewItem = lvFiles.Items.Add(GetFileName(Filename))
- Item.SubItems.Add(Filename)
- Next
- End If
-
- End Sub
-
- Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
-
- Dim Table As New FileTable
- For Each Item As ListViewItem In lvFiles.Items
- Table.AddFile(Item.Text, Item.SubItems(1).Text)
- Next
- ArchiveFile.Create(txtArchiveFilename.Text, Table)
- MsgBox("The archive has been created.", MsgBoxStyle.Information)
-
- End Sub
-
- Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
-
- If lvFiles.SelectedItems.Count = 0 Then
- MsgBox("Please select a file to remove first.", MsgBoxStyle.Information)
- Exit Sub
- End If
-
- If MsgBox("Are you sure you wish to remove the selected files?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
- For Each Item As ListViewItem In lvFiles.SelectedItems
- Item.Remove()
- Next
- End If
-
- End Sub
-
- Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
-
- If lvFiles.SelectedItems.Count = 0 Then
- MsgBox("Please select a file to edit first.", MsgBoxStyle.Information)
- Exit Sub
- End If
-
- ' Change the file name of the selected file
- Dim SelectedFile As String = lvFiles.SelectedItems(0).Text
- SelectedFile = InputBox("Please enter the new virtual file name for this file:", "Change Filename", SelectedFile)
- lvFiles.SelectedItems(0).Text = SelectedFile
-
- End Sub
-
- Private Sub btnAddFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFolder.Click
-
- If dlgAddFolder.ShowDialog = Windows.Forms.DialogResult.OK Then
- For Each Filename As String In IO.Directory.GetFiles(dlgAddFolder.SelectedPath, "*.*", IO.SearchOption.AllDirectories)
- Dim NewFilename As String = Filename.Remove(0, dlgAddFolder.SelectedPath.Length + 1)
- Dim Item As ListViewItem = lvFiles.Items.Add(NewFilename)
- Item.SubItems.Add(Filename)
- Next
- End If
-
- End Sub
-
- End Class