using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;
namespace MultiLanguage
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Login : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label lblUserID;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox tbUserID;
private System.Windows.Forms.TextBox tbPassword;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.GroupBox gbLanguage;
private System.Windows.Forms.RadioButton rdbCHS;
private System.Windows.Forms.RadioButton rdbCHT;
private System.Windows.Forms.RadioButton rdbEN;
protected CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name);
private static ResourceManager rmLogin = new ResourceManager("MultiLanguage.MultiLanguage.Login", Assembly.GetExecutingAssembly()); //
#region "构造函数"
public Login()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
#endregion
#region "VS.NET自动生成的代码"
/// <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.lblUserID = new System.Windows.Forms.Label();
this.lblPassword = new System.Windows.Forms.Label();
this.tbUserID = new System.Windows.Forms.TextBox();
this.tbPassword = new System.Windows.Forms.TextBox();
this.btnLogin = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.gbLanguage = new System.Windows.Forms.GroupBox();
this.rdbEN = new System.Windows.Forms.RadioButton();
this.rdbCHT = new System.Windows.Forms.RadioButton();
this.rdbCHS = new System.Windows.Forms.RadioButton();
this.gbLanguage.SuspendLayout();
this.SuspendLayout();
//
// lblUserID
//
this.lblUserID.Location = new System.Drawing.Point(24, 21);
this.lblUserID.Name = "lblUserID";
this.lblUserID.Size = new System.Drawing.Size(100, 16);
this.lblUserID.TabIndex = 0;
this.lblUserID.Text = "帐号";
//
// lblPassword
//
this.lblPassword.Location = new System.Drawing.Point(24, 53);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(100, 16);
this.lblPassword.TabIndex = 1;
this.lblPassword.Text = "密码";
//
// tbUserID
//
this.tbUserID.Location = new System.Drawing.Point(128, 16);
this.tbUserID.Name = "tbUserID";
this.tbUserID.Size = new System.Drawing.Size(160, 21);
this.tbUserID.TabIndex = 2;
this.tbUserID.Text = "";
//
// tbPassword
//
this.tbPassword.Location = new System.Drawing.Point(128, 48);
this.tbPassword.Name = "tbPassword";
this.tbPassword.Size = new System.Drawing.Size(160, 21);
this.tbPassword.TabIndex = 3;
this.tbPassword.Text = "";
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(128, 128);
this.btnLogin.Name = "btnLogin";
this.btnLogin.TabIndex = 4;
this.btnLogin.Text = "登陆";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(213, 128);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "取消";
//
// gbLanguage
//
this.gbLanguage.Controls.Add(this.rdbEN);
this.gbLanguage.Controls.Add(this.rdbCHT);
this.gbLanguage.Controls.Add(this.rdbCHS);
this.gbLanguage.Location = new System.Drawing.Point(24, 80);
this.gbLanguage.Name = "gbLanguage";
this.gbLanguage.Size = new System.Drawing.Size(264, 40);
this.gbLanguage.TabIndex = 6;
this.gbLanguage.TabStop = false;
this.gbLanguage.Text = "选择语言";
//
// rdbEN
//
this.rdbEN.Location = new System.Drawing.Point(152, 14);
this.rdbEN.Name = "rdbEN";
this.rdbEN.TabIndex = 2;
this.rdbEN.Text = "English";
this.rdbEN.CheckedChanged += new System.EventHandler(this.rdbCHS_CheckedChanged);
//
// rdbCHT
//
this.rdbCHT.Location = new System.Drawing.Point(80, 14);
this.rdbCHT.Name = "rdbCHT";
this.rdbCHT.TabIndex = 1;
this.rdbCHT.Text = "繁 体";
this.rdbCHT.CheckedChanged += new System.EventHandler(this.rdbCHS_CheckedChanged);
//
// rdbCHS
//
this.rdbCHS.Checked = true;
this.rdbCHS.Location = new System.Drawing.Point(16, 14);
this.rdbCHS.Name = "rdbCHS";
this.rdbCHS.TabIndex = 0;
this.rdbCHS.TabStop = true;
this.rdbCHS.Text = "简 体";
this.rdbCHS.CheckedChanged += new System.EventHandler(this.rdbCHS_CheckedChanged);
//
// Login
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(312, 157);
this.Controls.Add(this.gbLanguage);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.tbPassword);
this.Controls.Add(this.tbUserID);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.lblUserID);
this.Name = "Login";
this.Text = "Login";
this.Load += new System.EventHandler(this.Login_Load);
this.gbLanguage.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#endregion
#region "程序主入口点"
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Login());
}
#endregion
private void Login_Load(object sender, System.EventArgs e)
{
this.ci = new CultureInfo("zh-cn");
Thread.CurrentThread.CurrentUICulture = this.ci;
RePaintUI();
}
private void rdbCHS_CheckedChanged(object sender, System.EventArgs e)
{
string strLanguage = "zh-cn";
if (rdbCHS.Checked)
{
strLanguage = "zh-cn";
}
if (rdbCHT.Checked)
{
strLanguage = "zh-tw";
}
if (rdbEN.Checked)
{
strLanguage = "en-us";
}
this.ci = new CultureInfo(strLanguage);
//根据区域性"标识符"指定的区域性初始化 CultureInfo 类的新实例。
Thread.CurrentThread.CurrentUICulture = this.ci; //set当前区域性,属性值CultureInfo,它表示当前区域性。
RePaintUI(); //依据ResourceManager当前重绘当前UI
// 全球化,1)获得资源文件, 如Login.zh-tw.resx, 2)set当前线程依选择而指定相关的资源, 值为CultureInfo
}
private void RePaintUI()
{
lblUserID.Text = rmLogin.GetString("lblUserID");
lblPassword.Text = rmLogin.GetString("lblPassword");
btnLogin.Text = rmLogin.GetString("btnLogin");
btnCancel.Text = rmLogin.GetString("btnCancel");
gbLanguage.Text = rmLogin.GetString("gbLanguage");
}
}
}