最近想找一个半个小时提醒喝水(休息眼睛/提肛)的程序,找了几个都不合心,要么带广告,要么运行了几天后怎么也启动不起来了,怒了,下载了Visual Studio,现学了一下C#,让DeepSeek帮我写了,主要的程序代码直接奉出:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private Timer timer;
private NotifyIcon notifyIcon;
public Form1()
{
// 初始化NotifyIcon
notifyIcon = new NotifyIcon
{
Icon = SystemIcons.Information,
Visible = true,
Text = "提醒喝水"
};
// 添加退出菜单项
var exitMenuItem = new MenuItem("退出", OnExitClick);
notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] { exitMenuItem });
// 初始化Timer
timer = new Timer
{
Interva