Skip to content

Commit

Permalink
beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyiscute committed May 3, 2019
1 parent 557c6b9 commit 164568d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 33 deletions.
14 changes: 0 additions & 14 deletions WalkmanManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27703.2000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WalkmanManager", "WalkmanManager\WalkmanManager.vbproj", "{918DC2FB-7054-47E2-B4AF-9B36843023F0}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnitTest", "UnitTest\UnitTest.vbproj", "{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,18 +27,6 @@ Global
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x64.Build.0 = Release|x64
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x86.ActiveCfg = Release|x86
{918DC2FB-7054-47E2-B4AF-9B36843023F0}.Release|x86.Build.0 = Release|x86
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x64.ActiveCfg = Debug|x64
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x64.Build.0 = Debug|x64
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x86.ActiveCfg = Debug|x86
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Debug|x86.Build.0 = Debug|x86
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|Any CPU.Build.0 = Release|Any CPU
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x64.ActiveCfg = Release|x64
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x64.Build.0 = Release|x64
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x86.ActiveCfg = Release|x86
{8C6F2FDB-D5C3-44DD-8FA4-18B80F6A4CCE}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions WalkmanManager/Dialogs/DlgSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:local="clr-namespace:WalkmanManager"
xmlns:mD="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" Height="310" Width="485">
<mD:DialogHost x:Name="Dialog">
<Grid>
<mD:ColorZone Height="35" Mode="PrimaryMid">
<Grid>
Expand All @@ -29,4 +30,5 @@
</Grid>
</GroupBox>
</Grid>
</mD:DialogHost>
</UserControl>
18 changes: 16 additions & 2 deletions WalkmanManager/Dialogs/DlgSettings.xaml.vb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Imports System.Windows.Forms
Imports MaterialDesignThemes.Wpf.DialogHostEx

Public Class DlgSettings
Public Property _flgForceRestart As Boolean = False
Public Property FlgForceRestart As Boolean = False

Public Sub Init()
TextBoxSongDir.Text = My.Computer.FileSystem.GetDirectoryInfo(Database.GetSetting("song_dir")).FullName
Expand All @@ -14,16 +15,29 @@ Public Class DlgSettings
Console.WriteLine(dlg.SelectedPath)
Database.SaveSetting("song_dir", dlg.SelectedPath)
TextBoxSongDir.Text = dlg.SelectedPath
_flgForceRestart = True
FlgForceRestart = True
End If
End Using
End Sub

Private Sub showOKDialog()
Dim dlg As New DlgMessageDialog("", "操作完成")
Dialog.ShowDialog(dlg)
End Sub

Private Sub ButtonClearPlaylist_Click(sender As Object, e As RoutedEventArgs) Handles ButtonClearPlaylist.Click
Database.InitPlaylists()
showOKDialog()
End Sub

Private Sub ButtonClearSongs_Click(sender As Object, e As RoutedEventArgs) Handles ButtonClearSongs.Click
Database.InitSongLib()
showOKDialog()
End Sub

Private Sub ButtonRebuildDb_Click(sender As Object, e As RoutedEventArgs) Handles ButtonRebuildDb.Click
FlgForceRestart = True
Database.ClearDatabase()
showOKDialog()
End Sub
End Class
7 changes: 4 additions & 3 deletions WalkmanManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</Grid>
</mD:DialogHost>
</Grid>
<Grid x:Name="GridCloudMusic" Margin="0,55,0,0">
<Grid x:Name="GridCloudMusic" Margin="0,55,0,0" d:IsHidden="True">
<!-- Visibility="Hidden"-->
<mD:DialogHost x:Name="DlgCloudMusic">
<Grid>
Expand Down Expand Up @@ -227,7 +227,7 @@
</mD:DialogHost>
</Grid>

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

<Grid Margin="248,0,275,0">
<ScrollViewer Margin="0,10,0,10" VerticalScrollBarVisibility="Auto">
<WrapPanel>
<WrapPanel Height="24">
<CheckBox x:Name="CheckBoxSyncOptionNoSpaceCheck" FontSize="14" Margin="20,0,0,0">不检查空间</CheckBox>
<CheckBox x:Name="CheckBoxSyncOptionDoNotCopyLyric" FontSize="14" Margin="20,0,0,0">不同步歌词</CheckBox>
<CheckBox x:Name="CheckBoxSyncOptionHashCheck" FontSize="14" Margin="20,0,0,0">进行散列值检查(消耗大量时间)</CheckBox>
</WrapPanel>
</ScrollViewer>
</Grid>
Expand Down
53 changes: 40 additions & 13 deletions WalkmanManager/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,16 @@ Class MainWindow
Dim progressUpdateThread As Thread
Dim flgProgressUpdateThreadStop = False
Dim flgProgressUpdateThreadPause = False
Dim flgHashCheck = CheckBoxSyncOptionHashCheck.IsChecked

ProgressBarSyncSub.Maximum = 2
ProgressBarSyncSub.IsIndeterminate = False
ProgressBarSyncSub.Value = 0

If IsNothing(lstSongs) Then
GoTo Complete
End If

progressUpdateThread = New Thread(Sub()
Do
Dispatcher.Invoke(Sub()
Expand Down Expand Up @@ -687,7 +692,7 @@ Class MainWindow
AddSyncLog(LogType.Information, "发现需要删除的项目:" & lstDelete.Count, False)
AddSyncLog(LogType.Information, "查找需要复制/覆盖的项目", False)
Dim lstChanged = Await Task.Run(Function()
Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, True, progressSubscriber, _flgSyncStop)
Return SyncAnalyzer.FindChangedFiles(wmManagedPath, lstSongs, flgHashCheck, progressSubscriber, _flgSyncStop)
End Function)
If _flgSyncStop Then
GoTo Complete
Expand All @@ -698,6 +703,7 @@ Class MainWindow
AddSyncLog(LogType.Information, "正在计算所需空间...", False)
ProgressBarSyncSub.Maximum = lstChanged.Count + lstDelete.Count

ProgressBarSyncSub.IsIndeterminate = False
flgProgressUpdateThreadStop = True
Await Task.Run(Sub()
For Each itm In lstChanged
Expand Down Expand Up @@ -732,7 +738,9 @@ Class MainWindow
Next
End Sub)

If spaceNeeded > My.Computer.FileSystem.GetDriveInfo(drivePath).TotalFreeSpace And Not CheckBoxSyncOptionNoSpaceCheck.IsChecked Then
If _
spaceNeeded > My.Computer.FileSystem.GetDriveInfo(drivePath).TotalFreeSpace And
Not CheckBoxSyncOptionNoSpaceCheck.IsChecked Then
Dim errorDlg As New DlgMessageDialog("同步失败", "磁盘空间不足")
Await DialogHost.Show(errorDlg, "window-root")
ProgressBarSyncTotal.Value = 0
Expand Down Expand Up @@ -791,16 +799,33 @@ Class MainWindow

' Write playlist files
Await Task.Run(Sub()

Dim lstPlaylists = GetPlaylists()
For Each p In lstPlaylists
Try
AddSyncLog(LogType.Information, "写入:" & wmManagedPath & "\" & p & ".m3u")
Dim playlistFile = My.Computer.FileSystem.OpenTextFileWriter(wmManagedPath & "\" & p & ".m3u", False, Text.Encoding.UTF8)
For Each s In GetSongsFromPlaylist(p)
Dim sInfo = GetSongById(s)
playlistFile.WriteLine(My.Computer.FileSystem.GetFileInfo(sInfo.Path).Name)
playlistFile.Flush()
Next
playlistFile.Close()
Catch ex As Exception
AddSyncLog(LogType.Err, ex.Message)
End Try
Next
End Sub)

Complete:
ProgressBarSyncSub.Value = 0
ProgressBarSyncSub.IsIndeterminate = False
ProgressBarSyncTotal.Value = 0
ButtonRemoteSync.Content = _syncRemoteDeviceContent
Dim msgDlg As New DlgMessageDialog("", "同步完成")
If progressUpdateThread.IsAlive Then
progressUpdateThread.Abort()
If Not IsNothing(progressUpdateThread) Then
If progressUpdateThread.IsAlive Then
progressUpdateThread.Abort()
End If
End If
Await DlgWindowRoot.ShowDialog(msgDlg)
ButtonRemoteSync.IsEnabled = True
Expand Down Expand Up @@ -856,8 +881,8 @@ Complete:
If ListBoxPlaylist.SelectedItem.Content.GetType = GetType(String) Then
Dim textBoxRenamePlaylist = New TextBox _
With {.Tag = New Object() {ListBoxPlaylist.SelectedItem, ListBoxPlaylist.SelectedItem.Content},
.Width = ListBoxPlaylist.Width - 20,
.Text = ListBoxPlaylist.SelectedItem.Content}
.Width = ListBoxPlaylist.Width - 20,
.Text = ListBoxPlaylist.SelectedItem.Content}
AddHandler textBoxRenamePlaylist.KeyDown, AddressOf TextBoxRenamePlaylist_KeyDown
ListBoxPlaylist.SelectedItem.Content = textBoxRenamePlaylist
textBoxRenamePlaylist.Focus()
Expand All @@ -881,7 +906,6 @@ Complete:
sender = Nothing
End If
End If

End Sub

Private Sub ListBoxPlaylist_KeyDown(sender As Object, e As KeyEventArgs) Handles ListBoxPlaylist.KeyDown
Expand All @@ -893,10 +917,13 @@ Complete:
Private Async Sub BtnSettings_Click(sender As Object, e As RoutedEventArgs) Handles BtnSettings.Click
Dim dlg = New DlgSettings
dlg.Init()
Await DlgWindowRoot.ShowDialog(dlg)
If dlg._flgForceRestart Then
Process.Start(Application.ResourceAssembly.Location)
Environment.Exit(0)
End If
Try
Await DlgWindowRoot.ShowDialog(dlg)
If dlg.FlgForceRestart Then
Process.Start(Application.ResourceAssembly.Location)
Environment.Exit(0)
End If
Catch
End Try
End Sub
End Class
15 changes: 15 additions & 0 deletions WalkmanManager/Utils/Database.vb
Original file line number Diff line number Diff line change
Expand Up @@ -965,4 +965,19 @@ Public Class Database
cmd.ExecuteNonQuery()
conn.Close()
End Sub

Public Shared Sub ClearDatabase()
Dim conn = Connect()
Dim cmd = conn.CreateCommand
cmd.CommandText = "DROP TABLE playlists"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE playlist_detail"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE songs"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE settings"
cmd.ExecuteNonQuery()
conn.Close()
CreateDatabase()
End Sub
End Class
2 changes: 1 addition & 1 deletion WalkmanManager/Utils/Synchronizer.vb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Public Class Synchronizer

Dim sourceFile = New BinaryReader(New FileStream(source, FileMode.Open))
_totalLength = sourceFile.BaseStream.Length
_chunkSize = 512 * 1024 'Initial Chunk Size = .5MB
_chunkSize = 1024 * 1024 'Initial Chunk Size = 1MB
Dim destinationFile = New BinaryWriter(New FileStream(destination, FileMode.OpenOrCreate))
'Prepare variables
Dim rTime As Long
Expand Down

0 comments on commit 164568d

Please sign in to comment.