///退出时动画效果/////////privatevoidMainForm_FormClosed(objectsender,FormClosedEventArgse){if(this.WindowState!=FormWindowState.Minimized){while(this.Height>10){this.Location=newPoint(this.Location.X,this.Location.Y15);this.Height-=30;this.Opacity-=0.01;}}Application.Exit();}#region播放控制与信息显示相关变量MyMediamySong=newMyMedia();boolIsMute=false;boolIsStop=false;#endregion#regionAPI和常量[DllImport("user32.dll")]privatestaticexternboolAnimateWindow(IntPtrhwnd,intdwTime,intdwFlags);[DllImport("user32.dll")]publicstaticexternboolReleaseCapture();[DllImport("user32.dll")]privatestaticexternboolSendMessage(IntPtrhwnd,intwMsg,intwParam,intlParam);privateconstintWM_SYSCOMMAND=0x0112;privateconstintSC_MOVE=0xF010;privateconstintHTCAPTION=0x0002;privateconstintWM_NCHITTEST=0x84;privateconstintHTCLIENT=0x1;privateconstintWM_NCLBUTTONDBLCLK=0xA3;//鼠标双击标题栏消息//改变窗体大小publicconstintWMSZ_LEFT=0xF001;publicconstintWMSZ_RIGHT=0xF002;publicconstintWMSZ_TOP=0xF003;publicconstintWMSZ_TOPLEFT=0xF004;publicconstintWMSZ_TOPRIGHT=0xF005;publicconstintWMSZ_BOTTOM=0xF006;publicconstintWMSZ_BOTTOMLEFT=0xF007;publicconstintWMSZ_BOTTOMRIGHT=0xF008;#endregion#region无边框窗口拖动及大小状态切换protectedoverrideCreateParamsCreateParams{get{constintWS_MINIMIZEBOX=0x00020000;//Winuser.h中定义CreateParamscp=base.CreateParams;cp.Style=cp.Style|WS_MINIMIZEBOX;//允许最小化操作returncp;}}privatevoidtpnlMain_MouseDown(objectsender,MouseEventArgse){//如果是顶部或底部的空栏if((e.Y>0&&e.Y<30)||(e.Y>this.Height-40&&e.Y0&&e.Y<30)&&e.Button==MouseButtons.Left&&e.Clicks==2){if(this.WindowState==FormWindowState.Normal){SendMessage(this.Handle,274,61488,0);return;}if(this.WindowState==FormWindowState.Maximized){SendMessage(this.Handle,274,61728,0);return;}}}//拉伸改变大小if(e.Y>0&&e.Y<3){SendMessage(this.Handle,WM_SYSCOMMAND,WMSZ_TOP,0);}}privatevoidbtnCloseBox_Click(objectsender,EventArgse){this.Close();}privatevoidbtnMaximizeBox_Click(objectsender,EventArgse){//if(Properties.Settings.Default.RememberMaximizeFunction==0)//{//PointP=PointToScreen(newPoint(btnMaximizeBox.Left,btnMaximizeBox.Bottom));//cmenuMaxMode.Show(P);//}if(this.WindowState==FormWindowState.Normal){this.WindowState=FormWindowState.Maximized;}else{this.WindowState=FormWindowState.Normal;}}privatevoidbtnMinimizeBox_Click(objectsender,EventArgse){this.WindowState=FormWindowState.Minimized;}privatevoid音乐魔方模式ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid最大化ToolStripMenuItem_Click(objectsender,EventArgse){if(this.WindowState==FormWindowState.Normal){this.WindowState=FormWindowState.Maximized;}else{this.WindowState=FormWindowState.Normal;}}privatevoid记住我的选择ToolStripMenuItem_Click(objectsender,EventArgse){}#endregionprivatevoidMainForm_Load(objectsender,EventArgse){tbarVolume.Value=Properties.Settings.Default.Volume;webBrowser1.Url=newUri("http://www.kugou.com/fm2/");}#region播放控制和状态信息显示//////播放、暂停/////////privatevoidbtnPlayPause_Click(objectsender,EventArgse){if(mySong.CurrentState!=State.Playing){MyTime.Start();mySong.Play();}else{MyTime.Stop();mySong.Puase();}}//////上一首/////////privatevoidbtnPreSong_Click(objectsender,EventArgse){}privatevoidbtnNextSong_Click(objectsender,EventArgse){//OpenFileDialogofd=newOpenFileDialog();//ofd.Filter="歌词文件(*.lrc)|*.lrc";//if(ofd.ShowDialog()==DialogResult.OK)//{//LyricShow.Lyricl=newLyricShow.Lyric(ofd.FileName);//lyricShow1.SetLyric(l);//}}//////显示时间提示//////已播放时间///歌曲总时间privatevoidDisplayTime(longdurTime,longtotalTime){lblPastTime.Text=string.Format("{0:D2}:{1:D2}",durTime/60,durTime%60);lblTotalTime.Text=string.Format("{0:D2}:{1:D2}",totalTime/60,totalTime%60);}//////从完整路径中分离出歌曲名//////完整路径///歌名privatestringGetSongName(stringpath){intindex1=path.LastIndexOf(@"");intindex2=path.LastIndexOf(@".");stringsongName=path.Substring(index11,index2-index1);returnsongName;}#endregion//动态显示时间和时间条privatevoidMyTime_Tick(objectsender,EventArgse){//lyricShow1.CurrentProgress=mySong.CurrentPosition;//lyricShow1.RefreshDesktopLyric();IsStop=false;if(mySong.CurrentState==State.Playing){//tbarTime.Value=mySong.CurrentPosition;}elseif(mySong.CurrentState==State.Puased){MyTime.Stop();}//DisplayTime(tbarTime.Value,mySong.TotalSeconds);}//左上角标题图标点击,弹出菜单privatevoidbtnTitleAndIcon_Click(objectsender,EventArgse){PointP=PointToScreen(newPoint(btnTitleAndIcon.Left,btnTitleAndIcon.Bottom));cmenu.Show(P);}#region右键菜单操作privatevoid添加本地歌曲ToolStripMenuItem_Click(objectsender,EventArgse){OpenFileDialogofd=newOpenFileDialog();if(ofd.ShowDialog()==DialogResult.OK){}}privatevoid添加本地歌曲文件夹ToolStripMenuItem_Click(objectsender,EventArgse){FolderBrowserDialogfbd=newFolderBrowserDialog();if(fbd.ShowDialog()==DialogResult.OK){}}privatevoid增大音量ToolStripMenuItem_Click(objectsender,EventArgse){VolumeUp(50);}privatevoid减小音量ToolStripMenuItem_Click(objectsender,EventArgse){VolumeDown(50);}privatevoid显示桌面歌词ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid锁定桌面歌词ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid设置ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid退出ToolStripMenuItem_Click(objectsender,EventArgse){this.Close();}#endregion#region音量调节与提示//////增大音量//////音量改变量privatevoidVolumeUp(intstep){}//////减小音量//////音量改变量privatevoidVolumeDown(intstep){}privatevoidtbarVolume_ValueChanged(objectsender,EventArgse){}#endregion//////添加本地歌曲文件//////文件完全路径privatevoidAddSong(stringfilePath){}//////添加本地歌曲文件夹//////文件夹路径privatevoidAddSongFolder(stringfolderPath){}//退出时保存设置的音量等信息privatevoidMainForm_FormClosing(objectsender,FormClosingEventArgse){Properties.Settings.Default.Volume=tbarVolume.Value;Properties.Settings.Default.Save();}privatevoidbtnPreSong_MouseClick(objectsender,MouseEventArgse){if(e.Button==MouseButtons.Left){OpenFileDialogmydlg=newOpenFileDialog();mydlg.ShowDialog();mySong.FileName=mydlg.FileName;//tbarTime.Maximum=mySong.TotalSeconds;lblSongName.Text=GetSongName(mydlg.FileName);mySong.Play();MyTime.Start();//DisplayTime(tbarTime.Value,mySong.TotalSeconds);}}}}-IMDN开发者社群-imdn.cn"> ///退出时动画效果/////////privatevoidMainForm_FormClosed(objectsender,FormClosedEventArgse){if(this.WindowState!=FormWindowState.Minimized){while(this.Height>10){this.Location=newPoint(this.Location.X,this.Location.Y15);this.Height-=30;this.Opacity-=0.01;}}Application.Exit();}#region播放控制与信息显示相关变量MyMediamySong=newMyMedia();boolIsMute=false;boolIsStop=false;#endregion#regionAPI和常量[DllImport("user32.dll")]privatestaticexternboolAnimateWindow(IntPtrhwnd,intdwTime,intdwFlags);[DllImport("user32.dll")]publicstaticexternboolReleaseCapture();[DllImport("user32.dll")]privatestaticexternboolSendMessage(IntPtrhwnd,intwMsg,intwParam,intlParam);privateconstintWM_SYSCOMMAND=0x0112;privateconstintSC_MOVE=0xF010;privateconstintHTCAPTION=0x0002;privateconstintWM_NCHITTEST=0x84;privateconstintHTCLIENT=0x1;privateconstintWM_NCLBUTTONDBLCLK=0xA3;//鼠标双击标题栏消息//改变窗体大小publicconstintWMSZ_LEFT=0xF001;publicconstintWMSZ_RIGHT=0xF002;publicconstintWMSZ_TOP=0xF003;publicconstintWMSZ_TOPLEFT=0xF004;publicconstintWMSZ_TOPRIGHT=0xF005;publicconstintWMSZ_BOTTOM=0xF006;publicconstintWMSZ_BOTTOMLEFT=0xF007;publicconstintWMSZ_BOTTOMRIGHT=0xF008;#endregion#region无边框窗口拖动及大小状态切换protectedoverrideCreateParamsCreateParams{get{constintWS_MINIMIZEBOX=0x00020000;//Winuser.h中定义CreateParamscp=base.CreateParams;cp.Style=cp.Style|WS_MINIMIZEBOX;//允许最小化操作returncp;}}privatevoidtpnlMain_MouseDown(objectsender,MouseEventArgse){//如果是顶部或底部的空栏if((e.Y>0&&e.Y<30)||(e.Y>this.Height-40&&e.Y0&&e.Y<30)&&e.Button==MouseButtons.Left&&e.Clicks==2){if(this.WindowState==FormWindowState.Normal){SendMessage(this.Handle,274,61488,0);return;}if(this.WindowState==FormWindowState.Maximized){SendMessage(this.Handle,274,61728,0);return;}}}//拉伸改变大小if(e.Y>0&&e.Y<3){SendMessage(this.Handle,WM_SYSCOMMAND,WMSZ_TOP,0);}}privatevoidbtnCloseBox_Click(objectsender,EventArgse){this.Close();}privatevoidbtnMaximizeBox_Click(objectsender,EventArgse){//if(Properties.Settings.Default.RememberMaximizeFunction==0)//{//PointP=PointToScreen(newPoint(btnMaximizeBox.Left,btnMaximizeBox.Bottom));//cmenuMaxMode.Show(P);//}if(this.WindowState==FormWindowState.Normal){this.WindowState=FormWindowState.Maximized;}else{this.WindowState=FormWindowState.Normal;}}privatevoidbtnMinimizeBox_Click(objectsender,EventArgse){this.WindowState=FormWindowState.Minimized;}privatevoid音乐魔方模式ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid最大化ToolStripMenuItem_Click(objectsender,EventArgse){if(this.WindowState==FormWindowState.Normal){this.WindowState=FormWindowState.Maximized;}else{this.WindowState=FormWindowState.Normal;}}privatevoid记住我的选择ToolStripMenuItem_Click(objectsender,EventArgse){}#endregionprivatevoidMainForm_Load(objectsender,EventArgse){tbarVolume.Value=Properties.Settings.Default.Volume;webBrowser1.Url=newUri("http://www.kugou.com/fm2/");}#region播放控制和状态信息显示//////播放、暂停/////////privatevoidbtnPlayPause_Click(objectsender,EventArgse){if(mySong.CurrentState!=State.Playing){MyTime.Start();mySong.Play();}else{MyTime.Stop();mySong.Puase();}}//////上一首/////////privatevoidbtnPreSong_Click(objectsender,EventArgse){}privatevoidbtnNextSong_Click(objectsender,EventArgse){//OpenFileDialogofd=newOpenFileDialog();//ofd.Filter="歌词文件(*.lrc)|*.lrc";//if(ofd.ShowDialog()==DialogResult.OK)//{//LyricShow.Lyricl=newLyricShow.Lyric(ofd.FileName);//lyricShow1.SetLyric(l);//}}//////显示时间提示//////已播放时间///歌曲总时间privatevoidDisplayTime(longdurTime,longtotalTime){lblPastTime.Text=string.Format("{0:D2}:{1:D2}",durTime/60,durTime%60);lblTotalTime.Text=string.Format("{0:D2}:{1:D2}",totalTime/60,totalTime%60);}//////从完整路径中分离出歌曲名//////完整路径///歌名privatestringGetSongName(stringpath){intindex1=path.LastIndexOf(@"");intindex2=path.LastIndexOf(@".");stringsongName=path.Substring(index11,index2-index1);returnsongName;}#endregion//动态显示时间和时间条privatevoidMyTime_Tick(objectsender,EventArgse){//lyricShow1.CurrentProgress=mySong.CurrentPosition;//lyricShow1.RefreshDesktopLyric();IsStop=false;if(mySong.CurrentState==State.Playing){//tbarTime.Value=mySong.CurrentPosition;}elseif(mySong.CurrentState==State.Puased){MyTime.Stop();}//DisplayTime(tbarTime.Value,mySong.TotalSeconds);}//左上角标题图标点击,弹出菜单privatevoidbtnTitleAndIcon_Click(objectsender,EventArgse){PointP=PointToScreen(newPoint(btnTitleAndIcon.Left,btnTitleAndIcon.Bottom));cmenu.Show(P);}#region右键菜单操作privatevoid添加本地歌曲ToolStripMenuItem_Click(objectsender,EventArgse){OpenFileDialogofd=newOpenFileDialog();if(ofd.ShowDialog()==DialogResult.OK){}}privatevoid添加本地歌曲文件夹ToolStripMenuItem_Click(objectsender,EventArgse){FolderBrowserDialogfbd=newFolderBrowserDialog();if(fbd.ShowDialog()==DialogResult.OK){}}privatevoid增大音量ToolStripMenuItem_Click(objectsender,EventArgse){VolumeUp(50);}privatevoid减小音量ToolStripMenuItem_Click(objectsender,EventArgse){VolumeDown(50);}privatevoid显示桌面歌词ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid锁定桌面歌词ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid设置ToolStripMenuItem_Click(objectsender,EventArgse){}privatevoid退出ToolStripMenuItem_Click(objectsender,EventArgse){this.Close();}#endregion#region音量调节与提示//////增大音量//////音量改变量privatevoidVolumeUp(intstep){}//////减小音量//////音量改变量privatevoidVolumeDown(intstep){}privatevoidtbarVolume_ValueChanged(objectsender,EventArgse){}#endregion//////添加本地歌曲文件//////文件完全路径privatevoidAddSong(stringfilePath){}//////添加本地歌曲文件夹//////文件夹路径privatevoidAddSongFolder(stringfolderPath){}//退出时保存设置的音量等信息privatevoidMainForm_FormClosing(objectsender,FormClosingEventArgse){Properties.Settings.Default.Volume=tbarVolume.Value;Properties.Settings.Default.Save();}privatevoidbtnPreSong_MouseClick(objectsender,MouseEventArgse){if(e.Button==MouseButtons.Left){OpenFileDialogmydlg=newOpenFileDialog();mydlg.ShowDialog();mySong.FileName=mydlg.FileName;//tbarTime.Maximum=mySong.TotalSeconds;lblSongName.Text=GetSongName(mydlg.FileName);mySong.Play();MyTime.Start();//DisplayTime(tbarTime.Value,mySong.TotalSeconds);}}}} - IMDN开发者社群-imdn.cn">
登录
首页 » C# » 仿造酷狗音乐最新版代码(含各种用户控件源码)

