|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Globalization;
using System.Threading;
namespace TestCSharp
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
internal System.Windows.Forms.Label lblCulture;
internal System.Windows.Forms.ComboBox cmbCulture;
internal System.Windows.Forms.Label lblTitle;
internal System.Windows.Forms.Label Label5;
internal System.Windows.Forms.Label Label4;
internal System.Windows.Forms.Label Label3;
internal System.Windows.Forms.Label Label2;
internal System.Windows.Forms.Label Label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// 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()
{
this.lblCulture = new System.Windows.Forms.Label();
this.cmbCulture = new System.Windows.Forms.ComboBox();
this.lblTitle = new System.Windows.Forms.Label();
this.Label5 = new System.Windows.Forms.Label();
this.Label4 = new System.Windows.Forms.Label();
this.Label3 = new System.Windows.Forms.Label();
this.Label2 = new System.Windows.Forms.Label();
this.Label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblCulture
//
this.lblCulture.Location = new System.Drawing.Point(24, 40);
this.lblCulture.Name = "lblCulture";
this.lblCulture.Size = new System.Drawing.Size(216, 16);
this.lblCulture.TabIndex = 15;
this.lblCulture.Text = "Select Culture";
//
// cmbCulture
//
this.cmbCulture.Location = new System.Drawing.Point(24, 64);
this.cmbCulture.Name = "cmbCulture";
this.cmbCulture.Size = new System.Drawing.Size(232, 21);
this.cmbCulture.TabIndex = 14;
this.cmbCulture.Text = "Select Culture";
this.cmbCulture.SelectedIndexChanged += new System.EventHandler(this.cmbCulture_SelectedIndexChanged);
//
// lblTitle
//
this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
this.lblTitle.Location = new System.Drawing.Point(24, 16);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(272, 16);
this.lblTitle.TabIndex = 13;
this.lblTitle.Text = "CSharp Test of ResourceClassGenerator";
//
// Label5
//
this.Label5.Location = new System.Drawing.Point(24, 208);
this.Label5.Name = "Label5";
this.Label5.Size = new System.Drawing.Size(184, 16);
this.Label5.TabIndex = 12;
this.Label5.Text = "Label5";
//
// Label4
//
this.Label4.Location = new System.Drawing.Point(24, 184);
this.Label4.Name = "Label4";
this.Label4.Size = new System.Drawing.Size(184, 16);
this.Label4.TabIndex = 11;
this.Label4.Text = "Label4";
//
// Label3
//
this.Label3.Location = new System.Drawing.Point(24, 160);
this.Label3.Name = "Label3";
this.Label3.Size = new System.Drawing.Size(184, 16);
this.Label3.TabIndex = 10;
this.Label3.Text = "Label3";
//
// Label2
//
this.Label2.Location = new System.Drawing.Point(24, 136);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(184, 16);
this.Label2.TabIndex = 9;
this.Label2.Text = "Label2";
//
// Label1
//
this.Label1.Location = new System.Drawing.Point(24, 112);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(184, 16);
this.Label1.TabIndex = 8;
this.Label1.Text = "Label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(304, 266);
this.Controls.Add(this.lblCulture);
this.Controls.Add(this.cmbCulture);
this.Controls.Add(this.lblTitle);
this.Controls.Add(this.Label5);
this.Controls.Add(this.Label4);
this.Controls.Add(this.Label3);
this.Controls.Add(this.Label2);
this.Controls.Add(this.Label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
cmbCulture.Items.Add(new DisplayCulture(new CultureInfo("en")));
cmbCulture.Items.Add(new DisplayCulture(new CultureInfo("de")));
cmbCulture.SelectedIndex = 0;
Thread.CurrentThread.CurrentUICulture = ((DisplayCulture)cmbCulture.SelectedItem).Culture;
FillLabels();
}
private void FillLabels()
{
//This is how resources are fetched
//note the intellisense and how the tool forces you to use the correct number of arguments
Label1.Text = Resources.Strings.Label1.GetString();
Label2.Text = Resources.Strings.Label2.GetString("arg1", "arg2");
Label3.Text = Resources.Strings.Label3.GetString();
Label4.Text = Resources.Strings.Label4.GetString();
Label5.Text = Resources.Strings.Label5.GetString();
}
private void cmbCulture_SelectedIndexChanged(object sender, System.EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = ((DisplayCulture)cmbCulture.SelectedItem).Culture;
FillLabels();
}
private class DisplayCulture
{
public DisplayCulture(CultureInfo culture)
{
_culture = culture;
}
private CultureInfo _culture;
/// <summary>
/// Property Culture (CultureInfo)
/// </summary>
public CultureInfo Culture
{
get
{
return _culture;
}
}
public override string ToString()
{
return _culture.EnglishName;
}
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.