版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 第一单元第一节《体育礼仪与修养》课件+2025-2026学年人教版初中体育与健康八年级全一册
- 某著名企业私有云解决方案概览
- 抽动障碍总结2026
- 《GBT 139-2008使用硫酸亚铁剂量计测量水中吸收剂量的标准方法》专题研究报告
- 《GBT 22152-2008 国际货运代理业务统计导则》专题研究报告
- 《GBT 17590-2008铝易开盖三片罐》专题研究报告
- 道路安全培训有效时间课件
- 道路交通与安全课件
- 2026年度定点医疗机构医保业务知识考试试题解析及答案
- 2026年甘肃省高职单招职业适应性测试试题题库(答案+解析)
- 2025四川眉山市国有资本投资运营集团有限公司招聘50人笔试参考题库附带答案详解
- 边坡喷锚施工方案
- YS/T 3045-2022埋管滴淋堆浸提金技术规范
- 项目进度跟进及完成情况汇报总结报告
- 峨眉山城市介绍旅游宣传课件
- 浙江省温州市乐清市2023-2024学年五年级上学期期末语文试题
- 土壤改良合同模板
- 2024年中国成人心肌炎临床诊断与治疗指南解读课件
- 2024年新疆文旅旅游投资集团招聘笔试冲刺题(带答案解析)
- JT-T-915-2014机动车驾驶员安全驾驶技能培训要求
- (高清版)WST 442-2024 临床实验室生物安全指南
评论
0/150
提交评论