Commit 6d1716ad 几米阳光

增加界面隐藏功能,开机自动隐藏界面

1 个父辈 3e7085ac
......@@ -156,12 +156,18 @@
this.btnOpenWCF = new System.Windows.Forms.Button();
this.btnCloseWCF = new System.Windows.Forms.Button();
this.chbAuto = new System.Windows.Forms.CheckBox();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.显示ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox5.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox6.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// timer1
......@@ -1593,7 +1599,8 @@
this.启动ToolStripMenuItem,
this.停止ToolStripMenuItem,
this.复位ToolStripMenuItem,
this.回待机点ToolStripMenuItem});
this.回待机点ToolStripMenuItem,
this.退出ToolStripMenuItem});
this.料仓操作ToolStripMenuItem.Name = "料仓操作ToolStripMenuItem";
this.料仓操作ToolStripMenuItem.Size = new System.Drawing.Size(68, 21);
this.料仓操作ToolStripMenuItem.Text = "料仓操作";
......@@ -1805,6 +1812,42 @@
this.chbAuto.UseVisualStyleBackColor = true;
this.chbAuto.CheckedChanged += new System.EventHandler(this.chbAuto_CheckedChanged);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.显示ToolStripMenuItem,
this.toolStripMenuItem1});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(116, 48);
//
// 显示ToolStripMenuItem
//
this.显示ToolStripMenuItem.Name = "显示ToolStripMenuItem";
this.显示ToolStripMenuItem.Size = new System.Drawing.Size(115, 22);
this.显示ToolStripMenuItem.Text = "显示(&S)";
this.显示ToolStripMenuItem.Click += new System.EventHandler(this.显示ToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(115, 22);
this.toolStripMenuItem1.Text = "退出(&E)";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// notifyIcon1
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "料仓客户端";
this.notifyIcon1.Visible = true;
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.退出ToolStripMenuItem.Text = "退出系统";
this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
//
// FrmStoreBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
......@@ -1824,6 +1867,7 @@
this.Text = "AC_SA_料仓";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTest_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmStoreBox_FormClosed);
this.Load += new System.EventHandler(this.FrmTest_Load);
this.Shown += new System.EventHandler(this.FrmStoreBox_Shown);
this.groupBox5.ResumeLayout(false);
......@@ -1837,6 +1881,7 @@
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
......@@ -1976,6 +2021,11 @@
private System.Windows.Forms.CheckBox chbAutoRead;
private System.Windows.Forms.Label lblTemp;
private System.Windows.Forms.CheckBox chbAuto;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 显示ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
}
}
......@@ -145,6 +145,7 @@ namespace OnlineStore.ACSingleStore
this.ShowInTaskbar = true;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
LoadOk = true;
HideForm();
}
private DateTime preReadModblsTime = DateTime.Now;
private void timer1_Tick(object sender, EventArgs e)
......@@ -359,26 +360,10 @@ namespace OnlineStore.ACSingleStore
private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
{
try
if (e.CloseReason == CloseReason.UserClosing)//当用户点击窗体右上角X按钮或(Alt + F4)时 发生
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
if (this.停止ToolStripMenuItem.Enabled)
{
stop_button_Click(null, null);
}
KNDManager.CloseAllDO();
StoreOpenStatus(false);
KNDManager.CloseAllConnection();
WCFControl.CloseWCF();
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogUtil.error(LOGGER, ex.StackTrace);
e.Cancel = true;
HideForm();
}
}
private void btnOutStore_Click(object sender, EventArgs e)
......@@ -1116,5 +1101,68 @@ namespace OnlineStore.ACSingleStore
ManagerUtil.AutoRun(Application.ExecutablePath, false);
}
}
private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
private void ExitApp()
{
try
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
if (this.停止ToolStripMenuItem.Enabled)
{
stop_button_Click(null, null);
}
KNDManager.CloseAllDO();
StoreOpenStatus(false);
KNDManager.CloseAllConnection();
WCFControl.CloseWCF();
System.Environment.Exit(System.Environment.ExitCode);
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogUtil.error(LOGGER, ex.StackTrace);
}
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("是否确定退出?", "提示", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
ExitApp();
}
}
/// <summary>
/// 隐藏窗口
/// </summary>
private void HideForm()
{
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
this.Hide();
}
private void FrmStoreBox_FormClosed(object sender, FormClosedEventArgs e)
{
ExitApp();
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("是否确定退出?", "提示", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
ExitApp();
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!