本帖最后由 cancle 于 2014-3-15 09:37 编辑
- public Form1()
- {
- InitializeComponent();
- }
- string appPath = Environment.CurrentDirectory;
- private void Form1_Load(object sender, EventArgs e)
- {
- labtime.Text = DateTime.Now.ToString();
- //pictureBox1.Image = Image.FromFile(@"D:\照片\DCIM\13070126.jpg");
- panel1.Visible = true;
- panel2.Visible = false;
-
- }
- private void button1_Click(object sender, EventArgs e)
- {
- panel1.Visible = false;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- panel2.Visible = false;
- }
- private void 显示播放列表ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if(显示播放列表ToolStripMenuItem.Text == "☆显示播放列表")
- {
- panel1.Visible = true;
- }
- else
- {
- panel1.Visible = false;
- }
-
- }
- private void 清空当前播放列表ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- labtime.Text = DateTime.Now.ToString();
- if (panel1.Visible == true)
- {
- 显示播放列表ToolStripMenuItem.Text = "★取消播放列表";
- }
- else
- {
- 显示播放列表ToolStripMenuItem.Text = "☆显示播放列表";
- }
- if(panel2.Visible==true)
- {
- 显示文本ToolStripMenuItem.Text= "▲隐藏文本";
- }
- else
- {
- 显示文本ToolStripMenuItem.Text = "△显示文本";
- }
- }
- private void 显示文本ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if(显示文本ToolStripMenuItem.Text == "△显示文本")
- {
- panel2.Visible = true;
- }
- else
- {
- panel2.Visible = false;
- }
- }
- List<string> list = new List<string>();//存放歌曲路径
- private void btnMusic_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Title = "请选择你要添加的歌曲";
- ofd.InitialDirectory = @"C:\Users\Administrator\Desktop";
- ofd.Multiselect = true;
- ofd.Filter = "音乐文件|*.mp3";
- ofd.ShowDialog();
- string[] str = ofd.FileNames;
- if(str==null)
- {
- return;
- }
- list.AddRange(str);
- for (int i = 0; i < str.Length; i++)
- {
- listBox1.Items.Add(Path.GetFileName(str[i]));
- }
- }
- private void btnText_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Title = "请选择你要打开的文档";
- ofd.InitialDirectory = @"C:\Users\Administrator\Desktop";
- ofd.Filter = "文本文件|*.txt";
- ofd.ShowDialog();
- string str = ofd.FileName;
- if(str=="")
- {
- return;
- }
- using(FileStream fsRead=new FileStream(str,FileMode.OpenOrCreate,FileAccess.Read))
- {
- byte[] buffer = new byte[1024 * 1024 * 5];
- int val = fsRead.Read(buffer, 0, buffer.Length);
- textBox1.Text = Encoding.Default.GetString(buffer, 0, val);
- }
- MessageBox.Show("打开完成");
- panel2.Visible = true;
- }
- private void 清除文本ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- textBox1.Clear();
- textBox1.Focus();
- }
- private void 更换背景图片ToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Title = "请选择你要设置的背景图片";
- ofd.InitialDirectory = @"C:\Users\Administrator\Desktop";
- ofd.Filter = "图片文件|*.jpg|所有文件|*.*";
- ofd.ShowDialog();
- string str = ofd.FileName;
- if(str=="")
- {
- return;
- }
- pictureBox1.Image = Image.FromFile(str);
- }
- private void 关于xBox10ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show("名称:MusicBox\r\n版本:1.0\r\n最终解释权归宇星所有。");
- }
- private void listBox1_DoubleClick(object sender, EventArgs e)
- {
- Music.URL = list[listBox1.SelectedIndex];
- }
- private void 保存文本ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Title = "请选择要保存的路径";
- sfd.InitialDirectory = @"C:\Users\Administrator\Desktop";
- sfd.Filter = "文本文件|*.txt";
- sfd.ShowDialog();
- string str = sfd.FileName;
- if (str == "")
- {
- return;
- }
- using(FileStream fsWrite=new FileStream(str,FileMode.OpenOrCreate,FileAccess.Write))
- {
- byte[] buffer = Encoding.Default.GetBytes(textBox1.Text);
- fsWrite.Write(buffer,0,buffer.Length);
- }
- MessageBox.Show("保存成功");
- }
复制代码
播放器.zip
(1.63 MB, 下载次数: 126)
如图
后面会附上部分代码,这是文件http://bbs.itheima.com/forum.php?mod=attachment&aid=MzYzODB8ODA3Y2Q1NjEyMTRhYTA2MzJiYThmZWRlZDYwZGQ2NmR8MTczMjM3MzQyNw%3D%3D&request=yes&_f=.zip
|