Example #1
0
        /// <summary>
        /// 判断同名歌词文件是否存在,若存在则自动加载。
        /// </summary>
        /// <param name="mySong"></param>
        private void LoadLyric(MySong mySong)
        {
            hasLyric = false;
            string path = mySong.FilePath;

            path = path.Replace("mp3", "lrc");
            //尝试在该目录下加载同名歌词文件
            string dir = path.Substring(0, path.LastIndexOf('\\'));

            string[] fileNames = System.IO.Directory.EnumerateFiles(dir, "*.lrc",
                                                                    System.IO.SearchOption.TopDirectoryOnly).ToArray();
            foreach (var item in fileNames)
            {
                if (item.Contains(mySong.SongName))
                {
                    hasLyric = true;
                    InitializeMyLyric(item, "");
                    this.lyricFilePath = item;
                    break;
                }
            }
            if (hasLyric == false)
            {
                if (showDesktopLyricItem.IsChecked == true && dskLrc != null &&
                    dskLrc.IsVisible)
                {
                    dskLrc.ChangeLyricText("没有找到歌词......", "No lyric file exists...");
                    dskLrc.ShowDesktopLyricWithAnimation(1, 1);
                    dskLrc.Show();
                }
                lyricFilePath = string.Empty;
            }
        }
Example #2
0
 /// <summary>
 /// 添加歌曲按钮
 /// </summary>
 /// <param name="openFileDialog">是否打开选择文件对话框</param>
 /// <param name="fileNames">文件路径列表,可为null</param>
 private void AddSong(bool openFileDialog, string[] fileNames)
 {
     if (openFileDialog == true)
     {
         Microsoft.Win32.OpenFileDialog opf = new Microsoft.Win32.OpenFileDialog();
         opf.Filter      = "支持的音频文件|*.mp3;*.mp1;*.mp2;*.mpa;*.mp3pro;*.wav;*.cda;*.cue;*.m4a;*.mp4;*.aac;*.aa;*.ac3;*.wma;*.wmv|所有文件|*.*";
         opf.Multiselect = true;
         opf.FileName    = "";
         opf.Title       = "选择音频文件...";
         if (opf.ShowDialog() == true)
         {
             fileNames = opf.FileNames;
         }
     }
     if (fileNames != null)
     {
         //向列表中添加歌曲文件
         foreach (var str in fileNames)
         {
             bool   exists = false;
             MySong mSong  = new MySong(str);
             for (int i = 0; i < songList.Count; i++)
             {
                 if (mSong.SongName == songList[i].SongName)
                 {
                     exists = true;
                     break;
                 }
             }
             if (!exists)
             {
                 ListBoxItem item = new ListBoxItem();
                 //item.Foreground = new SolidColorBrush(Colors.White);
                 //item.FontSize = 15;
                 item.Content = mSong.SongName;
                 item.Style   = (Style)FindResource("ListBoxItemStyle");
                 //item.Style = null;
                 songList.Add(mSong);
                 item.MouseDoubleClick += item_MouseDoubleClick;
                 songListLB.Items.Add(item);
             }
             mSong = null;
         }
     }
     this.titleTB.Text = string.Format("歌曲列表(共{0}首)", songListLB.Items.Count);
 }
Example #3
0
 public SongDetailInfoFrm(MySong mSong, bool hasLrc)
 {
     InitializeComponent();
     if (mSong != null)
     {
         this.songAlbumTB.Text  = mSong.SongAlbum;
         this.songArtistTB.Text = mSong.SongArtist;
         this.songPathTB.Text   = mSong.FilePath;
         this.songTitleTB.Text  = mSong.SongTitle;
         //音频格式
         string tempStr = mSong.FilePath.Substring(mSong.FilePath.LastIndexOf(".") + 1);
         this.songFormationTB.Text = tempStr;
         //
         if (hasLrc)
         {
             this.songHasLrcTB.Text = "有";
         }
         else
         {
             this.songHasLrcTB.Text = "无";
         }
     }
 }