仿造酷狗音乐最新版代码(含各种用户控件源码)

于 2014-06-07 发布
0 37
下载积分: 1 下载次数: 0

代码说明:

 11111111111111111111111 核心代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using System.IO;using MediaControlLibrary;namespace MusicPlayer{ public partial class MainForm : Form { //public const Int32 AW_HOR_POSITIVE = 0x00000001; //public const Int32 AW_HOR_NEGATIVE = 0x00000002; //public const Int32 AW_VER_POSITIVE = 0x00000004; //public const Int32 AW_VER_NEGATIVE = 0x00000008; public const Int32 AW_CENTER = 0x00000010; //public const Int32 AW_HIDE = 0x00010000; //public const Int32 AW_ACTIVATE = 0x00020000; //public const Int32 AW_SLIDE = 0x00040000; //public const Int32 AW_BLEND = 0x00080000; public MainForm() { InitializeComponent(); //设置最大尺寸,防止全屏时遮挡任务栏 this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size; //启动动画 AnimateWindow(this.Handle, 100, 0x00000010);//开始窗体动画,中心展开 //歌词窗口 //lyricShow1.InitAndShowDesktopLyric(); for (int i = 0; i < 1; i ) { MediaList list = new MediaList("默认列表"); for (int j = 0; j < 10; j ) { MediaItem item = new MediaItem("歌曲" j, "00:00"); item.SecondContent = "111223"; list.SubItems.Add(item); } mediaContainer1.Lists.Add(list); MediaList list1 = new MediaList("新建列表"); mediaContainer1.Lists.Add(list1); } } /// /// 退出时动画效果 /// /// /// private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { if (this.WindowState != FormWindowState.Minimized) { while (this.Height > 10) { this.Location = new Point(this.Location.X, this.Location.Y 15); this.Height -= 30; this.Opacity -= 0.01; } } Application.Exit(); } #region 播放控制与信息显示相关变量 MyMedia mySong = new MyMedia(); bool IsMute = false; bool IsStop = false; #endregion #region API和常量 [DllImport("user32.dll")] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags); [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] private static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); private const int WM_SYSCOMMAND = 0x0112; private const int SC_MOVE = 0xF010; private const int HTCAPTION = 0x0002; private const int WM_NCHITTEST = 0x84; private const int HTCLIENT = 0x1; private const int WM_NCLBUTTONDBLCLK = 0xA3;//鼠标双击标题栏消息 //改变窗体大小 public const int WMSZ_LEFT = 0xF001; public const int WMSZ_RIGHT = 0xF002; public const int WMSZ_TOP = 0xF003; public const int WMSZ_TOPLEFT = 0xF004; public const int WMSZ_TOPRIGHT = 0xF005; public const int WMSZ_BOTTOM = 0xF006; public const int WMSZ_BOTTOMLEFT = 0xF007; public const int WMSZ_BOTTOMRIGHT = 0xF008; #endregion #region 无边框窗口拖动及大小状态切换 protected override CreateParams CreateParams { get { const int WS_MINIMIZEBOX = 0x00020000; // Winuser.h中定义 CreateParams cp = base.CreateParams; cp.Style = cp.Style | WS_MINIMIZEBOX; // 允许最小化操作 return cp; } } private void tpnlMain_MouseDown(object sender, MouseEventArgs e) { //如果是顶部或底部的空栏 if ((e.Y > 0 && e.Y < 30) || (e.Y > this.Height - 40 && e.Y < this.Height)) { //按下的是鼠标左键,则拖动窗口 if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE HTCAPTION, 0);//*********************调用移动无窗体控件函数 } //双击顶部标题栏切换窗口状态 if ((e.Y > 0 && e.Y < 30) && e.Button == MouseButtons.Left && e.Clicks == 2) { if (this.WindowState == FormWindowState.Normal) { SendMessage(this.Handle, 274, 61488, 0); return; } if (this.WindowState == FormWindowState.Maximized) { SendMessage(this.Handle, 274, 61728, 0); return; } } } //拉伸改变大小 if (e.Y>0&&e.Y

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 696518资源总数
  • 104224会员总数
  • 54今日下载