章政 7 лет назад
Родитель
Сommit
07db17a97b
2 измененных файлов с 61 добавлено и 15 удалено
  1. 18 15
      UAS-MES/Login.Designer.cs
  2. 43 0
      UAS-MES/Login.cs

+ 18 - 15
UAS-MES/Login.Designer.cs

@@ -37,11 +37,11 @@
             this.panel1 = new System.Windows.Forms.Panel();
             this.label4 = new System.Windows.Forms.Label();
             this.Source = new System.Windows.Forms.TextBox();
-            this.DB = new UAS_MES.CustomControl.ComBoxWithFocus.ComBoxWithFocus();
             this.label3 = new System.Windows.Forms.Label();
             this.LoginButton = new System.Windows.Forms.Button();
             this.panel2 = new System.Windows.Forms.Panel();
             this.label5 = new System.Windows.Forms.Label();
+            this.DB = new UAS_MES.CustomControl.ComBoxWithFocus.ComBoxWithFocus();
             this.panel1.SuspendLayout();
             this.panel2.SuspendLayout();
             this.SuspendLayout();
@@ -131,15 +131,6 @@
             this.Source.TabIndex = 2;
             this.Source.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Source_KeyDown);
             // 
-            // DB
-            // 
-            this.DB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.DB.FormattingEnabled = true;
-            this.DB.Location = new System.Drawing.Point(94, 204);
-            this.DB.Name = "DB";
-            this.DB.Size = new System.Drawing.Size(200, 25);
-            this.DB.TabIndex = 3;
-            // 
             // label3
             // 
             this.label3.AutoSize = true;
@@ -178,13 +169,22 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 14F);
-            this.label5.ForeColor = System.Drawing.SystemColors.Desktop;
+            this.label5.ForeColor = System.Drawing.Color.White;
             this.label5.Location = new System.Drawing.Point(3, 5);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(164, 25);
             this.label5.TabIndex = 0;
             this.label5.Text = "UAS制造执行系统";
             // 
+            // DB
+            // 
+            this.DB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.DB.FormattingEnabled = true;
+            this.DB.Location = new System.Drawing.Point(94, 204);
+            this.DB.Name = "DB";
+            this.DB.Size = new System.Drawing.Size(200, 25);
+            this.DB.TabIndex = 3;
+            // 
             // Login
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
@@ -195,7 +195,7 @@
             this.ClientSize = new System.Drawing.Size(705, 461);
             this.Controls.Add(this.panel1);
             this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.Name = "Login";
@@ -203,11 +203,14 @@
             this.Tag = "ShowDialogWindow";
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Login_FormClosing);
             this.Load += new System.EventHandler(this.Login_Load);
-            this.panel1.ResumeLayout(false);
+            this.Paint += new System.Windows.Forms.PaintEventHandler(this.Login_Paint);
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Login_MouseDown);
+            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Login_MouseMove);
+            this.panel1.ResumeLayout(true);
             this.panel1.PerformLayout();
-            this.panel2.ResumeLayout(false);
+            this.panel2.ResumeLayout(true);
             this.panel2.PerformLayout();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
 
         }
 

+ 43 - 0
UAS-MES/Login.cs

@@ -8,6 +8,9 @@ using System.Security.Cryptography.X509Certificates;
 using System.Net;
 using System.Net.Sockets;
 using System.Threading;
+using System.Drawing.Drawing2D;
+using System.Drawing;
+using UAS_MES.Properties;
 
 namespace UAS_MES
 {
@@ -21,6 +24,8 @@ namespace UAS_MES
         //注销的时候会重新生成这边变量,所以需要用static
         static LogicHandler lgc;
 
+        int Close_Size = 24;
+
         Thread LoadMasterInf;
 
         public Login()
@@ -225,5 +230,43 @@ namespace UAS_MES
             if (e.KeyCode == Keys.Enter)
                 PassWord.Focus();
         }
+
+        private void Login_Paint(object sender, PaintEventArgs e)
+        {
+            Bitmap image = Resources.dialog_close_24px_1173781_easyicon_net;
+            Rectangle rect = this.ClientRectangle;
+            //画关闭符号
+            using (Pen objpen = new Pen(Color.Black))
+            {
+                //使用图片
+                Bitmap bt = new Bitmap(image);
+                Point p5 = new Point(Width - Close_Size - 4, 4);
+                e.Graphics.DrawImage(bt, p5);
+            }
+        }
+
+        private Point offset;
+        private void Login_MouseDown(object sender, MouseEventArgs e)
+        {
+            if (MouseButtons.Left != e.Button) return;
+            Point cur = this.PointToScreen(e.Location);
+            offset = new Point(cur.X - this.Left, cur.Y - this.Top);
+
+            Rectangle rect = this.ClientRectangle;
+            rect.Offset(Width - Close_Size - 4, 4);
+            rect.Width = Close_Size;
+            rect.Height = Close_Size;
+            int x = e.X, y = e.Y;
+            bool isClose = x > rect.X && x < rect.Right && y > rect.Y && y < rect.Bottom;
+            if (isClose)
+                Close();
+        }
+
+        private void Login_MouseMove(object sender, MouseEventArgs e)
+        {
+            if (MouseButtons.Left != e.Button) return;
+            Point cur = MousePosition;
+            this.Location = new Point(cur.X - offset.X, cur.Y - offset.Y);
+        }
     }
 }