📄 logincontrol.cs
字号:
using System;
using System.Drawing;
using System.ComponentModel;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace DJD.Security
{
[ToolboxBitmap(typeof(Bitmap))]
public class LoginControl : System.Windows.Forms.UserControl
{
public event ResultDelegate Successful;
public event ResultDelegate Failed;
public event System.EventHandler Cancelled;
public delegate void ResultDelegate(string UserID);
private System.Windows.Forms.Label lPassword;
private System.Windows.Forms.PictureBox pbImage;
private System.Windows.Forms.Panel pHeader;
private System.Windows.Forms.ErrorProvider errorProvider;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Label lblUsername;
private System.Windows.Forms.ComboBox cboDomains;
private System.Windows.Forms.Label lblHeader;
private System.Windows.Forms.Label lblText;
private System.Windows.Forms.TextBox txtPassword;
public System.Windows.Forms.TextBox txtUsername;
private bool m_ShowMessageBox = true;
private string[] m_domains;
private string m_defaultDomain = System.Environment.UserDomainName;
private Authentication.AuthenticationTypes m_AuthType = Authentication.AuthenticationTypes.ActiveDirectory;
private System.Windows.Forms.Button btnCancel;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// The public Initializer.
/// </summary>
public LoginControl()
{
InitializeComponent();
this.txtUsername.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtUsername_KeyDown);
this.txtPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPassword_KeyDown);
this.cboDomains.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cboDomains_KeyDown);
this.btnCancel.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btnCancel_KeyDown);
this.btnLogin.KeyDown += new System.Windows.Forms.KeyEventHandler(this.btnLogin_KeyDown);
string[] ar = new Authentication().DomainsStr;
foreach (string s in ar)
{
this.cboDomains.Items.Add(s);
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(LoginControl));
this.btnLogin = new System.Windows.Forms.Button();
this.lPassword = new System.Windows.Forms.Label();
this.lblUsername = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.pHeader = new System.Windows.Forms.Panel();
this.pbImage = new System.Windows.Forms.PictureBox();
this.lblHeader = new System.Windows.Forms.Label();
this.lblText = new System.Windows.Forms.Label();
this.txtUsername = new System.Windows.Forms.TextBox();
this.errorProvider = new System.Windows.Forms.ErrorProvider();
this.label1 = new System.Windows.Forms.Label();
this.cboDomains = new System.Windows.Forms.ComboBox();
this.btnCancel = new System.Windows.Forms.Button();
this.pHeader.SuspendLayout();
this.SuspendLayout();
//
// btnLogin
//
this.btnLogin.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btnLogin.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnLogin.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.errorProvider.SetIconAlignment(this.btnLogin, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
this.errorProvider.SetIconPadding(this.btnLogin, 3);
this.btnLogin.Location = new System.Drawing.Point(228, 220);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(74, 20);
this.btnLogin.TabIndex = 3;
this.btnLogin.Text = "Login";
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// lPassword
//
this.lPassword.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lPassword.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lPassword.Location = new System.Drawing.Point(14, 123);
this.lPassword.Name = "lPassword";
this.lPassword.Size = new System.Drawing.Size(84, 20);
this.lPassword.TabIndex = 11;
this.lPassword.Text = "Password";
this.lPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// lblUsername
//
this.lblUsername.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblUsername.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblUsername.Location = new System.Drawing.Point(14, 83);
this.lblUsername.Name = "lblUsername";
this.lblUsername.Size = new System.Drawing.Size(84, 20);
this.lblUsername.TabIndex = 10;
this.lblUsername.Text = "Username";
this.lblUsername.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtPassword
//
this.txtPassword.Anchor = System.Windows.Forms.AnchorStyles.None;
this.txtPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtPassword.Location = new System.Drawing.Point(114, 123);
this.txtPassword.Name = "txtPassword";
this.txtPassword.Size = new System.Drawing.Size(274, 20);
this.txtPassword.TabIndex = 1;
this.txtPassword.Text = "";
//
// pHeader
//
this.pHeader.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.pHeader.Controls.Add(this.pbImage);
this.pHeader.Controls.Add(this.lblHeader);
this.pHeader.Controls.Add(this.lblText);
this.pHeader.Dock = System.Windows.Forms.DockStyle.Top;
this.pHeader.Location = new System.Drawing.Point(0, 0);
this.pHeader.Name = "pHeader";
this.pHeader.Size = new System.Drawing.Size(432, 60);
this.pHeader.TabIndex = 8;
//
// pbImage
//
this.pbImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pbImage.Image = ((System.Drawing.Image)(resources.GetObject("pbImage.Image")));
this.pbImage.Location = new System.Drawing.Point(372, 5);
this.pbImage.Name = "pbImage";
this.pbImage.Size = new System.Drawing.Size(48, 48);
this.pbImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pbImage.TabIndex = 5;
this.pbImage.TabStop = false;
//
// lblHeader
//
this.lblHeader.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lblHeader.Location = new System.Drawing.Point(10, 10);
this.lblHeader.Name = "lblHeader";
this.lblHeader.Size = new System.Drawing.Size(360, 20);
this.lblHeader.TabIndex = 3;
this.lblHeader.Text = "Login";
this.lblHeader.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblText
//
this.lblText.Location = new System.Drawing.Point(20, 30);
this.lblText.Name = "lblText";
this.lblText.Size = new System.Drawing.Size(360, 20);
this.lblText.TabIndex = 4;
this.lblText.Text = "Please enter your Username and Password.";
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// txtUsername
//
this.txtUsername.Anchor = System.Windows.Forms.AnchorStyles.None;
this.txtUsername.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtUsername.Location = new System.Drawing.Point(114, 83);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(274, 20);
this.txtUsername.TabIndex = 0;
this.txtUsername.Text = "";
//
// errorProvider
//
this.errorProvider.ContainerControl = this;
//
// label1
//
this.label1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(14, 163);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(84, 20);
this.label1.TabIndex = 13;
this.label1.Text = "Domain";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// cboDomains
//
this.cboDomains.Anchor = System.Windows.Forms.AnchorStyles.None;
this.cboDomains.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboDomains.Location = new System.Drawing.Point(114, 163);
this.cboDomains.Name = "cboDomains";
this.cboDomains.Size = new System.Drawing.Size(274, 21);
this.cboDomains.Sorted = true;
this.cboDomains.TabIndex = 2;
//
// btnCancel
//
this.btnCancel.Anchor = System.Windows.Forms.AnchorStyles.None;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnCancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnCancel.Location = new System.Drawing.Point(312, 220);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(74, 20);
this.btnCancel.TabIndex = 4;
this.btnCancel.Text = "Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// LoginControl
//
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.cboDomains);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.lPassword);
this.Controls.Add(this.lblUsername);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.pHeader);
this.Controls.Add(this.txtUsername);
this.Name = "LoginControl";
this.Size = new System.Drawing.Size(432, 250);
this.Load += new System.EventHandler(this.OnLoad);
this.pHeader.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
static void Main()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -