- 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 Wrox.ProCSharp.Localization
- {
- /// <summary>
- /// Summary description for Form1.
- /// </summary>
- public class BookOfTheDayForm : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label labelBooksOfTheDay;
- private System.Windows.Forms.TextBox textDate;
- private System.Windows.Forms.TextBox textTitle;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.TextBox textItemsSold;
- private System.Windows.Forms.PictureBox pictureFlag;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public void WelcomeMessage()
- {
- ResourceManager resource = new ResourceManager("Wrox.ProCSharp.Localization.Welcome",
- Assembly.GetExecutingAssembly());
- DateTime now = DateTime.Now;
- string message;
- if (now.Hour <= 12)
- {
- message = resource.GetString("Good Morning");
- }
- else if (now.Hour <= 19)
- {
- message = resource.GetString("Good Afternoon");
- }
- else
- {
- message = resource.GetString("Good Evening");
- }
- MessageBox.Show(message + "nThis is a localization sample");
- }
- public void SetDateAndNumber()
- {
- DateTime today = DateTime.Today;
- textDate.Text = today.ToString("D");
- int itemsSold = 327444;
- textItemsSold.Text = itemsSold.ToString("###,###,###");
- }
- public BookOfTheDayForm(string culture)
- {
- if (culture != "")
- {
- CultureInfo ci = new CultureInfo(culture);
- // set culture for formatting
- Thread.CurrentThread.CurrentCulture = ci;
- // set culture for resources
- Thread.CurrentThread.CurrentUICulture = ci;
- }
- WelcomeMessage();
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- SetDateAndNumber();
- }
- /// <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.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BookOfTheDayForm));
- this.pictureFlag = new System.Windows.Forms.PictureBox();
- this.labelBooksOfTheDay = new System.Windows.Forms.Label();
- this.textDate = new System.Windows.Forms.TextBox();
- this.textTitle = new System.Windows.Forms.TextBox();
- this.label2 = new System.Windows.Forms.Label();
- this.textItemsSold = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // pictureFlag
- //
- this.pictureFlag.AccessibleDescription = resources.GetString("pictureFlag.AccessibleDescription");
- this.pictureFlag.AccessibleName = resources.GetString("pictureFlag.AccessibleName");
- this.pictureFlag.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("pictureFlag.Anchor")));
- this.pictureFlag.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureFlag.BackgroundImage")));
- this.pictureFlag.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("pictureFlag.Dock")));
- this.pictureFlag.Enabled = ((bool)(resources.GetObject("pictureFlag.Enabled")));
- this.pictureFlag.Font = ((System.Drawing.Font)(resources.GetObject("pictureFlag.Font")));
- this.pictureFlag.Image = ((System.Drawing.Image)(resources.GetObject("pictureFlag.Image")));
- this.pictureFlag.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("pictureFlag.ImeMode")));
- this.pictureFlag.Location = ((System.Drawing.Point)(resources.GetObject("pictureFlag.Location")));
- this.pictureFlag.Name = "pictureFlag";
- this.pictureFlag.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("pictureFlag.RightToLeft")));
- this.pictureFlag.Size = ((System.Drawing.Size)(resources.GetObject("pictureFlag.Size")));
- this.pictureFlag.SizeMode = ((System.Windows.Forms.PictureBoxSizeMode)(resources.GetObject("pictureFlag.SizeMode")));
- this.pictureFlag.TabIndex = ((int)(resources.GetObject("pictureFlag.TabIndex")));
- this.pictureFlag.TabStop = false;
- this.pictureFlag.Text = resources.GetString("pictureFlag.Text");
- this.pictureFlag.Visible = ((bool)(resources.GetObject("pictureFlag.Visible")));
- //
- // labelBooksOfTheDay
- //
- this.labelBooksOfTheDay.AccessibleDescription = resources.GetString("labelBooksOfTheDay.AccessibleDescription");
- this.labelBooksOfTheDay.AccessibleName = resources.GetString("labelBooksOfTheDay.AccessibleName");
- this.labelBooksOfTheDay.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("labelBooksOfTheDay.Anchor")));
- this.labelBooksOfTheDay.AutoSize = ((bool)(resources.GetObject("labelBooksOfTheDay.AutoSize")));
- this.labelBooksOfTheDay.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("labelBooksOfTheDay.Dock")));
- this.labelBooksOfTheDay.Enabled = ((bool)(resources.GetObject("labelBooksOfTheDay.Enabled")));
- this.labelBooksOfTheDay.Font = ((System.Drawing.Font)(resources.GetObject("labelBooksOfTheDay.Font")));
- this.labelBooksOfTheDay.Image = ((System.Drawing.Image)(resources.GetObject("labelBooksOfTheDay.Image")));
- this.labelBooksOfTheDay.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("labelBooksOfTheDay.ImageAlign")));
- this.labelBooksOfTheDay.ImageIndex = ((int)(resources.GetObject("labelBooksOfTheDay.ImageIndex")));
- this.labelBooksOfTheDay.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("labelBooksOfTheDay.ImeMode")));
- this.labelBooksOfTheDay.Location = ((System.Drawing.Point)(resources.GetObject("labelBooksOfTheDay.Location")));
- this.labelBooksOfTheDay.Name = "labelBooksOfTheDay";
- this.labelBooksOfTheDay.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("labelBooksOfTheDay.RightToLeft")));
- this.labelBooksOfTheDay.Size = ((System.Drawing.Size)(resources.GetObject("labelBooksOfTheDay.Size")));
- this.labelBooksOfTheDay.TabIndex = ((int)(resources.GetObject("labelBooksOfTheDay.TabIndex")));
- this.labelBooksOfTheDay.Text = resources.GetString("labelBooksOfTheDay.Text");
- this.labelBooksOfTheDay.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("labelBooksOfTheDay.TextAlign")));
- this.labelBooksOfTheDay.Visible = ((bool)(resources.GetObject("labelBooksOfTheDay.Visible")));
- //
- // textDate
- //
- this.textDate.AccessibleDescription = resources.GetString("textDate.AccessibleDescription");
- this.textDate.AccessibleName = resources.GetString("textDate.AccessibleName");
- this.textDate.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textDate.Anchor")));
- this.textDate.AutoSize = ((bool)(resources.GetObject("textDate.AutoSize")));
- this.textDate.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textDate.BackgroundImage")));
- this.textDate.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textDate.Dock")));
- this.textDate.Enabled = ((bool)(resources.GetObject("textDate.Enabled")));
- this.textDate.Font = ((System.Drawing.Font)(resources.GetObject("textDate.Font")));
- this.textDate.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textDate.ImeMode")));
- this.textDate.Location = ((System.Drawing.Point)(resources.GetObject("textDate.Location")));
- this.textDate.MaxLength = ((int)(resources.GetObject("textDate.MaxLength")));
- this.textDate.Multiline = ((bool)(resources.GetObject("textDate.Multiline")));
- this.textDate.Name = "textDate";
- this.textDate.PasswordChar = ((char)(resources.GetObject("textDate.PasswordChar")));
- this.textDate.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textDate.RightToLeft")));
- this.textDate.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textDate.ScrollBars")));
- this.textDate.Size = ((System.Drawing.Size)(resources.GetObject("textDate.Size")));
- this.textDate.TabIndex = ((int)(resources.GetObject("textDate.TabIndex")));
- this.textDate.Text = resources.GetString("textDate.Text");
- this.textDate.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textDate.TextAlign")));
- this.textDate.Visible = ((bool)(resources.GetObject("textDate.Visible")));
- this.textDate.WordWrap = ((bool)(resources.GetObject("textDate.WordWrap")));
- //
- // textTitle
- //
- this.textTitle.AccessibleDescription = resources.GetString("textTitle.AccessibleDescription");
- this.textTitle.AccessibleName = resources.GetString("textTitle.AccessibleName");
- this.textTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textTitle.Anchor")));
- this.textTitle.AutoSize = ((bool)(resources.GetObject("textTitle.AutoSize")));
- this.textTitle.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textTitle.BackgroundImage")));
- this.textTitle.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textTitle.Dock")));
- this.textTitle.Enabled = ((bool)(resources.GetObject("textTitle.Enabled")));
- this.textTitle.Font = ((System.Drawing.Font)(resources.GetObject("textTitle.Font")));
- this.textTitle.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textTitle.ImeMode")));
- this.textTitle.Location = ((System.Drawing.Point)(resources.GetObject("textTitle.Location")));
- this.textTitle.MaxLength = ((int)(resources.GetObject("textTitle.MaxLength")));
- this.textTitle.Multiline = ((bool)(resources.GetObject("textTitle.Multiline")));
- this.textTitle.Name = "textTitle";
- this.textTitle.PasswordChar = ((char)(resources.GetObject("textTitle.PasswordChar")));
- this.textTitle.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textTitle.RightToLeft")));
- this.textTitle.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textTitle.ScrollBars")));
- this.textTitle.Size = ((System.Drawing.Size)(resources.GetObject("textTitle.Size")));
- this.textTitle.TabIndex = ((int)(resources.GetObject("textTitle.TabIndex")));
- this.textTitle.Text = resources.GetString("textTitle.Text");
- this.textTitle.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textTitle.TextAlign")));
- this.textTitle.Visible = ((bool)(resources.GetObject("textTitle.Visible")));
- this.textTitle.WordWrap = ((bool)(resources.GetObject("textTitle.WordWrap")));
- //
- // label2
- //
- this.label2.AccessibleDescription = resources.GetString("label2.AccessibleDescription");
- this.label2.AccessibleName = resources.GetString("label2.AccessibleName");
- this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label2.Anchor")));
- this.label2.AutoSize = ((bool)(resources.GetObject("label2.AutoSize")));
- this.label2.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label2.Dock")));
- this.label2.Enabled = ((bool)(resources.GetObject("label2.Enabled")));
- this.label2.Font = ((System.Drawing.Font)(resources.GetObject("label2.Font")));
- this.label2.Image = ((System.Drawing.Image)(resources.GetObject("label2.Image")));
- this.label2.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label2.ImageAlign")));
- this.label2.ImageIndex = ((int)(resources.GetObject("label2.ImageIndex")));
- this.label2.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label2.ImeMode")));
- this.label2.Location = ((System.Drawing.Point)(resources.GetObject("label2.Location")));
- this.label2.Name = "label2";
- this.label2.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label2.RightToLeft")));
- this.label2.Size = ((System.Drawing.Size)(resources.GetObject("label2.Size")));
- this.label2.TabIndex = ((int)(resources.GetObject("label2.TabIndex")));
- this.label2.Text = resources.GetString("label2.Text");
- this.label2.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label2.TextAlign")));
- this.label2.Visible = ((bool)(resources.GetObject("label2.Visible")));
- //
- // textItemsSold
- //
- this.textItemsSold.AccessibleDescription = resources.GetString("textItemsSold.AccessibleDescription");
- this.textItemsSold.AccessibleName = resources.GetString("textItemsSold.AccessibleName");
- this.textItemsSold.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textItemsSold.Anchor")));
- this.textItemsSold.AutoSize = ((bool)(resources.GetObject("textItemsSold.AutoSize")));
- this.textItemsSold.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textItemsSold.BackgroundImage")));
- this.textItemsSold.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textItemsSold.Dock")));
- this.textItemsSold.Enabled = ((bool)(resources.GetObject("textItemsSold.Enabled")));
- this.textItemsSold.Font = ((System.Drawing.Font)(resources.GetObject("textItemsSold.Font")));
- this.textItemsSold.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textItemsSold.ImeMode")));
- this.textItemsSold.Location = ((System.Drawing.Point)(resources.GetObject("textItemsSold.Location")));
- this.textItemsSold.MaxLength = ((int)(resources.GetObject("textItemsSold.MaxLength")));
- this.textItemsSold.Multiline = ((bool)(resources.GetObject("textItemsSold.Multiline")));
- this.textItemsSold.Name = "textItemsSold";
- this.textItemsSold.PasswordChar = ((char)(resources.GetObject("textItemsSold.PasswordChar")));
- this.textItemsSold.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textItemsSold.RightToLeft")));
- this.textItemsSold.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textItemsSold.ScrollBars")));
- this.textItemsSold.Size = ((System.Drawing.Size)(resources.GetObject("textItemsSold.Size")));
- this.textItemsSold.TabIndex = ((int)(resources.GetObject("textItemsSold.TabIndex")));
- this.textItemsSold.Text = resources.GetString("textItemsSold.Text");
- this.textItemsSold.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textItemsSold.TextAlign")));
- this.textItemsSold.Visible = ((bool)(resources.GetObject("textItemsSold.Visible")));
- this.textItemsSold.WordWrap = ((bool)(resources.GetObject("textItemsSold.WordWrap")));
- //
- // BookOfTheDayForm
- //
- this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
- this.AccessibleName = resources.GetString("$this.AccessibleName");
- this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
- this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
- this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
- this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
- this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
- this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
- this.Controls.Add(this.textItemsSold);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.textTitle);
- this.Controls.Add(this.textDate);
- this.Controls.Add(this.labelBooksOfTheDay);
- this.Controls.Add(this.pictureFlag);
- this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
- this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
- this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
- this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
- this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
- this.Name = "BookOfTheDayForm";
- this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
- this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
- this.Text = resources.GetString("$this.Text");
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- string culture = "";
- if (args.Length == 1)
- {
- culture = args[0];
- }
- Application.Run(new BookOfTheDayForm(culture));
- }
- }
- }