Procházet zdrojové kódy

更换启动程序和窗体禁止关闭

章政 před 7 roky
rodič
revize
616da3d646

+ 2 - 0
UAS_AutoUpdate/CheckUpdateWindow.Designer.cs

@@ -55,8 +55,10 @@
             this.ClientSize = new System.Drawing.Size(373, 142);
             this.Controls.Add(this._processrate);
             this.Controls.Add(this._progressbar);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
             this.Name = "CheckUpdateWindow";
             this.Text = "检测升级";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.CheckUpdateWindow_FormClosing);
             this.Load += new System.EventHandler(this.CheckUpdateWindow_Load);
             this.ResumeLayout(false);
             this.PerformLayout();

+ 13 - 2
UAS_AutoUpdate/CheckUpdateWindow.cs

@@ -17,6 +17,8 @@ namespace UAS_AutoUpdate
 
         string ServerConfigFile = "ServerConfig.xml";
 
+        public bool CloseWhenFinished = false;
+
         public CheckUpdateWindow()
         {
             InitializeComponent();
@@ -47,7 +49,7 @@ namespace UAS_AutoUpdate
             //进行版本的比较
             if (ver1 > ver2)
             {
-                Process[] pro = Process.GetProcessesByName("UAS_MES");
+                Process[] pro = Process.GetProcessesByName("UAS_MES_NEW");
                 if (pro.Length > 0)
                 {
                     string CloseProcess = MessageBox.Show(this.ParentForm, "检测到程序仍在运行,是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
@@ -60,6 +62,7 @@ namespace UAS_AutoUpdate
                     }
                     else
                     {
+                        CloseWhenFinished = true;
                         Close();
                         return;
                     }
@@ -71,6 +74,7 @@ namespace UAS_AutoUpdate
             else
             {
                 Process p = Process.Start("UAS_MES_NEW.exe");
+                CloseWhenFinished = true;
                 Close();
             }
         }
@@ -192,10 +196,17 @@ namespace UAS_AutoUpdate
                 }
                 else
                 {
+                    CloseWhenFinished = true;
                     Close();
                 }
             }
         }
+
+        private void CheckUpdateWindow_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            if (!CloseWhenFinished)
+                e.Cancel = true;
+        }
     }
 
     public class ZipHelper
@@ -226,7 +237,7 @@ namespace UAS_AutoUpdate
                     {
                         continue;
                     }
-                
+
                     string directorName = Path.Combine(UnZipPath, Path.GetDirectoryName(theEntry.Name));
                     string fileName = Path.Combine(directorName, Path.GetFileName(theEntry.Name));
                     if (!Directory.Exists(directorName))