DisplaySetting.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using PaintDotNet;
  2. using System;
  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 Metis.DedicatedAnalysis.DuctileIron.GBT9441_2009.PearliteNumber
  12. {
  13. public class DisplaySetting : Form
  14. {
  15. #region
  16. /// <summary>
  17. /// Required designer variable.
  18. /// </summary>
  19. private System.ComponentModel.IContainer components = null;
  20. /// <summary>
  21. /// Clean up any resources being used.
  22. /// </summary>
  23. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  24. protected override void Dispose(bool disposing)
  25. {
  26. if (disposing && (components != null))
  27. {
  28. components.Dispose();
  29. }
  30. base.Dispose(disposing);
  31. }
  32. #region Windows Form Designer generated code
  33. private void InitializeLanguageText()
  34. {
  35. this.groupBox2.Text = PdnResources.GetString("Menu.Colorsetting.text");
  36. this.label2.Text = PdnResources.GetString("Menu.fontcolor.text");
  37. this.label1.Text = PdnResources.GetString("Menu.Fontsize.text");
  38. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  39. this.btnClose.Text = PdnResources.GetString("Menu.File.Close.Text");
  40. this.btnPreservation.Text = PdnResources.GetString("CommonAction.Save");
  41. this.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  42. }
  43. /// <summary>
  44. /// Required method for Designer support - do not modify
  45. /// the contents of this method with the code editor.
  46. /// </summary>
  47. private void InitializeComponent()
  48. {
  49. this.groupBox2 = new System.Windows.Forms.GroupBox();
  50. this.comboFontSize = new System.Windows.Forms.NumericUpDown();
  51. this.label2 = new System.Windows.Forms.Label();
  52. this.label1 = new System.Windows.Forms.Label();
  53. this.panelColour = new System.Windows.Forms.Panel();
  54. this.groupBox1 = new System.Windows.Forms.GroupBox();
  55. this.btnClose = new System.Windows.Forms.Button();
  56. this.btnPreservation = new System.Windows.Forms.Button();
  57. this.groupBox2.SuspendLayout();
  58. ((System.ComponentModel.ISupportInitialize)(this.comboFontSize)).BeginInit();
  59. this.groupBox1.SuspendLayout();
  60. this.SuspendLayout();
  61. //
  62. // groupBox2
  63. //
  64. this.groupBox2.Controls.Add(this.comboFontSize);
  65. this.groupBox2.Controls.Add(this.label2);
  66. this.groupBox2.Controls.Add(this.label1);
  67. this.groupBox2.Controls.Add(this.panelColour);
  68. this.groupBox2.Location = new System.Drawing.Point(3, 77);
  69. this.groupBox2.Name = "groupBox2";
  70. this.groupBox2.Size = new System.Drawing.Size(597, 130);
  71. this.groupBox2.TabIndex = 4;
  72. this.groupBox2.TabStop = false;
  73. //
  74. // comboFontSize
  75. //
  76. this.comboFontSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  77. this.comboFontSize.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  78. this.comboFontSize.Location = new System.Drawing.Point(66, 31);
  79. this.comboFontSize.Maximum = new decimal(new int[] {
  80. 9999,
  81. 0,
  82. 0,
  83. 0});
  84. this.comboFontSize.Minimum = new decimal(new int[] {
  85. 1,
  86. 0,
  87. 0,
  88. 0});
  89. this.comboFontSize.Name = "comboFontSize";
  90. this.comboFontSize.Size = new System.Drawing.Size(70, 26);
  91. this.comboFontSize.TabIndex = 11;
  92. this.comboFontSize.Value = new decimal(new int[] {
  93. 10,
  94. 0,
  95. 0,
  96. 0});
  97. //
  98. // label2
  99. //
  100. this.label2.AutoSize = true;
  101. this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  102. this.label2.Location = new System.Drawing.Point(152, 37);
  103. this.label2.Name = "label2";
  104. this.label2.Size = new System.Drawing.Size(0, 12);
  105. this.label2.TabIndex = 8;
  106. //
  107. // label1
  108. //
  109. this.label1.AutoSize = true;
  110. this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  111. this.label1.Location = new System.Drawing.Point(22, 37);
  112. this.label1.Name = "label1";
  113. this.label1.Size = new System.Drawing.Size(0, 12);
  114. this.label1.TabIndex = 7;
  115. //
  116. // panelColour
  117. //
  118. this.panelColour.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  119. this.panelColour.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  120. this.panelColour.Location = new System.Drawing.Point(223, 30);
  121. this.panelColour.Name = "panelColour";
  122. this.panelColour.Size = new System.Drawing.Size(70, 27);
  123. this.panelColour.TabIndex = 6;
  124. this.panelColour.Click += new System.EventHandler(this.panelColour_Click);
  125. //
  126. // groupBox1
  127. //
  128. this.groupBox1.Controls.Add(this.btnClose);
  129. this.groupBox1.Controls.Add(this.btnPreservation);
  130. this.groupBox1.Location = new System.Drawing.Point(3, 8);
  131. this.groupBox1.Name = "groupBox1";
  132. this.groupBox1.Size = new System.Drawing.Size(597, 64);
  133. this.groupBox1.TabIndex = 3;
  134. this.groupBox1.TabStop = false;
  135. //
  136. // btnClose
  137. //
  138. this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  139. | System.Windows.Forms.AnchorStyles.Right)));
  140. this.btnClose.Location = new System.Drawing.Point(399, 21);
  141. this.btnClose.Name = "btnClose";
  142. this.btnClose.Size = new System.Drawing.Size(84, 30);
  143. this.btnClose.TabIndex = 4;
  144. this.btnClose.UseVisualStyleBackColor = true;
  145. this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
  146. //
  147. // btnPreservation
  148. //
  149. this.btnPreservation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  150. | System.Windows.Forms.AnchorStyles.Right)));
  151. this.btnPreservation.Location = new System.Drawing.Point(500, 21);
  152. this.btnPreservation.Name = "btnPreservation";
  153. this.btnPreservation.Size = new System.Drawing.Size(84, 30);
  154. this.btnPreservation.TabIndex = 3;
  155. this.btnPreservation.UseVisualStyleBackColor = true;
  156. this.btnPreservation.Click += new System.EventHandler(this.btnPreservation_Click);
  157. //
  158. // DisplaySetting
  159. //
  160. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  161. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  162. this.ClientSize = new System.Drawing.Size(604, 214);
  163. this.Controls.Add(this.groupBox2);
  164. this.Controls.Add(this.groupBox1);
  165. this.Name = "DisplaySetting";
  166. this.groupBox2.ResumeLayout(false);
  167. this.groupBox2.PerformLayout();
  168. ((System.ComponentModel.ISupportInitialize)(this.comboFontSize)).EndInit();
  169. this.groupBox1.ResumeLayout(false);
  170. this.ResumeLayout(false);
  171. }
  172. #endregion
  173. private System.Windows.Forms.GroupBox groupBox2;
  174. private System.Windows.Forms.NumericUpDown comboFontSize;
  175. private System.Windows.Forms.Label label2;
  176. private System.Windows.Forms.Label label1;
  177. private System.Windows.Forms.Panel panelColour;
  178. private System.Windows.Forms.GroupBox groupBox1;
  179. private System.Windows.Forms.Button btnClose;
  180. private System.Windows.Forms.Button btnPreservation;
  181. #endregion
  182. /// <summary>
  183. /// 调色板
  184. /// </summary>
  185. PaintDotNet.ColorsForm colorsForm;
  186. public DisplaySetting()
  187. {
  188. InitializeComponent();
  189. InitializeLanguageText();
  190. InitOtherTools();
  191. }
  192. private void InitOtherTools()
  193. {
  194. //
  195. //调色板
  196. //
  197. this.colorsForm = new ColorsForm();
  198. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  199. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  200. if (PearliteNumberDialog.pearliteNumberDialog.colourFont != null)
  201. {
  202. this.comboFontSize.Text = PearliteNumberDialog.pearliteNumberDialog.colourFont.Keys.First();
  203. this.panelColour.BackColor = PearliteNumberDialog.pearliteNumberDialog.colourFont.Values.First();
  204. }
  205. else
  206. {
  207. this.comboFontSize.Text = 10.ToString();
  208. this.panelColour.BackColor = Color.Black;
  209. }
  210. }
  211. /// <summary>
  212. /// 调色板回调函数
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="ce"></param>
  216. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  217. {
  218. }
  219. private void panelColour_Click(object sender, EventArgs e)
  220. {
  221. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panelColour.BackColor);
  222. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.colorsFormChanged));
  223. this.colorsForm.ShowDialog();
  224. }
  225. private void colorsFormChanged(object sender, EventArgs e)
  226. {
  227. this.panelColour.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  228. this.colorsForm.Close();
  229. }
  230. private void btnPreservation_Click(object sender, EventArgs e)
  231. {
  232. PearliteNumberDialog.pearliteNumberDialog.colourFont.Clear();
  233. PearliteNumberDialog.pearliteNumberDialog.colourFont.Add(this.comboFontSize.Text, this.panelColour.BackColor);
  234. if (PearliteNumberDialog.pearliteNumberDialog.checkBox5.Checked)
  235. {
  236. PearliteNumberDialog.pearliteNumberDialog.AddPictureBoxEvent();
  237. PearliteNumberDialog.pearliteNumberDialog.documentWorkspace.Refresh();
  238. }
  239. this.Close();
  240. }
  241. private void btnClose_Click(object sender, EventArgs e)
  242. {
  243. this.Close();
  244. }
  245. }
  246. }