@@ -647,11 +647,16 @@ Class MainWindow
647
647
Dim progressUpdateThread As Thread
648
648
Dim flgProgressUpdateThreadStop = False
649
649
Dim flgProgressUpdateThreadPause = False
650
+ Dim flgHashCheck = CheckBoxSyncOptionHashCheck.IsChecked
650
651
651
652
ProgressBarSyncSub.Maximum = 2
652
653
ProgressBarSyncSub.IsIndeterminate = False
653
654
ProgressBarSyncSub.Value = 0
654
655
656
+ If IsNothing(lstSongs) Then
657
+ GoTo Complete
658
+ End If
659
+
655
660
progressUpdateThread = New Thread( Sub ()
656
661
Do
657
662
Dispatcher.Invoke( Sub ()
@@ -687,7 +692,7 @@ Class MainWindow
687
692
AddSyncLog(LogType.Information, "发现需要删除的项目:" & lstDelete.Count, False )
688
693
AddSyncLog(LogType.Information, "查找需要复制/覆盖的项目" , False )
689
694
Dim lstChanged = Await Task.Run( Function ()
690
- Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, True , progressSubscriber, _flgSyncStop)
695
+ Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, flgHashCheck , progressSubscriber, _flgSyncStop)
691
696
End Function )
692
697
If _flgSyncStop Then
693
698
GoTo Complete
@@ -698,6 +703,7 @@ Class MainWindow
698
703
AddSyncLog(LogType.Information, "正在计算所需空间..." , False )
699
704
ProgressBarSyncSub.Maximum = lstChanged.Count + lstDelete.Count
700
705
706
+ ProgressBarSyncSub.IsIndeterminate = False
701
707
flgProgressUpdateThreadStop = True
702
708
Await Task.Run( Sub ()
703
709
For Each itm In lstChanged
@@ -732,7 +738,9 @@ Class MainWindow
732
738
Next
733
739
End Sub )
734
740
735
- If spaceNeeded > My.Computer.FileSystem.GetDriveInfo(drivePath).TotalFreeSpace And Not CheckBoxSyncOptionNoSpaceCheck.IsChecked Then
741
+ If _
742
+ spaceNeeded > My.Computer.FileSystem.GetDriveInfo(drivePath).TotalFreeSpace And
743
+ Not CheckBoxSyncOptionNoSpaceCheck.IsChecked Then
736
744
Dim errorDlg As New DlgMessageDialog( "同步失败" , "磁盘空间不足" )
737
745
Await DialogHost.Show(errorDlg, "window-root" )
738
746
ProgressBarSyncTotal.Value = 0
@@ -791,16 +799,33 @@ Class MainWindow
791
799
792
800
' Write playlist files
793
801
Await Task.Run( Sub ()
794
-
802
+ Dim lstPlaylists = GetPlaylists()
803
+ For Each p In lstPlaylists
804
+ Try
805
+ AddSyncLog(LogType.Information, "写入:" & wmManagedPath & "\" & p & ".m3u" )
806
+ Dim playlistFile = My.Computer.FileSystem.OpenTextFileWriter(wmManagedPath & "\" & p & ".m3u" , False , Text.Encoding.UTF8)
807
+ For Each s In GetSongsFromPlaylist(p)
808
+ Dim sInfo = GetSongById(s)
809
+ playlistFile.WriteLine(My.Computer.FileSystem.GetFileInfo(sInfo.Path).Name)
810
+ playlistFile.Flush()
811
+ Next
812
+ playlistFile.Close()
813
+ Catch ex As Exception
814
+ AddSyncLog(LogType.Err, ex.Message)
815
+ End Try
816
+ Next
795
817
End Sub )
796
818
797
819
Complete:
798
820
ProgressBarSyncSub.Value = 0
821
+ ProgressBarSyncSub.IsIndeterminate = False
799
822
ProgressBarSyncTotal.Value = 0
800
823
ButtonRemoteSync.Content = _syncRemoteDeviceContent
801
824
Dim msgDlg As New DlgMessageDialog( "" , "同步完成" )
802
- If progressUpdateThread.IsAlive Then
803
- progressUpdateThread.Abort()
825
+ If Not IsNothing(progressUpdateThread) Then
826
+ If progressUpdateThread.IsAlive Then
827
+ progressUpdateThread.Abort()
828
+ End If
804
829
End If
805
830
Await DlgWindowRoot.ShowDialog(msgDlg)
806
831
ButtonRemoteSync.IsEnabled = True
@@ -856,8 +881,8 @@ Complete:
856
881
If ListBoxPlaylist.SelectedItem.Content.GetType = GetType ( String ) Then
857
882
Dim textBoxRenamePlaylist = New TextBox _
858
883
With {.Tag = New Object () {ListBoxPlaylist.SelectedItem, ListBoxPlaylist.SelectedItem.Content},
859
- .Width = ListBoxPlaylist.Width - 20 ,
860
- .Text = ListBoxPlaylist.SelectedItem.Content}
884
+ .Width = ListBoxPlaylist.Width - 20 ,
885
+ .Text = ListBoxPlaylist.SelectedItem.Content}
861
886
AddHandler textBoxRenamePlaylist.KeyDown, AddressOf TextBoxRenamePlaylist_KeyDown
862
887
ListBoxPlaylist.SelectedItem.Content = textBoxRenamePlaylist
863
888
textBoxRenamePlaylist.Focus()
@@ -881,7 +906,6 @@ Complete:
881
906
sender = Nothing
882
907
End If
883
908
End If
884
-
885
909
End Sub
886
910
887
911
Private Sub ListBoxPlaylist_KeyDown(sender As Object , e As KeyEventArgs) Handles ListBoxPlaylist.KeyDown
@@ -893,10 +917,13 @@ Complete:
893
917
Private Async Sub BtnSettings_Click(sender As Object , e As RoutedEventArgs) Handles BtnSettings.Click
894
918
Dim dlg = New DlgSettings
895
919
dlg.Init()
896
- Await DlgWindowRoot.ShowDialog(dlg)
897
- If dlg._flgForceRestart Then
898
- Process.Start(Application.ResourceAssembly.Location)
899
- Environment.Exit( 0 )
900
- End If
920
+ Try
921
+ Await DlgWindowRoot.ShowDialog(dlg)
922
+ If dlg.FlgForceRestart Then
923
+ Process.Start(Application.ResourceAssembly.Location)
924
+ Environment.Exit( 0 )
925
+ End If
926
+ Catch
927
+ End Try
901
928
End Sub
902
929
End Class
0 commit comments