版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、namespace WindowsFormsApplication4 public partial class Form1 : Form #region public Form1() InitializeComponent(); #endregion #region 停止键 private void button3_Click(object sender, EventArgs e) musicPlayer.Ctlcontrols.stop(); #endregion #region 默认设置 private void Form1_Load(object sender, EventArgs e)
2、 /默认皮肤 skinEngine1.SkinFile = skinVISTA1.SSK; /默认图片 pictureBox1.Image = Image.FromFile(Images1.jpg); /调整大小不一致 pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; /关闭自动播放 musicPlayer.settings.autoStart = false; #endregion #region 点多了不知道怎么删 private void skinEngine1_CurrentSkinChanged(object sender
3、, Sunisoft.IrisSkin.SkinChangedEventArgs e) #endregion #region 每两秒自动换图片 int j = 0; private void timer1_Tick(object sender, EventArgs e) string imgPath = Directory.GetFiles(Images); j+; if (j = imgPath.Length) j = 0; pictureBox1.Image = Image.FromFile(imgPathj); #endregion #region 换肤键 int i = 0; priv
4、ate void button1_Click(object sender, EventArgs e) string skinPath = Directory.GetFiles(skin); i+; if (i = skinPath.Length) i = 0; skinEngine1.SkinFile = skinPathi; #endregion #region 播放暂停键 private void button2_Click(object sender, EventArgs e) if (button2.Text = 播放) musicPlayer.Ctlcontrols.play();
5、button2.Text = 暂停; else if (button2.Text = 暂停) musicPlayer.Ctlcontrols.pause(); button2.Text = 播放; #endregion #region 选择文件键 /创建集合 List listSongs = new List(); private void button4_Click(object sender, EventArgs e) /创建打开文件对话框对象 OpenFileDialog ofd = new OpenFileDialog(); /设置对话框的标题 ofd.Title = 请选择音乐文件;
6、 /设置对话框可以多选 ofd.Multiselect = true; /设置打开文件类型 ofd.Filter = 音乐文件|*.mp3|所有文件|*.*; /设置打开文件的初始路径 ofd.InitialDirectory = Songs; /显示对话框 ofd.ShowDialog(); /获得对话框中选中文件的全路径 string filePath = ofd.FileNames; for (int i = 0; i filePath.Length; i+) /将路径存储到泛型集合listSongs中 listSongs.Add(filePathi); /将文件名显示在ListBox控
7、件中 listBox1.Items.Add(Path.GetFileName(filePathi); #endregion #region 上一曲 private void button5_Click(object sender, EventArgs e) int index = listBox1.SelectedIndex; listBox1.SelectedIndices.Clear(); if (index = -1) return; index-; if (index =-1) index = listBox1.Items.Count-1; listBox1.SelectedIndex
8、 = index; musicPlayer.URL = listSongsindex; musicPlayer.Ctlcontrols.play(); button2.Text = 暂停; /加载歌词 LoadLrc(); #endregion #region 双击播放 private void listBox1_DoubleClick(object sender, EventArgs e) if (listBox1.SelectedIndex = -1) return; musicPlayer.URL = listSongslistBox1.SelectedIndex; musicPlaye
9、r.Ctlcontrols.play(); button2.Text = 暂停; /加载歌词 LoadLrc(); #endregion #region 歌词加载函数 private void LoadLrc() /根据正在播放的歌曲获取相应的歌词文件 string songPath = listSongslistBox1.SelectedIndex; string lrcPath = songPath + .lrc; if (File.Exists(lrcPath) string lrcText = File.ReadAllLines(lrcPath, Encoding.Default);
10、/将歌词文件的信息提取出来,分别处理 FormatLrc(lrcText); else /不存在歌词文件 label1.Text = =歌词未找到=; listTime.Clear(); listLrc.Clear(); /存储时间 List listTime = new List(); /存储歌词 List listLrc = new List(); private void FormatLrc(string lrcText) /00:18.58今天我 寒夜里看雪飘过 /lrcTemp0:00:18.58 /lrcTemp1:今天我 寒夜里看雪飘过 for (int i = 0; i lrc
11、Text.Length; i+) string lrcTemp = lrcTexti.Split(new char , , StringSplitOptions.RemoveEmptyEntries); listLrc.Add(lrcTemp1); /00:18.58 /lrcNewTemp0 00 /lrcNewTemp1 18.58 string lrcNewTemp = lrcTemp0.Split(new char : , StringSplitOptions.RemoveEmptyEntries); double time = double.Parse(lrcNewTemp0) *
12、60 + double.Parse(lrcNewTemp1); listTime.Add(time); #endregion #region 下一曲 private void button6_Click(object sender, EventArgs e) int index = listBox1.SelectedIndex; listBox1.SelectedIndices.Clear(); if (index = -1) return; index+; if (index = listBox1.Items.Count) index = 0; listBox1.SelectedIndex
13、= index; musicPlayer.URL = listSongsindex; musicPlayer.Ctlcontrols.play(); button2.Text = 暂停; /加载歌词 LoadLrc(); #endregion #region 右键上下栏删除功能 private void 删除ToolStripMenuItem_Click(object sender, EventArgs e) /获得需要删除的歌曲数量 int count = listBox1.SelectedItems.Count; for (int i = 0; i count; i+) /先删除集合lis
14、tSongs listSongs.RemoveAt(listBox1.SelectedIndex); /后删除列表 listBox1.Items.RemoveAt(listBox1.SelectedIndex); #endregion #region 自动下一曲 private void timer2_Tick(object sender, EventArgs e) /判断当前歌曲是否处于播放状态 if (musicPlayer.playState = WMPLib.WMPPlayState.wmppsPlaying) if (musicPlayer.currentMedia.duration
15、 - musicPlayer.Ctlcontrols.currentPosition = 1) /播放下一曲 int index = listBox1.SelectedIndex; listBox1.SelectedIndices.Clear(); if (index = -1) return; index+; if (index = listBox1.Items.Count) index = 0; listBox1.SelectedIndex = index; musicPlayer.URL = listSongsindex; musicPlayer.Ctlcontrols.play();
16、button2.Text = 暂停; /加载歌词 LoadLrc(); #endregion #region 显示歌词 private void timer3_Tick(object sender, EventArgs e) double currentTime = musicPlayer.Ctlcontrols.currentPosition; for (int i = 0; i = listTimei & currentTime listTimei + 1) label1.Text = listLrci; #endregion #region 窗体缩小显示图标 private void F
17、orm1_Resize(object sender, EventArgs e) /判断form大小做出相应事件反应 if (this.WindowState=FormWindowState.Minimized) this.ShowInTaskbar = false; notifyIcon1.Visible = true; else this.ShowInTaskbar = true; notifyIcon1.Visible = false; #endregion #region 小图标双击事件,复原 private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) this.WindowState = FormWindowState.Normal; #endregion #region 又是删不了的 private void contextMenuStrip2
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 关于完成2026年供应商资质审核的确认函8篇
- 2026雅安教资面试题及答案
- 关于专利申请的事宜函(7篇)范文
- 2026海盗面试题及答案
- 2026年项目融资计划反馈通知函(3篇范文)
- 2026年7月第一师十二团医院人才招聘(4人)笔试参考题库及答案详解
- 2026湖南永州市新田县定向培养毕业生考核招聘笔试模拟试题及答案详解
- 2026广东江门市台山市深诚农业发展有限公司招聘1人考试备考试题及答案详解
- 职业技能鉴定国家试题库试卷高级维修电工及答案
- 2026福建龙岩八中秋季招聘编外教师20人的考试备考题库及答案详解
- 水利工程安全生产保证措施方案
- 《塑料材质食品相关产品质量安全风险管控清单》
- 官方兽医题库及答案(更新版)
- 嵌甲性甲沟炎的外科治疗
- DZ∕T 0270-2014 地下水监测井建设规范(正式版)
- 园林绿化景观工程报价
- (高清版)WST 442-2024 临床实验室生物安全指南
- 办理退休委托书
- 企业安全防汛知识培训
- 08S523 建筑小区塑料排水检查井
- GB/T 8923.1-2011涂覆涂料前钢材表面处理表面清洁度的目视评定第1部分:未涂覆过的钢材表面和全面清除原有涂层后的钢材表面的锈蚀等级和处理等级
评论
0/150
提交评论