You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.3 KiB

using System;
using System.Threading;
using System.Windows.Forms;
namespace EC.AutoWeightServer.UI.Base
{
public partial class FrmServerBase : FrmBase
{
private bool EXIT_APP = false;
private const int WM_QUERYENDSESSION = 17; //0x0011
// public delegate void mydelegate(string str,bool isErr);
public FrmServerBase()
{
InitializeComponent();
}
#region 系统
private void FrmServerBase_Load(object sender, EventArgs e)
{
MenuItem menuitem = new MenuItem("退出");
notifyIcon1.ContextMenu = new ContextMenu(new MenuItem[] { menuitem });
menuitem.Click += new EventHandler(Menuitem_Click);
notifyIcon1.MouseClick += new MouseEventHandler(notifyicon_MouseClick);
// Thread.Sleep(2000);
}
private void notifyicon_MouseClick(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (this.WindowState == FormWindowState.Minimized)
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
else if (this.WindowState == FormWindowState.Normal)
{
this.Activate();
}
}
private void Menuitem_Click(object sender, EventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
StopServer();
Thread.Sleep(1000);
this.Dispose();
Application.Exit();
}
public virtual void StopServer()
{
throw new NotImplementedException();
}
private void FrmServerBase_SizeChanged(object sender, EventArgs e)
{
//如果最小化
if (this.WindowState == FormWindowState.Minimized)
{
HideWindow();
}
}
private void FrmServerBase_FormClosing(object sender, FormClosingEventArgs e)
{
if (!EXIT_APP)
{
e.Cancel = true;
HideWindow();
}
}
private void HideWindow()
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
this.Hide();
this.notifyIcon1.ShowBalloonTip(3000, "", "程序后台运行中", ToolTipIcon.Info); //弹出气泡提示
}
protected override void WndProc(ref Message message)
{
switch (message.Msg)
{
case WM_QUERYENDSESSION:
EXIT_APP = true;
break;
}
base.WndProc(ref message);
}
private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
// SOCKET_SERVER.ShowClient();
}
#endregion 系统
}
}