版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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年智能驾驶技术与交通法规解读题库
- 2026年程序员面试宝典软件开发练习题
- 2026年心理学基础人格与情绪管理理论题库
- 湖北随州市部分高中2025-2026学年上学期期末联考高二政治试题解析版
- 2026年建筑设计师等级考试模拟试题结构力学应用篇
- 2026年法律知识考试题集合同法与知识产权法
- 2026年市场营销策略消费者行为分析试题
- 2026年程序员面试算法编程能力测试题集
- YC/T 147-2023打叶烟叶质量要求
- T/TAC 9-2024中国时政话语笔译质量评价规范
- T/CMAM W-4-2022维吾尔医常见病诊疗指南妇科
- T/CAQI 129-2020储水式电热水器抗菌、除菌、净化功能技术规范
- 设计单位与施工方的协作配合措施
- 5000吨含氟聚醚胺项目可行性研究报告模板-立项拿地
- 种植金蝉合同协议
- 高管年薪制实施方案
- 新疆克州阿合奇县2024-2025学年七年级上学期期末质量检测英语试卷(含答案及听力原文无音频)
- 沈阳大学硕士学位论文模板(范例)
- 儿童特发性矮身材诊断与治疗中国专家共识(2023版)解读
评论
0/150
提交评论