VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX" Begin VB.Form RioFXP BorderStyle = 1 'Fixed Single Caption = "RiOFXP" ClientHeight = 6255 ClientLeft = 1815 ClientTop = 1215 ClientWidth = 8535 Icon = "RioFXP.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 6255 ScaleWidth = 8535 Tag = "0" Begin VB.Frame RioFrame Height = 6255 Left = 0 TabIndex = 0 Top = 0 Width = 8535 Begin ComctlLib.Toolbar ButtonBar Height = 600 Left = 240 TabIndex = 7 Top = 5520 Width = 8175 _ExtentX = 14420 _ExtentY = 1058 ButtonWidth = 2302 ButtonHeight = 953 AllowCustomize = 0 'False Wrappable = 0 'False ImageList = "Images" _Version = 327682 BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} NumButtons = 8 BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Create Folder" Key = "createfolder" Object.ToolTipText = "Create a new folder on the Rio 500" Object.Tag = "" ImageIndex = 1 EndProperty BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Format" Key = "format" Object.ToolTipText = "Format the selected file system" Object.Tag = "" ImageIndex = 5 EndProperty BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Delete Folder" Key = "deletefolder" Object.ToolTipText = "Delete selected folder including all files" Object.Tag = "" ImageIndex = 4 EndProperty BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Delete Files" Key = "deletefiles" Object.ToolTipText = "Delete selected files" Object.Tag = "" ImageIndex = 4 EndProperty BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Download Files" Key = "downloadfiles" Object.ToolTipText = "Download selected files to harddisk" Object.Tag = "" ImageIndex = 2 EndProperty BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7} Caption = "Download Folder" Key = "downloadfolder" Object.ToolTipText = "Download complete folder with files to harddisk" Object.Tag = "" ImageIndex = 3 EndProperty EndProperty End Begin VB.CommandButton AdvancedFunctions Caption = "Advanced" Height = 375 Left = 240 TabIndex = 17 Top = 5040 Width = 1575 End Begin VB.TextBox FontPreview Height = 285 Left = 360 Locked = -1 'True TabIndex = 16 Text = "Sample Text" Top = 4080 Width = 1335 End Begin VB.ComboBox SizeList BeginProperty DataFormat Type = 1 Format = "0" HaveTrueFalseNull= 0 FirstDayOfWeek = 0 FirstWeekOfYear = 0 LCID = 1033 SubFormatType = 1 EndProperty Height = 315 ItemData = "RioFXP.frx":030A Left = 360 List = "RioFXP.frx":032E Sorted = -1 'True Style = 2 'Dropdown List TabIndex = 15 Top = 3720 Width = 1335 End Begin VB.ComboBox FontList Height = 315 Left = 360 Style = 2 'Dropdown List TabIndex = 14 Top = 3360 Width = 1335 End Begin VB.OptionButton ExternalRAM Alignment = 1 'Right Justify Caption = "External (??MB)" Enabled = 0 'False Height = 255 Left = 6840 TabIndex = 13 Top = 4920 Width = 1455 End Begin VB.OptionButton InternalRAM Caption = "Internal (64MB)" Height = 255 Left = 2040 TabIndex = 12 Top = 4920 Value = -1 'True Width = 1455 End Begin ComctlLib.ProgressBar ExternalBar Height = 255 Left = 5520 TabIndex = 10 Top = 5160 Width = 2775 _ExtentX = 4895 _ExtentY = 450 _Version = 327682 Appearance = 1 Enabled = 0 'False Max = 65535 End Begin ComctlLib.ListView FilesView Height = 3375 Left = 2160 TabIndex = 3 ToolTipText = "DND: upload files/folders - Drag: move file - SHIFT-drag: swap file" Top = 1320 Width = 6015 _ExtentX = 10610 _ExtentY = 5953 View = 3 MultiSelect = -1 'True LabelWrap = -1 'True HideSelection = -1 'True OLEDropMode = 1 _Version = 327682 Icons = "Images" SmallIcons = "Images" ForeColor = -2147483640 BackColor = -2147483643 BorderStyle = 1 Appearance = 1 OLEDropMode = 1 NumItems = 2 BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} Key = "filename" Object.Tag = "" Text = "Type / Filename" Object.Width = 7585 EndProperty BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} Alignment = 1 SubItemIndex = 1 Key = "size" Object.Tag = "" Text = "Size" Object.Width = 1235 EndProperty End Begin VB.CheckBox SaveSettings Alignment = 1 'Right Justify Caption = "Save Settings" Height = 255 Left = 360 TabIndex = 5 ToolTipText = "Save all settings in registry" Top = 2880 Width = 1335 End Begin VB.CheckBox AlwaysOnTop Alignment = 1 'Right Justify Caption = "Always on top" Height = 255 Left = 360 TabIndex = 4 ToolTipText = "Makes RiOFXP stay on top" Top = 2400 Width = 1335 End Begin VB.PictureBox Logo Height = 1695 Left = 240 Picture = "RioFXP.frx":035A ScaleHeight = 1635 ScaleWidth = 1515 TabIndex = 2 ToolTipText = "Click for Credits" Top = 360 Width = 1575 End Begin VB.TextBox StatusText Height = 285 Left = 2040 Locked = -1 'True TabIndex = 1 Text = "Ready ..." ToolTipText = "The current state of RiOFXP" Top = 360 Width = 6255 End Begin VB.Frame Preferences Caption = "Preferences" Height = 2655 Left = 240 TabIndex = 6 Top = 2160 Width = 1575 Begin VB.CheckBox UseTag Alignment = 1 'Right Justify Caption = "Use MP3 Tag" Height = 255 Left = 120 TabIndex = 18 Top = 2280 Width = 1335 End Begin VB.CheckBox SaveDir Alignment = 1 'Right Justify Caption = "Save DL Path" Height = 255 Left = 120 TabIndex = 8 ToolTipText = "Save the path to download files and folders to" Top = 480 Width = 1335 End End Begin VB.Timer UploadTimer Left = 840 Top = 360 End Begin ComctlLib.TabStrip RioFolders Height = 3975 Left = 2040 TabIndex = 11 Top = 840 Width = 6255 _ExtentX = 11033 _ExtentY = 7011 _Version = 327682 BeginProperty Tabs {0713E432-850A-101B-AFC0-4210102A8DA7} NumTabs = 1 BeginProperty Tab1 {0713F341-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" ImageVarType = 2 EndProperty EndProperty End Begin ComctlLib.ProgressBar InternalBar Height = 255 Left = 2040 TabIndex = 9 Top = 5160 Width = 2775 _ExtentX = 4895 _ExtentY = 450 _Version = 327682 Appearance = 1 Max = 64960 End Begin ComctlLib.ImageList Images Left = 240 Top = 360 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 327682 BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} NumListImages = 6 BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":980C Key = "" EndProperty BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":9B26 Key = "" EndProperty BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":9E40 Key = "" EndProperty BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":A15A Key = "" EndProperty BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":A474 Key = "" EndProperty BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "RioFXP.frx":A78E Key = "dfl" EndProperty EndProperty End End End Attribute VB_Name = "RioFXP" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' some wild support functions ' ripped em off the internet Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _ ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _ ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" _ (pDicDesc As IconType, riid As CLSIdType, ByVal fown As Long, _ lpUnk As Object) As Long Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias _ "SHGetFileInfoA" (ByVal pszPath As String, ByVal _ dwFileAttributes As Long, psfi As ShellFileInfoType, ByVal _ cbFileInfo As Long, ByVal uFlags As Long) As Long Private Type IconType cbSize As Long picType As PictureTypeConstants hIcon As Long End Type Private Type CLSIdType id(16) As Byte End Type Private Type ShellFileInfoType hIcon As Long iIcon As Long dwAttributes As Long szDisplayName As String * 260 szTypeName As String * 80 End Type Const Large = &H110 Const Small = &H111 Private Function LoadIcon(Size&, extension) As IPictureDisp ' gets an Icon from windows for a gives 3-char suffix Dim Result&, File$, Slash$ Dim Unkown As IUnknown Dim Icon As IconType Dim CLSID As CLSIdType Dim ShellInfo As ShellFileInfoType Call SHGetFileInfo("." + extension, &H80, ShellInfo, Len(ShellInfo), Size) Icon.cbSize = Len(Icon) Icon.picType = vbPicTypeIcon Icon.hIcon = ShellInfo.hIcon CLSID.id(8) = &HC0 CLSID.id(15) = &H46 Result = OleCreatePictureIndirect(Icon, CLSID, 1, Unkown) Set LoadIcon = Unkown End Function Private Sub AddFolder() ' show AddFolderDialog and let User enter a name OnTop ("off") AddFolderDialog.Show vbModal OnTop ("on") End Sub Public Sub CreateFolder(fname As String) ' create a new folder .. SetWorking ("Adding new folder '" + fname + "'") Dim Rio500 Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.FontName = FontList.Text Rio500.FontSize = SizeList.ListIndex + 6 Rio500.AddFolder fname, RioFXP.Tag Rio500.Close buildfolders DisplaySpace SetOK ("Folder added ok") End Sub Private Sub OnTop(state As String) ' set onTop off/on ' 'state' overrides the User setting ' (needed for child dialogs) If (state = "off") Then Call SetWindowPos(Me.hWnd, -2, 0, 0, 0, 0, 3) Else If (AlwaysOnTop.Value) Then Call SetWindowPos(Me.hWnd, -1, 0, 0, 0, 0, 3) End If End If End Sub Private Sub AdvancedFunctions_Click() ' show AddFolderDialog and let User enter a name OnTop ("off") AdvancedDialog.Show vbModal OnTop ("on") End Sub Private Sub AlwaysOnTop_Click() If (AlwaysOnTop.Value) Then OnTop ("on") Else OnTop ("off") End If End Sub Private Sub DeleteFolder() SetWorking ("Deleting current folder ...") Dim Rio500 Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.DeleteFolder RioFolders.SelectedItem.Index - 1, RioFXP.Tag Rio500.Close DisplaySpace buildfolders buildfiles SetOK ("Folder deletion ok") End Sub Private Sub DeleteFiles() SetWorking ("Deleting file(s) ... ") Dim Rio500 Set Rio500 = CreateObject("Rio500Remix.Rio500") For i = FilesView.ListItems.Count To 1 Step -1 If (FilesView.ListItems(i).Selected = True) Then SetWorking ("Deleting file '" + FilesView.ListItems(i).Text + "' ...") Rio500.Open Rio500.DeleteSong RioFolders.SelectedItem.Index - 1, i - 1, RioFXP.Tag Rio500.Close End If Next DisplaySpace buildfiles SetOK ("File(s) deleted ok") End Sub Private Sub DownloadFiles() If (SaveDir.Tag = "Empty") Or SaveDir.Value = 0 Then OnTop ("off") SelectLocation.Show vbModal OnTop ("on") End If SetWorking ("Downloading file(s) ...") Dim Rio500 Set Rio500 = CreateObject("Rio500Remix.Rio500") For i = 1 To FilesView.ListItems.Count If (FilesView.ListItems(i).Selected = True) Then SetWorking ("Downloading file '" + FilesView.ListItems(i).Text + "' ...") Rio500.Open Rio500.GetSong RioFolders.SelectedItem.Index - 1, i - 1, SaveDir.Tag + FilesView.ListItems(i).Text, RioFXP.Tag Rio500.Close End If Next SetOK ("File(s) downloaded ok") If SaveDir.Value = 0 Then SaveDir.Tag = "Empty" End Sub Private Sub DownloadFolder() If (SaveDir.Tag = "Empty") Or SaveDir.Value = 0 Then OnTop ("off") SelectLocation.Show vbModal OnTop ("on") End If SetWorking ("Downloading Folder '" + RioFolders.SelectedItem.Caption + "' ...") MkDir (SaveDir.Tag + RioFolders.SelectedItem.Caption) Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Set Songs = Rio500.Songs(RioFXP.Tag, RioFolders.SelectedItem.Index - 1) Rio500.Close For Each Song In Songs SetWorking ("Downloading '" + Song.Name + "' ...") Rio500.Open Rio500.GetSong RioFolders.SelectedItem.Index - 1, Song.Number, SaveDir.Tag + RioFolders.SelectedItem.Caption + "\" + Song.Name, RioFXP.Tag Rio500.Close Next SetOK ("Folder download finished") If SaveDir.Value = 0 Then SaveDir.Tag = "Empty" End Sub Private Sub ExternalBar_Click() ExternalRAM.Value = True End Sub Private Sub ExternalRAM_Click() RioFXP.Tag = 1 buildfolders buildfiles DisplaySpace End Sub Private Sub FilesView_AfterLabelEdit(Cancel As Integer, NewString As String) If (Cancel) Then GoTo norename If (FilesView.SelectedItem.Text = "Empty folder") Then NewString = "Empty folder" GoTo norename End If SetWorking ("Renaming '" + FilesView.SelectedItem.Text + "' ...") Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.FontName = FontList.Text Rio500.FontSize = SizeList.ListIndex + 6 Rio500.RenameSong RioFolders.SelectedItem.Index - 1, FilesView.SelectedItem.Index - 1, NewString, RioFXP.Tag Rio500.Close SetOK ("File renamed to '" + NewString + "'") norename: End Sub Private Sub FontList_Click() FontPreview.Font.Name = FontList.Text FontPreview.Font.Italic = False FontPreview.Font.Bold = False FontPreview.Font.Strikethrough = False FontPreview.Font.Underline = False FontPreview.Font.Size = SizeList.ListIndex + 6 End Sub Private Sub InternalBar_Click() InternalRAM.Value = True End Sub Private Sub Logo_Click() OnTop ("off") AboutDialog.Show vbModal OnTop ("on") End Sub Private Sub RioFolders_Click() buildfiles End Sub Private Sub SaveDir_Click() If SaveDir.Value = 0 Then SaveDir.Tag = "Empty" End Sub Private Sub SizeList_Click() FontPreview.Font.Italic = False FontPreview.Font.Bold = False FontPreview.Font.Strikethrough = False FontPreview.Font.Underline = False FontPreview.Font.Size = SizeList.ListIndex + 6 End Sub Private Sub FilesView_KeyUp(KeyCode As Integer, Shift As Integer) ' use the same keys as explorer If (KeyCode = vbKeyF2) Then FilesView.StartLabelEdit End If End Sub Public Sub FilesView_OLEDragDrop(Data As ComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single) ' grab all the files out of the OLE drag/drop and set up the timer for the upload to ' start. we must exit here as quick as possible to release the drag source (explorer) j = 1 On Error GoTo nomorefiles While (Data.Files(j) <> "") ' files get added to a global array rfxpglobal.DroppedFiles(j) = Data.Files(j) j = j + 1 Wend nomorefiles: UploadTimer.Interval = 100 UploadTimer.Enabled = True End Sub Private Sub Form_Load() ' code entry point ' add a dummy entry to the ListView ' to avoid errors (strange ....) FilesView.ListItems.Add 1, , "DummyFile1" FilesView.ListItems(1).Selected = True SetWorking ("Initializing ...") ' set up flash card (if any) GetFlashSize ' load all prefs from the registry GetAll ' set up the display buildfolders buildfiles DisplaySpace ' now waiting for user ... SetOK ("Ready ...") End Sub Private Sub Form_Unload(Cancel As Integer) ' save the user prefs if wanted If (SaveSettings.Value = 1) Then SaveAll End Sub Private Sub FormatRio() SetWorking ("Formatting .. please wait") ' here it gets strange .. we must add a folder immediately ' after formatting. good. but to work around a bug in ' the object, we must add another one, then delete the first. ' weird .. but works Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.Format RioFXP.Tag Rio500.AddFolder "DFLFOLDER", RioFXP.Tag Rio500.Close Rio500.Open Rio500.AddFolder "Music", RioFXP.Tag Rio500.DeleteFolder 0, RioFXP.Tag Rio500.Close DisplaySpace buildfolders buildfiles SetOK ("File system formatted ok") End Sub Public Sub GetFlashSize() ' Get the size of the installed flash card (if any) ' and set the parameters for the Bar accordingly FlashPresent = 0 Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open If (Rio500.ExtFlash = 1) Then ExternalRAM.Enabled = True ExternalBar.Enabled = True total = 0 Set Folders = Rio500.Folders(1) For Each Folder In Folders Set Songs = Rio500.Songs(1, Folder.Number) For Each Song In Songs total = total + Song.Size Next Next total = total + Rio500.AvailableMemory(1) total = Round(total / 1024, 0) ' store the type of flash card in a global .. If (total > 6000) Then FlashPresent = 8 If (total > 10000) Then FlashPresent = 16 If (total > 30000) Then FlashPresent = 32 If (total > 60000) Then FlashPresent = 64 ExternalBar.Max = total End If Rio500.Close End Sub Public Sub DisplaySpace() Dim Rio500 Dim AvailI Dim AvailE Dim Firmware Dim version Dim temp Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open ' query internal flash (always 64MB) AvailI = Rio500.AvailableMemory(0) On Error GoTo negative InternalBar.Value = InternalBar.Max - (AvailI / 1024) GoTo weiter negative: InternalBar.Value = 0 weiter: InternalRAM.ToolTipText = CStr((AvailI / 1024)) + " KB free" InternalBar.ToolTipText = CStr((AvailI / 1024)) + " KB free" ' query external flash if present ' and display the total size of it If (FlashPresent > 0) Then AvailE = Rio500.AvailableMemory(1) On Error GoTo negative2 ExternalBar.Value = ExternalBar.Max - (AvailE / 1024) GoTo weiter2 negative2: ExternalBar.Value = 0 weiter2: ExternalRAM.Caption = "External (" + CStr(FlashPresent) + "MB)" ExternalRAM.ToolTipText = CStr((AvailE / 1024)) + " KB free" ExternalBar.ToolTipText = CStr((AvailE / 1024)) + " KB free" End If SetCaption Rio500 Rio500.Close CheckButtons End Sub Sub SetCaption(ByRef Rio500) 'Get other junk info If (RioFXP.Tag) Then Me.Caption = "RiOFXP - Ext Flash " + CStr(Round((Rio500.AvailableMemory(RioFXP.Tag) / 1024 / 1024), 0)) + " of " + CStr(FlashPresent) + "MB free" Else Me.Caption = "RiOFXP - Int Flash " + CStr(Round((Rio500.AvailableMemory(RioFXP.Tag) / 1024 / 1024), 0)) + " of 64MB free" End If End Sub Private Sub InternalRAM_Click() RioFXP.Tag = 0 buildfolders buildfiles DisplaySpace End Sub Private Sub FilesView_Click() CheckButtons End Sub Private Sub FilesView_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) ' prepare a file entry for swapping If (FilesView.Tag = "0") Then On Error GoTo nofile FilesView.Tag = FilesView.HitTest(x, y).Index FilesView.MousePointer = 7 End If nofile: End Sub Private Sub FilesView_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) ' swap files .. FilesView.MousePointer = 0 On Error GoTo nofiles If (FilesView.Tag <> "0") And (FilesView.HitTest(x, y).Index <> FilesView.Tag) _ And RioFolders.Tabs.Count > 0 Then Swap = IIf(Shift = vbShiftMask, 1, 0) Method = IIf(Swap, "Swapp", "Mov") SetWorking (Method + "ing File ...") Dim Rio500 Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open If (Swap) Then Rio500.SwapSong RioFolders.SelectedItem.Index - 1, FilesView.Tag - 1, FilesView.HitTest(x, y).Index - 1, RioFXP.Tag Else 'Doesn't support multiple moving of files ' Work out the direction to step the swap StepDirection = IIf(FilesView.Tag - 1 <= FilesView.HitTest(x, y).Index - 1, 1, -1) ViewInc = IIf(FilesView.Tag - 1 <= FilesView.HitTest(x, y).Index - 1, 0, 1) HitInc = IIf(FilesView.Tag - 1 <= FilesView.HitTest(x, y).Index - 1, 1, 0) ' Some dodgy code - but it's used to work out the move For i = FilesView.Tag - ViewInc To FilesView.HitTest(x, y).Index - HitInc Step StepDirection 'Debug.Print "Swap " & (i + ViewInc) & " to " & (i + ViewInc + StepDirection) & " <-" SwapStart = i + ViewInc SwapEnd = i + ViewInc + StepDirection Rio500.SwapSong RioFolders.SelectedItem.Index - 1, SwapStart - 1, SwapEnd - 1, RioFXP.Tag Next End If Rio500.Close buildfiles SetOK ("File " + Method + "ed ok") End If nofiles: FilesView.Tag = "0" End Sub Public Sub buildfiles() ' core function .. displays the files of the selected folder ' in the listview. FilesView.ListItems.Clear If RioFolders.Tabs.Count > 0 Then Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Set Songs = Rio500.Songs(RioFXP.Tag, RioFolders.SelectedItem.Index - 1) Rio500.Close i = 0 For Each Song In Songs i = i + 1 Dim img, imgs Set imgs = Images.ListImages For Each img In imgs If (img.Key = (LCase(right(Song.Name, 3)))) Then GoTo drawit Next On Error GoTo dflicon Images.ListImages.Add , LCase(right(Song.Name, 3)), LoadIcon(Small, LCase(right(Song.Name, 3))) GoTo drawit dflicon: Set Entry = FilesView.ListItems.Add(i, , Song.Name, "dfl", "dfl") GoTo sizecalc drawit: Set Entry = FilesView.ListItems.Add(i, , Song.Name, LCase(right(Song.Name, 3)), LCase(right(Song.Name, 3))) sizecalc: mysize = CStr(Round(Song.Size / 1024, 0) + 1) Entry.SubItems(1) = mysize + " KB" Next If i = 0 Then FilesView.ListItems.Add 1, "Empty folder", "Empty folder" End If ' select the 1st item by default FilesView.ListItems.Item(1).Selected = True FilesView.Tag = "0" End If End Sub Public Sub buildfolders() ' core function .. display all folders Dim Rio500 Dim Folder Dim Folders RioFolders.Tabs.Clear Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Set Folders = Rio500.Folders(RioFXP.Tag) For Each Folder In Folders RioFolders.Tabs.Add , , Folder.Name Next End Sub Private Sub SetWorking(Cause As String) ' show a text saying we are busy .. RioFXP.Enabled = False If Cause = "" Then Cause = "Busy .. please wait" End If StatusText.Text = Cause End Sub Private Sub SetOK(Cause As String) ' show a text saying we are ready for the user RioFXP.Enabled = True If Cause = "" Then Cause = "Ready ..." End If StatusText.Text = Cause End Sub Public Sub CheckButtons() ' sanity checks. disables buttons the user ' should not click on in the current program state On Error GoTo formatit GoTo noformat formatit: SetWorking ("No folder found ! Formatting first ...") On Error GoTo notagain Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.Format RioFXP.Tag Rio500.AddFolder "DFLFOLDER", RioFXP.Tag Rio500.Close Rio500.Open Rio500.AddFolder "Music", RioFXP.Tag Rio500.DeleteFolder 0, RioFXP.Tag Rio500.Close buildfolders buildfiles DisplaySpace SetOK ("Default folder 'Music' created") notagain: noformat: If FilesView.SelectedItem.Index > 0 And FilesView.SelectedItem.Text <> "Empty folder" Then ButtonBar.Buttons(8).Enabled = True Else ButtonBar.Buttons(8).Enabled = False End If If FilesView.SelectedItem.Index > 0 _ And FilesView.ListItems.Count > 0 _ And FilesView.SelectedItem.Text <> "Empty folder" Then ButtonBar.Buttons(5).Enabled = True Else ButtonBar.Buttons(5).Enabled = False End If If RioFolders.Tabs.Count < 8 Then ButtonBar.Buttons(1).Enabled = True Else ButtonBar.Buttons(1).Enabled = False End If If RioFolders.Tabs.Count > 1 Then ButtonBar.Buttons(4).Enabled = True Else ButtonBar.Buttons(4).Enabled = False End If If FilesView.ListItems.Count > 0 _ And RioFolders.Tabs.Count > 0 _ And FilesView.SelectedItem.Text <> "Empty folder" Then ButtonBar.Buttons(7).Enabled = True Else ButtonBar.Buttons(7).Enabled = False End If End Sub Private Sub SaveAll() ' save user prefs SaveSetting "RiOFXP", "Settings", "DLPath", SaveDir.Tag SaveSetting "RiOFXP", "Settings", "SaveDir", SaveDir.Value SaveSetting "RiOFXP", "Settings", "SaveSettings", SaveSettings.Value SaveSetting "RiOFXP", "Settings", "AlwaysOnTop", AlwaysOnTop.Value SaveSetting "RiOFXP", "Settings", "UseTag", UseTag.Value SaveSetting "RiOFXP", "Settings", "FontName", FontList.Text SaveSetting "RiOFXP", "Settings", "FontSize", SizeList.ListIndex End Sub Private Sub GetAll() ' load user prefs On Error GoTo defaults SaveDir.Tag = GetSetting("RiOFXP", "Settings", "DLPath", "Empty") SaveDir.Value = GetSetting("RiOFXP", "Settings", "SaveDir", 1) SaveSettings.Value = GetSetting("RiOFXP", "Settings", "SaveSettings", 1) AlwaysOnTop.Value = GetSetting("RiOFXP", "Settings", "AlwaysOnTop", 0) UseTag.Value = GetSetting("RiOFXP", "Settings", "UseTag", 0) myfontname = GetSetting("RiOFXP", "Settings", "FontName", "MS Sans Serif") SizeList.ListIndex = GetSetting("RiOFXP", "Settings", "FontSize", 1) GoTo nodefaults defaults: SaveDir.Tag = "Empty" SaveDir.Value = 1 SaveSettings.Value = 1 AlwaysOnTop.Value = 0 myfontname = "MS Sans Serif" SizeList.ListIndex = 3 UseTag.Value = 0 nodefaults: ' build font list For i = 0 To Screen.FontCount - 1 FontList.AddItem Screen.Fonts(i), i If myfontname = Screen.Fonts(i) Then FontList.ListIndex = i End If Next i OnTop ("on") End Sub Private Sub ButtonBar_ButtonClick(ByVal Button As ComctlLib.Button) ' button bar click distributor If Button.Key = "downloadfiles" Then DownloadFiles End If If Button.Key = "downloadfolder" Then DownloadFolder End If If Button.Key = "deletefolder" Then DeleteFolder End If If Button.Key = "deletefiles" Then DeleteFiles End If If Button.Key = "format" Then FormatRio End If If Button.Key = "createfolder" Then AddFolder End If End Sub Private Sub UploadTimer_Timer() UploadTimer.Enabled = False UploadTimer.Interval = 0 UploadFiles End Sub Public Sub UploadFiles() ' upload a batch of files to the Rio SetWorking ("Uploading Files ...") ' check space before uploading Set fs = CreateObject("Scripting.FileSystemObject") total = 0 j = 1 While (Len(rfxpglobal.DroppedFiles(j)) > 3) mypath = rfxpglobal.DroppedFiles(j) Result = GetAttr(mypath) And vbDirectory If Result Then ' here we have a directory i = InStrRev(mypath, "\") mydir = right(mypath, Len(mypath) - i) ' get the contents of the dir myfile = Dir(mypath + "\*.*", vbNormal) ' count space of all files in the directory Do While myfile <> "" Set x = fs.GetFile(mypath + "\" + myfile) total = total + x.Size myfile = Dir Loop Else ' here we have a single file Set x = fs.GetFile(mypath) total = total + x.Size End If j = j + 1 Wend Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open avail = Round(Rio500.AvailableMemory(RioFXP.Tag) / 1024, 0) Rio500.Close If ((Round(total / 1024, 0) + 100) > avail) Then MsgBox ("Sorry, not enough space on this file system") SetOK ("Upload aborted") Exit Sub End If Dim Data As InputInfo, TagData As TAG_INFO Dim tag1 As String, tag2 As String j = 1 While (Len(rfxpglobal.DroppedFiles(j)) > 3) mypath = rfxpglobal.DroppedFiles(j) Result = GetAttr(mypath) And vbDirectory If Result Then ' here we have a directory ' create the folder on the Rio i = InStrRev(mypath, "\") mydir = right(mypath, Len(mypath) - i) CreateFolder (mydir) ' get the contents of the dir myfile = Dir(mypath + "\*.*", vbNormal) ' upload all files in the directory Set Rio500 = CreateObject("Rio500Remix.Rio500") Do While myfile <> "" SetWorking ("Uploading '" + myfile + "' ...") Rio500.Open Rio500.FontName = FontList.Text Rio500.FontSize = SizeList.ListIndex + 6 bitmapname = myfile If (UseTag.Value = 1) Then If vbmp3_open(mypath + "\" + myfile, Data) = False Then Else If vbmp3_getTagInfo(TagData) = False Then Else tag1 = TagData.szArtistName tag2 = TagData.szTrackName tag1 = NTrim2(tag1) tag2 = NTrim2(tag2) bitmapname = "(" + tag1 + ") " + tag2 End If End If End If Rio500.AddSong RioFolders.Tabs.Count - 1, bitmapname, mypath + "\" + myfile, RioFXP.Tag Rio500.Close myfile = Dir Loop Else ' here we have a single file i = InStrRev(mypath, "\") myfile = right(mypath, Len(mypath) - i) SetWorking ("Uploading '" + myfile + "' ...") Set Rio500 = CreateObject("Rio500Remix.Rio500") Rio500.Open Rio500.FontName = FontList.Text Rio500.FontSize = SizeList.ListIndex + 6 bitmapname = myfile If (UseTag.Value = 1) Then If vbmp3_open(mypath, Data) = False Then Else If vbmp3_getTagInfo(TagData) = False Then Else tag1 = TagData.szArtistName tag2 = TagData.szTrackName tag1 = NTrim2(tag1) tag2 = NTrim2(tag2) bitmapname = "(" + tag1 + ") " + tag2 End If End If End If Rio500.AddSong RioFolders.SelectedItem.Index - 1, bitmapname, mypath, RioFXP.Tag Rio500.Close End If j = j + 1 Wend NoMoreFile: buildfiles DisplaySpace ' clear the global array For i = 1 To 1024 rfxpglobal.DroppedFiles(i) = "" Next SetOK ("File Upload ok") End Sub