Эх сурвалжийг харах

打印插件设为不可见

Hcsy 7 жил өмнө
parent
commit
fb83954923

+ 8 - 5
UAS_PRINT/Form2.Designer.cs

@@ -28,9 +28,10 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2));
-            this.提示 = new System.Windows.Forms.NotifyIcon();
-            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip();
+            this.提示 = new System.Windows.Forms.NotifyIcon(this.components);
+            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
             this.打开根目录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.contextMenuStrip1.SuspendLayout();
@@ -49,19 +50,19 @@
             this.打开根目录ToolStripMenuItem,
             this.退出ToolStripMenuItem});
             this.contextMenuStrip1.Name = "contextMenuStrip1";
-            this.contextMenuStrip1.Size = new System.Drawing.Size(153, 70);
+            this.contextMenuStrip1.Size = new System.Drawing.Size(137, 48);
             // 
             // 打开根目录ToolStripMenuItem
             // 
             this.打开根目录ToolStripMenuItem.Name = "打开根目录ToolStripMenuItem";
-            this.打开根目录ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.打开根目录ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
             this.打开根目录ToolStripMenuItem.Text = "打开根目录";
             this.打开根目录ToolStripMenuItem.Click += new System.EventHandler(this.打开根目录ToolStripMenuItem_Click);
             // 
             // 退出ToolStripMenuItem
             // 
             this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
-            this.退出ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.退出ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
             this.退出ToolStripMenuItem.Text = "退出";
             this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
             // 
@@ -74,7 +75,9 @@
             this.ShowInTaskbar = false;
             this.Text = "Form2";
             this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form2_FormClosing);
             this.Load += new System.EventHandler(this.Form2_Load);
+            this.Shown += new System.EventHandler(this.Form2_Shown);
             this.contextMenuStrip1.ResumeLayout(false);
             this.ResumeLayout(false);
 

+ 18 - 9
UAS_PRINT/Form2.cs

@@ -86,10 +86,7 @@ namespace UAS_PRINT
                         }
                         else
                         {
-                            lock ("B")
-                            {
-                                PrintHandler.zplprint(req);
-                            }
+                            PrintHandler.zplprint(req);
                         }
                     }
                     else if (requestContext.Request.Url.PathAndQuery == "/default?type=printer")
@@ -154,16 +151,28 @@ namespace UAS_PRINT
         }
 
         private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
-        {
-            ThrednHttpPostRequest.Abort();
-            httpPostRequest.Close();
-            this.Close();
-            this.Dispose();
+        {         
+            Close();
         }
 
         private void 打开根目录ToolStripMenuItem_Click(object sender, EventArgs e)
         {
             System.Diagnostics.Process.Start(System.AppDomain.CurrentDomain.BaseDirectory);
         }
+
+        private void Form2_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            提示.ShowBalloonTip(30, "提示", "程序关闭", ToolTipIcon.Info);
+            if (ThrednHttpPostRequest.IsAlive)
+                ThrednHttpPostRequest.Abort();
+            if (httpPostRequest.IsListening)
+                httpPostRequest.Close();
+            this.Dispose();
+        }
+
+        private void Form2_Shown(object sender, EventArgs e)
+        {
+            this.Visible = false;
+        }
     }
 }

+ 0 - 6
UAS_PRINT/UAS_PRINT.csproj

@@ -63,12 +63,6 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Form1.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="Form1.Designer.cs">
-      <DependentUpon>Form1.cs</DependentUpon>
-    </Compile>
     <Compile Include="Form2.cs">
       <SubType>Form</SubType>
     </Compile>