Skip to content

Commit

Permalink
Merge pull request #6 from guo40020/master
Browse files Browse the repository at this point in the history
Beta3
  • Loading branch information
Kelly authored Jun 3, 2019
2 parents 4fee5b7 + 5e36e7d commit b0781f8
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 133 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ A easy-to-use app to replace Sony MediaCenter with more features and better desi
**THE BETA RELEASE IS HERE!!!**
Download it [here](https://github.com/guo40020/WalkmanManager/releases)

## Authors

* [**Kelly**](https://github.com/guo40020) - *Initial work*
* [**Banyc**](https://github.com/Banyc) - *Initial work* for files in ".\WalkmanManager\music_files_management\" and for this "README.md"

See also [contributors](https://github.com/guo40020/WalkmanManager/graphs/contributors)
## TODO
* [x] Drag to import
* [ ] Match Cover and Lyrics for local songs
* [ ] Tries to Download CloudMusic Playlist
* [ ] Demos in README

## Demos
`It's in TODO (:P)`

## License

Expand Down
2 changes: 1 addition & 1 deletion WalkmanManager.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=34580ef4_002Dafc6_002D4f67_002Dab6a_002D9fa7ae88fe22/FileId/@EntryValue">918DC2FB-7054-47E2-B4AF-9B36843023F0/f:MainWindow.xaml</s:String>
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=34580ef4_002Dafc6_002D4f67_002Dab6a_002D9fa7ae88fe22/Owner/@EntryValue">AnonymousBookmarkManager</s:String>
<s:Boolean x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=e2a02703_002D5bd5_002D48a3_002Dba9c_002D8adee776f074/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=e2a02703_002D5bd5_002D48a3_002Dba9c_002D8adee776f074/Coords/@EntryValue">(Doc Ln 148 Col 11)</s:String>
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=e2a02703_002D5bd5_002D48a3_002Dba9c_002D8adee776f074/Coords/@EntryValue">(Doc Ln 150 Col 11)</s:String>
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=e2a02703_002D5bd5_002D48a3_002Dba9c_002D8adee776f074/FileId/@EntryValue">918DC2FB-7054-47E2-B4AF-9B36843023F0/f:MainWindow.xaml</s:String>
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=e2a02703_002D5bd5_002D48a3_002Dba9c_002D8adee776f074/Owner/@EntryValue">AnonymousBookmarkManager</s:String>
<s:String x:Key="/Default/Profiling/Configurations/=2/@EntryIndexedValue">&lt;data&gt;&lt;HostParameters type="LocalHostParameters" /&gt;&lt;Argument type="StandaloneArgument"&gt;&lt;Arguments IsNull="False"&gt;&lt;/Arguments&gt;&lt;FileName IsNull="False"&gt;&lt;/FileName&gt;&lt;WorkingDirectory IsNull="False"&gt;&lt;/WorkingDirectory&gt;&lt;Scope&gt;&lt;ProcessFilters /&gt;&lt;/Scope&gt;&lt;/Argument&gt;&lt;Info type="TimelineInfo" /&gt;&lt;CoreOptions type="CoreOptions"&gt;&lt;CoreTempPath IsNull="False"&gt;&lt;/CoreTempPath&gt;&lt;RemoteEndPoint&gt;127.0.0.1:55471&lt;/RemoteEndPoint&gt;&lt;AdditionalEnvironmentVariables /&gt;&lt;/CoreOptions&gt;&lt;HostOptions type="HostOptions"&gt;&lt;HostTempPath IsNull="False"&gt;&lt;/HostTempPath&gt;&lt;ReprofileDisableReason&gt;LaunchedByReSharperUnitTestRunner&lt;/ReprofileDisableReason&gt;&lt;/HostOptions&gt;&lt;/data&gt;</s:String></wpf:ResourceDictionary>
44 changes: 22 additions & 22 deletions WalkmanManager/Dialogs/DlgSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
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>
<Label HorizontalAlignment="Left" Foreground="White" VerticalContentAlignment="Center" Margin="10,0,0,0">设置</Label>
<Button HorizontalAlignment="Right" mD:ShadowAssist.ShadowDepth="Depth0" Height="Auto" Command="{x:Static mD:DialogHost.CloseDialogCommand}">
<mD:PackIcon Kind="Close"/>
</Button>
</Grid>
</mD:ColorZone>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,54,0,0">库位置:</Label>
<TextBox x:Name="TextBoxSongDir" VerticalAlignment="Top" Margin="73,54,52,0" IsReadOnly="True" mD:TextFieldAssist.DecorationVisibility="Collapsed" BorderThickness="0,0,0,1"/>
<Button x:Name="ButtonOpen" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,47,10,0" Width="37" Style="{DynamicResource MaterialDesignToolButton}" mD:RippleAssist.RippleSizeMultiplier="1" mD:RippleAssist.IsCentered="True">
<mD:PackIcon Kind="FolderOpen"/>
</Button>
<Grid>
<mD:ColorZone Height="35" Mode="PrimaryMid">
<Grid>
<Label HorizontalAlignment="Left" Foreground="White" VerticalContentAlignment="Center" Margin="10,0,0,0">设置</Label>
<Button HorizontalAlignment="Right" mD:ShadowAssist.ShadowDepth="Depth0" Height="Auto" Command="{x:Static mD:DialogHost.CloseDialogCommand}">
<mD:PackIcon Kind="Close"/>
</Button>
</Grid>
</mD:ColorZone>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,54,0,0">库位置:</Label>
<TextBox x:Name="TextBoxSongDir" VerticalAlignment="Top" Margin="73,54,52,0" IsReadOnly="True" mD:TextFieldAssist.DecorationVisibility="Collapsed" BorderThickness="0,0,0,1"/>
<Button x:Name="ButtonOpen" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,47,10,0" Width="37" Style="{DynamicResource MaterialDesignToolButton}" mD:RippleAssist.RippleSizeMultiplier="1" mD:RippleAssist.IsCentered="True">
<mD:PackIcon Kind="FolderOpen"/>
</Button>

<GroupBox Margin="10,93,10,0" Height="87" VerticalAlignment="Top" Header="数据库维护" BorderThickness="0" mD:ShadowAssist.ShadowDepth="Depth2">
<Grid>
<Button x:Name="ButtonClearSongs" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,0,0,0">删除曲库记录</Button>
<Button x:Name="ButtonClearPlaylist" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="173,0,0,0">清除播放列表</Button>
<Button x:Name="ButtonRebuildDb" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="322,0,0,0">重建数据库</Button>
</Grid>
</GroupBox>
</Grid>
<GroupBox Margin="10,118,10,0" Height="157" VerticalAlignment="Top" Header="数据库维护" BorderThickness="0" mD:ShadowAssist.ShadowDepth="Depth2">
<Grid>
<Button x:Name="ButtonClearSongs" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,0,0,0" Width="407" Style="{DynamicResource MaterialDesignFlatButton}">删除曲库记录</Button>
<Button x:Name="ButtonClearPlaylist" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,37,0,0" Width="407" Style="{DynamicResource MaterialDesignFlatButton}">清除播放列表</Button>
<Button x:Name="ButtonRebuildDb" VerticalAlignment="Top" Margin="20,74,20,0" Style="{DynamicResource MaterialDesignFlatButton}">重建数据库</Button>
</Grid>
</GroupBox>
</Grid>
</mD:DialogHost>
</UserControl>
18 changes: 18 additions & 0 deletions WalkmanManager/Dialogs/dlgDragImport.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<UserControl x:Class="dlgDragImport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mD="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:WalkmanManager"
mc:Ignorable="d" Height="211.481" Width="485.193" Background="White">
<Grid>
<mD:ColorZone Mode="PrimaryMid" Height="35">
<Label Foreground="White" VerticalContentAlignment="Center" Margin="10,0,0,0">导入到曲库</Label>
</mD:ColorZone>
<Grid Margin="0,35,0,0">
<TextBlock x:Name="TextBlockPrompt" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="23,38,0,0">正在导入(0/0)</TextBlock>
<ProgressBar x:Name="ProgressBar" Margin="32,82,29,0" VerticalAlignment="Top" Height="8"></ProgressBar>
</Grid>
</Grid>
</UserControl>
21 changes: 21 additions & 0 deletions WalkmanManager/Dialogs/dlgDragImport.xaml.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Public Class dlgDragImport
Property Progress
Get
Return ProgressBar.Value
End Get
Set(value)
ProgressBar.Value = value
TextBlockPrompt.Text = "正在导入(" & value & "/" & ProgressBar.Maximum & ")"
End Set
End Property

Property Max
Get
Return ProgressBar.Maximum
End Get
Set(value)
ProgressBar.Maximum = value
TextBlockPrompt.Text = "正在导入(" & ProgressBar.Value & "/" & value & ")"
End Set
End Property
End Class
8 changes: 5 additions & 3 deletions WalkmanManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@
PreviewMouseRightButtonDown="BlockRightClickSelection" Width="220" Margin="0,107,0,0">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="MenuDeletePlaylist" Header="删除播放列表" Width="150" Height="50" />
<MenuItem x:Name="MenuRenamePlaylist" Header="重命名" Width="150" Height="50" />
<MenuItem x:Name="MenuDeletePlaylist" Header="删除播放列表" Width="180" Height="50" />
<MenuItem x:Name="MenuRenamePlaylist" Header="重命名" Width="180" Height="50" />
<Separator/>
<MenuItem x:Name="MenuImportPlaylist" Header="导入m3u播放列表" Width="180" Height="50" />
</ContextMenu>
</ListBox.ContextMenu>
<ListBoxItem Padding="15,7,0,7" Tag="NewPlaylist" AllowDrop="True" Drop="ListBoxItem_Drop">
Expand All @@ -98,7 +100,7 @@
</ListBoxItem>
</ListBox>
</Grid>
<Grid x:Name="GridMusic" Margin="220,0,0,0">
<Grid x:Name="GridMusic" Margin="220,0,0,0" Background="#00000000">
<mD:ColorZone Height="45" Background="#FFF3F3F3" mD:ShadowAssist.ShadowDepth="Depth1">
<Grid>
<mD:ColorZone x:Name="PanelSearchLocalMusic" Mode="Standard" mD:ShadowAssist.ShadowDepth="Depth1" Height="35"
Expand Down
116 changes: 114 additions & 2 deletions WalkmanManager/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ Class MainWindow
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)
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)
Expand Down Expand Up @@ -952,7 +953,118 @@ Complete:

Private Sub dlgConvertNcm_Close()
GridRoot.Children.Remove(_toolWindowConvertNcm)
_toolWindowConvertNcm.dispose
_toolWindowConvertNcm.Dispose()
_toolWindowConvertNcm = Nothing
End Sub

Private Async Sub MenuImportPlaylist_Click(sender As Object, e As RoutedEventArgs) Handles MenuImportPlaylist.Click
Dim dlgOpen As New System.Windows.Forms.OpenFileDialog
dlgOpen.Filter = "兼容的播放列表 |*.m3u; *.m3u8"
dlgOpen.Multiselect = False
Dim r = dlgOpen.ShowDialog()
If r = Forms.DialogResult.OK And My.Computer.FileSystem.FileExists(dlgOpen.FileName) Then
Dim files As New List(Of String)
Dim playlistName As String
playlistName = My.Computer.FileSystem.GetFileInfo(dlgOpen.FileName).Name
playlistName = playlistName.Replace("." & My.Computer.FileSystem.GetFileInfo(dlgOpen.FileName).Extension, "")

Dim reader = My.Computer.FileSystem.OpenTextFileReader(dlgOpen.FileName, Text.Encoding.UTF8)
Do Until reader.EndOfStream
Dim t = reader.ReadLine
If Not t.StartsWith("#") Then
files.Add(t)
End If
Loop

'Check path
For i = 0 To files.Count - 1
files(i) = IIf(My.Computer.FileSystem.FileExists(files(i)), files(i),
My.Computer.FileSystem.CombinePath(My.Computer.FileSystem.GetFileInfo(dlgOpen.FileName).DirectoryName,
files(i)))
If Not My.Computer.FileSystem.FileExists(files(i)) Then
files(i) = ""
End If
Next

'Copy to library & add to database
Dim libDir = GetSetting("song_dir")
Dim localDir As String
Dim dlgWait As New dlg_progress()
DlgWindowRoot.ShowDialog(dlgWait)
dlgWait.Text = "0/" & files.Count
Await Task.Run(Sub()
'Add playlist, if there is one with the same name, merge
If Not CheckPlaylistNameAvailability(playlistName) Then
'Create
AddPlaylist(playlistName)
End If
Dim playlistId = GetPlaylistIdByName(playlistName)

For i = 0 To files.Count - 1
Dim audioInfo As New Track(files(i))
Dim songId As Integer
If SongExists(audioInfo.Title, audioInfo.Artist) <> "" Then
'if there is same song, dont copy
songId = FindSong(audioInfo.Title, audioInfo.Artist)(0) 'only take the first one
Else
'copy and add to db
localDir = My.Computer.FileSystem.CombinePath(libDir, My.Computer.FileSystem.GetFileInfo(files(i)).Name)
My.Computer.FileSystem.CopyFile(files(i), localDir, True)
songId = AddSong(audioInfo.Title, audioInfo.Artist, localDir)
dlgWait.Text = (i + 1) & "/" & files.Count
End If
'add to playlist
AddSongToPlaylist(playlistId, songId)

audioInfo = Nothing
Next
dlgWait.Text = "更新列表..."
_lstSongs = GetSongs()
DatSongList.ItemsSource = _lstSongs
End Sub)
DlgWindowRoot.IsOpen = False
End If
End Sub

Private Async Sub DatSongList_Drop(sender As Object, e As DragEventArgs) Handles DatSongList.Drop
If e.Data.GetFormats.Contains("FileNameW") Then
Dim filename() As String = e.Data.GetData("FileNameW")
Dim dlg As New dlgDragImport()
DlgWindowRoot.ShowDialog(dlg)
dlg.Max = filename.Count
Await Task.Run(Sub()
Dim libDir = GetSetting("song_dir")
Dim localDir As String

For i = 0 To filename.Count - 1
'Check extension
If Not DbUpdater.CheckExtention(filename(i)) Then
Continue For
End If
localDir = My.Computer.FileSystem.CombinePath(libDir, My.Computer.FileSystem.GetFileInfo(filename(i)).Name)
Dim audioInfo As New Track(localDir)
If SongExists(audioInfo.Title, audioInfo.Artist) = "" Then
My.Computer.FileSystem.CopyFile(filename(i), localDir, True)
AddSong(audioInfo.Title, audioInfo.Artist, localDir)
Dispatcher.Invoke(Sub() dlg.Progress += 1)
End If
audioInfo = Nothing
Next

Dispatcher.Invoke(Sub() dlg.ProgressBar.IsIndeterminate = True)
_lstSongs = GetSongs()

End Sub)
DlgWindowRoot.IsOpen = False
End If
End Sub

Private Sub DatSongList_DragOver(sender As Object, e As DragEventArgs) Handles DatSongList.DragOver
If e.Data.GetFormats.Contains("FileNameW") Or e.Data.GetFormats.Contains("GongSolutions.Wpf.DragDrop") Then
e.Effects = DragDropEffects.All
Else
e.Effects = DragDropEffects.None
End If
e.Handled = True
End Sub
End Class
21 changes: 0 additions & 21 deletions WalkmanManager/SongItm.xaml

This file was deleted.

60 changes: 0 additions & 60 deletions WalkmanManager/SongItm.xaml.vb

This file was deleted.

Loading

0 comments on commit b0781f8

Please sign in to comment.