1 Star 0 Fork 1

sunmjian/休息提醒闹钟

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
TipForm.cs 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
longware 提交于 2021-04-12 21:47 +08:00 . init
using System;
using System.IO;
using System.Media;
using System.Windows.Forms;
namespace TipTip
{
public partial class TipForm : Form
{
private static int CLOSE_SEC = 300;
private string STR_MIN = "";
private int RUN_SEC = 0;
public TipForm()
{
InitializeComponent();
}
public TipForm(string _min)
{
STR_MIN = _min;
InitializeComponent();
this.WindowState = FormWindowState.Maximized;
this.TopMost = true;
this.BringToFront();
}
private void TipForm_Load(object sender, EventArgs e)
{
label1.Text = "亲,您又工作了"+ STR_MIN + "分钟,该休息一下啦!";
timer1.Enabled = true;
//播放声音
string wavFile = Application.StartupPath + @"\alarm.wav";
Stream sm = null;
if (File.Exists(wavFile))
{
sm = new FileStream(wavFile, FileMode.Open);
} else
{
sm = Properties.Resources.Alarm02;
}
SoundPlayer player = new SoundPlayer(sm);
player.Play();
player.Dispose();
if (sm != null)
{
sm.Close();
sm.Dispose();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
RUN_SEC++;
if (RUN_SEC >= CLOSE_SEC)
{
RUN_SEC = 0;
Close();
} else
{
label2.Text = "[" + (CLOSE_SEC - RUN_SEC) + "秒后自动关闭]";
}
}
private void TipForm_Resize(object sender, EventArgs e)
{
label1.Width = this.Width - 50;
label1.Top = (this.Height - 150) / 2;
label2.Width = label1.Width;
label2.Top = label1.Top + 150;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/sunmjian/TipTip.git
git@gitee.com:sunmjian/TipTip.git
sunmjian
TipTip
休息提醒闹钟
master

搜索帮助