BookOfTheDayForm.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:17k
源码类别:

C#编程

开发平台:

Others

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Globalization;
  8. using System.Threading;
  9. using System.Resources;
  10. using System.Reflection;
  11. namespace Wrox.ProCSharp.Localization
  12. {
  13. /// <summary>
  14. /// Summary description for Form1.
  15. /// </summary>
  16. public class BookOfTheDayForm : System.Windows.Forms.Form
  17. {
  18. private System.Windows.Forms.Label labelBooksOfTheDay;
  19. private System.Windows.Forms.TextBox textDate;
  20. private System.Windows.Forms.TextBox textTitle;
  21. private System.Windows.Forms.Label label2;
  22. private System.Windows.Forms.TextBox textItemsSold;
  23. private System.Windows.Forms.PictureBox pictureFlag;
  24. /// <summary>
  25. /// Required designer variable.
  26. /// </summary>
  27. private System.ComponentModel.Container components = null;
  28. public void WelcomeMessage()
  29. {
  30. ResourceManager resource = new ResourceManager("Wrox.ProCSharp.Localization.Welcome", 
  31. Assembly.GetExecutingAssembly());
  32. DateTime now = DateTime.Now;
  33. string message;
  34. if (now.Hour <= 12)
  35. {
  36. message = resource.GetString("Good Morning");
  37. }
  38. else if (now.Hour <= 19)
  39. {
  40. message = resource.GetString("Good Afternoon");
  41. }
  42. else
  43. {
  44. message = resource.GetString("Good Evening");
  45. }
  46. MessageBox.Show(message + "nThis is a localization sample");
  47. }
  48. public void SetDateAndNumber()
  49. {
  50. DateTime today = DateTime.Today;
  51. textDate.Text = today.ToString("D");
  52. int itemsSold = 327444;
  53. textItemsSold.Text = itemsSold.ToString("###,###,###");
  54. }
  55. public BookOfTheDayForm(string culture)
  56. {
  57. if (culture != "")
  58. {
  59. CultureInfo ci = new CultureInfo(culture);
  60. // set culture for formatting
  61. Thread.CurrentThread.CurrentCulture = ci;
  62. // set culture for resources
  63. Thread.CurrentThread.CurrentUICulture = ci;
  64. }
  65. WelcomeMessage();
  66. //
  67. // Required for Windows Form Designer support
  68. //
  69. InitializeComponent();
  70. SetDateAndNumber();
  71. }
  72. /// <summary>
  73. /// Clean up any resources being used.
  74. /// </summary>
  75. protected override void Dispose( bool disposing )
  76. {
  77. if( disposing )
  78. {
  79. if (components != null) 
  80. {
  81. components.Dispose();
  82. }
  83. }
  84. base.Dispose( disposing );
  85. }
  86. #region Windows Form Designer generated code
  87. /// <summary>
  88. /// Required method for Designer support - do not modify
  89. /// the contents of this method with the code editor.
  90. /// </summary>
  91. private void InitializeComponent()
  92. {
  93. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BookOfTheDayForm));
  94. this.pictureFlag = new System.Windows.Forms.PictureBox();
  95. this.labelBooksOfTheDay = new System.Windows.Forms.Label();
  96. this.textDate = new System.Windows.Forms.TextBox();
  97. this.textTitle = new System.Windows.Forms.TextBox();
  98. this.label2 = new System.Windows.Forms.Label();
  99. this.textItemsSold = new System.Windows.Forms.TextBox();
  100. this.SuspendLayout();
  101. // 
  102. // pictureFlag
  103. // 
  104. this.pictureFlag.AccessibleDescription = resources.GetString("pictureFlag.AccessibleDescription");
  105. this.pictureFlag.AccessibleName = resources.GetString("pictureFlag.AccessibleName");
  106. this.pictureFlag.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("pictureFlag.Anchor")));
  107. this.pictureFlag.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureFlag.BackgroundImage")));
  108. this.pictureFlag.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("pictureFlag.Dock")));
  109. this.pictureFlag.Enabled = ((bool)(resources.GetObject("pictureFlag.Enabled")));
  110. this.pictureFlag.Font = ((System.Drawing.Font)(resources.GetObject("pictureFlag.Font")));
  111. this.pictureFlag.Image = ((System.Drawing.Image)(resources.GetObject("pictureFlag.Image")));
  112. this.pictureFlag.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("pictureFlag.ImeMode")));
  113. this.pictureFlag.Location = ((System.Drawing.Point)(resources.GetObject("pictureFlag.Location")));
  114. this.pictureFlag.Name = "pictureFlag";
  115. this.pictureFlag.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("pictureFlag.RightToLeft")));
  116. this.pictureFlag.Size = ((System.Drawing.Size)(resources.GetObject("pictureFlag.Size")));
  117. this.pictureFlag.SizeMode = ((System.Windows.Forms.PictureBoxSizeMode)(resources.GetObject("pictureFlag.SizeMode")));
  118. this.pictureFlag.TabIndex = ((int)(resources.GetObject("pictureFlag.TabIndex")));
  119. this.pictureFlag.TabStop = false;
  120. this.pictureFlag.Text = resources.GetString("pictureFlag.Text");
  121. this.pictureFlag.Visible = ((bool)(resources.GetObject("pictureFlag.Visible")));
  122. // 
  123. // labelBooksOfTheDay
  124. // 
  125. this.labelBooksOfTheDay.AccessibleDescription = resources.GetString("labelBooksOfTheDay.AccessibleDescription");
  126. this.labelBooksOfTheDay.AccessibleName = resources.GetString("labelBooksOfTheDay.AccessibleName");
  127. this.labelBooksOfTheDay.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("labelBooksOfTheDay.Anchor")));
  128. this.labelBooksOfTheDay.AutoSize = ((bool)(resources.GetObject("labelBooksOfTheDay.AutoSize")));
  129. this.labelBooksOfTheDay.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("labelBooksOfTheDay.Dock")));
  130. this.labelBooksOfTheDay.Enabled = ((bool)(resources.GetObject("labelBooksOfTheDay.Enabled")));
  131. this.labelBooksOfTheDay.Font = ((System.Drawing.Font)(resources.GetObject("labelBooksOfTheDay.Font")));
  132. this.labelBooksOfTheDay.Image = ((System.Drawing.Image)(resources.GetObject("labelBooksOfTheDay.Image")));
  133. this.labelBooksOfTheDay.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("labelBooksOfTheDay.ImageAlign")));
  134. this.labelBooksOfTheDay.ImageIndex = ((int)(resources.GetObject("labelBooksOfTheDay.ImageIndex")));
  135. this.labelBooksOfTheDay.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("labelBooksOfTheDay.ImeMode")));
  136. this.labelBooksOfTheDay.Location = ((System.Drawing.Point)(resources.GetObject("labelBooksOfTheDay.Location")));
  137. this.labelBooksOfTheDay.Name = "labelBooksOfTheDay";
  138. this.labelBooksOfTheDay.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("labelBooksOfTheDay.RightToLeft")));
  139. this.labelBooksOfTheDay.Size = ((System.Drawing.Size)(resources.GetObject("labelBooksOfTheDay.Size")));
  140. this.labelBooksOfTheDay.TabIndex = ((int)(resources.GetObject("labelBooksOfTheDay.TabIndex")));
  141. this.labelBooksOfTheDay.Text = resources.GetString("labelBooksOfTheDay.Text");
  142. this.labelBooksOfTheDay.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("labelBooksOfTheDay.TextAlign")));
  143. this.labelBooksOfTheDay.Visible = ((bool)(resources.GetObject("labelBooksOfTheDay.Visible")));
  144. // 
  145. // textDate
  146. // 
  147. this.textDate.AccessibleDescription = resources.GetString("textDate.AccessibleDescription");
  148. this.textDate.AccessibleName = resources.GetString("textDate.AccessibleName");
  149. this.textDate.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textDate.Anchor")));
  150. this.textDate.AutoSize = ((bool)(resources.GetObject("textDate.AutoSize")));
  151. this.textDate.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textDate.BackgroundImage")));
  152. this.textDate.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textDate.Dock")));
  153. this.textDate.Enabled = ((bool)(resources.GetObject("textDate.Enabled")));
  154. this.textDate.Font = ((System.Drawing.Font)(resources.GetObject("textDate.Font")));
  155. this.textDate.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textDate.ImeMode")));
  156. this.textDate.Location = ((System.Drawing.Point)(resources.GetObject("textDate.Location")));
  157. this.textDate.MaxLength = ((int)(resources.GetObject("textDate.MaxLength")));
  158. this.textDate.Multiline = ((bool)(resources.GetObject("textDate.Multiline")));
  159. this.textDate.Name = "textDate";
  160. this.textDate.PasswordChar = ((char)(resources.GetObject("textDate.PasswordChar")));
  161. this.textDate.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textDate.RightToLeft")));
  162. this.textDate.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textDate.ScrollBars")));
  163. this.textDate.Size = ((System.Drawing.Size)(resources.GetObject("textDate.Size")));
  164. this.textDate.TabIndex = ((int)(resources.GetObject("textDate.TabIndex")));
  165. this.textDate.Text = resources.GetString("textDate.Text");
  166. this.textDate.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textDate.TextAlign")));
  167. this.textDate.Visible = ((bool)(resources.GetObject("textDate.Visible")));
  168. this.textDate.WordWrap = ((bool)(resources.GetObject("textDate.WordWrap")));
  169. // 
  170. // textTitle
  171. // 
  172. this.textTitle.AccessibleDescription = resources.GetString("textTitle.AccessibleDescription");
  173. this.textTitle.AccessibleName = resources.GetString("textTitle.AccessibleName");
  174. this.textTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textTitle.Anchor")));
  175. this.textTitle.AutoSize = ((bool)(resources.GetObject("textTitle.AutoSize")));
  176. this.textTitle.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textTitle.BackgroundImage")));
  177. this.textTitle.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textTitle.Dock")));
  178. this.textTitle.Enabled = ((bool)(resources.GetObject("textTitle.Enabled")));
  179. this.textTitle.Font = ((System.Drawing.Font)(resources.GetObject("textTitle.Font")));
  180. this.textTitle.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textTitle.ImeMode")));
  181. this.textTitle.Location = ((System.Drawing.Point)(resources.GetObject("textTitle.Location")));
  182. this.textTitle.MaxLength = ((int)(resources.GetObject("textTitle.MaxLength")));
  183. this.textTitle.Multiline = ((bool)(resources.GetObject("textTitle.Multiline")));
  184. this.textTitle.Name = "textTitle";
  185. this.textTitle.PasswordChar = ((char)(resources.GetObject("textTitle.PasswordChar")));
  186. this.textTitle.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textTitle.RightToLeft")));
  187. this.textTitle.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textTitle.ScrollBars")));
  188. this.textTitle.Size = ((System.Drawing.Size)(resources.GetObject("textTitle.Size")));
  189. this.textTitle.TabIndex = ((int)(resources.GetObject("textTitle.TabIndex")));
  190. this.textTitle.Text = resources.GetString("textTitle.Text");
  191. this.textTitle.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textTitle.TextAlign")));
  192. this.textTitle.Visible = ((bool)(resources.GetObject("textTitle.Visible")));
  193. this.textTitle.WordWrap = ((bool)(resources.GetObject("textTitle.WordWrap")));
  194. // 
  195. // label2
  196. // 
  197. this.label2.AccessibleDescription = resources.GetString("label2.AccessibleDescription");
  198. this.label2.AccessibleName = resources.GetString("label2.AccessibleName");
  199. this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label2.Anchor")));
  200. this.label2.AutoSize = ((bool)(resources.GetObject("label2.AutoSize")));
  201. this.label2.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label2.Dock")));
  202. this.label2.Enabled = ((bool)(resources.GetObject("label2.Enabled")));
  203. this.label2.Font = ((System.Drawing.Font)(resources.GetObject("label2.Font")));
  204. this.label2.Image = ((System.Drawing.Image)(resources.GetObject("label2.Image")));
  205. this.label2.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label2.ImageAlign")));
  206. this.label2.ImageIndex = ((int)(resources.GetObject("label2.ImageIndex")));
  207. this.label2.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label2.ImeMode")));
  208. this.label2.Location = ((System.Drawing.Point)(resources.GetObject("label2.Location")));
  209. this.label2.Name = "label2";
  210. this.label2.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label2.RightToLeft")));
  211. this.label2.Size = ((System.Drawing.Size)(resources.GetObject("label2.Size")));
  212. this.label2.TabIndex = ((int)(resources.GetObject("label2.TabIndex")));
  213. this.label2.Text = resources.GetString("label2.Text");
  214. this.label2.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label2.TextAlign")));
  215. this.label2.Visible = ((bool)(resources.GetObject("label2.Visible")));
  216. // 
  217. // textItemsSold
  218. // 
  219. this.textItemsSold.AccessibleDescription = resources.GetString("textItemsSold.AccessibleDescription");
  220. this.textItemsSold.AccessibleName = resources.GetString("textItemsSold.AccessibleName");
  221. this.textItemsSold.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textItemsSold.Anchor")));
  222. this.textItemsSold.AutoSize = ((bool)(resources.GetObject("textItemsSold.AutoSize")));
  223. this.textItemsSold.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textItemsSold.BackgroundImage")));
  224. this.textItemsSold.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textItemsSold.Dock")));
  225. this.textItemsSold.Enabled = ((bool)(resources.GetObject("textItemsSold.Enabled")));
  226. this.textItemsSold.Font = ((System.Drawing.Font)(resources.GetObject("textItemsSold.Font")));
  227. this.textItemsSold.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textItemsSold.ImeMode")));
  228. this.textItemsSold.Location = ((System.Drawing.Point)(resources.GetObject("textItemsSold.Location")));
  229. this.textItemsSold.MaxLength = ((int)(resources.GetObject("textItemsSold.MaxLength")));
  230. this.textItemsSold.Multiline = ((bool)(resources.GetObject("textItemsSold.Multiline")));
  231. this.textItemsSold.Name = "textItemsSold";
  232. this.textItemsSold.PasswordChar = ((char)(resources.GetObject("textItemsSold.PasswordChar")));
  233. this.textItemsSold.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textItemsSold.RightToLeft")));
  234. this.textItemsSold.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textItemsSold.ScrollBars")));
  235. this.textItemsSold.Size = ((System.Drawing.Size)(resources.GetObject("textItemsSold.Size")));
  236. this.textItemsSold.TabIndex = ((int)(resources.GetObject("textItemsSold.TabIndex")));
  237. this.textItemsSold.Text = resources.GetString("textItemsSold.Text");
  238. this.textItemsSold.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textItemsSold.TextAlign")));
  239. this.textItemsSold.Visible = ((bool)(resources.GetObject("textItemsSold.Visible")));
  240. this.textItemsSold.WordWrap = ((bool)(resources.GetObject("textItemsSold.WordWrap")));
  241. // 
  242. // BookOfTheDayForm
  243. // 
  244. this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
  245. this.AccessibleName = resources.GetString("$this.AccessibleName");
  246. this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
  247. this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
  248. this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
  249. this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
  250. this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
  251. this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
  252. this.Controls.Add(this.textItemsSold);
  253. this.Controls.Add(this.label2);
  254. this.Controls.Add(this.textTitle);
  255. this.Controls.Add(this.textDate);
  256. this.Controls.Add(this.labelBooksOfTheDay);
  257. this.Controls.Add(this.pictureFlag);
  258. this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
  259. this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
  260. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  261. this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
  262. this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
  263. this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
  264. this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
  265. this.Name = "BookOfTheDayForm";
  266. this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
  267. this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
  268. this.Text = resources.GetString("$this.Text");
  269. this.ResumeLayout(false);
  270. }
  271. #endregion
  272. /// <summary>
  273. /// The main entry point for the application.
  274. /// </summary>
  275. [STAThread]
  276. static void Main(string[] args) 
  277. {
  278. string culture = "";
  279. if (args.Length == 1)
  280. {
  281. culture = args[0];
  282. }
  283. Application.Run(new BookOfTheDayForm(culture));
  284. }
  285. }
  286. }