private void 载ToolStripMenuItem_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { MessageBox.Show("请先选择需要下载的歌曲"); return; } if (!Pub_NetWork()) { this.trackBar1.Enabled = false; return; } else { this.trackBar1.Enabled = true; } if (!Ve()) { return; } DateTime start = DateTime.Now; int rowIndex = dataGridView1.SelectedRows[0].Index; string ID = dataGridView1.SelectedRows[0].Cells["ID"].Value + ""; string SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + ""; string Singer = dataGridView1.SelectedRows[0].Cells["Singer"].Value + ""; string u = StAPIHelper.Ex_Kuwo_GetSongDownUrl(ID); string filepath = StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\") + "\\" + Singer + " - " + SongName + u.Substring(u.LastIndexOf('.')); if (StFile.Exists(filepath, false, false)) { MessageBox.Show("该歌曲已经被下载过啦"); return; } Down(u, StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\"), Singer + " - " + SongName + u.Substring(u.LastIndexOf('.')), "歌曲"); //MessageBox.Show("下载" + (re ? "成功" : "失败")); }
private void 播放ToolStripMenuItem_Click(object sender, EventArgs e) { this.label20.Visible = false; if (dataGridView1.SelectedRows.Count <= 0) { MessageBox.Show("请先选择需要播放的歌曲"); return; } if (!Pub_NetWork()) { this.trackBar1.Enabled = false; return; } else { this.trackBar1.Enabled = true; } //if (!Ve()) return; DateTime start = DateTime.Now; int rowIndex = dataGridView1.SelectedRows[0].Index; string ID = dataGridView1.SelectedRows[0].Cells["ID"].Value + ""; string SongName = dataGridView1.SelectedRows[0].Cells["SongName"].Value + ""; string Singer = dataGridView1.SelectedRows[0].Cells["Singer"].Value + ""; string u = StAPIHelper.Ex_Kuwo_GetSongDownUrl(ID); if (string.IsNullOrEmpty(u)) { MessageBox.Show("资源不存在"); return; } SetSongName(SongName, Singer); axPlayer1.Open(u); CheckedMvOrLrc(1, true); kuwo_lrcs = StAPIHelper.Ex_Kuwo_SearchLyrics(ID); this.richTextBox1.Tag = "0"; this.richTextBox1.Text = string.Join("\r\n", kuwo_lrcs.Values.Select(i => i.TimeStr + "," + i.Text)); if (!string.IsNullOrWhiteSpace(this.richTextBox1.Text)) { this.richTextBox1.Text += "\r\n"; this.richTextBox1.Tag = "1"; kuwo_lrcs_index = 0; lrcPlay_Time = new Timer(); int tttI = Kuwo_GetWainTime(kuwo_lrcs_index, out temp_i); kuwo_lrcs_index += temp_i - 1; int i = richTextBox1.GetFirstCharIndexFromLine(kuwo_lrcs_index); int j = richTextBox1.GetFirstCharIndexFromLine(kuwo_lrcs_index + temp_i);//注意如果要选取最后一行的时候,这里可能会出错,应当直接把j设置成为最后一个字符的位置+1 richTextBox1.Select(i, j - i); this.richTextBox1.SelectionColor = Color.Red; this.richTextBox1.ScrollToCaret(); lrcPlay_Time.Tick += new EventHandler(t_Tick); lrcPlay_Time.Interval = tttI; lrcPlay_Time.Start(); } if (string.IsNullOrWhiteSpace(this.richTextBox1.Text)) { this.richTextBox1.Text = "很抱歉,未能找到您要的歌词"; } //string filepath = StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\") + "\\" + Singer + " - " + SongName + u.Substring(u.LastIndexOf('.')); //if (StFile.Exists(filepath, false, false)) //{ // MessageBox.Show("该歌曲已经被下载过啦"); // return; //} //bool re = StAPIHelper.DownLoad(u, StDirectory.CurrentAppDirectory + "\\" + this.textBox22.Text.Replace("/", "\\"), Singer + " - " + SongName); //this.label18.Text = "上次下载歌曲(" + SongName + ")共耗时 " + StPub.ToPrecision((DateTime.Now - start).TotalSeconds, 2) + " 秒"; //MessageBox.Show("下载" + (re ? "成功" : "失败")); }