コード例 #1
0
 public string getMergeKey()
 {
     return(Singer.Replace(" ", "") + SongName.Replace(" ", ""));
 }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: windygu/KtvMS
        private void btnStartDownLoad_Click(object sender, EventArgs e)
        {
            try
            {
                tsState.Value   = 0;
                tsState.Visible = true;

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (downloader == null)
                {
                    downloader = new SongDownloader(provider, path);
                }

                foreach (ListViewItem item in lvSongs.CheckedItems)
                {
                    timer1.Enabled  = true;
                    timer1.Interval = 100;
                    MergedSong1 song = (MergedSong1)item.Tag;
                    downloader.AddDownload(song);

                    //若路径更改,则不往库中保存数据
                    if (txtDownLoadPath.Text.Trim() == Directory.GetCurrentDirectory() + @"\misucs\")
                    {
                        //判断歌手是否已存在,若不存在则添加
                        if (!isExeitsSinger(song.Singer))
                        {
                            KtvMSModel.Singer singer = new KtvMSModel.Singer();
                            singer.Name = song.Singer;
                            singerManager.AddSingerInfo(singer);
                        }

                        //根据歌名判断歌曲是否存在,
                        if (!newSongManager.isExeitsSongByName(song.SongName))
                        {
                            Song1 song1 = new Song1();
                            song1.SongName = song.SongName;
                            song1.Singer   = song.Singer;
                            song1.Source   = song.Source;
                            song1.Duration = song.Duration;                                                //播放时间
                            song1.Size     = Convert.ToDouble((song.Size / (1024 * 1024)).ToString("F2")); //歌曲文件大小


                            int row = newSongManager.AddSong(song1);//添加歌曲
                            if (row > 0)
                            {
                                int songId = newSongManager.GetSongIdByName(song.SongName);
                                if (songId != null && songId != 0)
                                {
                                    downloadSongManger.AddDownloadSong(songId);//下载记录
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
 public string getFileName()
 {
     return(Singer.Trim() + "-" + SongName.Trim() + ".mp3");
 }