Browse Source

增加监听关闭窗体按钮,杀死依赖服务node

guozhaoshun 6 years atrás
parent
commit
a7ca4787be
1 changed files with 14 additions and 0 deletions
  1. 14 0
      WinBox/MainForm.cs

+ 14 - 0
WinBox/MainForm.cs

@@ -32,6 +32,7 @@ namespace WinBox
             this.webBrowser1.Location = new System.Drawing.Point(0, 0);
             this.webBrowser1.Location = new System.Drawing.Point(0, 0);
             this.webBrowser1.MinimumSize = new System.Drawing.Size(0, 0);
             this.webBrowser1.MinimumSize = new System.Drawing.Size(0, 0);
             this.webBrowser1.Size = new System.Drawing.Size(Screen.GetWorkingArea(this).Width + 20, Screen.GetWorkingArea(this).Height);
             this.webBrowser1.Size = new System.Drawing.Size(Screen.GetWorkingArea(this).Width + 20, Screen.GetWorkingArea(this).Height);
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
             this.webBrowser1.TabIndex = 2;
             this.webBrowser1.TabIndex = 2;
             this.webBrowser1.ScriptErrorsSuppressed = true;
             this.webBrowser1.ScriptErrorsSuppressed = true;
 
 
@@ -54,6 +55,19 @@ namespace WinBox
             pro.Close();
             pro.Close();
         }
         }
 
 
+        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (e.CloseReason == CloseReason.UserClosing)
+            {
+                DialogResult r = MessageBox.Show("确定要退出程序?未完成的任务将会终止", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+                if (r != DialogResult.OK)
+                {
+                    e.Cancel = true;//阻止关闭窗口
+                }
+                RunBat("C:\\Lingjiao\\winBoxNode\\stop.bat");
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// 定义IE版本的枚举
         /// 定义IE版本的枚举
         /// </summary>
         /// </summary>