📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Net;
using Microsoft.Win32;
using System.Diagnostics;
namespace XFMAS
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label todayL;
private System.Windows.Forms.Label tomorrowL;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button submit;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.CheckBox i002;
private System.Windows.Forms.CheckBox i003;
private System.Windows.Forms.CheckBox i001;
private System.Timers.Timer timer1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Label label4;
/// <summary>
/// 是否关机
/// </summary>
private bool isExitApp = false;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ImageList imageList1;
private int falseNum = 0;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
/// <summary>
/// 托盘图标文件
/// </summary>
private string iconFile = Application.StartupPath + "\\";
private int isff = 0;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//改变字体背景
Color lbg = Color.FromArgb(185,208,193);
this.label1.BackColor = lbg;
this.label2.BackColor = lbg;
this.label3.BackColor = lbg;
this.submit.BackColor = lbg;
lbg = Color.FromArgb(214,221,239);
this.todayL.BackColor = lbg;
this.tomorrowL.BackColor = lbg;
this.Text = Public.systemName + "[登录用户:"+ Public.currentUserName +"]";
this.notifyIcon1.Text = this.Text;
//默入今日已选
this.LoadSelectedFormDB();
//设置提醒时的日期
this.SetDate();
//this.ChangeNotIcon(false);
}
/// <summary>
/// 改变托盘图标
/// </summary>
/// <param name="conn"></param>
public void ChangeNotIcon(bool conn){
try{
Icon icon = null;
if(conn){
icon = new Icon(this.iconFile + "conn.ico");
this.Text = Public.systemName + "[登录用户:"+ Public.currentUserName +"]";
this.notifyIcon1.Text = this.Text;
}else{
icon = new Icon(this.iconFile + "noconn.ico");
this.notifyIcon1.Text = this.Text + "\r\n" + "-> 服务连接失败,等待重试....";
this.Text = Public.systemName + "[登录用户:"+ Public.currentUserName +"][当前不在线....]";
}
if(icon != null){
this.notifyIcon1.Icon = icon;
this.Icon = icon;
}
}catch{}
}
/// <summary>
///
/// </summary>
private void SetDate(){
DateTime _date = DBConn.GetServerTime();
//今日
int sIndex = _date.ToString().IndexOf(" ");
string __date = _date.ToString().Substring(0,sIndex);
this.todayL.Text = "今日("+ __date +")";
//明日
_date = _date.AddDays(1);
sIndex = _date.ToString().IndexOf(" ");
__date = _date.ToString().Substring(0,sIndex);
this.tomorrowL.Text = "明日("+ __date +")";
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 系统使用
/// <summary>
/// 获取系统关机或注销事件
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref System.Windows.Forms.Message m) {
switch (m.Msg) {
case 0x0011://系统询问是否可以关闭
this.isExitApp = true;
break;
case 0x0016://系统指示:关掉
this.notifyIcon1.Visible = false;
this.notifyIcon1.Dispose();
Application.Exit();
break;
default:
break;
}
base.WndProc(ref m);
}
#endregion
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.todayL = new System.Windows.Forms.Label();
this.tomorrowL = new System.Windows.Forms.Label();
this.i002 = new System.Windows.Forms.CheckBox();
this.i003 = new System.Windows.Forms.CheckBox();
this.i001 = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.submit = new System.Windows.Forms.Button();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.timer1 = new System.Timers.Timer();
this.label4 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(456, 152);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// todayL
//
this.todayL.BackColor = System.Drawing.Color.PaleGoldenrod;
this.todayL.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.todayL.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.todayL.Location = new System.Drawing.Point(88, 16);
this.todayL.Name = "todayL";
this.todayL.Size = new System.Drawing.Size(128, 24);
this.todayL.TabIndex = 1;
this.todayL.Text = "今日(2005-6-7)";
this.todayL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// tomorrowL
//
this.tomorrowL.BackColor = System.Drawing.Color.PaleGoldenrod;
this.tomorrowL.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.tomorrowL.Location = new System.Drawing.Point(312, 16);
this.tomorrowL.Name = "tomorrowL";
this.tomorrowL.Size = new System.Drawing.Size(128, 24);
this.tomorrowL.TabIndex = 2;
this.tomorrowL.Text = "明日(2005-6-7)";
this.tomorrowL.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// i002
//
this.i002.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.i002.Location = new System.Drawing.Point(64, 112);
this.i002.Name = "i002";
this.i002.Size = new System.Drawing.Size(16, 16);
this.i002.TabIndex = 3;
this.i002.CheckedChanged += new System.EventHandler(this.i002_CheckedChanged);
//
// i003
//
this.i003.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.i003.Location = new System.Drawing.Point(208, 112);
this.i003.Name = "i003";
this.i003.Size = new System.Drawing.Size(16, 16);
this.i003.TabIndex = 4;
this.i003.CheckedChanged += new System.EventHandler(this.i003_CheckedChanged);
//
// i001
//
this.i001.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.i001.Location = new System.Drawing.Point(368, 112);
this.i001.Name = "i001";
this.i001.Size = new System.Drawing.Size(16, 16);
this.i001.TabIndex = 5;
this.i001.CheckedChanged += new System.EventHandler(this.i001_CheckedChanged);
//
// label1
//
this.label1.BackColor = System.Drawing.Color.PaleGoldenrod;
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.label1.Location = new System.Drawing.Point(40, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 24);
this.label1.TabIndex = 6;
this.label1.Text = "午 餐";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.BackColor = System.Drawing.Color.PaleGoldenrod;
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.label2.Location = new System.Drawing.Point(184, 55);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 24);
this.label2.TabIndex = 7;
this.label2.Text = "晚 餐";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.BackColor = System.Drawing.Color.PaleGoldenrod;
this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.label3.Location = new System.Drawing.Point(344, 55);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 24);
this.label3.TabIndex = 8;
this.label3.Text = "早 餐";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(248, 168);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 10;
this.button1.Text = "历史记录";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Location = new System.Drawing.Point(320, 168);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -