private void pictureBox2_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.ShowDialog();
}
//这是第一窗体Form1,点击pictureBox2即可进入窗体Form2;下面是Form1;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ll
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = this.openFileDialog1.FileName;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (DateTime.Now.ToShortTimeString() == this.textBox2.Text.Trim().ToString())
{
this.axWindowsMediaPlayer1.URL = this.textBox1.Text; //设置音乐文件的播放路径
this.axWindowsMediaPlayer1.Ctlcontrols.play(); //播放多媒体文件
this.timer1.Enabled = false; //关闭timer1计时器
this.timer2.Enabled = true; //启动timer2计时器
this.timer2.Interval = 1000; //设置timer2计时器的Tick事件间隔为1s
this.Show(); //显示该窗体
}
}
private void button2_Click(object sender, EventArgs e)
{
this.timer1.Enabled = true;
this.Hide();
this.ShowInTaskbar = false ;
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (this.axWindowsMediaPlayer1.status != "正在播放") //当多媒体处于正在播放的状态时
{
this.timer2.Enabled = false; //关闭timer2计时器
MessageBox.Show("本次播放已完成,谢谢使用!!!"); //弹出信息提示
}
}
}
}
//From2是一个闹钟,
//问题来了,我这个闹钟Form2如果不通过Form1进入form2设定时间是可以用的,但用了多窗体之后闹铃不响了
相关分类