mike-wigan
Member
right i have a filelist (listbox = FilesList) that i want the user to select one file by double clicking.
then it will pass it to a list box listbox = KaraokeQue in to a que but before it passes that file to the que i need a name assoiated with that file
ie when double clicked it will ask for a name then pass it to the file list box with the file name and the name the user gave
ie
Mike ---------- file name.mp3
diane---------- file name.mp3
then i am going to pass that file one at a time to winamp for playing so i must keep the file path somehow..
i am thinking of this way but not to sure how to get it working fully
the controls i have are
combobox = DrivesList
listbox = FoldersList
listbox = FilesList ----- The place i want the double click to come from----------
listbox = KaraokeQue ---- the place i want the playlist ----
this is the code for my file browser
i thought might be easier to wrap the name / path into another class.
i.e.
i was told if i use this with the list box. If you create an array of these i could use the array as the datasource and it will automatically use the DisplayName for the listbox text.
just not sure how to sort it out
i could really need a hand here ......
then it will pass it to a list box listbox = KaraokeQue in to a que but before it passes that file to the que i need a name assoiated with that file
ie when double clicked it will ask for a name then pass it to the file list box with the file name and the name the user gave
ie
Mike ---------- file name.mp3
diane---------- file name.mp3
then i am going to pass that file one at a time to winamp for playing so i must keep the file path somehow..
i am thinking of this way but not to sure how to get it working fully
the controls i have are
combobox = DrivesList
listbox = FoldersList
listbox = FilesList ----- The place i want the double click to come from----------
listbox = KaraokeQue ---- the place i want the playlist ----
this is the code for my file browser
Code:
Dim currentDir As String
Public Shared E_Path As TextBox
Dim modern As Date
Public Shared Main_Files As ListBox
Dim ChosenFiles() As String
Dim intSize As Integer = 0
Dim MyProgress As New ProgressBar
Dim MyProgressCopy As New ProgressBar
Dim StrGenre As String
Dim Genre As Integer
Dim tooltip1 As New ToolTip
****** file browser load ******
modern = Date.Now
task.SelectedIndex = 2
E_Path = TextBox1
On Error Resume Next
If DrivesList.Text = "" Then
DrivesList.Items.Clear()
ShowAllDrives()
DrivesList.SelectedIndex = 0
Me.Text = Directory.GetCurrentDirectory
Else
DrivesList.Items.Clear()
ShowAllDrives()
DrivesList.Items.Insert(0, DrivesList.Text)
DrivesList.SelectedIndex = 0
Me.Text = Directory.GetCurrentDirectory
End If
MyProgress = ProgressBar1
MyProgress.Value = 0
MyProgressCopy = ProgressBar2
MyProgressCopy.Value = 0
Artist_ComboBox.Items.Insert(0, "Artist <Do Not Change>")
Album_ComboBox.Items.Insert(0, "Album <Do Not Change>")
TrackName_ComboBox.Items.Insert(0, "Track Name <Do Not Change>")
Year_ComboBox.Items.Insert(0, "Year <Do Not Change>")
CreateMyToolTip()
******** End file browser ******
End Sub
********************************************************************* ******************
*************** Enumeration SubRoutines *****************************************
********************************************************************* ******************
FOLDERS LIST
Private Sub FoldersList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FoldersList.SelectedIndexChanged
Dim DI As DirectoryInfo
Select Case FoldersList.Text
Case ""
MsgBox("Select a Folder to Expand", MsgBoxStyle.Information, "Batch Renamer")
Exit Sub
Case ".."
Try
DrivesList.Text = ""
Directory.SetCurrentDirectory("..")
DrivesList.Text = Directory.GetCurrentDirectory
Catch
End Try
Case Else
Try
DrivesList.Text = ""
Dim Path As String = DrivesList.Text
DrivesList.Text = Path & FoldersList.SelectedItem
Directory.SetCurrentDirectory(DrivesList.Text)
frmKaraoke.E_Path.Text = DrivesList.Text
Catch : End Try
End Select
Dim folders() As String
Dim selectedFolder As String = FoldersList.Text
Try
folders = Directory.GetDirectories(Directory.GetCurrentDirectory)
FoldersList.Items.Clear()
FoldersList.Items.Add("..")
Catch : End Try
Dim fldr As String
For Each fldr In folders
Try
DI = New DirectoryInfo(fldr)
FoldersList.Items.Add(fldr)
TextBox1.Text = fldr
Catch : End Try
Next
Me.Text = Directory.GetCurrentDirectory & " - [Mike N Dis Karaokes Form 2006 ]"
Dim NewThreadStart1 As New ThreadStart(AddressOf Me.ShowFilesInFolder)
Dim Newthread As New Thread(NewThreadStart1)
Newthread.Start()
End Sub
SHOW FILES IN FOLDERS
Sub ShowFilesInFolder()
Dim file As String
Dim i As Integer = 0
Dim FI As FileInfo
Dim selectedFile As String = fileselect.Text
FilesList.Items.Clear()
For Each file In Directory.GetFiles(Directory.GetCurrentDirectory)
i = i + 1
Next
MyProgress.Maximum = i
For Each file In Directory.GetFiles(Directory.GetCurrentDirectory)
Try
FI = New FileInfo(file)
If InStr(LCase(FI.Name), "mp3") > 0 = True Or InStr(LCase(FI.Name), "ace") > 0 = True Or InStr(LCase(FI.Name), "zip") > 0 = True Or InStr(LCase(FI.Name), "rar") > 0 = True Then
If Not FilesList.Items.Contains(FI.Name) = True Then
FilesList.Items.Add(FI.Name)
End If
End If
Catch : End Try
If MyProgress.Value < MyProgress.Maximum Then
MyProgress.Value = MyProgress.Value + 1
End If
Next
End Sub
DRIVES LIST
Private Sub DrivesList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrivesList.SelectedIndexChanged
FoldersList.Items.Insert(0, "..")
ShowFoldersInDrive(DrivesList.Text)
ShowFilesInFolder()
End Sub
SHOW ALL DRIVES
Sub ShowAllDrives()
On Error Resume Next
Dim drives() As String
drives = Directory.GetLogicalDrives
Dim aDrive As String
For Each aDrive In drives
DrivesList.Items.Add(aDrive)
Next
End Sub
SHOW FOLDERS IN DRIVE
Sub ShowFoldersInDrive(ByVal drive As String)
Dim folders() As String
Try
folders = Directory.GetDirectories(drive)
Catch
End Try
Dim fldr As String
FoldersList.Items.Clear()
FoldersList.Items.Insert(0, "..")
Dim DI As DirectoryInfo
For Each fldr In folders
Try
DI = New DirectoryInfo(fldr)
FoldersList.Items.Add(DI.FullName)
Catch
End Try
Next
Try
Directory.SetCurrentDirectory(drive)
DrivesList.Text = Directory.GetCurrentDirectory & FoldersList.SelectedItem
Me.Text = Directory.GetCurrentDirectory & " - [Mike N Dis Karaokes Form 2006 ]"
Catch : MsgBox(Err.Description, MsgBoxStyle.Critical) : End Try
End Sub
i thought might be easier to wrap the name / path into another class.
i.e.
Code:
Public Class FileItem
Private ReadOnly _DisplayName As String
Private ReadOnly _FilePath As String
Public Sub New(ByVal DisplayName As String, ByVal FilePath As String)
_DisplayName = DisplayName
_FilePath = FilePath
End Sub
Public Sub New(ByVal FilePath As String)
_FilePath = FilePath
_DisplayName = System.IO.Path.GetFileNameWithoutExtension(FilePath)
End Sub
Public Overrides Function ToString() As String
Return _DisplayName
End Function
Public ReadOnly Property DisplayName() As String
Get
Return _DisplayName
End Get
End Property
Public ReadOnly Property FilePath() As String
Get
Return _FilePath
End Get
End Property
i was told if i use this with the list box. If you create an array of these i could use the array as the datasource and it will automatically use the DisplayName for the listbox text.
just not sure how to sort it out
i could really need a hand here ......