Public Class frmMain Dim latestDate As String = "Friday, May 5th 2007" Dim ftpURL As String = "ftp.powweb.com" Dim ftpUname As String = "asfadmin" Dim ftpPwd As String = "g1ngerbread_guillotine" Function libraryContains(ByVal path As String) Dim index As Integer = -1 Dim i As Integer = 0 While i < sLibrary.Rows.Count If sLibrary.Rows.Item(i).Cells.Item(4).Value = path Then index = i Exit While End If i += 1 End While Return index End Function Private Sub addFile(ByVal path As String) Dim folderPath As String = IO.Path.GetDirectoryName(path) Dim folderName As String = folderPath.Remove(0, folderPath.LastIndexOf("\") + 1) Dim songPath As String Dim songName As String Dim songCat As String = "Last Added" If path.EndsWith(".mp3") Then songPath = path If libraryContains(songPath) = -1 Then Dim lIndex As Integer = songPath.LastIndexOf("\") + 1 songName = songPath.Substring(lIndex, songPath.Length - lIndex - 4) songName.Replace("#", "_") sLibrary.Rows.Add(True, songName, folderName, songCat, songPath, folderPath, "") End If End If End Sub Private Sub addFolder(ByVal path As String) Dim folderPath As String = path Dim folderName As String = folderPath.Remove(0, folderPath.LastIndexOf("\") + 1) Dim songPath As String Dim songName As String Dim songCat As String = "Last Added" For Each file As String In IO.Directory.GetFiles(path) If file.EndsWith(".mp3") Then songPath = file If libraryContains(songPath) = -1 Then Dim lIndex As Integer = songPath.LastIndexOf("\") + 1 songName = songPath.Substring(lIndex, songPath.Length - lIndex - 4) songName.Replace("#", "_") sLibrary.Rows.Add(True, songName, folderName, songCat, songPath, folderPath, "") End If End If Next For Each dir As String In IO.Directory.GetDirectories(path) folderPath = dir folderName = folderPath.Remove(0, folderPath.LastIndexOf("\") + 1) For Each file As String In IO.Directory.GetFiles(dir) If file.EndsWith(".mp3") Then songPath = file If libraryContains(songPath) = -1 Then Dim lIndex As Integer = songPath.LastIndexOf("\") + 1 songName = songPath.Substring(lIndex, songPath.Length - lIndex - 4) songName.Replace("#", "_") sLibrary.Rows.Add(True, songName, folderName, songCat, songPath, folderPath, "") End If End If Next Next End Sub Private Sub createPage() If IO.File.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cur.htm") = False Then IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater") Dim web As New Net.WebClient web.DownloadFile("http://aspaceforth.decidel.net/", System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cur.htm") End If Dim reader As New System.IO.StreamReader(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cur.htm") Dim writer As New System.IO.StreamWriter(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\index.htm") Dim i As Integer = 0 'preliminary While reader.Peek <> -1 writer.WriteLine(reader.ReadLine()) End While reader.Close() If sCatLibrary.Item(2, 0).Value = True Then i = 0 writer.WriteLine("
") writer.WriteLine("

The Latest

") While i < sCatLibrary.Rows.Count - 1 If sCatLibrary.Rows.Item(i).Cells.Item(0).Value = "The Latest" Then writer.WriteLine("

" & sCatLibrary.Rows.Item(i).Cells.Item(1).Value & "

") End If i += 1 End While writer.WriteLine("
") writer.WriteLine("") 'Latest i = 0 While i < sLibrary.Rows.Count - 1 If sLibrary.Rows.Item(i).Cells.Item(3).Value = "The Latest" Then writer.WriteLine("

" & sLibrary.Rows.Item(i).Cells.Item(1).Value & "

") writer.WriteLine("

-Recorded " & IO.File.GetCreationTime(sLibrary.Rows.Item(i).Cells.Item(4).Value) & "-



") End If i += 1 End While writer.WriteLine("") End If 'Last Added If sCatLibrary.Item(2, 1).Value = True Then writer.WriteLine("
") writer.WriteLine("

Last Added

") i = 0 While i < sCatLibrary.Rows.Count - 1 If sCatLibrary.Rows.Item(i).Cells.Item(0).Value = "Last Added" Then writer.WriteLine("

" & sCatLibrary.Rows.Item(i).Cells.Item(1).Value & "

") End If i += 1 End While writer.WriteLine("
") i = 0 While i < sLibrary.Rows.Count - 1 If sLibrary.Rows.Item(i).Cells.Item(3).Value = "Last Added" Then writer.WriteLine("

" & sLibrary.Rows.Item(i).Cells.Item(1).Value & "

") End If i += 1 End While writer.WriteLine("") End If 'All the rest i = 0 While i < sCatLibrary.Rows.Count - 1 If sCatLibrary.Rows.Item(i).Cells.Item(0).Value <> "The Latest" And sCatLibrary.Rows.Item(i).Cells.Item(0).Value <> "Last Added" And sCatLibrary.Rows.Item(i).Cells.Item(2).Value = True Then writer.WriteLine("
") writer.WriteLine("

" & sCatLibrary.Rows.Item(i).Cells.Item(0).Value & "

") writer.WriteLine("

" & sCatLibrary.Rows.Item(i).Cells.Item(1).Value & "

") writer.WriteLine("
") writer.WriteLine("") Dim j As Integer = 0 While j < sLibrary.Rows.Count - 1 If sLibrary.Rows.Item(j).Cells.Item(3).Value = sCatLibrary.Rows.Item(i).Cells.Item(0).Value Then writer.WriteLine("

" & sLibrary.Rows.Item(j).Cells.Item(1).Value & "

") End If j += 1 End While End If i += 1 End While writer.WriteLine("") 'footer writer.WriteLine("
") writer.WriteLine("

Get All ASF Audio") writer.WriteLine("

- © Jarfunk McMarkenstein Gush 20XX -

") writer.WriteLine("") writer.WriteLine("") writer.WriteLine("") writer.WriteLine("") writer.Close() End Sub Private Sub AddFolderToLibraryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddFolderToLibraryToolStripMenuItem.Click Dim res As DialogResult = FolderBrowser.ShowDialog() If res <> Windows.Forms.DialogResult.Cancel Then addFolder(FolderBrowser.SelectedPath) End If End Sub Private Sub AddFileToLibraryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddFileToLibraryToolStripMenuItem.Click Dim res As DialogResult = FileBrowser.ShowDialog If res <> Windows.Forms.DialogResult.Cancel Then addFile(FileBrowser.FileName) End If End Sub Private Sub SaveLibraryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveLibraryToolStripMenuItem.Click Dim res As DialogResult = SaveFileBrowser.ShowDialog If res <> Windows.Forms.DialogResult.Cancel Then Dim w As New System.IO.StreamWriter(SaveFileBrowser.FileName) Dim i As Integer = 0 While i < sLibrary.Rows.Count - 1 Dim j As Integer = 0 While j < 7 w.WriteLine(sLibrary.Rows.Item(i).Cells.Item(j).Value) j += 1 End While i += 1 End While w.Close() Me.btnDone_Click(Me, System.EventArgs.Empty) End If End Sub Private Sub LoadLibraryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadLibraryToolStripMenuItem.Click sLibrary.Rows.Clear() Dim res As DialogResult = LoadFileBrowser.ShowDialog If res <> Windows.Forms.DialogResult.Cancel Then Dim r As New System.IO.StreamReader(LoadFileBrowser.FileName) While r.Peek <> -1 sLibrary.Rows.Add(r.ReadLine, r.ReadLine, r.ReadLine, r.ReadLine, r.ReadLine, r.ReadLine, r.ReadLine) End While r.Close() End If End Sub Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click Me.Close() End Sub Private Sub PreviewASFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreviewASFToolStripMenuItem.Click createPage() PreviewWindow.Navigate(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\index.htm") PreviewWindow.Dock = DockStyle.Fill btnFinished.Visible = True PreviewWindow.Visible = True End Sub Private Sub CatagoriesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CatagoriesToolStripMenuItem.Click sCatLibrary.Dock = DockStyle.Fill sCatLibrary.Visible = True btnDone.Visible = True End Sub Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IO.File.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") = False Then IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater") Dim w As New System.IO.StreamWriter(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") w.WriteLine("The Latest") w.WriteLine("Last Added") If cCat.Items.Contains("Last Added") = False Then cCat.Items.Add("The Latest") cCat.Items.Add("Last Added") End If w.WriteLine("The songs added on the latest update. (Excluding the latest song I wrote.)") w.Close() sCatLibrary.Rows.Add("Last Added", "The songs added on the latest update. (Excluding the latest song I wrote.)") Else Dim r As New System.IO.StreamReader(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") ftpURL = r.ReadLine ftpUname = r.ReadLine ftpPwd = r.ReadLine Dim i As Integer = 0 While r.Peek <> -1 sCatLibrary.Rows.Add(r.ReadLine, r.ReadLine, r.ReadLine) If cCat.Items.Contains(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) = False Then cCat.Items.Add(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) End If i += 1 End While r.Close() End If End Sub Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.Click If IO.File.Exists(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") = False Then IO.Directory.CreateDirectory(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater") Dim w As New System.IO.StreamWriter(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") w.WriteLine(ftpURL) w.WriteLine(ftpUname) w.WriteLine(ftpPwd) Dim i As Integer = 0 While i < sCatLibrary.Rows.Count - 1 w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) If cCat.Items.Contains(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) = False Then cCat.Items.Add(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) End If w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(1).Value) w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(2).Value) i += 1 End While w.Close() Else Dim w As New System.IO.StreamWriter(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\cats.txt") w.WriteLine(ftpURL) w.WriteLine(ftpUname) w.WriteLine(ftpPwd) Dim i As Integer = 0 While i < sCatLibrary.Rows.Count - 1 w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) If cCat.Items.Contains(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) = False Then cCat.Items.Add(sCatLibrary.Rows.Item(i).Cells.Item(0).Value) End If w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(1).Value) w.WriteLine(sCatLibrary.Rows.Item(i).Cells.Item(2).Value) i += 1 End While w.Close() End If sCatLibrary.Visible = False btnDone.Visible = False End Sub Private Sub cCat_Key(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles cCat.KeyDown If e.KeyData = Keys.Enter Then If cCat.Items.Contains(cCat.Text) Then Dim i As Integer = 0 While i < sLibrary.SelectedRows.Count sLibrary.SelectedRows(i).Cells.Item(3).Value = cCat.SelectedText i += 1 End While mSub.Close() End If End If End Sub Private Sub sCatLibrary_Key(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles sCatLibrary.KeyDown If e.KeyData = Keys.Left Then If sCatLibrary.SelectedRows.Count() = 1 And sCatLibrary.SelectedRows.Item(0).Index() < sCatLibrary.Rows.Count() - 1 And sCatLibrary.SelectedRows.Item(0).Index() > 2 Then Dim i As Integer = 0 Dim selRow As Integer = sCatLibrary.SelectedRows.Item(0).Index() Dim targetCell0 As String = sCatLibrary.Rows.Item(selRow - 1).Cells.Item(0).Value Dim targetCell1 As String = sCatLibrary.Rows.Item(selRow - 1).Cells.Item(1).Value Dim targetCell2 As Boolean = sCatLibrary.Rows.Item(selRow - 1).Cells.Item(2).Value sCatLibrary.Item(0, selRow - 1).Value = sCatLibrary.Item(0, selRow).Value sCatLibrary.Item(1, selRow - 1).Value = sCatLibrary.Item(1, selRow).Value sCatLibrary.Item(2, selRow - 1).Value = sCatLibrary.Item(2, selRow).Value sCatLibrary.Item(0, selRow).Value = targetCell0 sCatLibrary.Item(1, selRow).Value = targetCell1 sCatLibrary.Item(2, selRow).Value = targetCell2 sCatLibrary.Rows.Item(selRow).Selected = 0 sCatLibrary.Rows.Item(selRow - 1).Selected = 1 End If End If If e.KeyData = Keys.Right Then If sCatLibrary.SelectedRows.Count() = 1 And sCatLibrary.SelectedRows.Item(0).Index() < sCatLibrary.Rows.Count() - 2 And sCatLibrary.SelectedRows.Item(0).Index() > 1 Then Dim i As Integer = 0 Dim selRow As Integer = sCatLibrary.SelectedRows.Item(0).Index() Dim targetCell0 As String = sCatLibrary.Rows.Item(selRow + 1).Cells.Item(0).Value Dim targetCell1 As String = sCatLibrary.Rows.Item(selRow + 1).Cells.Item(1).Value Dim targetCell2 As Boolean = sCatLibrary.Rows.Item(selRow + 1).Cells.Item(2).Value sCatLibrary.Item(0, selRow + 1).Value = sCatLibrary.Item(0, selRow).Value sCatLibrary.Item(1, selRow + 1).Value = sCatLibrary.Item(1, selRow).Value sCatLibrary.Item(2, selRow + 1).Value = sCatLibrary.Item(2, selRow).Value sCatLibrary.Item(0, selRow).Value = targetCell0 sCatLibrary.Item(1, selRow).Value = targetCell1 sCatLibrary.Item(2, selRow).Value = targetCell2 sCatLibrary.Rows.Item(selRow).Selected = 0 sCatLibrary.Rows.Item(selRow + 1).Selected = 1 End If End If End Sub Private Sub cCat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cCat.LostFocus mSub.Close() End Sub Private Sub btnFinished_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinished.Click PreviewWindow.Visible = False btnFinished.Visible = False End Sub Private Sub SyncLibraryWithASFToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SyncLibraryWithASFToolStripMenuItem.Click pBarSync.Visible = True SyncWorker.RunWorkerAsync() End Sub Private Sub AlwaysOnTopToolStripMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AlwaysOnTopToolStripMenuItem.CheckedChanged Me.TopMost = AlwaysOnTopToolStripMenuItem.Checked End Sub Private Sub EditToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EditToolStripMenuItem.Click ToolStripTxtFTPURL.Text = ftpURL ToolStripTxtUname.Text = ftpUname ToolStripTxtPwd.Text = ftpPwd End Sub Private Sub ToolStripTxtFTPURL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTxtFTPURL.TextChanged ftpURL = ToolStripTxtFTPURL.Text End Sub Private Sub ToolStripTxtFTPURL_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTxtFTPURL.KeyDown If e.KeyData = Keys.Enter Then ToolStripTxtFTPURL.SelectAll() Me.btnDone_Click(Me, System.EventArgs.Empty) End If End Sub Private Sub ToolStripTxtUname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTxtUname.TextChanged ftpUname = ToolStripTxtUname.Text End Sub Private Sub ToolStripTxtUname_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTxtUname.KeyDown If e.KeyData = Keys.Enter Then ToolStripTxtUname.SelectAll() Me.btnDone_Click(Me, System.EventArgs.Empty) End If End Sub Private Sub ToolStripTxtPwd_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTxtPwd.TextChanged ftpPwd = ToolStripTxtPwd.Text End Sub Private Sub ToolStripTxtPwd_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTxtPwd.KeyDown If e.KeyData = Keys.Enter Then ToolStripTxtPwd.SelectAll() Me.btnDone_Click(Me, System.EventArgs.Empty) End If End Sub Private Sub mSyncCheckSel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mSyncCheckSel.Click Dim selTotal As Integer = sLibrary.SelectedRows.Count Dim i As Integer = 0 While i < selTotal sLibrary.SelectedRows.Item(i).Cells.Item(0).Value = True i += 1 End While End Sub Private Sub mSyncUncheckSel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mSyncUncheckSel.Click Dim selTotal As Integer = sLibrary.SelectedRows.Count Dim i As Integer = 0 While i < selTotal sLibrary.SelectedRows.Item(i).Cells.Item(0).Value = False i += 1 End While End Sub Private Sub mSyncInvertSel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mSyncInvertSel.Click Dim selTotal As Integer = sLibrary.SelectedRows.Count Dim i As Integer = 0 While i < selTotal sLibrary.SelectedRows.Item(i).Cells.Item(0).Value = Not sLibrary.SelectedRows.Item(i).Cells.Item(0).Value i += 1 End While End Sub Private Sub UpdateASFSiteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateASFSiteToolStripMenuItem.Click Dim ftpLocation As String = "ftp://" & ftpUname & ":" & ftpPwd & "@" & ftpURL & "/" createPage() Me.Text = "Updating ASF Site..." Threading.Thread.Sleep(100) Dim web As New Net.WebClient web.UploadFile(ftpLocation & "index.htm", System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\index.htm") MessageBox.Show("ASF site update complete!") Me.Text = "A Space Forth" End Sub Private Sub SyncWorker_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles SyncWorker.DoWork sLibrary.Enabled = False sCatLibrary.Enabled = False mSync.Enabled = False mSub.Enabled = False ToolStripTxtFTPURL.Enabled = False ToolStripTxtUname.Enabled = False ToolStripTxtPwd.Enabled = False LoadLibraryToolStripMenuItem.Enabled = False AddFileToLibraryToolStripMenuItem.Enabled = False AddFolderToLibraryToolStripMenuItem.Enabled = False UpdateASFSiteToolStripMenuItem.Enabled = False SyncLibraryWithASFToolStripMenuItem.Enabled = False Dim ftpLocation As String = "ftp://" & ftpUname & ":" & ftpPwd & "@" & ftpURL & "/" Dim i As Integer = 0 Dim curFile As Integer = 1 Dim tFiles As Integer = sLibrary.Rows.Count - 1 tFiles += 1 'Accounting for the .htm file While i < sLibrary.Rows.Count - 1 If sLibrary.Rows.Item(i).Cells.Item(0).Value = False Then tFiles -= 1 End If i += 1 End While i = 0 Me.Text = "Syncing... (File " & curFile.ToString & "/" & tFiles.ToString & ")" createPage() 'Threading.Thread.Sleep(100) Dim web As New Net.WebClient web.UploadFile(ftpLocation & "indexFIG.htm", System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString & "\ASF_Updater\index.htm") web.Dispose() SyncWorker.ReportProgress(System.Convert.ToInt32((curFile / tFiles) * 100)) curFile += 1 Me.Text = "Syncing... (File " & curFile.ToString & "/" & tFiles.ToString & ")" Dim ftp As New Net.WebClient While i < sLibrary.Rows.Count - 1 If sLibrary.Rows.Item(i).Cells.Item(0).Value = True Then ftp.UploadFile(ftpLocation & sLibrary.Rows.Item(i).Cells.Item(1).Value & ".mp3", sLibrary.Rows.Item(i).Cells.Item(4).Value) sLibrary.Rows.Item(i).Cells.Item(0).Value = False SyncWorker.ReportProgress(System.Convert.ToInt32((curFile / tFiles) * 100)) curFile += 1 Me.Text = "Syncing... (File " & curFile.ToString & "/" & tFiles.ToString & ")" End If i += 1 End While ftp.Dispose() MessageBox.Show("Sync complete!") Me.Text = "A Space Forth" sLibrary.Enabled = True sCatLibrary.Enabled = True mSync.Enabled = True mSub.Enabled = True ToolStripTxtFTPURL.Enabled = True ToolStripTxtUname.Enabled = True ToolStripTxtPwd.Enabled = True LoadLibraryToolStripMenuItem.Enabled = True AddFileToLibraryToolStripMenuItem.Enabled = True AddFolderToLibraryToolStripMenuItem.Enabled = True UpdateASFSiteToolStripMenuItem.Enabled = True SyncLibraryWithASFToolStripMenuItem.Enabled = True pBarSync.Value = 0 pBarSync.Visible = False End Sub Private Sub SyncWorker_ProgressChanged(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles SyncWorker.ProgressChanged If e.ProgressPercentage >= 0 Then pBarSync.Value = e.ProgressPercentage End If End Sub End Class