📄 main.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Windows.Forms.ComponentModel;
namespace Clock
{
/// <summary>
/// Form1 的摘要说明。
/// 组件由三部分组成
/// 一:主框体
/// 二:说明框体
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.Panel panel1;
private bool m_bShowWnd;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.MenuItem menuItem4;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
//m_bFlag=true;
m_bShowWnd=true;
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.panel1 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 24);
this.label1.TabIndex = 0;
this.label1.Text = "现在时刻:";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem11});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem5,
this.menuItem9,
this.menuItem10,
this.menuItem6});
this.menuItem1.Text = "设置";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem5
//
this.menuItem5.Index = 0;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7,
this.menuItem8});
this.menuItem5.Text = "系统设定";
//
// menuItem7
//
this.menuItem7.Index = 0;
this.menuItem7.Text = "提醒时间";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem8
//
this.menuItem8.Index = 1;
this.menuItem8.Text = "记录事件";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 1;
this.menuItem9.Text = "后台显示";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem10
//
this.menuItem10.Index = 2;
this.menuItem10.Text = "-";
//
// menuItem6
//
this.menuItem6.Index = 3;
this.menuItem6.Text = "退出";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuItem4});
this.menuItem2.Text = "帮助";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "关于定时提醒";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem11
//
this.menuItem11.Index = 2;
this.menuItem11.Text = "";
//
// panel1
//
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label2);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(384, 200);
this.panel1.TabIndex = 1;
//
// label3
//
this.label3.Location = new System.Drawing.Point(112, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(168, 24);
this.label3.TabIndex = 1;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 56);
this.label2.Name = "label2";
this.label2.TabIndex = 0;
this.label2.Text = "系统当前时间:";
//
// notifyIcon1
//
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "定时提醒";
this.notifyIcon1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDown);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "关于定时提醒";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click_1);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(312, 137);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Location = new System.Drawing.Point(512, 384);
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "定时提醒 V1.0";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void groupBox1_Enter(object sender, System.EventArgs e)
{
//File file1=new FileDialog();
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
Form Time_Set_Form=new TimeSet();
Time_Set_Form.Show();
}
private void notifyIcon1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Visible=true;
this.notifyIcon1.Visible=false;
m_bShowWnd=true;
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
if(m_bShowWnd == true)//隐藏主界面
{
this.Visible = false;
this.notifyIcon1.Visible=true;
m_bShowWnd = false;
}
else//显示主界面
{
this.Visible = true;
this.notifyIcon1.Visible=false;
m_bShowWnd = true;
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
Form About_form=new About();
About_form.Show();
//About_form.Show();
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Everthing to be continue....");
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void menuItem8_Click(object sender, System.EventArgs e)
{
Form Note_Form=new Note();
Note_Form.Show();
}
private void menuItem4_Click_1(object sender, System.EventArgs e)
{
Form About_form=new About();
About_form.Show();
}
}
public class TimeSet : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.DateTimePicker dateTimePicker;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public TimeSet()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
//#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.label2 = new System.Windows.Forms.Label();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(128, 24);
this.label1.TabIndex = 1;
this.label1.Text = "请输入要设定的日期:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 136);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 2;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(104, 136);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 3;
this.button2.Text = "重置";
//
// button3
//
this.button3.Location = new System.Drawing.Point(200, 136);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 24);
this.button3.TabIndex = 4;
this.button3.Text = "取消";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(136, 37);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(144, 21);
this.dateTimePicker1.TabIndex = 5;
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 23);
this.label2.TabIndex = 6;
this.label2.Text = "请输入要提醒的时间:";
//
// dateTimePicker
//
this.dateTimePicker.CalendarFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dateTimePicker.Cursor = System.Windows.Forms.Cursors.Arrow;
this.dateTimePicker.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Time;
this.dateTimePicker.Location = new System.Drawing.Point(136, 72);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.dateTimePicker.Size = new System.Drawing.Size(72, 21);
this.dateTimePicker.TabIndex = 7;
this.dateTimePicker.Value = new System.DateTime(2002, 9, 27, 0, 0, 0, 0);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 189);
this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.label2);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "时间设定";
this.ResumeLayout(false);
}
//#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
private void button1_Click(object sender, System.EventArgs e)
{
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void dateTimePicker2_ValueChanged(object sender, System.EventArgs e)
{
//this.dateTimePicker.Value = System.DateTime.Now;
//this.dateTimePicker.Enabled=false;
this.dateTimePicker.Text=System.DateTime.Now.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -