




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
功能简介:1、循环模式:顺不播放axWMusicPlayer.settings.setMode(shuffle, false); 全部循环axWMusicPlayer.settings.setMode(loop, true); 随机播放axWMusicPlayer.settings.setMode(shuffle, true); 2、模拟定时关机程序写到定时关机,具体的调用定时关机程序省略了,程序中相应地方有注解。定时关机代码 1 private void 关机时间toolStripTextBox_KeyPress(object sender, KeyPressEventArgs e)2 3 if (e.KeyChar = (char)Keys.Enter & 关机时间toolStripTextBox.Text != )4 5 try6 7 DateTime time = DateTime.Parse(关机时间toolStripTextBox.Text);8 Timefont font = new Timefont(time.Hour, time.Minute, 0);9 if (font.CompareTo(new Timefont(DateTime.Now.Hour, DateTime.Now.Minute, 0) = 0) /当前关机时间10 11 if (MessageBox.Show(你设定的关机时间是当前计算机时间,是否直接关机?, 提示, MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.OK)12 13 MynotifyIcon.Icon = Icon.ExtractAssociatedIcon(PathBase + Images + ShutDown_notifyIcon.ico);14 /15 /调用关机程序16 /17 18 else19 20 return;21 22 23 if (font.CompareTo(new Timefont(DateTime.Now.Hour, DateTime.Now.Minute, 0) 0) /有效关机时间29 30 31 ShutDownTime = 关机时间toolStripTextBox.Text;32 MessageBox.Show(成功设置定时关机,计算机将于“ + ShutDownTime + ”关机 *, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);33 this.关机时间toolStripTextBox.Visible = false;34 this.取消定时关机QToolStripMenuItem.Visible = true;35 36 /37 /调用关机程序38 /39 40 41 catch42 43 MessageBox.Show(日期格式不正确,请重新输入。, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);44 return;45 46 47 if (e.KeyChar = (char)Keys.Enter & 关机时间toolStripTextBox.Text = )48 49 关机时间toolStripTextBox.Visible = false;50 51 3、歌曲列表信息保存在XML文件中添加歌曲保存代码 1 private void btnList_Click(object sender, EventArgs e) /添加歌曲2 3 openFileDialog1.Title = 添加歌曲;4 openFileDialog1.FileName = ;5 openFileDialog1.Multiselect = true;6 openFileDialog1.Filter = Mp3文件|*.mp3|Wav文件|*.wav|Wma文件|*.wma|Wmv文件|*.wmv|所有格式|*.*;7 openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);8 try9 10 if (openFileDialog1.ShowDialog() = DialogResult.OK)11 12 /IsCreateXmlFile();13 XmlDocument xmldoc = new XmlDocument();14 xmldoc.Load(xmlfile);15 XmlNode root = xmldoc.SelectSingleNode(MusicList);16 string FileNamesList = openFileDialog1.FileNames;17 foreach (string file in FileNamesList)18 19 string filename= Path.GetFileName(file).Substring(0,Path.GetFileName(file).LastIndexOf(.);20 axWMusicPlayer.currentPlaylist.appendItem(axWMusicPlayer.newMedia(file);21 XmlElement newelement = xmldoc.CreateElement(MusicProperty);22 newelement.SetAttribute(MusicUrl, file);23 newelement.SetAttribute(MusicName, filename);24 newelement.SetAttribute(LikeCount, 0);25 root.AppendChild(newelement);26 Application.DoEvents();27 28 xmldoc.Save(xmlfile);29 30 31 catch(Exception ex)32 33 MessageBox.Show(ex.Message, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);34 35 4、主界面上的喜爱按钮实现的是歌曲排列顺序在下次启动程序后,程序会自动将喜爱点击次数多的歌曲排到前面喜爱按钮事件 1 private void btnFavorite_Click(object sender, EventArgs e) /喜爱2 3 if (axWMusicPlayer.currentMedia != null)4 5 XmlDocument doc = new XmlDocument();6 doc.Load(xmlfile);7 XmlNodeList nodelist = doc.SelectSingleNode(MusicList).ChildNodes;8 foreach (XmlNode node in nodelist)9 10 XmlElement element = (XmlElement)node; /将XmlNode节点node转化成XmlElement型的node11 if (element.GetAttribute(MusicUrl) = axWMusicPlayer.currentMedia.sourceURL)12 13 int likecount = Convert.ToInt32(element.GetAttribute(LikeCount) + 1;14 element.SetAttribute(LikeCount, likecount.ToString();15 16 17 doc.Save(xmlfile);18 19 5、点击进度条歌曲直接跳到当前位置继续播放设置当前播放位置private void pictureBox2_MouseDown(object sender, MouseEventArgs e) if (e.Button = MouseButtons.Left) axWMusicPlayer.Ctlcontrols.currentPosition = e.X * axWMusicPlayer.currentMedia.duration / 170; 注解:170为进度条总长度6、进度条采用自定义控件自定义进度条控件代码 1 / 2 / 迷你音乐播放器3 / 4 /漓江烟雨 5 /6484452136 /2011.12.3 7 / 8 / 9 10 11 namespace UCCurrentTime12 13 public partial class UserControl1 : UserControl14 15 / 16 / 设置或获取当前播放进度条的宽度17 / 18 public int UCTime19 20 get return this.Width; 21 set 22 23 if (this.Width = 16)24 25 this.Width = value;26 27 else28 29 this.Width = value + 16;30 31 32 33 34 35 / 36 / 设置或获取当前播放进度条左边背景图片37 / 38 public Image LeftBackImage39 40 get return picBoxLeft.BackgroundImage; 41 set picBoxLeft.BackgroundImage = value; 42 43 44 / 45 / 设置或获取当前播放进度条右边背景图片46 / 47 public Image RightBackImage 48 49 get return picBoxRight.BackgroundImage; 50 set picBoxRight.BackgroundImage = value; 51 52 53 / 54 / 设置或获取当前播放进度条中间背景图片55 / 56 public Image MiddleBackImage 57 58 get return picBoxMiddle.BackgroundImage; 59 set picBoxMiddle.BackgroundImage = value; 60 61 public UserControl1()62 63 InitializeComponent();64 65 picBoxLeft.Size = new Size(8, 10); /左边66 picBoxRight.Size = new Size(8, 10); /右边67 picBoxMiddle.Size = new Size(0, 10); /中间68 69 picBoxLeft.Dock = DockStyle.Left;70 picBoxRight.Dock = DockStyle.Right;71 picBoxMiddle.Width = this.Width - 16;72 picBoxMiddle.Location = new Point(8, 0);73 74 this.BackColor = Color.Transparent;75 picBoxLeft.BackColor = Color.Transparent;76 picBoxRight.BackColor = Color.Transparent;77 picBoxMiddle.BackColor = Color.Transparent;78 79 picBoxLeft.BackgroundImage = LeftBackImage;80 picBoxRight.BackgroundImage = RightBackImage;81 picBoxMiddle.BackgroundImage = MiddleBackImage;82 83 84 private void UserControl1_SizeChanged(object sender, EventArgs e)85 86 this.Size = new Size(UCTime, 10);87 picBoxMiddle.Width = this.Width - 16;88 89 90 timer_tick事件timer_tick事件代码 1 private void timer1_Tick(object sender, EventArgs e)2 3 try4 5 if (axWMusicPlayer.currentMedia != null)6 7 if (axWMusicPlayer.currentM.Length 9)8 9 lblMusicName.Text = axWMusicPlayer.currentM.Substring(0, 9) + .;10 11 else12 13 lblMusicName.Text = axWMusicPlayer.currentM;14 15 lblcurrenttime.Text = axWMusicPlayer.Ctlcontrols.currentPositionString + / + axWMusicPlayer.currentMedia.durationString;16 UCcurrenttime = Convert.ToInt32(axWMusicPlayer.Ctlcontrols.currentPosition / axWMusicPlayer.currentMedia.duration * 170);17 if (UCcurrenttime = 16)18 19 UCcurrenttime = 16;20 21 this.userControl11.Width = UCcurrenttime;22 23 24 catch25 26 return;27 28 this.userControl11.Width = UCcurrenttime; 设置进度条长度7、由于去掉了默认的标题框所以自己添加了鼠标拖动事件鼠标拖动窗体代码 private void MiniMusicPlayer_MouseDown(object sender, MouseEventArgs e)if (e.Button = MouseButtons.Left)FormPositioX = e.X;FormPositioY = e.Y;private void MiniMusicPlayer_MouseMove(object sender, MouseEventArgs e)if (e.Button = MouseButtons.Left)this.Left += e.X - FormPositioX;this.Top += e.Y - FormPositioY;8、检测窗体位置,超出了屏幕范围会自动靠边处理窗体被拖动到屏幕外 1 private void MiniMusicPlayer_MouseUp(object sender, MouseEventArgs e)2 3 if (this.Left = 0)4 5 this.Left = 0;6 7 if (this.Top = ScreenEidth)15 16 this.Left = ScreenEidth - this.Width;17 18 if (this.Top + this.Height = ScreenGeight)19 20 this.Top = ScreenGeight - this.Height;21 22 9、组合键控制音量,默认音量为70控制音量代码 1 private void MiniMusicPlayer_KeyDown(object sender, KeyEventArgs e) /接收组合键调节音量2 3 if (e.Control) & (e.Alt) & (e.KeyCode = Keys.Up)4 5 if (axWMusicPlayer.settings.volume = 100)6 7 axWMusicPlayer.settings.volume = 100;8 9 else10 11 axWMusicPlayer.settings.volume += 5;12 13 14 if (e.Control & e.Alt & (e.KeyCode = Keys.Down)15 16 if (axWMusicPlayer.settings.volume = 0)17 18 axWMusicPlayer.settings.volume = 0;19 20 else21 22 axWMusicPlayer.settings.volume -= 5;23 24 25 10、跟据点击喜爱次数填充播放列表按喜爱次数自动填充播放列表 1 / 2 / 填充播放列表3 / 4 protected void FillCurrenrList()5 6 XmlDocument doc = new XmlDocument();7 doc.Load(xmlfile);8 if (doc.SelectSingleNode(MusicList).ChildNodes.Count != 0)9 10 XmlNodeList NodeList = doc.SelectSingleNode(MusicList).ChildNodes;11 string musiclist = new stringdoc.SelectSingleNode(MusicList).ChildNodes.Count; /每条MusicProperty组成一维数组12 int num = 0;13 foreach (XmlNode node in NodeList)14 15 XmlElement element = (XmlElement)node;16
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 机械租赁合作协议与合同
- 食品生产许可授权协议书
- 臭豆腐店铺转让合同范本
- 终止合同协议书文案模板
- 自建房商业售卖合同范本
- 烘焙店用品转让合同范本
- 芯模板设备出售合同协议
- 篮球俱乐部转让合同范本
- 派遣合同三方协议书范本
- 注册造价教材转让协议书
- 品牌授权使用协议合同书
- 管理学教学设计创新汇报
- 2024年天津市公安局滨海分局招聘警务辅助人员考试真题
- 2025至2030停车场项目发展趋势分析与未来投资战略咨询研究报告
- 装置保运方案(3篇)
- 重症心脏超声指南解读
- 职工诉求服务管理制度
- 义务教育化学课程标准(2022年版)
- 护理心绞痛课件
- 2025年高考真题-物理(江苏卷) 含答案
- 2025年高考真题-化学(安徽卷) 含答案
评论
0/150
提交评论