主界面代码
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 using System.Data.SqlClient; 11 12 namespace 私属音乐点播 13 { 14 public partial class frmMain : Form 15 { 16 public frmMain() 17 { 18 InitializeComponent(); 19 } 20 DBHelper db = new DBHelper(); 21 /// <summary> 22 /// lv的目标界面定义,0歌曲,1歌手,2国家,3性别, 23 /// 亮点 24 /// </summary> 25 int num = 0; //lv的目标界面定义,0歌曲,1歌手,2国家,3性别,4字数 26 //单击歌星点歌按钮事件 27 private void tsbtnTool_singer_Click(object sender, EventArgs e) 28 { 29 //目标项在表中的个数 30 string strCounts=@"select COUNT(1) from singer_info"; 31 //查询歌手Id和歌手名字,私有dr方法 32 string str = @"select singer_id,singer_name from singer_info"; 33 //获取歌手方法 34 GetSinger(strCounts, str); 35 } 36 //双击lv_Login组件事件 37 string gender = "男"; 38 private void lv_Login_DoubleClick(object sender, EventArgs e) 39 { 40 41 //亮点 42 switch (num) 43 { 44 //歌曲双击事件 45 case 0: 46 int result = Convert.ToInt32(lv_Login.SelectedItems[0].Tag); 47 DoubleClickSong(result); 48 break; 49 //歌手双击事件 50 case 1: 51 int singerId = Convert.ToInt32(lv_Login.SelectedItems[0].Tag); 52 string str = @"select song_id,song_name,singer_name,song_play_count from song_info,singer_info where song_info.singer_id=" + singerId + " and song_info.singer_id = singer_info.singer_id"; 53 num = 0; 54 SingerToSongs(str); 55 break; 56 //国家双击事件 57 case 2: 58 int type_id = Convert.ToInt32(lv_Login.SelectedItems[0].Tag); 59 string strCount = @"select count(1) from singer_info where singer_sex='" + gender + "' and singertype_id=" + type_id + ""; 60 string strInfo=@"select singer_id,singer_name from singer_info where singer_sex='" + gender + "' and singertype_id=" + type_id + ""; 61 //下一个lv_Login为歌曲,num=1 62 num = 1; 63 GetSinger(strCount,strInfo); 64 break; 65 //性别双击事件 66 case 3: 67 gender = lv_Login.SelectedItems[0].Text; 68 //下一个为歌手地区,num值为2 69 num = 2; 70 //搞出国家lv方法 71 GetSingerType(); 72 break; 73 //字数点歌 74 case 4: 75 num = 0; 76 string playCount; 77 if (Convert.ToInt32(lv_Login.SelectedItems[0].Tag)!=11) 78 { 79 playCount = @"select song_id,song_name,singer_name,song_play_count from song_info,singer_info where song_word_count = " + lv_Login.SelectedItems[0].Tag + " and song_info.singer_id = singer_info.singer_id"; 80 } 81 else 82 { 83 playCount = @"select song_id,song_name,singer_name,song_play_count from song_info,singer_info where song_word_count > 10 and song_info.singer_id = singer_info.singer_id"; 84 } 85 SingerToSongs(playCount); 86 break; 87 //其他非合法组件双击事件,直接跳出 88 default: 89 //不用思索,直接跳出 90 return; 91 } 92 } 93 //类型点歌按钮事件 94 private void tsbtnTool_type_Click(object sender, EventArgs e) 95 { 96 //打开性别lv 97 //目标lv为性别,所以num为3 98 num = 3; 99 imglist.Images.Clear(); 100 lv_Login.Clear(); 101 lv_Login.Controls.Clear(); 102 lv_Login.View = View.LargeIcon; 103 try 104 { 105 imglist.ImageSize = new Size(166, 168); 106 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\male.png")); 107 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\female.png")); 108 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\couple.png")); 109 } 110 catch (Exception) 111 { 112 imglist.ImageSize = new Size(100, 100); 113 ListViewItem male1 = new ListViewItem("男"); 114 ListViewItem female1 = new ListViewItem("女"); 115 ListViewItem couple1 = new ListViewItem("组合"); 116 lv_Login.Items.Add(male1); 117 lv_Login.Items.Add(female1); 118 lv_Login.Items.Add(couple1); 119 return; 120 } 121 lv_Login.LargeImageList = imglist; 122 ListViewItem male = new ListViewItem("男", 0); 123 ListViewItem female = new ListViewItem("女", 1); 124 ListViewItem couple = new ListViewItem("组合", 2); 125 lv_Login.Items.Add(male); 126 lv_Login.Items.Add(female); 127 lv_Login.Items.Add(couple); 128 } 129 #region 拼音点歌事件 130 private void tsbtnTool_pinyin_Click(object sender, EventArgs e) 131 { 132 lv_Login.Clear(); 133 lv_Login.Controls.Add(txt); 134 lv_Login.Controls.Add(lbl); 135 txt.Location = new Point(200, 10); 136 txt.Size = new System.Drawing.Size(new Point(150, 18)); 137 txt.Focus(); 138 lbl.Text = "(请输入要查找的歌曲拼音或缩写)"; 139 lbl.Font = new Font("幼圆", 10); 140 lbl.ForeColor = Color.Blue; 141 lbl.Location = new Point(350, 10); 142 lbl.Size = new Size(new Point(250, 18)); 143 txt.TextChanged += txt_TextChanged; 144 lvNew.Location = new Point(-1, 40); 145 lvNew.Size = new Size(680, 580); 146 lvNew.FullRowSelect = true; 147 lvNew.View = View.Details; 148 lvNew.Columns.Clear(); 149 lvNew.Columns.Add("歌曲名称", 300); 150 lvNew.Columns.Add("歌手", 150); 151 lvNew.Columns.Add("点播次数", 100); 152 lvNew.DoubleClick += lvNew_DoubleClick; 153 lv_Login.Controls.Add(lvNew); 154 } 155 //添加三个个控件 156 TextBox txt = new TextBox(); 157 Label lbl = new Label(); 158 ListView lvNew = new ListView(); 159 //lv_Login的新添项lvNew的Items双击事件 160 private void lvNew_DoubleClick(object sender, EventArgs e) 161 { 162 //在这里引用歌曲双击事件 163 int result = Convert.ToInt32(lvNew.SelectedItems[0].Tag); 164 //MessageBox.Show(result.ToString()); 165 DoubleClickSong(result); 166 } 167 //new出的txt的text值改变时事件 168 private void txt_TextChanged(object sender, EventArgs e) 169 { 170 lvNew.Items.Clear(); 171 string result=""; 172 if (!txt.Text.Trim().Equals(string.Empty)) 173 { 174 foreach (char item in txt.Text) 175 { 176 if (item>='a'&&item<='z') 177 { 178 result += item; 179 result += '%'; 180 }else if (item>='A'&&item<='Z') 181 { 182 result += item.ToString().ToLower(); 183 result += '%'; 184 } 185 } 186 } 187 string str; 188 if (!result.Equals(string.Empty)) 189 { 190 str = @"select song_id,song_name,singer_name,song_play_count from song_info,singer_info where song_ab like '%" + result + "%' and song_info.singer_id = singer_info.singer_id"; 191 } 192 else 193 { 194 return; 195 } 196 try 197 { 198 SqlDataReader dr = db.Dr(str); 199 if (dr.HasRows) 200 { 201 while (dr.Read()) 202 { 203 ListViewItem item = new ListViewItem(dr["song_name"].ToString()); 204 item.Tag = dr["song_id"].ToString(); 205 item.SubItems.Add(dr["singer_name"].ToString()); 206 item.SubItems.Add(dr["song_play_count"].ToString()); 207 lvNew.Items.Add(item); 208 } 209 dr.Close(); 210 } 211 } 212 catch (Exception) 213 { 214 MessageBox.Show("私有连接异常!"); 215 } 216 finally 217 { 218 db.CloseConnection(); 219 } 220 } 221 #endregion 222 //金榜排行按钮点击事件 223 private void tsbtnTool_order_Click(object sender, EventArgs e) 224 { 225 imglist.Images.Clear(); 226 lv_Login.SmallImageList = imglist; 227 string str = @"select top 10 song_id,song_name,singer_name,song_play_count from song_info,singer_info where song_info.singer_id=singer_info.singer_id order by song_play_count desc"; 228 num = 0; 229 SingerToSongs(str); 230 lv_Login.View = View.List; 231 imglist.ImageSize = new Size(60, 60); 232 try 233 { 234 for (int i = 0; i < 10; i++) 235 { 236 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\" + i + ".png")); 237 lv_Login.Items[i].ImageIndex = i; 238 } 239 } 240 catch (Exception) 241 { 242 243 } 244 } 245 //单击字数点歌按钮事件 246 private void tsbtnTool_counts_Click(object sender, EventArgs e) 247 { 248 //目标lv_Login为字数lv, num为4 249 num = 4; 250 lv_Login.Clear(); 251 lv_Login.Controls.Clear(); 252 imglist.Images.Clear(); 253 lv_Login.LargeImageList = imglist; 254 imglist.ImageSize = new System.Drawing.Size(60, 60); 255 lv_Login.View = View.LargeIcon; 256 for (int i = 1; i < 11; i++) 257 { 258 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\" + i + ".png")); 259 ListViewItem item = new ListViewItem((i) + "个字",i-1); 260 item.Tag = i+1; 261 lv_Login.Items.Add(item); 262 } 263 imglist.Images.Add(Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image\N.png")); 264 ListViewItem itemN = new ListViewItem("N个字", 10); 265 itemN.Tag = 11; 266 lv_Login.Items.Add(itemN); 267 } 268 //定时器事件 269 private void timer_Tick(object sender, EventArgs e) 270 { 271 Playing(); 272 } 273 /// <summary> 274 /// 歌手双击方法 275 /// </summary> 276 /// <param name="str">查询歌曲语句</param> 277 public void SingerToSongs(string str) 278 { 279 num = 0; 280 lv_Login.View = View.Details; 281 lv_Login.Clear(); 282 lv_Login.Controls.Clear(); 283 lv_Login.Columns.Add("歌曲名称", 300); 284 lv_Login.Columns.Add("歌手", 150); 285 lv_Login.Columns.Add("点播次数", 100); 286 try 287 { 288 SqlDataReader dr = db.Dr(str); 289 if (dr.HasRows) 290 { 291 while (dr.Read()) 292 { 293 ListViewItem item = new ListViewItem(dr["song_name"].ToString()); 294 item.Tag = dr["song_id"].ToString(); 295 item.SubItems.Add(dr["singer_name"].ToString()); 296 item.SubItems.Add(dr["song_play_count"].ToString()); 297 lv_Login.Items.Add(item); 298 } 299 dr.Close(); 300 } 301 } 302 catch (Exception) 303 { 304 MessageBox.Show("私有连接异常!"); 305 } 306 finally 307 { 308 db.CloseConnection(); 309 } 310 } 311 /// <summary> 312 /// 播放列表专属数组 313 /// </summary> 314 Song[] playing_list = new Song[100]; 315 /// <summary> 316 /// 歌曲双击方法 317 /// </summary> 318 /// <param name="result">双击歌曲项的Tag值</param> 319 public void DoubleClickSong(int result) 320 { 321 //循环判定 322 foreach (Song song in playing_list) 323 { 324 if (song!=null && song.SongId == result.ToString()) 325 { 326 MessageBox.Show("已点!"); 327 return; 328 } 329 else if (song==null) 330 { 331 break; 332 } 333 } 334 int i = 0; 335 foreach (Song one in playing_list) 336 { 337 if (one != null) 338 i++; 339 } 340 string str = @"select song_name from song_info where song_id = " + result + ""; 341 try 342 { 343 SqlDataReader dr = db.Dr(str); 344 if (dr.HasRows) 345 { 346 if (dr.Read()) 347 { 348 playing_list[i] = new Song(); 349 playing_list[i].SongName = dr["song_name"].ToString(); 350 playing_list[i].SongId = result.ToString(); 351 } 352 } 353 dr.Close(); 354 } 355 catch (Exception) 356 { 357 MessageBox.Show("私有连接异常!"); 358 } 359 finally 360 { 361 db.CloseConnection(); 362 if (playing_list[i]!=null) 363 { 364 playing_list[i].Songurl = GetSongurlById(result.ToString()); 365 } 366 } 367 ListViewItem item = new ListViewItem(playing_list[i].SongName); 368 ///注意 369 ///注意 370 if (i == 0) 371 { 372 item.SubItems.Add("正在播放"); 373 wmp.URL = playing_list[i].Songurl; 374 try 375 { 376 SetPlayCount(playing_list[i].SongId); 377 } 378 catch (Exception ex) 379 { 380 MessageBox.Show(ex.Message); 381 } 382 } 383 else 384 { 385 item.SubItems.Add("未播放"); 386 try 387 { 388 SetPlayCount(playing_list[i].SongId); 389 } 390 catch (Exception ex) 391 { 392 MessageBox.Show(ex.Message); 393 } 394 } 395 item.SubItems.Add(playing_list[i].SongId); 396 item.Tag = playing_list[i].Songurl; 397 lvPlay_list.Items.Add(item); 398 timer.Enabled = true; 399 } 400 /// 当前播放的歌曲在对象数组中的下标 401 /// </summary> 402 int playingIndex = 0; 403 /// <summary> 404 /// 播放方法 405 /// </summary> 406 public void Playing() 407 { 408 //重新写 409 if (wmp.playState==WMPLib.WMPPlayState.wmppsPlaying) 410 { 411 try 412 { 413 //面板信息更改 414 lblPlaying_name.Text = playing_list[playingIndex].SongName; 415 lblNext_name.Text = playing_list[playingIndex+1].SongName; 416 } 417 catch (Exception) 418 { 419 lblNext_name.Text = "无"; 420 } 421 } 422 else if (wmp.playState == WMPLib.WMPPlayState.wmppsStopped) 423 { 424 try 425 { 426 //状态更新 427 lvPlay_list.Items[playingIndex].SubItems[1].Text = "已播放"; 428 } 429 catch (Exception) 430 { 431 return; 432 } 433 playingIndex++; 434 //为播放列表的最后一个时,返回index,跳出方法 435 if (playing_list[playingIndex] == null) 436 { 437 playingIndex--; 438 wmp.URL = string.Empty; 439 return; 440 } 441 wmp.URL = playing_list[playingIndex].Songurl; 442 lvPlay_list.Items[playingIndex].SubItems[1].Text = "正在播放"; 443 //面板提示信息更新 444 lblPlaying_name.Text = playing_list[playingIndex].SongName; 445 try 446 { 447 lblNext_name.Text = playing_list[playingIndex + 1].SongName; 448 } 449 catch (Exception) 450 { 451 lblNext_name.Text = "无"; 452 } 453 } 454 //歌曲读取异常(为空,或,路径异常) 455 else if (wmp.playState==WMPLib.WMPPlayState.wmppsReady) 456 { 457 if (wmp.URL==string.Empty) 458 { 459 //只要路径为空,只需要判定播放列表是否为空,否则直接播放 460 if (playing_list[playingIndex] == null) 461 { 462 return; 463 } 464 wmp.URL = playing_list[playingIndex].Songurl; 465 try 466 { 467 lvPlay_list.Items[playingIndex].SubItems[1].Text = "正在播放"; 468 } 469 catch (Exception) 470 { 471 return; 472 } 473 //面板提示信息更新 474 lblPlaying_name.Text = playing_list[playingIndex].SongName; 475 try 476 { 477 lblNext_name.Text = playing_list[playingIndex +1].SongName; 478 } 479 catch (Exception) 480 { 481 lblNext_name.Text = "无"; 482 } 483 } 484 else 485 { 486 lvPlay_list.Items[playingIndex].SubItems[1].Text = "路径异常"; 487 playingIndex++; 488 //为播放列表的最后一个时,返回index,跳出方法 489 if (playing_list[playingIndex] == null) 490 { 491 wmp.URL = string.Empty; 492 return; 493 } 494 wmp.URL = playing_list[playingIndex].Songurl; 495 try 496 { 497 lvPlay_list.Items[playingIndex].SubItems[1].Text = "正在播放"; 498 } 499 catch (Exception) 500 { 501 return; 502 } 503 504 //面板提示信息更新 505 lblPlaying_name.Text = playing_list[playingIndex].SongName; 506 try 507 { 508 lblNext_name.Text = playing_list[playingIndex + 1].SongName; 509 } 510 catch (Exception) 511 { 512 lblNext_name.Text = "无"; 513 } 514 } 515 } 516 else 517 { 518 return; 519 } 520 } 521 /// <summary> 522 /// 根据歌手id查找歌手图片路径 523 /// </summary> 524 /// <param name="id">singerId</param> 525 /// <returns>singerPhotoUrl</returns> 526 public string GetSingerurlById(string id) 527 { 528 string str2 = @"select resource_path from resource where resource_type='歌手图片地址'"; 529 string singerphoto_url = db.ScalForString(str2); 530 string str = @"select singer_photo_url from singer_info where singer_id='" + id + "'"; 531 string singer_url = db.ScalForString(str); 532 string sb = singerphoto_url + singer_url; 533 return sb; 534 } 535 /// <summary> 536 /// 根据歌曲id查找歌曲路径 537 /// </summary> 538 /// <param name="id">songId</param> 539 /// <returns>songUrl</returns> 540 public string GetSongurlById(string id) 541 { 542 string str = @"select resource_path from resource where resource_type = '歌曲地址'"; 543 StringBuilder sb = new StringBuilder(db.ScalForString(str)); 544 string str2 = @"select song_url from song_info where song_id = " + id + ""; 545 sb.Append(db.ScalForString(str2)); 546 return sb.ToString(); 547 } 548 /// <summary> 549 /// 播放次数更新方法 550 /// </summary> 551 /// <param name="songId">歌曲Id的字符串格式</param> 552 /// <returns>是否成功</returns> 553 public bool SetPlayCount(string songId) 554 { 555 int result; 556 string str1 = @"select song_play_count from song_info where song_id=" + songId + ""; 557 try 558 { 559 result = Convert.ToInt32(db.Scal(str1)); 560 } 561 catch (Exception) 562 { 563 result = 0; 564 } 565 result++; 566 string str = @"update song_info set song_play_count = " + result + " where song_id=" + songId + ""; 567 if (db.Non(str)>0) 568 { 569 return true; 570 } 571 else 572 { 573 return false; 574 } 575 } 576 /// <summary> 577 /// new国家lv_Login方法 578 /// </summary> 579 private void GetSingerType() 580 { 581 lv_Login.Clear(); 582 lv_Login.Controls.Clear(); 583 imglist.Images.Clear(); 584 lv_Login.View = View.LargeIcon; 585 lv_Login.LargeImageList = imglist; 586 string str1 = @"select count(1) from singer_type"; 587 int result; 588 try 589 { 590 result = Convert.ToInt32(db.Scal(str1)); 591 } 592 catch (Exception) 593 { 594 return; 595 } 596 string str = @"select singertype_id, singertype_name from singer_type"; 597 try 598 { 599 SqlDataReader dr = db.Dr(str); 600 if (dr.HasRows) 601 { 602 for (int i = 0; i < result; i++) 603 { 604 dr.Read(); 605 Image img; 606 try 607 { 608 img = Image.FromFile(@"D:\课程\S1\KTV\MyKTV\image" + Convert.ToString(dr["singertype_name"]) + ".png"); 609 } 610 catch (Exception) 611 { 612 img = Image.FromFile("D:\\课程\\S1\\KTV\\MyKTV\\image\\singer_temp.jpg"); 613 } 614 imglist.Images.Add(img); 615 ListViewItem item = new ListViewItem(dr["singertype_name"].ToString(),i); 616 item.Tag = Convert.ToString(dr["singertype_id"]); 617 lv_Login.Items.Add(item); 618 } 619 } 620 dr.Close(); 621 } 622 catch (Exception) 623 { 624 MessageBox.Show("歌手地区读取异常!"); 625 } 626 finally 627 { 628 db.CloseConnection(); 629 } 630 } 631 /// <summary> 632 /// 获取歌手信息 633 /// </summary> 634 /// <param name="strCounts">条件下歌手个数查询语句</param> 635 /// <param name="str">条件下歌手信息查询语句</param> 636 private void GetSinger(string strCounts, string str) 637 { 638 //歌手lv的目标lv为歌曲 639 num = 1; 640 imglist.Images.Clear(); 641 lv_Login.Clear(); 642 lv_Login.Controls.Clear(); 643 lv_Login.View = View.LargeIcon; 644 //确定大图标的图像列表对象 645 lv_Login.LargeImageList = imglist; 646 imglist.ImageSize = new System.Drawing.Size(72, 128); 647 int result = db.ScalForInt(strCounts); 648 SqlCommand comm = new SqlCommand(str, db.conn); 649 //new出对象数组,用于存储目标表格信息 650 Song[] song = new Song[result]; 651 try 652 { 653 db.OpenConnection(); 654 SqlDataReader dr = comm.ExecuteReader(); 655 if (dr != null) 656 if (dr.HasRows) 657 { 658 for (int i = 0; i < result; i++) 659 { 660 if (dr.Read()) 661 { 662 //读取了歌手id,歌手名称 663 song[i] = new Song(); 664 song[i].SingerId = dr["singer_id"].ToString(); 665 song[i].SingerName = dr["singer_name"].ToString(); 666 } 667 } 668 dr.Close(); 669 } 670 } 671 catch (Exception) 672 { 673 MessageBox.Show("私有连接异常!"); 674 } 675 finally 676 { 677 db.CloseConnection(); 678 } 679 680 //改变imagelist的图片大小:imglist.ImageSize = new Size(32, 32); 681 682 //循环读出图片url,加载对应图片到imglist,给items组合项添加对象数组中每一项 683 for (int i = 0; i < result; i++) 684 { 685 song[i].SingerPhoto = GetSingerurlById(song[i].SingerId); 686 Image img; 687 //亮点 688 try 689 { 690 img = Image.FromFile(song[i].SingerPhoto); 691 } 692 catch (Exception) 693 { 694 img = Image.FromFile("D:\\课程\\S1\\KTV\\MyKTV\\image\\singer_temp.jpg"); 695 } 696 imglist.Images.Add(img); 697 ListViewItem item = new ListViewItem(song[i].SingerName, i); 698 item.Tag = song[i].SingerId; 699 lv_Login.Items.Add(item); 700 } 701 } 702 #region 删除播放列表歌曲,双击播放 703 ////删除选中歌曲按钮事件 704 private void btnDel_Click(object sender, EventArgs e) 705 { 706 int result; 707 try 708 { 709 result = Convert.ToInt32(lvPlay_list.SelectedItems[0].Index); 710 } 711 catch (Exception) 712 { 713 return; 714 } 715 //清空对象数组与列表 716 lvPlay_list.SelectedItems[0].Remove(); 717 ///亮点 718 if (result == playingIndex) 719 { 720 721 try 722 { 723 if (playing_list[result + 1] != null) 724 { 725 for (int i = result + 1; i < playing_list.Length; i++) 726 { 727 playing_list[i - 1].SongId = playing_list[i].SongId; 728 playing_list[i - 1].SongName = playing_list[i].SongName; 729 playing_list[i - 1].Songurl = playing_list[i].Songurl; 730 } 731 wmp.URL = playing_list[result].Songurl; 732 } 733 else 734 { 735 playing_list[result] = playing_list[result + 1]; 736 wmp.URL = string.Empty; 737 } 738 } 739 catch (Exception) 740 { 741 wmp.URL = string.Empty; 742 } 743 } 744 745 } 746 ////双击播放列表组件时 747 private void lvPlay_list_DoubleClick(object sender, EventArgs e) 748 { 749 try 750 { 751 wmp.URL = playing_list[Convert.ToInt32(lvPlay_list.SelectedItems[0].Index)].Songurl; 752 lvPlay_list.Items[playingIndex].SubItems[1].Text = "已播放"; 753 playingIndex = Convert.ToInt32(lvPlay_list.SelectedItems[0].Index); 754 lvPlay_list.Items[playingIndex].SubItems[1].Text = "正在播放"; 755 } 756 catch (Exception) 757 { 758 return; 759 } 760 } 761 ////列表循环方式按钮点击事件 762 private void btnState_Click(object sender, EventArgs e) 763 { 764 // Timer timeResult = new Timer(); 765 // if (btnState.Text=="列表循环模式") 766 // { 767 // btnState.Text = "单曲循环模式"; 768 // timer.Enabled = false; 769 // timeResult.Enabled = true; 770 // timeResult.Interval = 1000; 771 // timeResult.Tick += timeResult_Tick; 772 // } 773 // else if (btnState.Text=="单曲循环模式") 774 // { 775 // btnState.Text = "无循环模式"; 776 // timer.Enabled = true; 777 // timeResult.Enabled = false; 778 // } 779 // else if (btnState.Text=="无循环模式") 780 // { 781 // btnState.Text = "列表循环模式"; 782 // timer.Enabled = false; 783 // timeResult.Enabled = true; 784 // timeResult.Interval = 1000; 785 // timeResult.Tick += timeResult_Tick; 786 // } 787 } 788 ////附加定时器事件 789 void timeResult_Tick(object sender, EventArgs e) 790 { 791 792 // if (wmp.playState==WMPLib.WMPPlayState.wmppsStopped&&btnState.Text=="单曲循环模式") 793 // { 794 // wmp.URL = playing_list[playingIndex].Songurl; 795 // } 796 // else if (btnState.Text=="列表循环模式") 797 // { 798 // int result=-1; 799 // foreach (Song item in playing_list) 800 // { 801 // if (item!=null) 802 // { 803 // result++; 804 // } 805 // else 806 // { 807 // break; 808 // } 809 // } 810 // if (playingIndex==result) 811 // { 812 // playingIndex = 0; 813 // } 814 // } 815 } 816 #endregion 817 818 } 819 }