|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text;
using Simple_AD_Browser_Helpers;
namespace Simple_AD_Browser
{
/// <summary>
/// Summary description for FrmConfig.
/// </summary>
public class FrmConnect : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label user;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txt_User;
private System.Windows.Forms.TextBox txt_Pass;
private System.Windows.Forms.Button btnOK;
private TextBox txt_Domain;
private Button btnCancel;
public Credits LoginCredits = new Credits();
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public FrmConnect()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmConnect));
this.panel1 = new System.Windows.Forms.Panel();
this.btnCancel = new System.Windows.Forms.Button();
this.txt_Domain = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.txt_Pass = new System.Windows.Forms.TextBox();
this.txt_User = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.user = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.btnCancel);
this.panel1.Controls.Add(this.txt_Domain);
this.panel1.Controls.Add(this.btnOK);
this.panel1.Controls.Add(this.txt_Pass);
this.panel1.Controls.Add(this.txt_User);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.user);
this.panel1.Controls.Add(this.label1);
resources.ApplyResources(this.panel1, "panel1");
this.panel1.Name = "panel1";
//
// btnCancel
//
resources.ApplyResources(this.btnCancel, "btnCancel");
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Name = "btnCancel";
//
// txt_Domain
//
resources.ApplyResources(this.txt_Domain, "txt_Domain");
this.txt_Domain.Name = "txt_Domain";
//
// btnOK
//
resources.ApplyResources(this.btnOK, "btnOK");
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Name = "btnOK";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// txt_Pass
//
resources.ApplyResources(this.txt_Pass, "txt_Pass");
this.txt_Pass.Name = "txt_Pass";
//
// txt_User
//
resources.ApplyResources(this.txt_User, "txt_User");
this.txt_User.Name = "txt_User";
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
//
// user
//
resources.ApplyResources(this.user, "user");
this.user.Name = "user";
//
// label1
//
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
//
// FrmConnect
//
resources.ApplyResources(this, "$this");
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FrmConnect";
this.ShowInTaskbar = false;
this.Load += new System.EventHandler(this.FrmConnect_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void btnOK_Click(object sender, System.EventArgs e)
{
if (ValidateUserInput() == true)
{
LoginCredits.Domain = txt_Domain.Text;
LoginCredits.Username = txt_User.Text;
LoginCredits.Pwd = txt_Pass.Text;
FrmConnect.ActiveForm.Close();
}
else
{
DialogResult = System.Windows.Forms.DialogResult.None;
}
}
private bool ValidateUserInput()
{
try
{
if (string.IsNullOrEmpty(txt_Domain.Text)) { throw new Exception("Please maintain domain"); }
if (string.IsNullOrEmpty(txt_User.Text)) { throw new Exception("Please maintain username"); }
if (string.IsNullOrEmpty(txt_Pass.Text)) { throw new Exception("Please maintain password"); }
return true;
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
private void FrmConnect_Load(object sender, System.EventArgs e)
{
btnOK.DialogResult = DialogResult.OK;
AcceptButton = btnOK;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Sebastian is an consultant who works at Ciber Germany. He engineers software in various languages but loves C# and C. In his past projects he did CAD SAP integration, SharePoint, software design with UML and coordinating fellow developers.
In his free time he likes to build&fly R/C airplanes and take his mountain bike out for a ride.