diff --git a/FishMusic/FishMusic/FishMusic.csproj b/FishMusic/FishMusic/FishMusic.csproj index a532442..550d85c 100644 --- a/FishMusic/FishMusic/FishMusic.csproj +++ b/FishMusic/FishMusic/FishMusic.csproj @@ -71,6 +71,7 @@ + ..\packages\ControlzEx.3.0.2.4\lib\net40\System.Windows.Interactivity.dll @@ -101,13 +102,14 @@ - + - + + @@ -372,7 +374,7 @@ Downloading.xaml - + DownSetting.xaml @@ -384,6 +386,9 @@ PlayingPage.xaml + + PlaySetting.xaml + DiscoveryView.xaml @@ -399,7 +404,7 @@ SearchView.xaml - + SettingView.xaml @@ -442,7 +447,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -458,6 +463,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -478,7 +487,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer diff --git a/FishMusic/FishMusic/Helper/CommonHelper.cs b/FishMusic/FishMusic/Helper/CommonHelper.cs index 17e2d95..0755da5 100644 --- a/FishMusic/FishMusic/Helper/CommonHelper.cs +++ b/FishMusic/FishMusic/Helper/CommonHelper.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using AnyListen.Models; using FishMusic.Download; +using FishMusic.Model.Setting; using Newtonsoft.Json.Linq; namespace FishMusic.Helper diff --git a/FishMusic/FishMusic/Model/Setting/DownloadSettings.cs b/FishMusic/FishMusic/Model/Setting/DownloadSettings.cs new file mode 100644 index 0000000..92494b4 --- /dev/null +++ b/FishMusic/FishMusic/Model/Setting/DownloadSettings.cs @@ -0,0 +1,134 @@ +using System; +using System.IO; +using GalaSoft.MvvmLight; + +namespace FishMusic.Model.Setting +{ + public class DownloadSettings : ViewModelBase + { + private int _bitRate; + private int _lossType; + private string _downPath; + private string _userFolder; + private string _userName; + private int _nameSelect; + private int _folderSelect; + private bool _downPic; + private bool _downLrc; + private bool _enableUserSetting; + + public int BitRate + { + get => _bitRate; + set + { + _bitRate = value; + RaisePropertyChanged("BitRate"); + } + } + + public int LossType + { + get => _lossType; + set + { + _lossType = value; + RaisePropertyChanged("LossType"); + } + } + + public string DownPath + { + get => _downPath; + set + { + _downPath = value; + RaisePropertyChanged("DownPath"); + } + } + + public string UserFolder + { + get => _userFolder; + set + { + _userFolder = value; + RaisePropertyChanged("UserFolder"); + } + } + + public string UserName + { + get => _userName; + set + { + _userName = value; + RaisePropertyChanged("UserName"); + } + } + + public int NameSelect + { + get => _nameSelect; + set + { + _nameSelect = value; + RaisePropertyChanged("NameSelect"); + } + } + + public int FolderSelect + { + get => _folderSelect; + set + { + _folderSelect = value; + RaisePropertyChanged("FolderSelect"); + } + } + + public bool DownPic + { + get => _downPic; + set + { + _downPic = value; + RaisePropertyChanged("DownPic"); + } + } + + public bool DownLrc + { + get => _downLrc; + set + { + _downLrc = value; + RaisePropertyChanged("DownLrc"); + } + } + + public bool EnableUserSetting + { + get => _enableUserSetting; + set + { + _enableUserSetting = value; + RaisePropertyChanged("EnableUserSetting"); + } + } + + public DownloadSettings() + { + BitRate = 1; + LossType = 0; + DownPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Music"); + DownLrc = false; + DownPic = false; + EnableUserSetting = false; + NameSelect = 1; + FolderSelect = 0; + UserName = "%ARTIST% - %SONG%"; + UserFolder = ""; + } + } +} \ No newline at end of file diff --git a/FishMusic/FishMusic/Model/Setting/PlaySettings.cs b/FishMusic/FishMusic/Model/Setting/PlaySettings.cs new file mode 100644 index 0000000..5281b19 --- /dev/null +++ b/FishMusic/FishMusic/Model/Setting/PlaySettings.cs @@ -0,0 +1,24 @@ +using GalaSoft.MvvmLight; + +namespace FishMusic.Model.Setting +{ + public class PlaySettings : ViewModelBase + { + private int _playQuality; + + public int PlayQuality + { + get => _playQuality; + set + { + _playQuality = value; + RaisePropertyChanged("PlayQuality"); + } + } + + public PlaySettings() + { + PlayQuality = 1; + } + } +} \ No newline at end of file diff --git a/FishMusic/FishMusic/Model/Setting/SoftSetting.cs b/FishMusic/FishMusic/Model/Setting/SoftSetting.cs new file mode 100644 index 0000000..97f4969 --- /dev/null +++ b/FishMusic/FishMusic/Model/Setting/SoftSetting.cs @@ -0,0 +1,43 @@ +using System; +using GalaSoft.MvvmLight; + +namespace FishMusic.Model.Setting +{ + public class SoftSetting : ViewModelBase + { + private DownloadSettings _downSetting; + + public DownloadSettings DownSetting + { + get => _downSetting; + set + { + _downSetting = value; + RaisePropertyChanged("DownSetting"); + } + } + + private PlaySettings _playSetting; + + public PlaySettings PlaySetting + { + get => _playSetting; + set + { + _playSetting = value; + RaisePropertyChanged("PlaySetting"); + } + } + + public string Id { get; set; } + public DateTime UpdateTime { get; set; } + + public SoftSetting() + { + Id = "luooqi"; + UpdateTime = DateTime.Now; + DownSetting = new DownloadSettings(); + PlaySetting = new PlaySettings(); + } + } +} \ No newline at end of file diff --git a/FishMusic/FishMusic/View/Download/Downloaded.xaml b/FishMusic/FishMusic/View/Download/Downloaded.xaml index 7cf9157..b2f1b8c 100644 --- a/FishMusic/FishMusic/View/Download/Downloaded.xaml +++ b/FishMusic/FishMusic/View/Download/Downloaded.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:FishMusic.View.Download" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:converter="clr-namespace:FishMusic.Converter" + xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> @@ -36,7 +37,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FishMusic/FishMusic/View/Setting/DownSetting.xaml.cs b/FishMusic/FishMusic/View/Setting/DownSetting.xaml.cs new file mode 100644 index 0000000..48b23d1 --- /dev/null +++ b/FishMusic/FishMusic/View/Setting/DownSetting.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FishMusic.View.Download +{ + /// + /// DownSetting.xaml 的交互逻辑 + /// + public partial class DownSetting : UserControl + { + public DownSetting() + { + InitializeComponent(); + } + } +} diff --git a/FishMusic/FishMusic/View/Setting/PlaySetting.xaml b/FishMusic/FishMusic/View/Setting/PlaySetting.xaml new file mode 100644 index 0000000..e2201f6 --- /dev/null +++ b/FishMusic/FishMusic/View/Setting/PlaySetting.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FishMusic/FishMusic/View/Setting/PlaySetting.xaml.cs b/FishMusic/FishMusic/View/Setting/PlaySetting.xaml.cs new file mode 100644 index 0000000..b1614b3 --- /dev/null +++ b/FishMusic/FishMusic/View/Setting/PlaySetting.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FishMusic.View.Setting +{ + /// + /// PlaySetting.xaml 的交互逻辑 + /// + public partial class PlaySetting : UserControl + { + public PlaySetting() + { + InitializeComponent(); + } + } +} diff --git a/FishMusic/FishMusic/View/Setting/SettingView.xaml b/FishMusic/FishMusic/View/Setting/SettingView.xaml new file mode 100644 index 0000000..75c10f8 --- /dev/null +++ b/FishMusic/FishMusic/View/Setting/SettingView.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FishMusic/FishMusic/View/Setting/SettingView.xaml.cs b/FishMusic/FishMusic/View/Setting/SettingView.xaml.cs new file mode 100644 index 0000000..3cece4b --- /dev/null +++ b/FishMusic/FishMusic/View/Setting/SettingView.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace FishMusic.View.SubModel +{ + /// + /// Interaction logic for SettingView.xaml + /// + public partial class SettingView : UserControl + { + public SettingView() + { + InitializeComponent(); + } + } +} diff --git a/FishMusic/FishMusic/ViewModel/DownloadViewModel.cs b/FishMusic/FishMusic/ViewModel/DownloadViewModel.cs index d012ff5..cfb21ad 100644 --- a/FishMusic/FishMusic/ViewModel/DownloadViewModel.cs +++ b/FishMusic/FishMusic/ViewModel/DownloadViewModel.cs @@ -13,6 +13,7 @@ using FishMusic.Download; using FishMusic.Helper; using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; using TagLib; using TagLib.Id3v2; using CommonHelper = AnyListen.Helper.CommonHelper; @@ -35,6 +36,18 @@ public int ItemSelIndex } } + private DownloadInfo _selectDownloaded; + + public DownloadInfo SelectDownloaded + { + get => _selectDownloaded; + set + { + _selectDownloaded = value; + RaisePropertyChanged("SelectDownloaded"); + } + } + private ObservableCollection _downloadingCollection = new ObservableCollection(); private ObservableCollection _downloadedCollection = new ObservableCollection(); @@ -77,6 +90,9 @@ public bool TaskStop } } + + public RelayCommand OpenFileCmd { get; set; } + public DownloadViewModel() { InitDownCollection(); @@ -94,6 +110,21 @@ public DownloadViewModel() } })); Task.Factory.StartNew(DownloadSong); + OpenFileCmd = new RelayCommand(OpenFile); + } + + private void OpenFile(object obj) + { + if (SelectDownloaded == null || string.IsNullOrEmpty(SelectDownloaded.FilePath)) + { + return; + } + var info = new FileInfo(SelectDownloaded.FilePath); + if (info.Exists) + { + // ReSharper disable once AssignNullToNotNullAttribute + System.Diagnostics.Process.Start(info.DirectoryName); + } } private void InitDownCollection() diff --git a/FishMusic/FishMusic/ViewModel/PlayViewModel.cs b/FishMusic/FishMusic/ViewModel/PlayViewModel.cs index 9665407..55482c4 100644 --- a/FishMusic/FishMusic/ViewModel/PlayViewModel.cs +++ b/FishMusic/FishMusic/ViewModel/PlayViewModel.cs @@ -8,8 +8,10 @@ using System.Windows.Input; using System.Windows.Interop; using AnyListen.Models; +using CommonServiceLocator; using FishMusic.Download; using FishMusic.Helper; +using FishMusic.Model.Setting; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using MahApps.Metro.IconPacks; @@ -223,6 +225,7 @@ public override void Cleanup() #endregion + private SoftSetting _softSetting; public PlayViewModel() { @@ -271,15 +274,10 @@ public PlayViewModel() return; } PlayingSong = s; - if (s.Type == "sn" || !string.IsNullOrEmpty(s.FlacUrl)) - { - PlaySong(AnyListen.AnyListen.GetRealUrl(string.IsNullOrEmpty(s.FlacUrl) ? s.CopyUrl : s.FlacUrl)); - } - else - { - PlaySong(AnyListen.AnyListen.GetRealUrl(s.CopyUrl)); - } + var songUrl = AnyListen.AnyListen.GetRealUrl(CommonHelper.GetDownloadUrl(s, 0, _softSetting.DownSetting.LossType, false)); + PlaySong(songUrl); })); + _softSetting = ServiceLocator.Current.GetInstance().SoftSetting; } private void GridMouseMove(object obj) @@ -395,7 +393,7 @@ private void PlayClick() } else { - PlaySong(@"http://itwusun.com/files/music/xm_320_1770867412.mp3?sign=9a69f6320e963aad8359c821db79288f"); + PlaySong(@"https://luooqi.com/music/cloud/xm_320_1770824323.mp3?sign=1943de79f63ea6fb1ad91775a1d6167a"); } } } diff --git a/FishMusic/FishMusic/ViewModel/SearchViewModel.cs b/FishMusic/FishMusic/ViewModel/SearchViewModel.cs index 80ade7e..1f2a0d0 100644 --- a/FishMusic/FishMusic/ViewModel/SearchViewModel.cs +++ b/FishMusic/FishMusic/ViewModel/SearchViewModel.cs @@ -8,6 +8,7 @@ using CommonServiceLocator; using FishMusic.Download; using FishMusic.Model; +using FishMusic.Model.Setting; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; @@ -127,7 +128,7 @@ public SearchViewModel() new SearchEngine {Key = "kg", Name = "酷狗音乐"}, new SearchEngine {Key = "kw", Name = "酷我音乐"}, new SearchEngine {Key = "bd", Name = "百度音乐"}, - new SearchEngine {Key = "sn", Name = "索尼音乐"}, + //new SearchEngine {Key = "sn", Name = "索尼音乐"}, }; HotWords = new List {"布衣乐队", "丢火车", "α·Pav", "甜梅号", "田馥甄", "华晨宇", "林俊杰"}; @@ -200,7 +201,7 @@ private void PlaySong(object song) return; } - if (SelectSong == null) + if (SelectSong == null || string.IsNullOrEmpty(SelectSong.SongId)) { SelectSong = (SongResult)song; } diff --git a/FishMusic/FishMusic/ViewModel/SettingViewModel.cs b/FishMusic/FishMusic/ViewModel/SettingViewModel.cs index 2899785..8ddf811 100644 --- a/FishMusic/FishMusic/ViewModel/SettingViewModel.cs +++ b/FishMusic/FishMusic/ViewModel/SettingViewModel.cs @@ -1,7 +1,9 @@ using System.Linq; +using System.Windows.Forms; using FishMusic.Helper; -using FishMusic.Model; +using FishMusic.Model.Setting; using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; namespace FishMusic.ViewModel { @@ -30,9 +32,11 @@ public SoftSetting SoftSetting } } + + public RelayCommand ChangeDownPathCmd { get; set; } + public SettingViewModel() { - SelectIndex = 3; using (var db = DbHelper.GetDatabase()) { var coll = db.GetCollection(); @@ -48,6 +52,17 @@ public SettingViewModel() } } SoftSetting.DownSetting.PropertyChanged += DownSetting_PropertyChanged; + SoftSetting.PlaySetting.PropertyChanged += DownSetting_PropertyChanged; + ChangeDownPathCmd = new RelayCommand(ChangeDownPath); + } + + private void ChangeDownPath(object obj) + { + var dialog = new FolderBrowserDialog(); + if (DialogResult.OK == dialog.ShowDialog()) + { + SoftSetting.DownSetting.DownPath = dialog.SelectedPath; + } } private void DownSetting_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)