WorkTypeSettingDialog.cs 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. using PaintDotNet.Base.SettingModel;
  2. using PaintDotNet.Base.CommTool;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace PaintDotNet.Setting
  15. {
  16. public partial class WorkTypeSettingDialog : PdnBaseForm
  17. {
  18. #region 控件
  19. private System.Windows.Forms.GroupBox groupBox2;
  20. private System.Windows.Forms.GroupBox groupBox3;
  21. private System.Windows.Forms.GroupBox groupBox4;
  22. private System.Windows.Forms.GroupBox groupBox5;
  23. private System.Windows.Forms.Label label2;
  24. private System.Windows.Forms.Label label4;
  25. private System.Windows.Forms.RadioButton fzxRBF;
  26. private System.Windows.Forms.RadioButton fzxRBT;
  27. private System.Windows.Forms.Label label3;
  28. private System.Windows.Forms.PictureBox pictureBox;
  29. private System.Windows.Forms.Label label6;
  30. private System.Windows.Forms.Label label5;
  31. private System.Windows.Forms.RadioButton ljxRBF;
  32. private System.Windows.Forms.RadioButton ljxRBT;
  33. private System.Windows.Forms.Label label7;
  34. private System.Windows.Forms.Label label9;
  35. private System.Windows.Forms.Label label8;
  36. private System.Windows.Forms.RadioButton clxRangeRBF;
  37. private System.Windows.Forms.RadioButton clxRangeRBT;
  38. private System.Windows.Forms.Label label10;
  39. private System.Windows.Forms.Label label11;
  40. private System.Windows.Forms.Label label14;
  41. private System.Windows.Forms.Label label13;
  42. private System.Windows.Forms.RadioButton clxLenRBF;
  43. private System.Windows.Forms.RadioButton clxLenRBT;
  44. private System.Windows.Forms.Label label12;
  45. private System.Windows.Forms.Panel fzxColourPanel;
  46. private System.Windows.Forms.Panel ljxColourPanel;
  47. private System.Windows.Forms.Panel clxColourPanel;
  48. private System.Windows.Forms.GroupBox groupBox1;
  49. private System.Windows.Forms.Button button2;
  50. private ComboBox fontComboBox;
  51. private NumericUpDown fontSizeNumeric;
  52. private ComboBox styleComboBox;
  53. private Label label1;
  54. private Button button4;
  55. private Button button3;
  56. private System.Windows.Forms.Button button1;
  57. private Panel fontColourPanel;
  58. private NumericUpDown ljxLineWidthNumeric;
  59. private NumericUpDown fzxLineWidthNumeric;
  60. private NumericUpDown clxLineWidthNumeric;
  61. /// <summary>
  62. /// 字体列表
  63. /// </summary>
  64. ArrayList fontsItems = new ArrayList();
  65. /// <summary>
  66. /// 调色板测量线
  67. /// </summary>
  68. PaintDotNet.ColorsForm colorsFormclx;
  69. /// <summary>
  70. /// 调色板辅助线
  71. /// </summary>
  72. PaintDotNet.ColorsForm colorsFormfzx;
  73. /// <summary>
  74. /// 调色板连接线
  75. /// </summary>
  76. PaintDotNet.ColorsForm colorsFormljx;
  77. /// <summary>
  78. /// 调色板字体
  79. /// </summary>
  80. PaintDotNet.ColorsForm colorsFormfont;
  81. /// <summary>
  82. /// 与xml对应得映射类
  83. /// </summary>
  84. private WorkTypeStyleModel workTypeStyleModel;
  85. /// <summary>
  86. /// 另存为弹出框显示
  87. /// </summary>
  88. private CreateNameDialog dialog;
  89. /// <summary>
  90. /// 操作样式下拉数据
  91. /// </summary>
  92. private List<string> files = new List<string>();
  93. /// <summary>
  94. /// 另存为文件名
  95. /// </summary>
  96. private string newName;
  97. private Panel panel1;
  98. /// <summary>
  99. /// 初始化标识
  100. /// </summary>
  101. private int initflag = 0;
  102. #endregion
  103. public WorkTypeSettingDialog()
  104. {
  105. InitializeComponent();
  106. InitializeLanguageText();
  107. InitializeComponent2();
  108. InitializeControl();
  109. InitializeData();
  110. // 测量出最大的字符大小
  111. int maxSize = 0;
  112. System.Drawing.Graphics g = CreateGraphics();
  113. for (int i = 0; i < fontComboBox.Items.Count; i++)
  114. {
  115. fontComboBox.SelectedIndex = i;
  116. SizeF size = g.MeasureString(fontComboBox.Text, fontComboBox.Font);
  117. if (maxSize < (int)size.Width)
  118. {
  119. maxSize = (int)size.Width;
  120. }
  121. }
  122. fontComboBox.DropDownWidth = fontComboBox.Width;
  123. if (fontComboBox.DropDownWidth < maxSize)
  124. {
  125. fontComboBox.DropDownWidth = maxSize + 15;
  126. //comboBox1.Width = maxSize;
  127. }
  128. }
  129. #region 初始化控件
  130. private void InitializeLanguageText()
  131. {
  132. this.groupBox2.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
  133. this.label4.Text = PdnResources.GetString("Menu.display.text") + ":";
  134. this.fzxRBF.Text = PdnResources.GetString("Menu.no.text");
  135. this.fzxRBT.Text = PdnResources.GetString("Menu.Yes.text");
  136. this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  137. this.label2.Text = PdnResources.GetString("Menu.color.text") + ":";
  138. this.groupBox3.Text = PdnResources.GetString("Menu.Set.typesettings.the communicationscablesetting.text");
  139. this.ljxRBF.Text = PdnResources.GetString("Menu.no.text");
  140. this.ljxRBT.Text = PdnResources.GetString("Menu.Yes.text");
  141. this.label7.Text = PdnResources.GetString("Menu.display.text") + ":";
  142. this.label6.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  143. this.label5.Text = PdnResources.GetString("Menu.color.text") + ":";
  144. this.groupBox4.Text = PdnResources.GetString("Menu.Measuringlinesetting.text");
  145. this.clxRangeRBF.Text = PdnResources.GetString("Menu.no.text");
  146. this.clxRangeRBT.Text = PdnResources.GetString("Menu.Yes.text");
  147. this.label10.Text = PdnResources.GetString("Menu.Set.typesettings.Displaymeasuringlinedistance.text") + ":";
  148. this.label14.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  149. this.label13.Text = PdnResources.GetString("Menu.Font.text") + ":";
  150. this.clxLenRBF.Text = PdnResources.GetString("Menu.no.text");
  151. this.clxLenRBT.Text = PdnResources.GetString("Menu.Yes.text");
  152. this.label12.Text = PdnResources.GetString("Menu.Set.typesettings.Displaythelengthofmeasuringline.text") + ":";
  153. this.label11.Text = PdnResources.GetString("Menu.fontcolor.text") + ":";
  154. this.label9.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  155. this.label8.Text = PdnResources.GetString("Menu.color.text") + ":";
  156. this.groupBox5.Text = PdnResources.GetString("Menu.Preview.text");
  157. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  158. this.label1.Text = PdnResources.GetString("Menu.Currentoperationstyle.text") + ":";
  159. this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  160. this.button3.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
  161. this.button2.Text = PdnResources.GetString("Menu.application.text");
  162. this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
  163. this.Text = PdnResources.GetString("Menu.Setting.WorkTypeSetting.Text");
  164. }
  165. /// <summary>
  166. /// Required method for Designer support - do not modify
  167. /// the contents of this method with the code editor.
  168. /// </summary>
  169. private void InitializeComponent()
  170. {
  171. this.groupBox2 = new System.Windows.Forms.GroupBox();
  172. this.fzxLineWidthNumeric = new System.Windows.Forms.NumericUpDown();
  173. this.fzxColourPanel = new System.Windows.Forms.Panel();
  174. this.label4 = new System.Windows.Forms.Label();
  175. this.fzxRBF = new System.Windows.Forms.RadioButton();
  176. this.fzxRBT = new System.Windows.Forms.RadioButton();
  177. this.label3 = new System.Windows.Forms.Label();
  178. this.label2 = new System.Windows.Forms.Label();
  179. this.groupBox3 = new System.Windows.Forms.GroupBox();
  180. this.ljxLineWidthNumeric = new System.Windows.Forms.NumericUpDown();
  181. this.ljxColourPanel = new System.Windows.Forms.Panel();
  182. this.ljxRBF = new System.Windows.Forms.RadioButton();
  183. this.ljxRBT = new System.Windows.Forms.RadioButton();
  184. this.label7 = new System.Windows.Forms.Label();
  185. this.label6 = new System.Windows.Forms.Label();
  186. this.label5 = new System.Windows.Forms.Label();
  187. this.groupBox4 = new System.Windows.Forms.GroupBox();
  188. this.panel1 = new System.Windows.Forms.Panel();
  189. this.clxRangeRBF = new System.Windows.Forms.RadioButton();
  190. this.clxRangeRBT = new System.Windows.Forms.RadioButton();
  191. this.label10 = new System.Windows.Forms.Label();
  192. this.clxLineWidthNumeric = new System.Windows.Forms.NumericUpDown();
  193. this.fontColourPanel = new System.Windows.Forms.Panel();
  194. this.fontSizeNumeric = new System.Windows.Forms.NumericUpDown();
  195. this.fontComboBox = new System.Windows.Forms.ComboBox();
  196. this.clxColourPanel = new System.Windows.Forms.Panel();
  197. this.label14 = new System.Windows.Forms.Label();
  198. this.label13 = new System.Windows.Forms.Label();
  199. this.clxLenRBF = new System.Windows.Forms.RadioButton();
  200. this.clxLenRBT = new System.Windows.Forms.RadioButton();
  201. this.label12 = new System.Windows.Forms.Label();
  202. this.label11 = new System.Windows.Forms.Label();
  203. this.label9 = new System.Windows.Forms.Label();
  204. this.label8 = new System.Windows.Forms.Label();
  205. this.groupBox5 = new System.Windows.Forms.GroupBox();
  206. this.pictureBox = new System.Windows.Forms.PictureBox();
  207. this.groupBox1 = new System.Windows.Forms.GroupBox();
  208. this.styleComboBox = new System.Windows.Forms.ComboBox();
  209. this.label1 = new System.Windows.Forms.Label();
  210. this.button4 = new System.Windows.Forms.Button();
  211. this.button3 = new System.Windows.Forms.Button();
  212. this.button2 = new System.Windows.Forms.Button();
  213. this.button1 = new System.Windows.Forms.Button();
  214. this.groupBox2.SuspendLayout();
  215. ((System.ComponentModel.ISupportInitialize)(this.fzxLineWidthNumeric)).BeginInit();
  216. this.groupBox3.SuspendLayout();
  217. ((System.ComponentModel.ISupportInitialize)(this.ljxLineWidthNumeric)).BeginInit();
  218. this.groupBox4.SuspendLayout();
  219. this.panel1.SuspendLayout();
  220. ((System.ComponentModel.ISupportInitialize)(this.clxLineWidthNumeric)).BeginInit();
  221. ((System.ComponentModel.ISupportInitialize)(this.fontSizeNumeric)).BeginInit();
  222. this.groupBox5.SuspendLayout();
  223. ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
  224. this.groupBox1.SuspendLayout();
  225. this.SuspendLayout();
  226. //
  227. // groupBox2
  228. //
  229. this.groupBox2.Controls.Add(this.fzxLineWidthNumeric);
  230. this.groupBox2.Controls.Add(this.fzxColourPanel);
  231. this.groupBox2.Controls.Add(this.label4);
  232. this.groupBox2.Controls.Add(this.fzxRBF);
  233. this.groupBox2.Controls.Add(this.fzxRBT);
  234. this.groupBox2.Controls.Add(this.label3);
  235. this.groupBox2.Controls.Add(this.label2);
  236. this.groupBox2.Location = new System.Drawing.Point(12, 76);
  237. this.groupBox2.Name = "groupBox2";
  238. this.groupBox2.Size = new System.Drawing.Size(509, 79);
  239. this.groupBox2.TabIndex = 2;
  240. this.groupBox2.TabStop = false;
  241. this.groupBox2.Text = "辅助线设置";
  242. //
  243. // fzxLineWidthNumeric
  244. //
  245. this.fzxLineWidthNumeric.Location = new System.Drawing.Point(333, 17);
  246. this.fzxLineWidthNumeric.Minimum = new decimal(new int[] {
  247. 1,
  248. 0,
  249. 0,
  250. 0});
  251. this.fzxLineWidthNumeric.Name = "fzxLineWidthNumeric";
  252. this.fzxLineWidthNumeric.Size = new System.Drawing.Size(161, 21);
  253. this.fzxLineWidthNumeric.TabIndex = 23;
  254. this.fzxLineWidthNumeric.Value = new decimal(new int[] {
  255. 1,
  256. 0,
  257. 0,
  258. 0});
  259. //
  260. // fzxColourPanel
  261. //
  262. this.fzxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  263. this.fzxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  264. this.fzxColourPanel.Location = new System.Drawing.Point(70, 17);
  265. this.fzxColourPanel.Name = "fzxColourPanel";
  266. this.fzxColourPanel.Size = new System.Drawing.Size(161, 21);
  267. this.fzxColourPanel.TabIndex = 8;
  268. this.fzxColourPanel.Click += new System.EventHandler(this.fzxColorPanel_Click);
  269. //
  270. // label4
  271. //
  272. this.label4.Location = new System.Drawing.Point(18, 50);
  273. this.label4.Name = "label4";
  274. this.label4.Size = new System.Drawing.Size(46, 23);
  275. this.label4.TabIndex = 7;
  276. this.label4.Text = "显示:";
  277. //
  278. // fzxRBF
  279. //
  280. this.fzxRBF.AutoSize = true;
  281. this.fzxRBF.Location = new System.Drawing.Point(164, 48);
  282. this.fzxRBF.Name = "fzxRBF";
  283. this.fzxRBF.Size = new System.Drawing.Size(35, 16);
  284. this.fzxRBF.TabIndex = 6;
  285. this.fzxRBF.TabStop = true;
  286. this.fzxRBF.Text = "否";
  287. this.fzxRBF.UseVisualStyleBackColor = true;
  288. //
  289. // fzxRBT
  290. //
  291. this.fzxRBT.AutoSize = true;
  292. this.fzxRBT.Checked = true;
  293. this.fzxRBT.Location = new System.Drawing.Point(70, 48);
  294. this.fzxRBT.Name = "fzxRBT";
  295. this.fzxRBT.Size = new System.Drawing.Size(35, 16);
  296. this.fzxRBT.TabIndex = 5;
  297. this.fzxRBT.TabStop = true;
  298. this.fzxRBT.Text = "是";
  299. this.fzxRBT.UseVisualStyleBackColor = true;
  300. //
  301. // label3
  302. //
  303. this.label3.Location = new System.Drawing.Point(281, 20);
  304. this.label3.Name = "label3";
  305. this.label3.Size = new System.Drawing.Size(46, 23);
  306. this.label3.TabIndex = 4;
  307. this.label3.Text = "线宽:";
  308. //
  309. // label2
  310. //
  311. this.label2.Location = new System.Drawing.Point(18, 17);
  312. this.label2.Name = "label2";
  313. this.label2.Size = new System.Drawing.Size(46, 23);
  314. this.label2.TabIndex = 1;
  315. this.label2.Text = "颜色:";
  316. //
  317. // groupBox3
  318. //
  319. this.groupBox3.Controls.Add(this.ljxLineWidthNumeric);
  320. this.groupBox3.Controls.Add(this.ljxColourPanel);
  321. this.groupBox3.Controls.Add(this.ljxRBF);
  322. this.groupBox3.Controls.Add(this.ljxRBT);
  323. this.groupBox3.Controls.Add(this.label7);
  324. this.groupBox3.Controls.Add(this.label6);
  325. this.groupBox3.Controls.Add(this.label5);
  326. this.groupBox3.Location = new System.Drawing.Point(12, 161);
  327. this.groupBox3.Name = "groupBox3";
  328. this.groupBox3.Size = new System.Drawing.Size(509, 79);
  329. this.groupBox3.TabIndex = 3;
  330. this.groupBox3.TabStop = false;
  331. this.groupBox3.Text = "连接线设置";
  332. //
  333. // ljxLineWidthNumeric
  334. //
  335. this.ljxLineWidthNumeric.Location = new System.Drawing.Point(335, 20);
  336. this.ljxLineWidthNumeric.Minimum = new decimal(new int[] {
  337. 1,
  338. 0,
  339. 0,
  340. 0});
  341. this.ljxLineWidthNumeric.Name = "ljxLineWidthNumeric";
  342. this.ljxLineWidthNumeric.Size = new System.Drawing.Size(161, 21);
  343. this.ljxLineWidthNumeric.TabIndex = 22;
  344. this.ljxLineWidthNumeric.Value = new decimal(new int[] {
  345. 1,
  346. 0,
  347. 0,
  348. 0});
  349. //
  350. // ljxColourPanel
  351. //
  352. this.ljxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  353. this.ljxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  354. this.ljxColourPanel.Location = new System.Drawing.Point(70, 20);
  355. this.ljxColourPanel.Name = "ljxColourPanel";
  356. this.ljxColourPanel.Size = new System.Drawing.Size(161, 21);
  357. this.ljxColourPanel.TabIndex = 11;
  358. this.ljxColourPanel.Click += new System.EventHandler(this.ljxColorPanel_Click);
  359. //
  360. // ljxRBF
  361. //
  362. this.ljxRBF.AutoSize = true;
  363. this.ljxRBF.Location = new System.Drawing.Point(164, 49);
  364. this.ljxRBF.Name = "ljxRBF";
  365. this.ljxRBF.Size = new System.Drawing.Size(35, 16);
  366. this.ljxRBF.TabIndex = 10;
  367. this.ljxRBF.TabStop = true;
  368. this.ljxRBF.Text = "否";
  369. this.ljxRBF.UseVisualStyleBackColor = true;
  370. //
  371. // ljxRBT
  372. //
  373. this.ljxRBT.AutoSize = true;
  374. this.ljxRBT.Checked = true;
  375. this.ljxRBT.Location = new System.Drawing.Point(70, 47);
  376. this.ljxRBT.Name = "ljxRBT";
  377. this.ljxRBT.Size = new System.Drawing.Size(35, 16);
  378. this.ljxRBT.TabIndex = 9;
  379. this.ljxRBT.TabStop = true;
  380. this.ljxRBT.Text = "是";
  381. this.ljxRBT.UseVisualStyleBackColor = true;
  382. //
  383. // label7
  384. //
  385. this.label7.Location = new System.Drawing.Point(18, 49);
  386. this.label7.Name = "label7";
  387. this.label7.Size = new System.Drawing.Size(46, 23);
  388. this.label7.TabIndex = 8;
  389. this.label7.Text = "显示:";
  390. //
  391. // label6
  392. //
  393. this.label6.Location = new System.Drawing.Point(281, 23);
  394. this.label6.Name = "label6";
  395. this.label6.Size = new System.Drawing.Size(46, 23);
  396. this.label6.TabIndex = 5;
  397. this.label6.Text = "线宽:";
  398. //
  399. // label5
  400. //
  401. this.label5.Location = new System.Drawing.Point(18, 20);
  402. this.label5.Name = "label5";
  403. this.label5.Size = new System.Drawing.Size(46, 23);
  404. this.label5.TabIndex = 2;
  405. this.label5.Text = "颜色:";
  406. //
  407. // groupBox4
  408. //
  409. this.groupBox4.Controls.Add(this.panel1);
  410. this.groupBox4.Controls.Add(this.clxLineWidthNumeric);
  411. this.groupBox4.Controls.Add(this.fontColourPanel);
  412. this.groupBox4.Controls.Add(this.fontSizeNumeric);
  413. this.groupBox4.Controls.Add(this.fontComboBox);
  414. this.groupBox4.Controls.Add(this.clxColourPanel);
  415. this.groupBox4.Controls.Add(this.label14);
  416. this.groupBox4.Controls.Add(this.label13);
  417. this.groupBox4.Controls.Add(this.clxLenRBF);
  418. this.groupBox4.Controls.Add(this.clxLenRBT);
  419. this.groupBox4.Controls.Add(this.label12);
  420. this.groupBox4.Controls.Add(this.label11);
  421. this.groupBox4.Controls.Add(this.label9);
  422. this.groupBox4.Controls.Add(this.label8);
  423. this.groupBox4.Location = new System.Drawing.Point(12, 246);
  424. this.groupBox4.Name = "groupBox4";
  425. this.groupBox4.Size = new System.Drawing.Size(509, 100);
  426. this.groupBox4.TabIndex = 4;
  427. this.groupBox4.TabStop = false;
  428. this.groupBox4.Text = "测量线设置";
  429. //
  430. // panel1
  431. //
  432. this.panel1.Controls.Add(this.clxRangeRBF);
  433. this.panel1.Controls.Add(this.clxRangeRBT);
  434. this.panel1.Controls.Add(this.label10);
  435. this.panel1.Location = new System.Drawing.Point(16, 41);
  436. this.panel1.Name = "panel1";
  437. this.panel1.Size = new System.Drawing.Size(211, 28);
  438. this.panel1.TabIndex = 24;
  439. //
  440. // clxRangeRBF
  441. //
  442. this.clxRangeRBF.AutoSize = true;
  443. this.clxRangeRBF.Location = new System.Drawing.Point(150, 5);
  444. this.clxRangeRBF.Name = "clxRangeRBF";
  445. this.clxRangeRBF.Size = new System.Drawing.Size(14, 13);
  446. this.clxRangeRBF.TabIndex = 11;
  447. this.clxRangeRBF.TabStop = true;
  448. this.clxRangeRBF.UseVisualStyleBackColor = true;
  449. //
  450. // clxRangeRBT
  451. //
  452. this.clxRangeRBT.AutoSize = true;
  453. this.clxRangeRBT.Checked = true;
  454. this.clxRangeRBT.Location = new System.Drawing.Point(109, 5);
  455. this.clxRangeRBT.Name = "clxRangeRBT";
  456. this.clxRangeRBT.Size = new System.Drawing.Size(14, 13);
  457. this.clxRangeRBT.TabIndex = 10;
  458. this.clxRangeRBT.TabStop = true;
  459. this.clxRangeRBT.UseVisualStyleBackColor = true;
  460. //
  461. // label10
  462. //
  463. this.label10.Location = new System.Drawing.Point(3, 5);
  464. this.label10.Name = "label10";
  465. this.label10.Size = new System.Drawing.Size(112, 19);
  466. this.label10.TabIndex = 9;
  467. this.label10.Text = "显示测量线距离:";
  468. //
  469. // clxLineWidthNumeric
  470. //
  471. this.clxLineWidthNumeric.Location = new System.Drawing.Point(335, 14);
  472. this.clxLineWidthNumeric.Minimum = new decimal(new int[] {
  473. 1,
  474. 0,
  475. 0,
  476. 0});
  477. this.clxLineWidthNumeric.Name = "clxLineWidthNumeric";
  478. this.clxLineWidthNumeric.Size = new System.Drawing.Size(161, 21);
  479. this.clxLineWidthNumeric.TabIndex = 23;
  480. this.clxLineWidthNumeric.Value = new decimal(new int[] {
  481. 1,
  482. 0,
  483. 0,
  484. 0});
  485. //
  486. // fontColourPanel
  487. //
  488. this.fontColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  489. this.fontColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  490. this.fontColourPanel.Location = new System.Drawing.Point(335, 41);
  491. this.fontColourPanel.Name = "fontColourPanel";
  492. this.fontColourPanel.Size = new System.Drawing.Size(161, 23);
  493. this.fontColourPanel.TabIndex = 22;
  494. this.fontColourPanel.Click += new System.EventHandler(this.fontColorPanel_Click);
  495. //
  496. // fontSizeNumeric
  497. //
  498. this.fontSizeNumeric.Location = new System.Drawing.Point(441, 69);
  499. this.fontSizeNumeric.Minimum = new decimal(new int[] {
  500. 1,
  501. 0,
  502. 0,
  503. 0});
  504. this.fontSizeNumeric.Name = "fontSizeNumeric";
  505. this.fontSizeNumeric.Size = new System.Drawing.Size(55, 21);
  506. this.fontSizeNumeric.TabIndex = 21;
  507. this.fontSizeNumeric.Value = new decimal(new int[] {
  508. 12,
  509. 0,
  510. 0,
  511. 0});
  512. //
  513. // fontComboBox
  514. //
  515. this.fontComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  516. this.fontComboBox.FormattingEnabled = true;
  517. this.fontComboBox.Location = new System.Drawing.Point(335, 70);
  518. this.fontComboBox.Name = "fontComboBox";
  519. this.fontComboBox.Size = new System.Drawing.Size(57, 20);
  520. this.fontComboBox.TabIndex = 20;
  521. //
  522. // clxColourPanel
  523. //
  524. this.clxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  525. this.clxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  526. this.clxColourPanel.Location = new System.Drawing.Point(70, 14);
  527. this.clxColourPanel.Name = "clxColourPanel";
  528. this.clxColourPanel.Size = new System.Drawing.Size(161, 21);
  529. this.clxColourPanel.TabIndex = 19;
  530. this.clxColourPanel.Click += new System.EventHandler(this.clxColorPanel_Click);
  531. //
  532. // label14
  533. //
  534. this.label14.Location = new System.Drawing.Point(398, 71);
  535. this.label14.Name = "label14";
  536. this.label14.Size = new System.Drawing.Size(45, 23);
  537. this.label14.TabIndex = 18;
  538. this.label14.Text = "字号:";
  539. //
  540. // label13
  541. //
  542. this.label13.Location = new System.Drawing.Point(281, 74);
  543. this.label13.Name = "label13";
  544. this.label13.Size = new System.Drawing.Size(45, 23);
  545. this.label13.TabIndex = 17;
  546. this.label13.Text = "字体:";
  547. //
  548. // clxLenRBF
  549. //
  550. this.clxLenRBF.AutoSize = true;
  551. this.clxLenRBF.Location = new System.Drawing.Point(166, 71);
  552. this.clxLenRBF.Name = "clxLenRBF";
  553. this.clxLenRBF.Size = new System.Drawing.Size(14, 13);
  554. this.clxLenRBF.TabIndex = 16;
  555. this.clxLenRBF.TabStop = true;
  556. this.clxLenRBF.UseVisualStyleBackColor = true;
  557. this.clxLenRBF.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  558. //
  559. // clxLenRBT
  560. //
  561. this.clxLenRBT.AutoSize = true;
  562. this.clxLenRBT.Checked = true;
  563. this.clxLenRBT.Location = new System.Drawing.Point(125, 71);
  564. this.clxLenRBT.Name = "clxLenRBT";
  565. this.clxLenRBT.Size = new System.Drawing.Size(14, 13);
  566. this.clxLenRBT.TabIndex = 15;
  567. this.clxLenRBT.TabStop = true;
  568. this.clxLenRBT.UseVisualStyleBackColor = true;
  569. //
  570. // label12
  571. //
  572. this.label12.Location = new System.Drawing.Point(18, 73);
  573. this.label12.Name = "label12";
  574. this.label12.Size = new System.Drawing.Size(113, 23);
  575. this.label12.TabIndex = 14;
  576. this.label12.Text = "显示测量线长度:";
  577. //
  578. // label11
  579. //
  580. this.label11.Location = new System.Drawing.Point(258, 46);
  581. this.label11.Name = "label11";
  582. this.label11.Size = new System.Drawing.Size(117, 23);
  583. this.label11.TabIndex = 12;
  584. this.label11.Text = "字体颜色:";
  585. //
  586. // label9
  587. //
  588. this.label9.Location = new System.Drawing.Point(282, 18);
  589. this.label9.Name = "label9";
  590. this.label9.Size = new System.Drawing.Size(46, 23);
  591. this.label9.TabIndex = 6;
  592. this.label9.Text = "线宽:";
  593. //
  594. // label8
  595. //
  596. this.label8.Location = new System.Drawing.Point(18, 17);
  597. this.label8.Name = "label8";
  598. this.label8.Size = new System.Drawing.Size(46, 23);
  599. this.label8.TabIndex = 3;
  600. this.label8.Text = "颜色:";
  601. //
  602. // groupBox5
  603. //
  604. this.groupBox5.Controls.Add(this.pictureBox);
  605. this.groupBox5.Location = new System.Drawing.Point(12, 352);
  606. this.groupBox5.Name = "groupBox5";
  607. this.groupBox5.Size = new System.Drawing.Size(509, 148);
  608. this.groupBox5.TabIndex = 5;
  609. this.groupBox5.TabStop = false;
  610. this.groupBox5.Text = "预览";
  611. //
  612. // pictureBox
  613. //
  614. this.pictureBox.Location = new System.Drawing.Point(99, 20);
  615. this.pictureBox.Name = "pictureBox";
  616. this.pictureBox.Size = new System.Drawing.Size(306, 122);
  617. this.pictureBox.TabIndex = 0;
  618. this.pictureBox.TabStop = false;
  619. //
  620. // groupBox1
  621. //
  622. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  623. | System.Windows.Forms.AnchorStyles.Right)));
  624. this.groupBox1.Controls.Add(this.styleComboBox);
  625. this.groupBox1.Controls.Add(this.label1);
  626. this.groupBox1.Controls.Add(this.button4);
  627. this.groupBox1.Controls.Add(this.button3);
  628. this.groupBox1.Controls.Add(this.button2);
  629. this.groupBox1.Controls.Add(this.button1);
  630. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  631. this.groupBox1.Name = "groupBox1";
  632. this.groupBox1.Size = new System.Drawing.Size(509, 58);
  633. this.groupBox1.TabIndex = 2;
  634. this.groupBox1.TabStop = false;
  635. this.groupBox1.Text = "操作";
  636. //
  637. // styleComboBox
  638. //
  639. this.styleComboBox.FormattingEnabled = true;
  640. this.styleComboBox.Location = new System.Drawing.Point(99, 21);
  641. this.styleComboBox.Name = "styleComboBox";
  642. this.styleComboBox.Size = new System.Drawing.Size(80, 20);
  643. this.styleComboBox.TabIndex = 22;
  644. //
  645. // label1
  646. //
  647. this.label1.Location = new System.Drawing.Point(8, 24);
  648. this.label1.Name = "label1";
  649. this.label1.Size = new System.Drawing.Size(101, 23);
  650. this.label1.TabIndex = 9;
  651. this.label1.Text = "当前操作样式:";
  652. //
  653. // button4
  654. //
  655. this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
  656. this.button4.Location = new System.Drawing.Point(185, 20);
  657. this.button4.Name = "button4";
  658. this.button4.Size = new System.Drawing.Size(75, 23);
  659. this.button4.TabIndex = 3;
  660. this.button4.Text = "删除";
  661. this.button4.UseVisualStyleBackColor = true;
  662. this.button4.Click += new System.EventHandler(this.Button4_Click);
  663. //
  664. // button3
  665. //
  666. this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
  667. this.button3.Location = new System.Drawing.Point(266, 21);
  668. this.button3.Name = "button3";
  669. this.button3.Size = new System.Drawing.Size(75, 23);
  670. this.button3.TabIndex = 2;
  671. this.button3.Text = "另存为";
  672. this.button3.UseVisualStyleBackColor = true;
  673. this.button3.Click += new System.EventHandler(this.Button3_Click);
  674. //
  675. // button2
  676. //
  677. this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  678. this.button2.Location = new System.Drawing.Point(428, 21);
  679. this.button2.Name = "button2";
  680. this.button2.Size = new System.Drawing.Size(75, 23);
  681. this.button2.TabIndex = 1;
  682. this.button2.Text = "应用";
  683. this.button2.UseVisualStyleBackColor = true;
  684. this.button2.Click += new System.EventHandler(this.Button2_Click);
  685. //
  686. // button1
  687. //
  688. this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  689. this.button1.Location = new System.Drawing.Point(347, 21);
  690. this.button1.Name = "button1";
  691. this.button1.Size = new System.Drawing.Size(75, 23);
  692. this.button1.TabIndex = 0;
  693. this.button1.Text = "保存";
  694. this.button1.UseVisualStyleBackColor = true;
  695. this.button1.Click += new System.EventHandler(this.Button1_Click);
  696. //
  697. // WorkTypeSettingDialog
  698. //
  699. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  700. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  701. this.ClientSize = new System.Drawing.Size(533, 512);
  702. this.Controls.Add(this.groupBox1);
  703. this.Controls.Add(this.groupBox5);
  704. this.Controls.Add(this.groupBox4);
  705. this.Controls.Add(this.groupBox3);
  706. this.Controls.Add(this.groupBox2);
  707. this.Name = "WorkTypeSettingDialog";
  708. this.Text = "工型设置";
  709. this.Controls.SetChildIndex(this.groupBox2, 0);
  710. this.Controls.SetChildIndex(this.groupBox3, 0);
  711. this.Controls.SetChildIndex(this.groupBox4, 0);
  712. this.Controls.SetChildIndex(this.groupBox5, 0);
  713. this.Controls.SetChildIndex(this.groupBox1, 0);
  714. this.groupBox2.ResumeLayout(false);
  715. this.groupBox2.PerformLayout();
  716. ((System.ComponentModel.ISupportInitialize)(this.fzxLineWidthNumeric)).EndInit();
  717. this.groupBox3.ResumeLayout(false);
  718. this.groupBox3.PerformLayout();
  719. ((System.ComponentModel.ISupportInitialize)(this.ljxLineWidthNumeric)).EndInit();
  720. this.groupBox4.ResumeLayout(false);
  721. this.groupBox4.PerformLayout();
  722. this.panel1.ResumeLayout(false);
  723. this.panel1.PerformLayout();
  724. ((System.ComponentModel.ISupportInitialize)(this.clxLineWidthNumeric)).EndInit();
  725. ((System.ComponentModel.ISupportInitialize)(this.fontSizeNumeric)).EndInit();
  726. this.groupBox5.ResumeLayout(false);
  727. ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
  728. this.groupBox1.ResumeLayout(false);
  729. this.ResumeLayout(false);
  730. }
  731. #endregion
  732. #region InitializeComponent2
  733. /// <summary>
  734. /// 初始化组件
  735. /// </summary>
  736. private void InitializeComponent2()
  737. {
  738. this.colorsFormljx = new ColorsForm();
  739. this.colorsFormljx.StartPosition = FormStartPosition.CenterScreen;
  740. this.colorsFormljx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  741. this.colorsFormfzx = new ColorsForm();
  742. this.colorsFormfzx.StartPosition = FormStartPosition.CenterScreen;
  743. this.colorsFormfzx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  744. this.colorsFormclx = new ColorsForm();
  745. this.colorsFormclx.StartPosition = FormStartPosition.CenterScreen;
  746. this.colorsFormclx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  747. this.colorsFormfont = new ColorsForm();
  748. this.colorsFormfont.StartPosition = FormStartPosition.CenterScreen;
  749. this.colorsFormfont.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  750. }
  751. #endregion
  752. /// <summary>
  753. /// 连接线Panel被点击
  754. /// </summary>
  755. /// <param name="sender"></param>
  756. /// <param name="e"></param>
  757. private void ljxColorPanel_Click(object sender, EventArgs e)
  758. {
  759. this.colorsFormljx.UserPrimaryColor = ColorBgra.FromColor(this.ljxColourPanel.BackColor);
  760. this.colorsFormljx.setSaveBtn_Click(new System.EventHandler(this.ljxColorChanged));
  761. this.colorsFormljx.ShowDialog();
  762. }
  763. /// <summary>
  764. /// 连接线Panel的调色板颜色改变
  765. /// </summary>
  766. /// <param name="sender"></param>
  767. /// <param name="e"></param>
  768. private void ljxColorChanged(object sender, EventArgs e)
  769. {
  770. this.ljxColourPanel.BackColor = this.colorsFormljx.UserPrimaryColor.ToColor();
  771. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  772. this.colorsFormljx.Close();
  773. }
  774. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  775. {
  776. }
  777. /// <summary>
  778. /// 测量线Panel被点击
  779. /// </summary>
  780. /// <param name="sender"></param>
  781. /// <param name="e"></param>
  782. private void clxColorPanel_Click(object sender, EventArgs e)
  783. {
  784. this.colorsFormclx.UserPrimaryColor = ColorBgra.FromColor(this.clxColourPanel.BackColor);
  785. this.colorsFormclx.setSaveBtn_Click(new System.EventHandler(this.clxColorChanged));
  786. this.colorsFormclx.ShowDialog();
  787. }
  788. /// <summary>
  789. /// 测量线Panel的调色板颜色改变
  790. /// </summary>
  791. /// <param name="sender"></param>
  792. /// <param name="e"></param>
  793. private void clxColorChanged(object sender, EventArgs e)
  794. {
  795. this.clxColourPanel.BackColor = this.colorsFormclx.UserPrimaryColor.ToColor();
  796. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  797. this.colorsFormclx.Close();
  798. }
  799. /// <summary>
  800. /// 处理控件
  801. /// </summary>
  802. private void InitializeControl()
  803. {
  804. this.pictureBox.Paint += new PaintEventHandler(this.pictureBox_Paint);
  805. }
  806. /// <summary>
  807. /// pictureBox的绘制事件
  808. /// </summary>
  809. /// <param name="sender"></param>
  810. /// <param name="e"></param>
  811. private void pictureBox_Paint(object sender, PaintEventArgs e)
  812. {
  813. WorkTypeStyleModel model = this.workTypeStyleModel;
  814. Graphics gps = e.Graphics;
  815. Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value));
  816. gps.DrawLine(measurePen, 150, 20 + model.guideLineWidth / 2, 150, 80 - model.connectLineWidth / 2);
  817. if (model.guideShowFlag == 1)
  818. {
  819. Pen guidePen = new Pen(Color.FromArgb(model.guideColour), Convert.ToInt32(model.guideLineWidth));
  820. gps.DrawLine(guidePen, 50, 20, 250, 20);
  821. }
  822. if (model.connectShowFlag == 1) {
  823. Pen connectPen = new Pen(Color.FromArgb(model.connectColour), model.connectLineWidth);
  824. gps.DrawLine(connectPen, 50, 80, 250, 80);
  825. }
  826. }
  827. /// <summary>
  828. /// 应用按钮被点击
  829. /// </summary>
  830. /// <param name="sender"></param>
  831. /// <param name="e"></param>
  832. private void Button2_Click(object sender, EventArgs e)
  833. {
  834. /*//预览展示
  835. Graphics gps = pictureBox.CreateGraphics();
  836. // gps.Clear(Color.Empty);
  837. Pen guidePen = new Pen(this.fzxColourPanel.BackColor , Convert.ToInt32(this.fzxLineWidthNumeric.Value));
  838. Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value));
  839. Pen connectPen = new Pen(this.ljxColourPanel.BackColor, Convert.ToInt32(this.ljxLineWidthNumeric.Value));
  840. gps.DrawLine(measurePen, 150, 20 + Convert.ToInt32(this.fzxLineWidthNumeric.Value)/2, 150, 80 - Convert.ToInt32(this.ljxLineWidthNumeric.Value)/2);
  841. gps.DrawLine(guidePen, 50, 20, 250, 20);
  842. gps.DrawLine(connectPen, 50, 80, 250, 80);*/
  843. //检查数据
  844. this.checkData();
  845. this.pictureBox.Invalidate();
  846. Startup.instance.workTypeStyleModel = this.workTypeStyleModel;
  847. }
  848. /// <summary>
  849. /// 检查数据并且赋值到model中
  850. /// </summary>
  851. private void checkData() {
  852. UpDownBase fzxLineWidthup = (UpDownBase)this.fzxLineWidthNumeric;
  853. if (string.IsNullOrEmpty(fzxLineWidthup.Text)) {
  854. this.fzxLineWidthNumeric.Value = 1;
  855. }
  856. UpDownBase ljxLineWidthup = (UpDownBase)this.ljxLineWidthNumeric;
  857. if (string.IsNullOrEmpty(ljxLineWidthup.Text))
  858. {
  859. this.ljxLineWidthNumeric.Value = 1;
  860. }
  861. UpDownBase clxLineWidthup = (UpDownBase)this.clxLineWidthNumeric;
  862. if (string.IsNullOrEmpty(clxLineWidthup.Text))
  863. {
  864. this.clxLineWidthNumeric.Value = 1;
  865. }
  866. UpDownBase fontSizeWidthup = (UpDownBase)this.fontSizeNumeric;
  867. if (string.IsNullOrEmpty(fontSizeWidthup.Text))
  868. {
  869. this.fontSizeNumeric.Value = 1;
  870. }
  871. /* if (string.IsNullOrEmpty(fontComboBox.Text)) {
  872. fontComboBox.Text = this.workTypeStyleModel.font;
  873. }*/
  874. //辅助线设置赋值
  875. this.workTypeStyleModel.guideColour = Convert.ToInt32(this.fzxColourPanel.BackColor.ToArgb());
  876. this.workTypeStyleModel.guideLineWidth = Convert.ToInt32(this.fzxLineWidthNumeric.Value);
  877. if (this.fzxRBF.Checked)
  878. {
  879. this.workTypeStyleModel.guideShowFlag = 0;
  880. }
  881. else
  882. {
  883. this.workTypeStyleModel.guideShowFlag = 1;
  884. }
  885. //连接线设置赋值
  886. this.workTypeStyleModel.connectColour = Convert.ToInt32(this.ljxColourPanel.BackColor.ToArgb());
  887. this.workTypeStyleModel.connectLineWidth = Convert.ToInt32(this.ljxLineWidthNumeric.Value);
  888. if (this.ljxRBF.Checked)
  889. {
  890. this.workTypeStyleModel.connectShowFlag = 0;
  891. }
  892. else
  893. {
  894. this.workTypeStyleModel.connectShowFlag = 1;
  895. }
  896. //测量线设置
  897. this.workTypeStyleModel.measureColour = Convert.ToInt32(this.clxColourPanel.BackColor.ToArgb());
  898. this.workTypeStyleModel.measureLineWidth = Convert.ToInt32(this.clxLineWidthNumeric.Value);
  899. if (this.clxRangeRBF.Checked)
  900. {
  901. this.workTypeStyleModel.measureRangeShowFlag = 0;
  902. }
  903. else
  904. {
  905. this.workTypeStyleModel.measureRangeShowFlag = 1;
  906. }
  907. if (this.clxLenRBF.Checked)
  908. {
  909. this.workTypeStyleModel.measureLengthShowFlag = 0;
  910. }
  911. else
  912. {
  913. this.workTypeStyleModel.measureLengthShowFlag = 1;
  914. }
  915. this.workTypeStyleModel.fontColour = Convert.ToInt32(this.fontColourPanel.BackColor.ToArgb());
  916. this.workTypeStyleModel.font = this.fontComboBox.Text;
  917. this.workTypeStyleModel.fontSize = Convert.ToInt32(this.fontSizeNumeric.Value);
  918. }
  919. /// <summary>
  920. /// 保存按钮被点击
  921. /// </summary>
  922. /// <param name="sender"></param>
  923. /// <param name="e"></param>
  924. private void Button1_Click(object sender, EventArgs e)
  925. {
  926. //调用检查方法
  927. this.checkData();
  928. //以下保存xml文件信息
  929. string workTypeStyleModelXml = XmlSerializeHelper.XmlSerialize<WorkTypeStyleModel>(this.workTypeStyleModel);
  930. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml";
  931. FileOperationHelper.WriteStringToFile(workTypeStyleModelXml, filePath, FileMode.Create);
  932. }
  933. /// <summary>
  934. /// 另存为
  935. /// </summary>
  936. /// <param name="sender"></param>
  937. /// <param name="e"></param>
  938. private void Button3_Click(object sender, EventArgs e)
  939. {
  940. dialog = new CreateNameDialog(this);
  941. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  942. dialog.StartPosition = FormStartPosition.CenterParent;
  943. dialog.ShowDialog();
  944. }
  945. /// <summary>
  946. /// 初始化数据
  947. /// </summary>
  948. private void InitializeData()
  949. {
  950. this.fontsItems.Clear();
  951. //绑定字体数据
  952. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  953. foreach (FontFamily fontFamily in fonts.Families)
  954. {
  955. fontsItems.Add(fontFamily.Name);
  956. }
  957. this.fontComboBox.DataSource = fontsItems;
  958. //绑定样式默认数据
  959. /*this.comboBox11.Text = this.measureStyleModel.measureLine.font;
  960. this.numericUpDown21.Value = this.measureStyleModel.measureLine.fontSize;
  961. this.textPanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.textColor);
  962. this.linePanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.lineColor);
  963. this.numericUpDown11.Value = this.measureStyleModel.measureLine.lineWidth;
  964. this.comboBox21.Text = this.measureStyleModel.measureLine.lineStyle;*/
  965. //绑定样式下拉 todo
  966. if (initflag++ == 0)
  967. {
  968. InitializeStyleName();
  969. }
  970. //辅助线设置赋值
  971. this.fzxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.guideColour);
  972. this.fzxLineWidthNumeric.Value = this.workTypeStyleModel.guideLineWidth;
  973. if (this.workTypeStyleModel.guideShowFlag == 0)
  974. {
  975. this.fzxRBF.Checked = true;
  976. }
  977. else
  978. {
  979. this.fzxRBT.Checked = true;
  980. }
  981. //连接线设置赋值
  982. this.ljxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.connectColour);
  983. this.ljxLineWidthNumeric.Value = this.workTypeStyleModel.connectLineWidth;
  984. if (this.workTypeStyleModel.connectShowFlag == 0)
  985. {
  986. this.ljxRBF.Checked = true;
  987. }
  988. else
  989. {
  990. this.ljxRBT.Checked = true;
  991. }
  992. //测量线设置
  993. this.clxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.measureColour);
  994. this.clxLineWidthNumeric.Value = this.workTypeStyleModel.measureLineWidth;
  995. if (this.workTypeStyleModel.measureRangeShowFlag == 0)
  996. {
  997. this.clxRangeRBF.Checked = true;
  998. }
  999. else
  1000. {
  1001. this.clxRangeRBT.Checked = true;
  1002. }
  1003. if (this.workTypeStyleModel.measureLengthShowFlag == 0)
  1004. {
  1005. this.clxLenRBF.Checked = true;
  1006. }
  1007. else
  1008. {
  1009. this.clxLenRBT.Checked = true;
  1010. }
  1011. this.fontColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.fontColour);
  1012. this.fontComboBox.Text = this.workTypeStyleModel.font;
  1013. this.fontSizeNumeric.Value = this.workTypeStyleModel.fontSize;
  1014. }
  1015. /// <summary>
  1016. /// 调色板回调函数
  1017. /// </summary>
  1018. /// <param name="sender"></param>
  1019. /// <param name="ce"></param>
  1020. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1021. {
  1022. }
  1023. /// <summary>
  1024. /// 辅助线Panel被点击
  1025. /// </summary>
  1026. /// <param name="sender"></param>
  1027. /// <param name="e"></param>
  1028. private void fzxColorPanel_Click(object sender, EventArgs e)
  1029. {
  1030. this.colorsFormfzx.UserPrimaryColor = ColorBgra.FromColor(this.fzxColourPanel.BackColor);
  1031. this.colorsFormfzx.setSaveBtn_Click(new System.EventHandler(this.fzxColorChanged));
  1032. this.colorsFormfzx.ShowDialog();
  1033. }
  1034. /// <summary>
  1035. /// 辅助线Panel的调色板颜色改变
  1036. /// </summary>
  1037. /// <param name="sender"></param>
  1038. /// <param name="e"></param>
  1039. private void fzxColorChanged(object sender, EventArgs e)
  1040. {
  1041. this.fzxColourPanel.BackColor = this.colorsFormfzx.UserPrimaryColor.ToColor();
  1042. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1043. this.colorsFormfzx.Close();
  1044. }
  1045. /// <summary>
  1046. /// 字体颜色Panel被点击
  1047. /// </summary>
  1048. /// <param name="sender"></param>
  1049. /// <param name="e"></param>
  1050. private void fontColorPanel_Click(object sender, EventArgs e)
  1051. {
  1052. this.colorsFormfont.UserPrimaryColor = ColorBgra.FromColor(this.fontColourPanel.BackColor);
  1053. this.colorsFormfont.setSaveBtn_Click(new System.EventHandler(this.fontColorChanged));
  1054. this.colorsFormfont.ShowDialog();
  1055. }
  1056. /// <summary>
  1057. /// 字体颜色Panel的调色板颜色改变
  1058. /// </summary>
  1059. /// <param name="sender"></param>
  1060. /// <param name="e"></param>
  1061. private void fontColorChanged(object sender, EventArgs e)
  1062. {
  1063. this.fontColourPanel.BackColor = this.colorsFormfont.UserPrimaryColor.ToColor();
  1064. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1065. this.colorsFormfont.Close();
  1066. }
  1067. /// <summary>
  1068. /// 绑定样式下拉
  1069. /// </summary>
  1070. private void InitializeStyleName()
  1071. {
  1072. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\");
  1073. files.Clear();
  1074. foreach (string fileName in fileNames)
  1075. {
  1076. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  1077. files.Add(name);
  1078. }
  1079. this.styleComboBox.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  1080. this.styleComboBox.DataSource = null;
  1081. this.styleComboBox.DataSource = files;
  1082. string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  1083. this.styleComboBox.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  1084. this.workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1085. // InitializeData();
  1086. this.styleComboBox.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  1087. }
  1088. /// <summary>
  1089. /// 删除按钮
  1090. /// </summary>
  1091. /// <param name="sender"></param>
  1092. /// <param name="e"></param>
  1093. private void Button4_Click(object sender, EventArgs e)
  1094. {
  1095. if ("Default".Equals(this.styleComboBox.Text))
  1096. {
  1097. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1098. return;
  1099. }
  1100. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1101. if (dr == DialogResult.OK)
  1102. {
  1103. int newIndex = 0;
  1104. int selectIndex = this.styleComboBox.SelectedIndex;
  1105. int tall = files.Count - 1;
  1106. if (selectIndex < tall)
  1107. {
  1108. newIndex = selectIndex;
  1109. }
  1110. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml";
  1111. FileInfo fileInfo = new FileInfo(filePath);
  1112. fileInfo.Delete();
  1113. InitializeStyleName();
  1114. this.styleComboBox.SelectedIndex = newIndex;
  1115. workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1116. InitializeData();
  1117. }
  1118. else if (dr == DialogResult.Cancel)
  1119. {
  1120. }
  1121. }
  1122. /// <summary>
  1123. /// 弹出另存为框点击保存效果
  1124. /// </summary>
  1125. /// <param name="name"></param>
  1126. public override void GetCreateName(string name)
  1127. {
  1128. string currentcomboBox = this.styleComboBox.Text;
  1129. this.newName = name;
  1130. if (files.Contains(this.newName))
  1131. {
  1132. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1133. return;
  1134. }
  1135. CopyConfigAndRename();
  1136. InitializeStyleName();
  1137. this.styleComboBox.Text = currentcomboBox;
  1138. dialog.Close();
  1139. }
  1140. /// <summary>
  1141. /// 另存配置文件
  1142. /// </summary>
  1143. private void CopyConfigAndRename()
  1144. {
  1145. /*if (this.checkBox1.Checked)
  1146. {
  1147. this.watermarkModel.bold = 1;
  1148. }
  1149. else
  1150. {
  1151. this.watermarkModel.bold = 2;
  1152. }
  1153. if (this.checkBox2.Checked)
  1154. {
  1155. this.watermarkModel.italic = 1;
  1156. }
  1157. else
  1158. {
  1159. this.watermarkModel.italic = 2;
  1160. }
  1161. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1162. this.watermarkModel.typeface = this.comboBox3.Text;
  1163. this.watermarkModel.fontSize = Int32.Parse(this.comboBox4.Text);*/
  1164. //检查保存类型
  1165. // this.checkSaveModel();
  1166. //另存为
  1167. //调用检查方法
  1168. this.checkData();
  1169. string stageModelXml = XmlSerializeHelper.XmlSerialize<WorkTypeStyleModel>(this.workTypeStyleModel);
  1170. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.newName + ".xml";
  1171. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1172. }
  1173. /// <summary>
  1174. /// 当前操作样式
  1175. /// </summary>
  1176. /// <param name="sender"></param>
  1177. /// <param name="e"></param>
  1178. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  1179. {
  1180. workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1181. InitializeData();
  1182. }
  1183. private void ClxRangeRBT_CheckedChanged(object sender, EventArgs e)
  1184. {
  1185. }
  1186. }
  1187. }