Browse Source

自动过站提示框自动隐藏可自选

Hcsy 7 years ago
parent
commit
9a7396f5b9
2 changed files with 77 additions and 23 deletions
  1. 42 12
      UAS_AutoPass/Form2.Designer.cs
  2. 35 11
      UAS_AutoPass/Form2.cs

+ 42 - 12
UAS_AutoPass/Form2.Designer.cs

@@ -29,6 +29,9 @@
         private void InitializeComponent()
         {
             this.label1 = new System.Windows.Forms.Label();
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.panel1.SuspendLayout();
             this.SuspendLayout();
             // 
             // label1
@@ -37,36 +40,63 @@
             this.label1.BackColor = System.Drawing.SystemColors.Menu;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label1.ForeColor = System.Drawing.Color.Black;
-            this.label1.Location = new System.Drawing.Point(37, 22);
-            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label1.MaximumSize = new System.Drawing.Size(360, 0);
+            this.label1.Location = new System.Drawing.Point(10, 8);
+            this.label1.MaximumSize = new System.Drawing.Size(300, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(0, 27);
+            this.label1.Size = new System.Drawing.Size(0, 21);
             this.label1.TabIndex = 0;
             // 
+            // checkBox1
+            // 
+            this.checkBox1.AutoSize = true;
+            this.checkBox1.BackColor = System.Drawing.SystemColors.Menu;
+            this.checkBox1.Checked = true;
+            this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.checkBox1.Font = new System.Drawing.Font("宋体", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.checkBox1.ForeColor = System.Drawing.Color.Black;
+            this.checkBox1.Location = new System.Drawing.Point(10, 54);
+            this.checkBox1.Name = "checkBox1";
+            this.checkBox1.Size = new System.Drawing.Size(84, 14);
+            this.checkBox1.TabIndex = 1;
+            this.checkBox1.Text = "是否自动隐藏";
+            this.checkBox1.UseVisualStyleBackColor = false;
+            this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
+            // 
+            // panel1
+            // 
+            this.panel1.Controls.Add(this.checkBox1);
+            this.panel1.Controls.Add(this.label1);
+            this.panel1.Location = new System.Drawing.Point(2, 0);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(310, 73);
+            this.panel1.TabIndex = 2;
+            this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
+            this.panel1.MouseEnter += new System.EventHandler(this.Form2_MouseEnter);
+            this.panel1.MouseLeave += new System.EventHandler(this.Form2_MouseLeave);
+            // 
             // Tip
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Menu;
-            this.ClientSize = new System.Drawing.Size(416, 98);
-            this.Controls.Add(this.label1);
+            this.ClientSize = new System.Drawing.Size(312, 78);
+            this.Controls.Add(this.panel1);
             this.ForeColor = System.Drawing.Color.White;
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.Name = "Tip";
             this.Text = "Form2";
             this.TopMost = true;
             this.Load += new System.EventHandler(this.Form2_Load);
-            this.MouseEnter += new System.EventHandler(this.Form2_MouseEnter);
-            this.MouseLeave += new System.EventHandler(this.Form2_MouseLeave);
-            this.ResumeLayout(false);
-            this.PerformLayout();
+            this.panel1.ResumeLayout(true);
+            this.panel1.PerformLayout();
+            this.ResumeLayout(true);
 
         }
 
         #endregion
 
         private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.CheckBox checkBox1;
+        private System.Windows.Forms.Panel panel1;
     }
 }

+ 35 - 11
UAS_AutoPass/Form2.cs

@@ -1,5 +1,6 @@
 using System;
 using System.ComponentModel;
+using System.Drawing;
 using System.Threading;
 using System.Windows.Forms;
 
@@ -47,9 +48,12 @@ namespace UAS_AutoPass
         }
         private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
         {
-            aa();
-            Thread.Sleep(2000);
-            bb();
+            if (checkBox1.Checked)
+            {
+                aa();
+                Thread.Sleep(2000);
+                bb();
+            }
         }
         public void aa()
         {
@@ -98,17 +102,37 @@ namespace UAS_AutoPass
 
         private void Form2_MouseLeave(object sender, EventArgs e)
         {
-            if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
+            if (checkBox1.Checked)
             {
-                state = 1;
-                int t = this.Left;
-                for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i=i+2)
+                Panel p = sender as Panel;
+                //如果Mouse Leave,则清除背景图,否则不处理
+                Point mousePoint = p.PointToClient(Control.MousePosition);
+                if (!p.ClientRectangle.Contains(mousePoint))
                 {
-                    this.Left = i;
-                    Application.DoEvents();
+                    if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
+                    {
+                        state = 1;
+                        int t = this.Left;
+                        for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i = i + 2)
+                        {
+                            this.Left = i;
+                            Application.DoEvents();
+                        }
+                        state = 0;
+                    }
                 }
-                state = 0;
-            }
+            }      
+        }
+
+        private void panel1_Paint(object sender, PaintEventArgs e)
+        {
+
+        }
+
+        private void checkBox1_CheckedChanged(object sender, EventArgs e)
+        {
+            if (!checkBox1.Checked)
+                aa();  
         }
     }
 }