Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Aqua Player - frmSeek.vb

frmSeek.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports Songs_Collector.frmSong
  2. Public Class frmSeek
  3.     Public Const TrovaTutto As Int16 = 22
  4.     Public Const TrovaFiles As Int16 = 6
  5.     Public Structure MFile
  6.         Dim Name As String
  7.         Dim Ext As String
  8.     End Structure
  9.     Public Sub ElencaFiles(ByVal PercSorg As String, ByVal TipoFile As String, ByVal InSottoDir As Boolean)
  10.         Dim ListaDir As New Collection
  11.         Dim PercAtt As String
  12.         Dim NomeFile As String
  13.         Dim FileAtt As String
  14.         Dim DirNum As Integer
  15.         Dim S(1) As String
  16.  
  17.         If PercSorg.Chars(PercSorg.Length - 1) <> "\" Then
  18.             PercSorg = PercSorg & "\"
  19.         End If
  20.         If Dir(PercSorg, TrovaTutto) <> "" Then
  21.             ListaDir.Add(PercSorg)
  22.         End If
  23.  
  24.         If InSottoDir Then
  25.             DirNum = 1
  26.             Do Until DirNum > ListaDir.Count
  27.                 PercAtt = ListaDir.Item(DirNum)
  28.                 NomeFile = Dir(PercAtt, TrovaTutto)
  29.                 Do Until NomeFile = ""
  30.                     If NomeFile.Chars(0) <> "." Then
  31.                         FileAtt = PercAtt & NomeFile
  32.                         If (GetAttr(FileAtt) And vbDirectory) Then
  33.                             ListaDir.Add(FileAtt & "\")
  34.                         End If
  35.                     End If
  36.                     NomeFile = Dir()
  37.                 Loop
  38.                 DirNum = DirNum + 1
  39.             Loop
  40.         End If
  41.  
  42.         Dim L As ListViewItem
  43.         For DirNum = 1 To ListaDir.Count
  44.             PercAtt = ListaDir.Item(DirNum)
  45.             NomeFile = Dir(PercAtt & TipoFile, TrovaFiles)
  46.             Do Until NomeFile = ""
  47.                 S(0) = NomeFile
  48.                 S(1) = ListaDir.Item(DirNum)
  49.                 L = New ListViewItem(S)
  50.                 lstFiles.Items.Add(L)
  51.                 NomeFile = Dir()
  52.             Loop
  53.         Next
  54.     End Sub
  55.     Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
  56.         If DFolder.ShowDialog = Windows.Forms.DialogResult.OK Then
  57.             txtDir.Text = DFolder.SelectedPath
  58.         End If
  59.     End Sub
  60.     Private Sub cmdSeek_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSeek.Click
  61.         If chbMp3.Checked Then
  62.             ElencaFiles(txtDir.Text, "*.mp3", chbDir.Checked)
  63.         End If
  64.         If chbWav.Checked Then
  65.             ElencaFiles(txtDir.Text, "*.wav", chbDir.Checked)
  66.         End If
  67.         If chbAvi.Checked Then
  68.             ElencaFiles(txtDir.Text, "*.avi", chbDir.Checked)
  69.         End If
  70.         If chbWmv.Checked Then
  71.             ElencaFiles(txtDir.Text, "*.wmv", chbDir.Checked)
  72.         End If
  73.         If chbWma.Checked Then
  74.             ElencaFiles(txtDir.Text, "*.wma", chbDir.Checked)
  75.         End If
  76.         If chbMpg.Checked Then
  77.             ElencaFiles(txtDir.Text, "*.mpg", chbDir.Checked)
  78.         End If
  79.         If lstFiles.Items.Count = 0 Then
  80.             MsgBox("Nessun elemento trovato!", MsgBoxStyle.Exclamation)
  81.         End If
  82.     End Sub
  83.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  84.         Dim L As ListViewItem
  85.         Dim S As Song = Nothing
  86.  
  87.         For Each L In lstFiles.Items
  88.             S.Nome = IO.Path.GetFileNameWithoutExtension(L.SubItems(0).Text)
  89.             S.Path = L.SubItems(1).Text + L.SubItems(0).Text
  90.             MainDB.Add(S)
  91.             frmSong.lstSongs.Items.Add(S.Nome)
  92.         Next
  93.         Me.Close()
  94.     End Sub
  95.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  96.         Dim L As ListViewItem
  97.         Dim S As Song = Nothing
  98.  
  99.         For Each L In lstFiles.CheckedItems
  100.             S.Nome = IO.Path.GetFileNameWithoutExtension(L.SubItems(0).Text)
  101.             S.Path = L.SubItems(1).Text + L.SubItems(0).Text
  102.             MainDB.Add(S)
  103.             frmSong.lstSongs.Items.Add(S.Nome)
  104.         Next
  105.         Me.Close()
  106.     End Sub
  107. End Class