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;
|
using WebAPI.Controllers;
|
namespace LMES
|
{
|
public partial class XiaoZhuGe_autoGetData : Form
|
{
|
public XiaoZhuGe_autoGetData()
|
{
|
InitializeComponent();
|
|
//为系统托盘图标增加 右击菜单项
|
ContextMenu contextMenu = new ContextMenu();
|
MenuItem exitMenuItem = new MenuItem("退出");
|
exitMenuItem.Click += ExitMenuItem_Click;
|
contextMenu.MenuItems.Add(exitMenuItem);
|
notifyIcon_Icon.ContextMenu = contextMenu;
|
|
//页面初始化
|
set_initPage();
|
}
|
|
#region 页面初始化
|
public void set_initPage()
|
{
|
timer1.Enabled = true;
|
}
|
#endregion
|
|
#region 定时器1:用于隐藏页面与任务栏图标
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
//系统托盘显示软件图标
|
this.notifyIcon_Icon.Visible = true;
|
// 隐藏主窗体
|
this.Hide();
|
// 隐藏任务栏软件图标
|
this.ShowInTaskbar = false;
|
|
timer1.Enabled = false;
|
}
|
#endregion
|
|
#region 定时器2:用于定时同步数据
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
try
|
{
|
XZG_DataSynchronizationController t = new XZG_DataSynchronizationController();
|
t.dataAnsy();
|
}catch(Exception e1)
|
{
|
string sErrMsg = "";
|
}
|
}
|
#endregion
|
|
#region 系统托盘点击图标后图标仍存在
|
private void notifyIcon_Icon_MouseDoubleClick(object sender, MouseEventArgs e)
|
{
|
|
|
if (e.Button == MouseButtons.Left && e.Clicks == 2) // 双击左键事件示例
|
{
|
// 处理双击事件,例如显示或隐藏主窗体等。
|
//this.Show(); // 示例:显示主窗体(如果之前是隐藏的)
|
//this.WindowState = FormWindowState.Normal; // 确保窗口处于正常状态(非最小化)
|
|
//系统托盘显示软件图标
|
this.notifyIcon_Icon.Visible = true; //保证系统托盘图标仍旧存在
|
}
|
}
|
#endregion
|
|
#region 系统托盘图标 右击功能菜单退出按钮事件
|
private void ExitMenuItem_Click(object sender, EventArgs e)
|
{
|
Application.Exit(); // 这将关闭整个应用程序
|
}
|
#endregion
|
}
|
}
|