262 lines
8.6 KiB
C#
262 lines
8.6 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
namespace AyaNovaOL
|
|
{
|
|
/// <summary>
|
|
/// Summary description for Login.
|
|
/// </summary>
|
|
public class Login : System.Windows.Forms.Form
|
|
{
|
|
// private IContainer components;
|
|
// Create a logger for use in this class
|
|
//private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
private string mUsername;
|
|
private string mPassword;
|
|
private System.Windows.Forms.PictureBox pictureBox3;
|
|
private System.Windows.Forms.PictureBox pictureBox2;
|
|
private System.Windows.Forms.Button btnLogin;
|
|
private System.Windows.Forms.Button btnCancel;
|
|
private System.Windows.Forms.TextBox edPassword;
|
|
private System.Windows.Forms.TextBox edUsername;
|
|
private PictureBox pictureBox1;
|
|
private bool mLogin;
|
|
//case 1157
|
|
private const int WM_ACTIVATEAPP = 0x001C;
|
|
[DllImportAttribute("User32.dll")]
|
|
private static extern int SetForegroundWindow( IntPtr hWnd );
|
|
|
|
|
|
public Login(string defUserName, string defPassword)
|
|
{
|
|
|
|
//
|
|
|
|
//
|
|
// Required for Windows Form Designer support
|
|
//
|
|
InitializeComponent();
|
|
this.pictureBox1.Image = Resource1.AyaNovaOLIsplash;
|
|
this.Icon = Resource1.AyaNova5;
|
|
this.edPassword.Text=defPassword;
|
|
this.edUsername.Text=defUserName;
|
|
mUsername="";
|
|
mPassword="";
|
|
mLogin=false;
|
|
//case 1157
|
|
SetForegroundWindow(this.Handle);
|
|
}
|
|
|
|
|
|
/// <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 Windows Form 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()
|
|
{
|
|
this.pictureBox3 = new System.Windows.Forms.PictureBox();
|
|
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
|
this.btnLogin = new System.Windows.Forms.Button();
|
|
this.btnCancel = new System.Windows.Forms.Button();
|
|
this.edPassword = new System.Windows.Forms.TextBox();
|
|
this.edUsername = new System.Windows.Forms.TextBox();
|
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
|
this.SuspendLayout();
|
|
//
|
|
// pictureBox3
|
|
//
|
|
this.pictureBox3.Image = global::AyaNovaOL.Resource1.Login32;
|
|
this.pictureBox3.Location = new System.Drawing.Point(14, 120);
|
|
this.pictureBox3.Name = "pictureBox3";
|
|
this.pictureBox3.Size = new System.Drawing.Size(68, 39);
|
|
this.pictureBox3.TabIndex = 29;
|
|
this.pictureBox3.TabStop = false;
|
|
//
|
|
// pictureBox2
|
|
//
|
|
this.pictureBox2.Image = global::AyaNovaOL.Resource1.LoginPassword32;
|
|
this.pictureBox2.Location = new System.Drawing.Point(14, 166);
|
|
this.pictureBox2.Name = "pictureBox2";
|
|
this.pictureBox2.Size = new System.Drawing.Size(68, 35);
|
|
this.pictureBox2.TabIndex = 28;
|
|
this.pictureBox2.TabStop = false;
|
|
//
|
|
// btnLogin
|
|
//
|
|
this.btnLogin.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
|
this.btnLogin.Image = global::AyaNovaOL.Resource1.OK24;
|
|
this.btnLogin.Location = new System.Drawing.Point(386, 227);
|
|
this.btnLogin.Name = "btnLogin";
|
|
this.btnLogin.Size = new System.Drawing.Size(68, 41);
|
|
this.btnLogin.TabIndex = 26;
|
|
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
|
|
//
|
|
// btnCancel
|
|
//
|
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
|
this.btnCancel.Image = global::AyaNovaOL.Resource1.Cancel24;
|
|
this.btnCancel.Location = new System.Drawing.Point(14, 227);
|
|
this.btnCancel.Name = "btnCancel";
|
|
this.btnCancel.Size = new System.Drawing.Size(68, 41);
|
|
this.btnCancel.TabIndex = 25;
|
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
|
//
|
|
// edPassword
|
|
//
|
|
this.edPassword.Location = new System.Drawing.Point(82, 166);
|
|
this.edPassword.Name = "edPassword";
|
|
this.edPassword.PasswordChar = '*';
|
|
this.edPassword.Size = new System.Drawing.Size(376, 22);
|
|
this.edPassword.TabIndex = 24;
|
|
//
|
|
// edUsername
|
|
//
|
|
this.edUsername.Location = new System.Drawing.Point(82, 120);
|
|
this.edUsername.Name = "edUsername";
|
|
this.edUsername.Size = new System.Drawing.Size(372, 22);
|
|
this.edUsername.TabIndex = 23;
|
|
//
|
|
// pictureBox1
|
|
//
|
|
this.pictureBox1.Location = new System.Drawing.Point(14, 14);
|
|
this.pictureBox1.Name = "pictureBox1";
|
|
this.pictureBox1.Size = new System.Drawing.Size(440, 83);
|
|
this.pictureBox1.TabIndex = 30;
|
|
this.pictureBox1.TabStop = false;
|
|
//
|
|
// Login
|
|
//
|
|
this.AcceptButton = this.btnLogin;
|
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
|
this.CancelButton = this.btnCancel;
|
|
this.ClientSize = new System.Drawing.Size(476, 287);
|
|
this.ControlBox = false;
|
|
this.Controls.Add(this.pictureBox1);
|
|
this.Controls.Add(this.pictureBox3);
|
|
this.Controls.Add(this.pictureBox2);
|
|
this.Controls.Add(this.btnLogin);
|
|
this.Controls.Add(this.btnCancel);
|
|
this.Controls.Add(this.edPassword);
|
|
this.Controls.Add(this.edUsername);
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
this.Name = "Login";
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
|
this.Tag = "";
|
|
this.Text = "AyaNova";
|
|
this.TopMost = true;
|
|
this.Closing += new System.ComponentModel.CancelEventHandler(this.Login_Closing);
|
|
this.Load += new System.EventHandler(this.Login_Load);
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
|
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
|
this.ResumeLayout(false);
|
|
this.PerformLayout();
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void edUsername_TextChanged(object sender, System.EventArgs e)
|
|
{
|
|
btnLogin.Enabled=(edUsername.Text.Length>0);
|
|
}
|
|
|
|
private void btnLogin_Click(object sender, System.EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("btnLogin_Click");
|
|
mUsername=edUsername.Text;
|
|
mPassword=edPassword.Text;
|
|
mLogin=true;
|
|
Hide();
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, System.EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("btnCancel_Click");
|
|
mUsername="";
|
|
mPassword="";
|
|
mLogin=false;
|
|
Hide();
|
|
}
|
|
|
|
private void Login_Load(object sender, System.EventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Login_Load");
|
|
|
|
////case 1157
|
|
//this.TopLevel = true;
|
|
//this.Focus();
|
|
//edUsername.Focus();
|
|
//this.BringToFront();
|
|
|
|
}
|
|
|
|
private void Login_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
//case 1039 //log.Debug("Login_Closing");
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Username
|
|
{
|
|
get
|
|
{
|
|
return mUsername;
|
|
}
|
|
}
|
|
|
|
public string Password
|
|
{
|
|
get
|
|
{
|
|
return mPassword;
|
|
}
|
|
}
|
|
|
|
public bool LoggingIn
|
|
{
|
|
get
|
|
{
|
|
return mLogin;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|