Skip to content

Commit 164568d

Browse files
committed
beta release
1 parent 557c6b9 commit 164568d

File tree

7 files changed

+78
-33
lines changed

7 files changed

+78
-33
lines changed

WalkmanManager.sln

-14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27703.2000
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WalkmanManager", "WalkmanManager\WalkmanManager.vbproj", "{918DC2FB-7054-47E2-B4AF-9B36843023F0}"
77
EndProject
8-
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnitTest", "UnitTest\UnitTest.vbproj", "{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}"
9-
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1210
Debug|Any CPU = Debug|Any CPU
@@ -29,18 +27,6 @@ Global
2927
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x64.Build.0 = Release|x64
3028
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x86.ActiveCfg = Release|x86
3129
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x86.Build.0 = Release|x86
32-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x64.ActiveCfg = Debug|x64
35-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x64.Build.0 = Debug|x64
36-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x86.ActiveCfg = Debug|x86
37-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x86.Build.0 = Debug|x86
38-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|Any CPU.Build.0 = Release|Any CPU
40-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x64.ActiveCfg = Release|x64
41-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x64.Build.0 = Release|x64
42-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x86.ActiveCfg = Release|x86
43-
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x86.Build.0 = Release|x86
4430
EndGlobalSection
4531
GlobalSection(SolutionProperties) = preSolution
4632
HideSolutionNode = FALSE

WalkmanManager/Dialogs/DlgSettings.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:local="clr-namespace:WalkmanManager"
77
xmlns:mD="http://materialdesigninxaml.net/winfx/xaml/themes"
88
mc:Ignorable="d" Height="310" Width="485">
9+
<mD:DialogHost x:Name="Dialog">
910
<Grid>
1011
<mD:ColorZone Height="35" Mode="PrimaryMid">
1112
<Grid>
@@ -29,4 +30,5 @@
2930
</Grid>
3031
</GroupBox>
3132
</Grid>
33+
</mD:DialogHost>
3234
</UserControl>

WalkmanManager/Dialogs/DlgSettings.xaml.vb

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Imports System.Windows.Forms
2+
Imports MaterialDesignThemes.Wpf.DialogHostEx
23

34
Public Class DlgSettings
4-
Public Property _flgForceRestart As Boolean = False
5+
Public Property FlgForceRestart As Boolean = False
56

67
Public Sub Init()
78
TextBoxSongDir.Text = My.Computer.FileSystem.GetDirectoryInfo(Database.GetSetting("song_dir")).FullName
@@ -14,16 +15,29 @@ Public Class DlgSettings
1415
Console.WriteLine(dlg.SelectedPath)
1516
Database.SaveSetting("song_dir", dlg.SelectedPath)
1617
TextBoxSongDir.Text = dlg.SelectedPath
17-
_flgForceRestart = True
18+
FlgForceRestart = True
1819
End If
1920
End Using
2021
End Sub
2122

23+
Private Sub showOKDialog()
24+
Dim dlg As New DlgMessageDialog("", "操作完成")
25+
Dialog.ShowDialog(dlg)
26+
End Sub
27+
2228
Private Sub ButtonClearPlaylist_Click(sender As Object, e As RoutedEventArgs) Handles ButtonClearPlaylist.Click
2329
Database.InitPlaylists()
30+
showOKDialog()
2431
End Sub
2532

2633
Private Sub ButtonClearSongs_Click(sender As Object, e As RoutedEventArgs) Handles ButtonClearSongs.Click
34+
Database.InitSongLib()
35+
showOKDialog()
36+
End Sub
2737

38+
Private Sub ButtonRebuildDb_Click(sender As Object, e As RoutedEventArgs) Handles ButtonRebuildDb.Click
39+
FlgForceRestart = True
40+
Database.ClearDatabase()
41+
showOKDialog()
2842
End Sub
2943
End Class

WalkmanManager/MainWindow.xaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
</Grid>
145145
</mD:DialogHost>
146146
</Grid>
147-
<Grid x:Name="GridCloudMusic" Margin="0,55,0,0">
147+
<Grid x:Name="GridCloudMusic" Margin="0,55,0,0" d:IsHidden="True">
148148
<!-- Visibility="Hidden"-->
149149
<mD:DialogHost x:Name="DlgCloudMusic">
150150
<Grid>
@@ -227,7 +227,7 @@
227227
</mD:DialogHost>
228228
</Grid>
229229

230-
<Grid x:Name="GridRemote" Margin="0,55,0,0" d:IsHidden="True">
230+
<Grid x:Name="GridRemote" Margin="0,55,0,0">
231231
<Grid Margin="0,0,0,95">
232232
</Grid>
233233
<mD:ColorZone VerticalAlignment="Top" Margin="10,10,10,0" Height="70" CornerRadius="10"
@@ -245,9 +245,10 @@
245245

246246
<Grid Margin="248,0,275,0">
247247
<ScrollViewer Margin="0,10,0,10" VerticalScrollBarVisibility="Auto">
248-
<WrapPanel>
248+
<WrapPanel Height="24">
249249
<CheckBox x:Name="CheckBoxSyncOptionNoSpaceCheck" FontSize="14" Margin="20,0,0,0">不检查空间</CheckBox>
250250
<CheckBox x:Name="CheckBoxSyncOptionDoNotCopyLyric" FontSize="14" Margin="20,0,0,0">不同步歌词</CheckBox>
251+
<CheckBox x:Name="CheckBoxSyncOptionHashCheck" FontSize="14" Margin="20,0,0,0">进行散列值检查(消耗大量时间)</CheckBox>
251252
</WrapPanel>
252253
</ScrollViewer>
253254
</Grid>

WalkmanManager/MainWindow.xaml.vb

+40-13
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,16 @@ Class MainWindow
647647
Dim progressUpdateThread As Thread
648648
Dim flgProgressUpdateThreadStop = False
649649
Dim flgProgressUpdateThreadPause = False
650+
Dim flgHashCheck = CheckBoxSyncOptionHashCheck.IsChecked
650651

651652
ProgressBarSyncSub.Maximum = 2
652653
ProgressBarSyncSub.IsIndeterminate = False
653654
ProgressBarSyncSub.Value = 0
654655

656+
If IsNothing(lstSongs) Then
657+
GoTo Complete
658+
End If
659+
655660
progressUpdateThread = New Thread(Sub()
656661
Do
657662
Dispatcher.Invoke(Sub()
@@ -687,7 +692,7 @@ Class MainWindow
687692
AddSyncLog(LogType.Information, "发现需要删除的项目:" & lstDelete.Count, False)
688693
AddSyncLog(LogType.Information, "查找需要复制/覆盖的项目", False)
689694
Dim lstChanged = Await Task.Run(Function()
690-
Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, True, progressSubscriber, _flgSyncStop)
695+
Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, flgHashCheck, progressSubscriber, _flgSyncStop)
691696
End Function)
692697
If _flgSyncStop Then
693698
GoTo Complete
@@ -698,6 +703,7 @@ Class MainWindow
698703
AddSyncLog(LogType.Information, "正在计算所需空间...", False)
699704
ProgressBarSyncSub.Maximum = lstChanged.Count + lstDelete.Count
700705

706+
ProgressBarSyncSub.IsIndeterminate = False
701707
flgProgressUpdateThreadStop = True
702708
Await Task.Run(Sub()
703709
For Each itm In lstChanged
@@ -732,7 +738,9 @@ Class MainWindow
732738
Next
733739
End Sub)
734740

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
736744
Dim errorDlg As New DlgMessageDialog("同步失败", "磁盘空间不足")
737745
Await DialogHost.Show(errorDlg, "window-root")
738746
ProgressBarSyncTotal.Value = 0
@@ -791,16 +799,33 @@ Class MainWindow
791799

792800
' Write playlist files
793801
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
795817
End Sub)
796818

797819
Complete:
798820
ProgressBarSyncSub.Value = 0
821+
ProgressBarSyncSub.IsIndeterminate = False
799822
ProgressBarSyncTotal.Value = 0
800823
ButtonRemoteSync.Content = _syncRemoteDeviceContent
801824
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
804829
End If
805830
Await DlgWindowRoot.ShowDialog(msgDlg)
806831
ButtonRemoteSync.IsEnabled = True
@@ -856,8 +881,8 @@ Complete:
856881
If ListBoxPlaylist.SelectedItem.Content.GetType = GetType(String) Then
857882
Dim textBoxRenamePlaylist = New TextBox _
858883
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}
861886
AddHandler textBoxRenamePlaylist.KeyDown, AddressOf TextBoxRenamePlaylist_KeyDown
862887
ListBoxPlaylist.SelectedItem.Content = textBoxRenamePlaylist
863888
textBoxRenamePlaylist.Focus()
@@ -881,7 +906,6 @@ Complete:
881906
sender = Nothing
882907
End If
883908
End If
884-
885909
End Sub
886910

887911
Private Sub ListBoxPlaylist_KeyDown(sender As Object, e As KeyEventArgs) Handles ListBoxPlaylist.KeyDown
@@ -893,10 +917,13 @@ Complete:
893917
Private Async Sub BtnSettings_Click(sender As Object, e As RoutedEventArgs) Handles BtnSettings.Click
894918
Dim dlg = New DlgSettings
895919
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
901928
End Sub
902929
End Class

WalkmanManager/Utils/Database.vb

+15
Original file line numberDiff line numberDiff line change
@@ -965,4 +965,19 @@ Public Class Database
965965
cmd.ExecuteNonQuery()
966966
conn.Close()
967967
End Sub
968+
969+
Public Shared Sub ClearDatabase()
970+
Dim conn = Connect()
971+
Dim cmd = conn.CreateCommand
972+
cmd.CommandText = "DROP TABLE playlists"
973+
cmd.ExecuteNonQuery()
974+
cmd.CommandText = "DROP TABLE playlist_detail"
975+
cmd.ExecuteNonQuery()
976+
cmd.CommandText = "DROP TABLE songs"
977+
cmd.ExecuteNonQuery()
978+
cmd.CommandText = "DROP TABLE settings"
979+
cmd.ExecuteNonQuery()
980+
conn.Close()
981+
CreateDatabase()
982+
End Sub
968983
End Class

WalkmanManager/Utils/Synchronizer.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Public Class Synchronizer
6565

6666
Dim sourceFile = New BinaryReader(New FileStream(source, FileMode.Open))
6767
_totalLength = sourceFile.BaseStream.Length
68-
_chunkSize = 512 * 1024 'Initial Chunk Size = .5MB
68+
_chunkSize = 1024 * 1024 'Initial Chunk Size = 1MB
6969
Dim destinationFile = New BinaryWriter(New FileStream(destination, FileMode.OpenOrCreate))
7070
'Prepare variables
7171
Dim rTime As Long

0 commit comments

Comments
 (0)