Browse Source

绘制登录界面关闭按钮

章政 7 years ago
parent
commit
871078eec2
3 changed files with 199 additions and 145 deletions
  1. 134 143
      UAS-MES/Login.Designer.cs
  2. 63 0
      UAS-MES/Login.cs
  3. 2 2
      UAS-MES/Main.Designer.cs

+ 134 - 143
UAS-MES/Login.Designer.cs

@@ -29,125 +29,37 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login));
-            this.UserName = new System.Windows.Forms.TextBox();
-            this.PassWord = new System.Windows.Forms.TextBox();
-            this.ForGetPwd = new System.Windows.Forms.LinkLabel();
-            this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            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.pictureBox1 = new System.Windows.Forms.PictureBox();
-            this.panel1.SuspendLayout();
-            this.panel2.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.ForGetPwd = new System.Windows.Forms.LinkLabel();
+            this.ChineseTitle = new System.Windows.Forms.Label();
+            this.Source = new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox();
+            this.PassWord = new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox();
+            this.UserName = new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox();
+            this.DB = new UAS_MES.CustomControl.ComBoxWithFocus.ComBoxWithFocus();
             this.SuspendLayout();
             // 
-            // UserName
-            // 
-            this.UserName.Location = new System.Drawing.Point(94, 62);
-            this.UserName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.UserName.Name = "UserName";
-            this.UserName.Size = new System.Drawing.Size(200, 27);
-            this.UserName.TabIndex = 0;
-            this.UserName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UserName_KeyDown);
-            // 
-            // PassWord
-            // 
-            this.PassWord.Location = new System.Drawing.Point(94, 107);
-            this.PassWord.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.PassWord.Name = "PassWord";
-            this.PassWord.PasswordChar = '*';
-            this.PassWord.Size = new System.Drawing.Size(200, 27);
-            this.PassWord.TabIndex = 1;
-            this.PassWord.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PassWord_KeyDown);
-            // 
-            // ForGetPwd
-            // 
-            this.ForGetPwd.AutoSize = true;
-            this.ForGetPwd.Location = new System.Drawing.Point(295, 66);
-            this.ForGetPwd.Name = "ForGetPwd";
-            this.ForGetPwd.Size = new System.Drawing.Size(84, 20);
-            this.ForGetPwd.TabIndex = 5;
-            this.ForGetPwd.TabStop = true;
-            this.ForGetPwd.Text = "忘记密码?";
-            this.ForGetPwd.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.ForGetPwd_LinkClicked);
-            // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(42, 66);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(54, 20);
-            this.label1.TabIndex = 4;
-            this.label1.Text = "用户名";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(42, 111);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(51, 20);
-            this.label2.TabIndex = 5;
-            this.label2.Text = "密   码";
-            // 
-            // panel1
-            // 
-            this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
-            this.panel1.Controls.Add(this.label4);
-            this.panel1.Controls.Add(this.Source);
-            this.panel1.Controls.Add(this.DB);
-            this.panel1.Controls.Add(this.label3);
-            this.panel1.Controls.Add(this.LoginButton);
-            this.panel1.Controls.Add(this.panel2);
-            this.panel1.Controls.Add(this.UserName);
-            this.panel1.Controls.Add(this.ForGetPwd);
-            this.panel1.Controls.Add(this.PassWord);
-            this.panel1.Controls.Add(this.label2);
-            this.panel1.Controls.Add(this.label1);
-            this.panel1.Location = new System.Drawing.Point(164, 86);
-            this.panel1.Name = "panel1";
-            this.panel1.Size = new System.Drawing.Size(381, 297);
-            this.panel1.TabIndex = 9;
-            // 
             // label4
             // 
             this.label4.AutoSize = true;
-            this.label4.Location = new System.Drawing.Point(42, 160);
+            this.label4.BackColor = System.Drawing.Color.Transparent;
+            this.label4.Location = new System.Drawing.Point(242, 245);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(51, 20);
-            this.label4.TabIndex = 14;
+            this.label4.Size = new System.Drawing.Size(44, 17);
+            this.label4.TabIndex = 24;
             this.label4.Text = "资   源";
             // 
-            // Source
-            // 
-            this.Source.Location = new System.Drawing.Point(94, 157);
-            this.Source.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.Source.Name = "Source";
-            this.Source.Size = new System.Drawing.Size(200, 27);
-            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, 28);
-            this.DB.TabIndex = 3;
-            // 
             // label3
             // 
             this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(42, 209);
+            this.label3.BackColor = System.Drawing.Color.Transparent;
+            this.label3.Location = new System.Drawing.Point(242, 294);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(54, 20);
-            this.label3.TabIndex = 11;
+            this.label3.Size = new System.Drawing.Size(44, 17);
+            this.label3.TabIndex = 23;
             this.label3.Text = "数据库";
             // 
             // LoginButton
@@ -157,74 +69,153 @@
             this.LoginButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.LoginButton.Enabled = false;
             this.LoginButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
-            this.LoginButton.Location = new System.Drawing.Point(153, 250);
+            this.LoginButton.Location = new System.Drawing.Point(355, 341);
             this.LoginButton.Name = "LoginButton";
             this.LoginButton.Size = new System.Drawing.Size(75, 30);
-            this.LoginButton.TabIndex = 4;
+            this.LoginButton.TabIndex = 19;
             this.LoginButton.Text = "登陆";
             this.LoginButton.UseVisualStyleBackColor = false;
             this.LoginButton.Click += new System.EventHandler(this.LoginButton_Click);
             // 
-            // panel2
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.BackColor = System.Drawing.Color.Transparent;
+            this.label2.Location = new System.Drawing.Point(242, 203);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(44, 17);
+            this.label2.TabIndex = 22;
+            this.label2.Text = "密   码";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.BackColor = System.Drawing.Color.Transparent;
+            this.label1.Location = new System.Drawing.Point(242, 155);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(44, 17);
+            this.label1.TabIndex = 20;
+            this.label1.Text = "用户名";
+            // 
+            // ForGetPwd
+            // 
+            this.ForGetPwd.AutoSize = true;
+            this.ForGetPwd.BackColor = System.Drawing.Color.Transparent;
+            this.ForGetPwd.Location = new System.Drawing.Point(519, 153);
+            this.ForGetPwd.Name = "ForGetPwd";
+            this.ForGetPwd.Size = new System.Drawing.Size(68, 17);
+            this.ForGetPwd.TabIndex = 21;
+            this.ForGetPwd.TabStop = true;
+            this.ForGetPwd.Text = "忘记密码?";
+            this.ForGetPwd.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.ForGetPwd_LinkClicked);
+            // 
+            // ChineseTitle
+            // 
+            this.ChineseTitle.AutoSize = true;
+            this.ChineseTitle.BackColor = System.Drawing.Color.Transparent;
+            this.ChineseTitle.Font = new System.Drawing.Font("微软雅黑", 18F);
+            this.ChineseTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(6)))), ((int)(((byte)(60)))), ((int)(((byte)(130)))));
+            this.ChineseTitle.Location = new System.Drawing.Point(297, 98);
+            this.ChineseTitle.Name = "ChineseTitle";
+            this.ChineseTitle.Size = new System.Drawing.Size(207, 31);
+            this.ChineseTitle.TabIndex = 28;
+            this.ChineseTitle.Text = "UAS制造执行系统";
             // 
-            this.panel2.BackColor = System.Drawing.SystemColors.ActiveCaption;
-            this.panel2.Controls.Add(this.pictureBox1);
-            this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
-            this.panel2.Location = new System.Drawing.Point(0, 0);
-            this.panel2.Name = "panel2";
-            this.panel2.Size = new System.Drawing.Size(381, 33);
-            this.panel2.TabIndex = 6;
+            // Source
             // 
-            // pictureBox1
+            this.Source.BackColor = System.Drawing.Color.Transparent;
+            this.Source.Location = new System.Drawing.Point(303, 240);
+            this.Source.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
+            this.Source.Name = "Source";
+            this.Source.PassWordChar = '\0';
+            this.Source.R = 7;
+            this.Source.Size = new System.Drawing.Size(200, 26);
+            this.Source.TabIndex = 27;
+            this.Source.UserKeyDown += new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox.OnUserKeyDown(this.Source_KeyDown);
             // 
-            this.pictureBox1.Image = global::UAS_MES.Properties.Resources.uas_blue;
-            this.pictureBox1.Location = new System.Drawing.Point(1, 0);
-            this.pictureBox1.Name = "pictureBox1";
-            this.pictureBox1.Size = new System.Drawing.Size(83, 33);
-            this.pictureBox1.TabIndex = 0;
-            this.pictureBox1.TabStop = false;
+            // PassWord
+            // 
+            this.PassWord.BackColor = System.Drawing.Color.Transparent;
+            this.PassWord.Location = new System.Drawing.Point(303, 198);
+            this.PassWord.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
+            this.PassWord.Name = "PassWord";
+            this.PassWord.PassWordChar = '*';
+            this.PassWord.R = 7;
+            this.PassWord.Size = new System.Drawing.Size(200, 26);
+            this.PassWord.TabIndex = 26;
+            this.PassWord.UserKeyDown += new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox.OnUserKeyDown(this.PassWord_KeyDown);
+            // 
+            // UserName
+            // 
+            this.UserName.BackColor = System.Drawing.Color.Transparent;
+            this.UserName.Location = new System.Drawing.Point(303, 150);
+            this.UserName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+            this.UserName.Name = "UserName";
+            this.UserName.PassWordChar = '\0';
+            this.UserName.R = 7;
+            this.UserName.Size = new System.Drawing.Size(200, 26);
+            this.UserName.TabIndex = 25;
+            this.UserName.UserKeyDown += new UAS_MES.CustomControl.TextBoxWithIcon.RoundTextBox.OnUserKeyDown(this.UserName_KeyDown);
+            // 
+            // DB
+            // 
+            this.DB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.DB.FormattingEnabled = true;
+            this.DB.Location = new System.Drawing.Point(303, 289);
+            this.DB.Name = "DB";
+            this.DB.Size = new System.Drawing.Size(200, 25);
+            this.DB.TabIndex = 18;
             // 
             // Login
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Control;
-            this.BackgroundImage = global::UAS_MES.Properties.Resources.LoginBG;
+            this.BackgroundImage = global::UAS_MES.Properties.Resources._5600c803afc2d;
             this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
-            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.ClientSize = new System.Drawing.Size(781, 445);
+            this.Controls.Add(this.ChineseTitle);
+            this.Controls.Add(this.Source);
+            this.Controls.Add(this.PassWord);
+            this.Controls.Add(this.UserName);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.DB);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.LoginButton);
+            this.Controls.Add(this.ForGetPwd);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.DoubleBuffered = true;
+            this.Font = new System.Drawing.Font("微软雅黑", 9F);
+            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";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Tag = "ShowDialogWindow";
-            this.Text = "UAS-MES";
+            this.Text = "UAS制造执行系统";
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Login_FormClosing);
             this.Load += new System.EventHandler(this.Login_Load);
-            this.panel1.ResumeLayout(false);
-            this.panel1.PerformLayout();
-            this.panel2.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+            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.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
         #endregion
 
-        private System.Windows.Forms.TextBox UserName;
-        private System.Windows.Forms.TextBox PassWord;
-        private System.Windows.Forms.LinkLabel ForGetPwd;
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Panel panel1;
-        private System.Windows.Forms.Panel panel2;
-        private System.Windows.Forms.PictureBox pictureBox1;
-        private System.Windows.Forms.Button LoginButton;
+        private CustomControl.TextBoxWithIcon.RoundTextBox Source;
+        private CustomControl.TextBoxWithIcon.RoundTextBox PassWord;
+        private CustomControl.TextBoxWithIcon.RoundTextBox UserName;
+        private System.Windows.Forms.Label label4;
         private CustomControl.ComBoxWithFocus.ComBoxWithFocus DB;
         private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.TextBox Source;
+        private System.Windows.Forms.Button LoginButton;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.LinkLabel ForGetPwd;
+        private System.Windows.Forms.Label ChineseTitle;
     }
 }

+ 63 - 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,63 @@ namespace UAS_MES
             if (e.KeyCode == Keys.Enter)
                 PassWord.Focus();
         }
+
+        private void Login_Paint(object sender, PaintEventArgs e)
+        {
+            //简单的画一个浅蓝色的背景
+            Graphics gra = e.Graphics;
+            //绘制背景框
+            int startheight = 65;
+            int startwidth = 100;
+            int boxheight = 330;
+            Rectangle Rect = new Rectangle(startwidth, startheight, Width - startwidth * 2 - 5, boxheight);
+            LinearGradientBrush Bru = new LinearGradientBrush(Rect, Color.FromArgb(125, Color.WhiteSmoke), Color.FromArgb(229, 237, 248), LinearGradientMode.Vertical);
+            gra.FillRectangle(Bru, Rect);
+            Pen ArcPen = new Pen(Color.FromArgb(77, 109, 148), 3);
+            int R = 14;
+            GraphicsPath path = new GraphicsPath();
+            gra.SmoothingMode = SmoothingMode.HighQuality;
+            path.AddArc(startwidth, startheight - 3, R, R, 180, 90);
+            path.AddArc(this.Width - startwidth - 19, startheight - 3, R, R, -90, 90);
+            path.AddArc(this.Width - startwidth - 19, startheight + boxheight - R, R, R, 0, 90);
+            path.AddArc(startwidth, startheight + boxheight - R, R, R, 90, 90);
+            path.CloseFigure();
+            gra.DrawPath(ArcPen, path);
+
+            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);
+        }
     }
 }

+ 2 - 2
UAS-MES/Main.Designer.cs

@@ -72,10 +72,10 @@
             this.MainTabControl.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
             this.MainTabControl.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.MainTabControl.ItemSize = new System.Drawing.Size(96, 25);
-            this.MainTabControl.Location = new System.Drawing.Point(173, 33);
+            this.MainTabControl.Location = new System.Drawing.Point(170, 33);
             this.MainTabControl.Name = "MainTabControl";
             this.MainTabControl.SelectedIndex = 0;
-            this.MainTabControl.Size = new System.Drawing.Size(802, 560);
+            this.MainTabControl.Size = new System.Drawing.Size(805, 560);
             this.MainTabControl.TabIndex = 7;
             this.MainTabControl.Selected += new System.Windows.Forms.TabControlEventHandler(this.MainTabControl_Selected);
             this.MainTabControl.ControlRemoved += new System.Windows.Forms.ControlEventHandler(this.MainTabControl_ControlRemoved);