VermiculateCastIronSetFontDialog.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace PaintDotNet.DedicatedAnalysis.VermiculateCastIron.GBT26656_2011
  12. {
  13. /// <summary>
  14. /// 字体设置
  15. /// </summary>
  16. internal class VermiculateCastIronSetFontDialog : PdnBaseForm
  17. {
  18. private GroupBox groupBox1;
  19. private Button button2;
  20. private GroupBox groupBox2;
  21. private Label label1;
  22. private ComboBox comboBox2;
  23. private ComboBox comboBox1;
  24. private Label label2;
  25. private Button button1;
  26. private VermiculateCastIronGBT26656Classification mainForm;
  27. private Label label3;
  28. private Panel panel1;
  29. private int[] fontSizes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  30. PaintDotNet.ColorsForm colorsForm1;
  31. public VermiculateCastIronSetFontDialog(VermiculateCastIronGBT26656Classification mainForm)
  32. {
  33. this.mainForm = mainForm;
  34. InitializeComponent();
  35. InitializeLanguageText();
  36. InitializeOthers();
  37. }
  38. private void InitializeLanguageText()
  39. {
  40. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  41. this.button2.Text = PdnResources.GetString("ConfirmLanguageDialog.CancelTB.ActionText");
  42. this.button1.Text = PdnResources.GetString("Menu.confirm.Text");
  43. this.groupBox2.Text = PdnResources.GetString("Menu.fonet.Text");
  44. this.label3.Text = PdnResources.GetString("Menu.fontcolor.text") + ":";
  45. this.label2.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  46. this.label1.Text = PdnResources.GetString("Menu.Font.text") + ":";
  47. this.Text = PdnResources.GetString("Menu.fonet.Text");
  48. }
  49. private void InitializeComponent()
  50. {
  51. this.groupBox1 = new System.Windows.Forms.GroupBox();
  52. this.button2 = new System.Windows.Forms.Button();
  53. this.button1 = new System.Windows.Forms.Button();
  54. this.groupBox2 = new System.Windows.Forms.GroupBox();
  55. this.panel1 = new System.Windows.Forms.Panel();
  56. this.label3 = new System.Windows.Forms.Label();
  57. this.comboBox2 = new System.Windows.Forms.ComboBox();
  58. this.comboBox1 = new System.Windows.Forms.ComboBox();
  59. this.label2 = new System.Windows.Forms.Label();
  60. this.label1 = new System.Windows.Forms.Label();
  61. this.groupBox1.SuspendLayout();
  62. this.groupBox2.SuspendLayout();
  63. this.SuspendLayout();
  64. //
  65. // groupBox1
  66. //
  67. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  68. | System.Windows.Forms.AnchorStyles.Right)));
  69. this.groupBox1.Controls.Add(this.button2);
  70. this.groupBox1.Controls.Add(this.button1);
  71. this.groupBox1.Location = new System.Drawing.Point(13, 12);
  72. this.groupBox1.Name = "groupBox1";
  73. this.groupBox1.Size = new System.Drawing.Size(283, 49);
  74. this.groupBox1.TabIndex = 1;
  75. this.groupBox1.TabStop = false;
  76. //
  77. // button2
  78. //
  79. this.button2.Location = new System.Drawing.Point(211, 17);
  80. this.button2.Name = "button2";
  81. this.button2.Size = new System.Drawing.Size(58, 22);
  82. this.button2.TabIndex = 1;
  83. this.button2.UseVisualStyleBackColor = true;
  84. this.button2.Click += new System.EventHandler(this.button2_Click);
  85. //
  86. // button1
  87. //
  88. this.button1.Location = new System.Drawing.Point(136, 17);
  89. this.button1.Name = "button1";
  90. this.button1.Size = new System.Drawing.Size(58, 22);
  91. this.button1.TabIndex = 0;
  92. this.button1.UseVisualStyleBackColor = true;
  93. this.button1.Click += new System.EventHandler(this.button1_Click);
  94. //
  95. // groupBox2
  96. //
  97. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  98. | System.Windows.Forms.AnchorStyles.Left)
  99. | System.Windows.Forms.AnchorStyles.Right)));
  100. this.groupBox2.Controls.Add(this.panel1);
  101. this.groupBox2.Controls.Add(this.label3);
  102. this.groupBox2.Controls.Add(this.comboBox2);
  103. this.groupBox2.Controls.Add(this.comboBox1);
  104. this.groupBox2.Controls.Add(this.label2);
  105. this.groupBox2.Controls.Add(this.label1);
  106. this.groupBox2.Location = new System.Drawing.Point(13, 68);
  107. this.groupBox2.Name = "groupBox2";
  108. this.groupBox2.Size = new System.Drawing.Size(283, 103);
  109. this.groupBox2.TabIndex = 2;
  110. this.groupBox2.TabStop = false;
  111. //
  112. // panel1
  113. //
  114. this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  115. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  116. this.panel1.Location = new System.Drawing.Point(120, 76);
  117. this.panel1.Name = "panel1";
  118. this.panel1.Size = new System.Drawing.Size(111, 20);
  119. this.panel1.TabIndex = 5;
  120. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  121. //
  122. // label3
  123. //
  124. this.label3.AutoSize = true;
  125. this.label3.Location = new System.Drawing.Point(51, 79);
  126. this.label3.Name = "label3";
  127. this.label3.Size = new System.Drawing.Size(65, 12);
  128. this.label3.TabIndex = 4;
  129. //
  130. // comboBox2
  131. //
  132. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  133. this.comboBox2.FormattingEnabled = true;
  134. this.comboBox2.Location = new System.Drawing.Point(120, 46);
  135. this.comboBox2.Name = "comboBox2";
  136. this.comboBox2.Size = new System.Drawing.Size(111, 20);
  137. this.comboBox2.TabIndex = 3;
  138. //
  139. // comboBox1
  140. //
  141. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  142. this.comboBox1.FormattingEnabled = true;
  143. this.comboBox1.Location = new System.Drawing.Point(120, 16);
  144. this.comboBox1.Name = "comboBox1";
  145. this.comboBox1.Size = new System.Drawing.Size(111, 20);
  146. this.comboBox1.TabIndex = 2;
  147. //
  148. // label2
  149. //
  150. this.label2.AutoSize = true;
  151. this.label2.Location = new System.Drawing.Point(51, 49);
  152. this.label2.Name = "label2";
  153. this.label2.Size = new System.Drawing.Size(41, 12);
  154. this.label2.TabIndex = 1;
  155. //
  156. // label1
  157. //
  158. this.label1.AutoSize = true;
  159. this.label1.Location = new System.Drawing.Point(51, 19);
  160. this.label1.Name = "label1";
  161. this.label1.Size = new System.Drawing.Size(41, 12);
  162. this.label1.TabIndex = 0;
  163. //
  164. // VermiculateCastIronSetFontDialog
  165. //
  166. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  167. this.ClientSize = new System.Drawing.Size(308, 184);
  168. this.Controls.Add(this.groupBox2);
  169. this.Controls.Add(this.groupBox1);
  170. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  171. this.MaximizeBox = false;
  172. this.MinimizeBox = false;
  173. this.Name = "VermiculateCastIronSetFontDialog";
  174. this.Controls.SetChildIndex(this.groupBox1, 0);
  175. this.Controls.SetChildIndex(this.groupBox2, 0);
  176. this.groupBox1.ResumeLayout(false);
  177. this.groupBox2.ResumeLayout(false);
  178. this.groupBox2.PerformLayout();
  179. this.ResumeLayout(false);
  180. }
  181. private void InitializeOthers()
  182. {
  183. ArrayList fontsItems = new ArrayList();
  184. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  185. foreach (FontFamily fontFamily in fonts.Families)
  186. {
  187. fontsItems.Add(fontFamily.Name);
  188. }
  189. this.comboBox1.DataSource = fontsItems;
  190. this.comboBox1.Text = this.mainForm.fontStyle;
  191. this.comboBox2.DataSource = fontSizes;
  192. this.comboBox2.Text = this.mainForm.fontSize + "";
  193. this.colorsForm1 = new ColorsForm();
  194. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  195. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  196. this.panel1.BackColor = this.mainForm.fontColor;
  197. }
  198. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  199. {
  200. }
  201. /// <summary>
  202. /// 取消按钮
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void button2_Click(object sender, EventArgs e)
  207. {
  208. this.Close();
  209. }
  210. /// <summary>
  211. /// 确认按钮
  212. /// </summary>
  213. /// <param name="sender"></param>
  214. /// <param name="e"></param>
  215. private void button1_Click(object sender, EventArgs e)
  216. {
  217. this.mainForm.SetVermiculateCastIronFont(this.comboBox1.SelectedItem.ToString(), float.Parse(this.comboBox2.SelectedItem.ToString()), this.panel1.BackColor);
  218. this.Close();
  219. }
  220. /// <summary>
  221. /// 字体颜色被点击
  222. /// </summary>
  223. /// <param name="sender"></param>
  224. /// <param name="e"></param>
  225. private void panel1_Click(object sender, EventArgs e)
  226. {
  227. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  228. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  229. this.colorsForm1.ShowDialog();
  230. }
  231. private void colorsForm1Changed(object sender, EventArgs e)
  232. {
  233. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  234. this.colorsForm1.Close();
  235. }
  236. }
  237. }