Form1.cs
Upload User: chinafred
Upload Date: 2007-08-14
Package Size: 10127k
Code Size: 8k
Category:

ADO-ODBC

Development Platform:

C#

  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. namespace ch3_9
  8. {
  9. /// <summary>
  10. /// Form1 的摘要说明。
  11. /// </summary>
  12. public class Form1 : System.Windows.Forms.Form
  13. {
  14. private System.Windows.Forms.Label label1;
  15. private System.Windows.Forms.ComboBox comboBox1;
  16. private System.Windows.Forms.GroupBox groupBox1;
  17. private System.Windows.Forms.GroupBox groupBox2;
  18. private System.Windows.Forms.Label label2;
  19. private System.Windows.Forms.TextBox textBox1;
  20. private System.Windows.Forms.Label label3;
  21. private System.Windows.Forms.TextBox textBox2;
  22. private System.Windows.Forms.Label label4;
  23. private System.Windows.Forms.TextBox textBox3;
  24. private System.Windows.Forms.RichTextBox richTextBox1;
  25. /// <summary>
  26. /// 必需的设计器变量。
  27. /// </summary>
  28. private System.ComponentModel.Container components = null;
  29. public Form1()
  30. {
  31. //
  32. // Windows 窗体设计器支持所必需的
  33. //
  34. InitializeComponent();
  35. //初始化comboBox
  36. InitialComboBox();
  37. //更新输入法信息
  38. UpdateInfo();
  39. //
  40. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  41. //
  42. }
  43. private void InitialComboBox()
  44. {
  45. //获取系统中已经存在的输入法
  46.     InputLanguageCollection ilCollection=InputLanguage.InstalledInputLanguages;
  47. //将输入法的名称都放到comboBox中
  48. foreach (InputLanguage il in ilCollection)
  49. {
  50. this.comboBox1.Items.Add(il.LayoutName);
  51. }
  52. }
  53. /// <summary>
  54. /// 清理所有正在使用的资源。
  55. /// </summary>
  56. protected override void Dispose( bool disposing )
  57. {
  58. if( disposing )
  59. {
  60. if (components != null) 
  61. {
  62. components.Dispose();
  63. }
  64. }
  65. base.Dispose( disposing );
  66. }
  67. #region Windows Form Designer generated code
  68. /// <summary>
  69. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  70. /// 此方法的内容。
  71. /// </summary>
  72. private void InitializeComponent()
  73. {
  74. this.label1 = new System.Windows.Forms.Label();
  75. this.comboBox1 = new System.Windows.Forms.ComboBox();
  76. this.groupBox1 = new System.Windows.Forms.GroupBox();
  77. this.groupBox2 = new System.Windows.Forms.GroupBox();
  78. this.label2 = new System.Windows.Forms.Label();
  79. this.textBox1 = new System.Windows.Forms.TextBox();
  80. this.label3 = new System.Windows.Forms.Label();
  81. this.textBox2 = new System.Windows.Forms.TextBox();
  82. this.label4 = new System.Windows.Forms.Label();
  83. this.textBox3 = new System.Windows.Forms.TextBox();
  84. this.richTextBox1 = new System.Windows.Forms.RichTextBox();
  85. this.groupBox1.SuspendLayout();
  86. this.groupBox2.SuspendLayout();
  87. this.SuspendLayout();
  88. // 
  89. // label1
  90. // 
  91. this.label1.Location = new System.Drawing.Point(16, 32);
  92. this.label1.Name = "label1";
  93. this.label1.Size = new System.Drawing.Size(80, 23);
  94. this.label1.TabIndex = 0;
  95. this.label1.Text = "请选择输入法";
  96. // 
  97. // comboBox1
  98. // 
  99. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  100. this.comboBox1.Location = new System.Drawing.Point(104, 32);
  101. this.comboBox1.Name = "comboBox1";
  102. this.comboBox1.Size = new System.Drawing.Size(121, 20);
  103. this.comboBox1.TabIndex = 1;
  104. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  105. // 
  106. // groupBox1
  107. // 
  108. this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
  109. this.textBox3,
  110. this.label4,
  111. this.textBox2,
  112. this.label3,
  113. this.textBox1,
  114. this.label2});
  115. this.groupBox1.Location = new System.Drawing.Point(224, 16);
  116. this.groupBox1.Name = "groupBox1";
  117. this.groupBox1.Size = new System.Drawing.Size(240, 216);
  118. this.groupBox1.TabIndex = 3;
  119. this.groupBox1.TabStop = false;
  120. this.groupBox1.Text = "输入法信息";
  121. // 
  122. // groupBox2
  123. // 
  124. this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
  125. this.label1,
  126. this.comboBox1});
  127. this.groupBox2.Location = new System.Drawing.Point(224, 240);
  128. this.groupBox2.Name = "groupBox2";
  129. this.groupBox2.Size = new System.Drawing.Size(240, 72);
  130. this.groupBox2.TabIndex = 5;
  131. this.groupBox2.TabStop = false;
  132. this.groupBox2.Text = "选择";
  133. // 
  134. // label2
  135. // 
  136. this.label2.Location = new System.Drawing.Point(24, 24);
  137. this.label2.Name = "label2";
  138. this.label2.Size = new System.Drawing.Size(100, 24);
  139. this.label2.TabIndex = 0;
  140. this.label2.Text = "当前的输入法是";
  141. // 
  142. // textBox1
  143. // 
  144. this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  145. this.textBox1.Location = new System.Drawing.Point(24, 56);
  146. this.textBox1.Name = "textBox1";
  147. this.textBox1.Size = new System.Drawing.Size(200, 21);
  148. this.textBox1.TabIndex = 1;
  149. this.textBox1.Text = "";
  150. // 
  151. // label3
  152. // 
  153. this.label3.Location = new System.Drawing.Point(24, 88);
  154. this.label3.Name = "label3";
  155. this.label3.Size = new System.Drawing.Size(136, 23);
  156. this.label3.TabIndex = 2;
  157. this.label3.Text = "系统默认的输入法是";
  158. // 
  159. // textBox2
  160. // 
  161. this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  162. this.textBox2.Location = new System.Drawing.Point(24, 112);
  163. this.textBox2.Name = "textBox2";
  164. this.textBox2.Size = new System.Drawing.Size(200, 21);
  165. this.textBox2.TabIndex = 3;
  166. this.textBox2.Text = "";
  167. // 
  168. // label4
  169. // 
  170. this.label4.Location = new System.Drawing.Point(24, 152);
  171. this.label4.Name = "label4";
  172. this.label4.Size = new System.Drawing.Size(100, 16);
  173. this.label4.TabIndex = 4;
  174. this.label4.Text = "语言区域性";
  175. // 
  176. // textBox3
  177. // 
  178. this.textBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  179. this.textBox3.Location = new System.Drawing.Point(24, 176);
  180. this.textBox3.Name = "textBox3";
  181. this.textBox3.Size = new System.Drawing.Size(200, 21);
  182. this.textBox3.TabIndex = 5;
  183. this.textBox3.Text = "";
  184. // 
  185. // richTextBox1
  186. // 
  187. this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Left;
  188. this.richTextBox1.Name = "richTextBox1";
  189. this.richTextBox1.Size = new System.Drawing.Size(200, 341);
  190. this.richTextBox1.TabIndex = 6;
  191. this.richTextBox1.Text = "";
  192. // 
  193. // Form1
  194. // 
  195. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  196. this.ClientSize = new System.Drawing.Size(488, 341);
  197. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  198.   this.richTextBox1,
  199.   this.groupBox2,
  200.   this.groupBox1});
  201. this.Name = "Form1";
  202. this.Text = "输入法设置";
  203. this.groupBox1.ResumeLayout(false);
  204. this.groupBox2.ResumeLayout(false);
  205. this.ResumeLayout(false);
  206. }
  207. #endregion
  208. /// <summary>
  209. /// 应用程序的主入口点。
  210. /// </summary>
  211. [STAThread]
  212. static void Main() 
  213. {
  214. Application.Run(new Form1());
  215. }
  216. private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
  217. {
  218. //获取选定的输入法
  219. InputLanguage il = InputLanguage.InstalledInputLanguages[this.comboBox1.SelectedIndex];
  220. //设置当前输入法
  221.             InputLanguage.CurrentInputLanguage = il;
  222.             //更新输入法信息
  223.             UpdateInfo();
  224. }
  225. private void UpdateInfo()
  226. {
  227. //获取当前输入法信息
  228. InputLanguage currentl=InputLanguage.CurrentInputLanguage;
  229. this.textBox1.Text=currentl.LayoutName;
  230.         //获取默认输入法信息
  231. InputLanguage defaultl=InputLanguage.DefaultInputLanguage;
  232. this.textBox2.Text=defaultl.LayoutName;
  233.         //当前输入法的语言区域性
  234. this.textBox3.Text=currentl.Culture.DisplayName;
  235. }
  236. }
  237. }