GuideStyleSettingsDialog.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. using PaintDotNet.Base.SettingModel;
  2. using PaintDotNet.Base.CommTool;
  3. using System;
  4. using System.Collections;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Windows.Forms;
  8. namespace PaintDotNet.DedicatedAnalysis
  9. {
  10. public partial class GuideStyleSettingsDialog : Form
  11. {
  12. #region 控件
  13. private GroupBox groupBox2;
  14. private GroupBox groupBox3;
  15. private Button button1;
  16. private Button button2;
  17. private Label label6;
  18. private Label label5;
  19. private Label label4;
  20. private Label label3;
  21. private Label label2;
  22. private Label label1;
  23. private Panel panel1;
  24. private Panel panel2;
  25. private GroupBox groupBox1;
  26. private NumericUpDown numericUpDown2;
  27. private NumericUpDown numericUpDown1;
  28. private NumericUpDown numericUpDown4;
  29. private NumericUpDown numericUpDown3;
  30. private ComboBox comboBox1;
  31. private void InitializeLanguageText()
  32. {
  33. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  34. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  35. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  36. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.AuxiliaryLine.Text");
  37. this.label6.Text = PdnResources.GetString("Menu.size.text") + ":";
  38. this.label5.Text = PdnResources.GetString("Menu.Font.text") + ":";
  39. this.label4.Text = PdnResources.GetString("Menu.spacing.text") + ":";
  40. this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  41. this.label2.Text = PdnResources.GetString("Menu.color.text") + ":";
  42. this.label1.Text = PdnResources.GetString("Menu.Numberof.text") + ":";
  43. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  44. this.Text = PdnResources.GetString("Menu.Auxiliarylinestylesettings.text");
  45. }
  46. private void InitializeComponent()
  47. {
  48. this.groupBox1 = new System.Windows.Forms.GroupBox();
  49. this.button2 = new System.Windows.Forms.Button();
  50. this.button1 = new System.Windows.Forms.Button();
  51. this.groupBox2 = new System.Windows.Forms.GroupBox();
  52. this.comboBox1 = new System.Windows.Forms.ComboBox();
  53. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  54. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  55. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  56. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  57. this.panel2 = new System.Windows.Forms.Panel();
  58. this.label6 = new System.Windows.Forms.Label();
  59. this.label5 = new System.Windows.Forms.Label();
  60. this.label4 = new System.Windows.Forms.Label();
  61. this.label3 = new System.Windows.Forms.Label();
  62. this.label2 = new System.Windows.Forms.Label();
  63. this.label1 = new System.Windows.Forms.Label();
  64. this.groupBox3 = new System.Windows.Forms.GroupBox();
  65. this.panel1 = new System.Windows.Forms.Panel();
  66. this.groupBox1.SuspendLayout();
  67. this.groupBox2.SuspendLayout();
  68. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  69. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  70. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  71. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  72. this.groupBox3.SuspendLayout();
  73. this.SuspendLayout();
  74. //
  75. // groupBox1
  76. //
  77. this.groupBox1.Controls.Add(this.button2);
  78. this.groupBox1.Controls.Add(this.button1);
  79. this.groupBox1.Location = new System.Drawing.Point(11, 12);
  80. this.groupBox1.Name = "groupBox1";
  81. this.groupBox1.Size = new System.Drawing.Size(320, 54);
  82. this.groupBox1.TabIndex = 0;
  83. this.groupBox1.TabStop = false;
  84. //
  85. // button2
  86. //
  87. this.button2.Location = new System.Drawing.Point(228, 15);
  88. this.button2.Name = "button2";
  89. this.button2.Size = new System.Drawing.Size(70, 28);
  90. this.button2.TabIndex = 1;
  91. this.button2.UseVisualStyleBackColor = true;
  92. this.button2.Click += new System.EventHandler(this.button2_Click);
  93. //
  94. // button1
  95. //
  96. this.button1.Location = new System.Drawing.Point(139, 15);
  97. this.button1.Name = "button1";
  98. this.button1.Size = new System.Drawing.Size(70, 28);
  99. this.button1.TabIndex = 0;
  100. this.button1.UseVisualStyleBackColor = true;
  101. this.button1.Click += new System.EventHandler(this.button1_Click);
  102. //
  103. // groupBox2
  104. //
  105. this.groupBox2.Controls.Add(this.comboBox1);
  106. this.groupBox2.Controls.Add(this.numericUpDown4);
  107. this.groupBox2.Controls.Add(this.numericUpDown3);
  108. this.groupBox2.Controls.Add(this.numericUpDown2);
  109. this.groupBox2.Controls.Add(this.numericUpDown1);
  110. this.groupBox2.Controls.Add(this.panel2);
  111. this.groupBox2.Controls.Add(this.label6);
  112. this.groupBox2.Controls.Add(this.label5);
  113. this.groupBox2.Controls.Add(this.label4);
  114. this.groupBox2.Controls.Add(this.label3);
  115. this.groupBox2.Controls.Add(this.label2);
  116. this.groupBox2.Controls.Add(this.label1);
  117. this.groupBox2.Location = new System.Drawing.Point(12, 72);
  118. this.groupBox2.Name = "groupBox2";
  119. this.groupBox2.Size = new System.Drawing.Size(319, 145);
  120. this.groupBox2.TabIndex = 1;
  121. this.groupBox2.TabStop = false;
  122. //
  123. // comboBox1
  124. //
  125. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  126. this.comboBox1.FormattingEnabled = true;
  127. this.comboBox1.Location = new System.Drawing.Point(214, 65);
  128. this.comboBox1.Name = "comboBox1";
  129. this.comboBox1.Size = new System.Drawing.Size(82, 20);
  130. this.comboBox1.TabIndex = 17;
  131. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  132. //
  133. // numericUpDown4
  134. //
  135. this.numericUpDown4.Location = new System.Drawing.Point(214, 27);
  136. this.numericUpDown4.Maximum = new decimal(new int[] {
  137. 99999,
  138. 0,
  139. 0,
  140. 0});
  141. this.numericUpDown4.Minimum = new decimal(new int[] {
  142. 1,
  143. 0,
  144. 0,
  145. 0});
  146. this.numericUpDown4.Name = "numericUpDown4";
  147. this.numericUpDown4.Size = new System.Drawing.Size(82, 21);
  148. this.numericUpDown4.TabIndex = 16;
  149. this.numericUpDown4.Value = new decimal(new int[] {
  150. 1,
  151. 0,
  152. 0,
  153. 0});
  154. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  155. //
  156. // numericUpDown3
  157. //
  158. this.numericUpDown3.Location = new System.Drawing.Point(214, 104);
  159. this.numericUpDown3.Minimum = new decimal(new int[] {
  160. 1,
  161. 0,
  162. 0,
  163. 0});
  164. this.numericUpDown3.Name = "numericUpDown3";
  165. this.numericUpDown3.Size = new System.Drawing.Size(82, 21);
  166. this.numericUpDown3.TabIndex = 15;
  167. this.numericUpDown3.Value = new decimal(new int[] {
  168. 1,
  169. 0,
  170. 0,
  171. 0});
  172. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  173. //
  174. // numericUpDown2
  175. //
  176. this.numericUpDown2.Location = new System.Drawing.Point(57, 104);
  177. this.numericUpDown2.Minimum = new decimal(new int[] {
  178. 1,
  179. 0,
  180. 0,
  181. 0});
  182. this.numericUpDown2.Name = "numericUpDown2";
  183. this.numericUpDown2.Size = new System.Drawing.Size(82, 21);
  184. this.numericUpDown2.TabIndex = 14;
  185. this.numericUpDown2.Value = new decimal(new int[] {
  186. 1,
  187. 0,
  188. 0,
  189. 0});
  190. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  191. //
  192. // numericUpDown1
  193. //
  194. this.numericUpDown1.Location = new System.Drawing.Point(57, 27);
  195. this.numericUpDown1.Maximum = new decimal(new int[] {
  196. 5,
  197. 0,
  198. 0,
  199. 0});
  200. this.numericUpDown1.Minimum = new decimal(new int[] {
  201. 3,
  202. 0,
  203. 0,
  204. 0});
  205. this.numericUpDown1.Name = "numericUpDown1";
  206. this.numericUpDown1.Size = new System.Drawing.Size(82, 21);
  207. this.numericUpDown1.TabIndex = 13;
  208. this.numericUpDown1.Value = new decimal(new int[] {
  209. 3,
  210. 0,
  211. 0,
  212. 0});
  213. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  214. //
  215. // panel2
  216. //
  217. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  218. this.panel2.Location = new System.Drawing.Point(58, 65);
  219. this.panel2.Name = "panel2";
  220. this.panel2.Size = new System.Drawing.Size(81, 21);
  221. this.panel2.TabIndex = 12;
  222. this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
  223. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  224. //
  225. // label6
  226. //
  227. this.label6.AutoSize = true;
  228. this.label6.Location = new System.Drawing.Point(180, 107);
  229. this.label6.Name = "label6";
  230. this.label6.Size = new System.Drawing.Size(41, 12);
  231. this.label6.TabIndex = 5;
  232. //
  233. // label5
  234. //
  235. this.label5.AutoSize = true;
  236. this.label5.Location = new System.Drawing.Point(180, 69);
  237. this.label5.Name = "label5";
  238. this.label5.Size = new System.Drawing.Size(41, 12);
  239. this.label5.TabIndex = 4;
  240. //
  241. // label4
  242. //
  243. this.label4.AutoSize = true;
  244. this.label4.Location = new System.Drawing.Point(180, 31);
  245. this.label4.Name = "label4";
  246. this.label4.Size = new System.Drawing.Size(41, 12);
  247. this.label4.TabIndex = 3;
  248. //
  249. // label3
  250. //
  251. this.label3.AutoSize = true;
  252. this.label3.Location = new System.Drawing.Point(18, 107);
  253. this.label3.Name = "label3";
  254. this.label3.Size = new System.Drawing.Size(41, 12);
  255. this.label3.TabIndex = 2;
  256. //
  257. // label2
  258. //
  259. this.label2.AutoSize = true;
  260. this.label2.Location = new System.Drawing.Point(18, 69);
  261. this.label2.Name = "label2";
  262. this.label2.Size = new System.Drawing.Size(41, 12);
  263. this.label2.TabIndex = 1;
  264. //
  265. // label1
  266. //
  267. this.label1.AutoSize = true;
  268. this.label1.Location = new System.Drawing.Point(18, 31);
  269. this.label1.Name = "label1";
  270. this.label1.Size = new System.Drawing.Size(41, 12);
  271. this.label1.TabIndex = 0;
  272. //
  273. // groupBox3
  274. //
  275. this.groupBox3.Controls.Add(this.panel1);
  276. this.groupBox3.Location = new System.Drawing.Point(12, 223);
  277. this.groupBox3.Name = "groupBox3";
  278. this.groupBox3.Size = new System.Drawing.Size(319, 116);
  279. this.groupBox3.TabIndex = 1;
  280. this.groupBox3.TabStop = false;
  281. //
  282. // panel1
  283. //
  284. this.panel1.Location = new System.Drawing.Point(27, 17);
  285. this.panel1.Name = "panel1";
  286. this.panel1.Size = new System.Drawing.Size(270, 88);
  287. this.panel1.TabIndex = 0;
  288. this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
  289. //
  290. // GuideStyleSettingsDialog
  291. //
  292. this.ClientSize = new System.Drawing.Size(343, 351);
  293. this.Controls.Add(this.groupBox3);
  294. this.Controls.Add(this.groupBox2);
  295. this.Controls.Add(this.groupBox1);
  296. this.MaximizeBox = false;
  297. this.MaximumSize = new System.Drawing.Size(359, 390);
  298. this.MinimizeBox = false;
  299. this.MinimumSize = new System.Drawing.Size(359, 390);
  300. this.Name = "GuideStyleSettingsDialog";
  301. this.ShowInTaskbar = false;
  302. this.groupBox1.ResumeLayout(false);
  303. this.groupBox2.ResumeLayout(false);
  304. this.groupBox2.PerformLayout();
  305. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  306. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  307. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  308. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  309. this.groupBox3.ResumeLayout(false);
  310. this.ResumeLayout(false);
  311. }
  312. #endregion
  313. /// <summary>
  314. /// 字体列表
  315. /// </summary>
  316. private ArrayList fontsItems = new ArrayList();
  317. /// <summary>
  318. /// 调色板
  319. /// </summary>
  320. private PaintDotNet.ColorsForm colorsForm;
  321. public GuideStyleSettingsDialog(bool lineChange)
  322. {
  323. InitializeComponent();
  324. InitializeLanguageText();
  325. InitializeData();
  326. this.numericUpDown1.Enabled = lineChange;
  327. //调色板
  328. this.colorsForm = new ColorsForm();
  329. this.colorsForm.StartPosition = FormStartPosition.CenterScreen;
  330. this.colorsForm.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  331. }
  332. /// <summary>
  333. /// 初始化数据
  334. /// </summary>
  335. private void InitializeData()
  336. {
  337. this.fontsItems.Clear();
  338. //绑定字体数据
  339. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  340. foreach (FontFamily fontFamily in fonts.Families)
  341. {
  342. fontsItems.Add(fontFamily.Name);
  343. }
  344. this.comboBox1.DataSource = fontsItems;
  345. CompoundRatioStyleModel compoundRatioStyleModel = XmlSerializeHelper.DESerializer<CompoundRatioStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GuideStyle.xml", FileMode.Open));
  346. if (compoundRatioStyleModel.guideStyle != null)
  347. {
  348. this.numericUpDown1.Value = compoundRatioStyleModel.guideStyle.linesNumber;
  349. this.panel2.BackColor = Color.FromArgb(compoundRatioStyleModel.guideStyle.lineColor);
  350. this.numericUpDown2.Value = compoundRatioStyleModel.guideStyle.lineWidth;
  351. this.numericUpDown4.Value = compoundRatioStyleModel.guideStyle.spacing;
  352. this.comboBox1.Text = compoundRatioStyleModel.guideStyle.font;
  353. this.numericUpDown3.Value = compoundRatioStyleModel.guideStyle.fontSize;
  354. }
  355. }
  356. /// <summary>
  357. /// 页面关闭
  358. /// </summary>
  359. /// <param name="sender"></param>
  360. /// <param name="e"></param>
  361. private void button1_Click(object sender, EventArgs e)
  362. {
  363. this.Close();
  364. }
  365. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  366. {
  367. }
  368. private void panel2_Click(object sender, EventArgs e)
  369. {
  370. this.colorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  371. this.colorsForm.setSaveBtn_Click(new System.EventHandler(this.panel2Changed));
  372. this.colorsForm.ShowDialog();
  373. }
  374. private void panel2Changed(object sender, EventArgs e)
  375. {
  376. this.panel2.BackColor = this.colorsForm.UserPrimaryColor.ToColor();
  377. this.colorsForm.Close();
  378. }
  379. /// <summary>
  380. /// 保存按钮
  381. /// </summary>
  382. /// <param name="sender"></param>
  383. /// <param name="e"></param>
  384. private void button2_Click(object sender, EventArgs e)
  385. {
  386. CompoundRatioStyleModel compoundRatioStyleModelOld = XmlSerializeHelper.DESerializer<CompoundRatioStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GuideStyle.xml", FileMode.Open));
  387. CompoundRatioStyleModel compoundRatioStyleModel = new CompoundRatioStyleModel();
  388. compoundRatioStyleModel.guideStyle = new CompoundRatioStyleModel.GuideStyle();
  389. compoundRatioStyleModel.guideStyle.font = this.comboBox1.Text;
  390. compoundRatioStyleModel.guideStyle.fontSize = Convert.ToInt32(numericUpDown3.Value);
  391. compoundRatioStyleModel.guideStyle.lineColor = Convert.ToInt32(this.panel2.BackColor.ToArgb());
  392. compoundRatioStyleModel.guideStyle.linesNumber = Convert.ToInt32(numericUpDown1.Value);
  393. compoundRatioStyleModel.guideStyle.lineWidth = Convert.ToInt32(numericUpDown2.Value);
  394. compoundRatioStyleModel.guideStyle.spacing = Convert.ToInt32(numericUpDown4.Value);
  395. //以下保存xml文件信息
  396. string stageModelXml = XmlSerializeHelper.XmlSerialize<CompoundRatioStyleModel>(compoundRatioStyleModel);
  397. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GuideStyle.xml";
  398. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  399. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  400. recombinationRateDialog.RefreshPanel();
  401. if (compoundRatioStyleModelOld.guideStyle.linesNumber != Convert.ToInt32(numericUpDown1.Value)
  402. || compoundRatioStyleModelOld.guideStyle.spacing != Convert.ToInt32(numericUpDown4.Value))
  403. recombinationRateDialog.InitMeasurePoints();
  404. }
  405. /// <summary>
  406. /// 辅助线样式预览
  407. /// </summary>
  408. /// <param name="sender"></param>
  409. /// <param name="e"></param>
  410. private void panel1_Paint(object sender, PaintEventArgs e)
  411. {
  412. GuideStylePreview(e.Graphics);
  413. }
  414. /// <summary>
  415. /// 辅助线样式预览
  416. /// </summary>
  417. private void GuideStylePreview(Graphics g)
  418. {
  419. this.panel1.BackColor = Color.Black;
  420. Pen linePen = new Pen(this.panel2.BackColor, Convert.ToInt32(numericUpDown2.Value));
  421. Font textfont = new Font(this.comboBox1.Text, Convert.ToInt32(numericUpDown3.Value));
  422. SizeF size = g.MeasureString("abc", textfont);
  423. if(Convert.ToInt32(numericUpDown1.Value) == 3)
  424. {
  425. g.DrawLine(linePen, new Point(this.panel1.Width / 2 - 90, 0), new Point(this.panel1.Width / 2 - 90, this.panel1.Height));
  426. g.DrawLine(linePen, new Point(this.panel1.Width / 2, 0), new Point(this.panel1.Width / 2, this.panel1.Height));
  427. g.DrawLine(linePen, new Point(this.panel1.Width / 2 + 90, 0), new Point(this.panel1.Width / 2 + 90, this.panel1.Height));
  428. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - 90 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  429. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  430. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 + 90 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  431. }
  432. else if (Convert.ToInt32(numericUpDown1.Value) == 4)
  433. {
  434. g.DrawLine(linePen, new Point(this.panel1.Width / 2 - 105, 0), new Point(this.panel1.Width / 2 - 105, this.panel1.Height));
  435. g.DrawLine(linePen, new Point(this.panel1.Width / 2 - 35, 0), new Point(this.panel1.Width / 2 - 35, this.panel1.Height));
  436. g.DrawLine(linePen, new Point(this.panel1.Width / 2 + 35, 0), new Point(this.panel1.Width / 2 + 35, this.panel1.Height));
  437. g.DrawLine(linePen, new Point(this.panel1.Width / 2 + 105, 0), new Point(this.panel1.Width / 2 + 105, this.panel1.Height));
  438. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - 105 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  439. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - 35 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  440. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 + 35 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  441. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 + 105 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  442. }
  443. else if (Convert.ToInt32(numericUpDown1.Value) == 5)
  444. {
  445. g.DrawLine(linePen, new Point(this.panel1.Width / 2 - 108, 0), new Point(this.panel1.Width / 2 - 108, this.panel1.Height));
  446. g.DrawLine(linePen, new Point(this.panel1.Width / 2 - 54, 0), new Point(this.panel1.Width / 2 - 54, this.panel1.Height));
  447. g.DrawLine(linePen, new Point(this.panel1.Width / 2, 0), new Point(this.panel1.Width / 2, this.panel1.Height));
  448. g.DrawLine(linePen, new Point(this.panel1.Width / 2 + 54, 0), new Point(this.panel1.Width / 2 + 54, this.panel1.Height));
  449. g.DrawLine(linePen, new Point(this.panel1.Width / 2 + 108, 0), new Point(this.panel1.Width / 2 + 108, this.panel1.Height));
  450. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - 108 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  451. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - 54 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  452. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  453. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 + 54 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  454. g.DrawString("abc", textfont, new SolidBrush(Color.Red), new PointF(this.panel1.Width / 2 + 108 - size.Width / 2, this.panel1.Height / 2 - size.Height / 2));
  455. }
  456. }
  457. /// <summary>
  458. /// 线颜色改变
  459. /// </summary>
  460. /// <param name="sender"></param>
  461. /// <param name="e"></param>
  462. private void panel2_BackColorChanged(object sender, EventArgs e)
  463. {
  464. this.panel1.Refresh();
  465. }
  466. /// <summary>
  467. /// 线宽改变
  468. /// </summary>
  469. /// <param name="sender"></param>
  470. /// <param name="e"></param>
  471. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  472. {
  473. this.panel1.Refresh();
  474. }
  475. /// <summary>
  476. /// 线间距改变
  477. /// </summary>
  478. /// <param name="sender"></param>
  479. /// <param name="e"></param>
  480. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  481. {
  482. this.panel1.Refresh();
  483. }
  484. /// <summary>
  485. /// 字体改变
  486. /// </summary>
  487. /// <param name="sender"></param>
  488. /// <param name="e"></param>
  489. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  490. {
  491. this.panel1.Refresh();
  492. }
  493. /// <summary>
  494. /// 字体大小改变
  495. /// </summary>
  496. /// <param name="sender"></param>
  497. /// <param name="e"></param>
  498. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  499. {
  500. this.panel1.Refresh();
  501. }
  502. /// <summary>
  503. /// 线条数改变
  504. /// </summary>
  505. /// <param name="sender"></param>
  506. /// <param name="e"></param>
  507. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  508. {
  509. this.panel1.Refresh();
  510. }
  511. }
  512. }