Imports Songs_Collector.frmSong
Public Class frmSeek
Public Const TrovaTutto As Int16 = 22
Public Const TrovaFiles As Int16 = 6
Public Structure MFile
Dim Name As String
Dim Ext As String
End Structure
Public Sub ElencaFiles(ByVal PercSorg As String, ByVal TipoFile As String, ByVal InSottoDir As Boolean)
Dim PercAtt As String
Dim NomeFile As String
Dim FileAtt As String
Dim DirNum As Integer
Dim S(1) As String
If PercSorg.Chars(PercSorg.Length - 1) <> "\" Then
PercSorg = PercSorg & "\"
End If
If Dir(PercSorg, TrovaTutto) <> "" Then
ListaDir.Add(PercSorg)
End If
If InSottoDir Then
DirNum = 1
Do Until DirNum > ListaDir.Count
PercAtt = ListaDir.Item(DirNum)
NomeFile = Dir(PercAtt, TrovaTutto)
Do Until NomeFile = ""
If NomeFile.Chars(0) <> "." Then
FileAtt = PercAtt & NomeFile
If (GetAttr(FileAtt) And vbDirectory) Then
ListaDir.Add(FileAtt & "\")
End If
End If
NomeFile = Dir()
Loop
DirNum = DirNum + 1
Loop
End If
Dim L As ListViewItem
For DirNum = 1 To ListaDir.Count
PercAtt = ListaDir.Item(DirNum)
NomeFile = Dir(PercAtt & TipoFile, TrovaFiles)
Do Until NomeFile = ""
S(0) = NomeFile
S(1) = ListaDir.Item(DirNum)
L = New ListViewItem(S)
lstFiles.Items.Add(L)
NomeFile = Dir()
Loop
Next
End Sub
Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
If DFolder.ShowDialog = Windows.Forms.DialogResult.OK Then
txtDir.Text = DFolder.SelectedPath
End If
End Sub
Private Sub cmdSeek_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSeek.Click
If chbMp3.Checked Then
ElencaFiles(txtDir.Text, "*.mp3", chbDir.Checked)
End If
If chbWav.Checked Then
ElencaFiles(txtDir.Text, "*.wav", chbDir.Checked)
End If
If chbAvi.Checked Then
ElencaFiles(txtDir.Text, "*.avi", chbDir.Checked)
End If
If chbWmv.Checked Then
ElencaFiles(txtDir.Text, "*.wmv", chbDir.Checked)
End If
If chbWma.Checked Then
ElencaFiles(txtDir.Text, "*.wma", chbDir.Checked)
End If
If chbMpg.Checked Then
ElencaFiles(txtDir.Text, "*.mpg", chbDir.Checked)
End If
If lstFiles.Items.Count = 0 Then
MsgBox("Nessun elemento trovato!", MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim L As ListViewItem
Dim S As Song = Nothing
For Each L In lstFiles.Items
S.Nome = IO.Path.GetFileNameWithoutExtension(L.SubItems(0).Text)
S.Path = L.SubItems(1).Text + L.SubItems(0).Text
MainDB.Add(S)
frmSong.lstSongs.Items.Add(S.Nome)
Next
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim L As ListViewItem
Dim S As Song = Nothing
For Each L In lstFiles.CheckedItems
S.Nome = IO.Path.GetFileNameWithoutExtension(L.SubItems(0).Text)
S.Path = L.SubItems(1).Text + L.SubItems(0).Text
MainDB.Add(S)
frmSong.lstSongs.Items.Add(S.Nome)
Next
Me.Close()
End Sub
End Class