WorkTypeSettingDialog.cs 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  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.Maximum = new decimal(new int[] {
  500. 49000,
  501. 0,
  502. 0,
  503. 0});
  504. this.fontSizeNumeric.Minimum = new decimal(new int[] {
  505. 1,
  506. 0,
  507. 0,
  508. 0});
  509. this.fontSizeNumeric.Name = "fontSizeNumeric";
  510. this.fontSizeNumeric.Size = new System.Drawing.Size(55, 21);
  511. this.fontSizeNumeric.TabIndex = 21;
  512. this.fontSizeNumeric.Value = new decimal(new int[] {
  513. 12,
  514. 0,
  515. 0,
  516. 0});
  517. //
  518. // fontComboBox
  519. //
  520. this.fontComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  521. this.fontComboBox.FormattingEnabled = true;
  522. this.fontComboBox.Location = new System.Drawing.Point(335, 70);
  523. this.fontComboBox.Name = "fontComboBox";
  524. this.fontComboBox.Size = new System.Drawing.Size(57, 20);
  525. this.fontComboBox.TabIndex = 20;
  526. //
  527. // clxColourPanel
  528. //
  529. this.clxColourPanel.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  530. this.clxColourPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  531. this.clxColourPanel.Location = new System.Drawing.Point(70, 14);
  532. this.clxColourPanel.Name = "clxColourPanel";
  533. this.clxColourPanel.Size = new System.Drawing.Size(161, 21);
  534. this.clxColourPanel.TabIndex = 19;
  535. this.clxColourPanel.Click += new System.EventHandler(this.clxColorPanel_Click);
  536. //
  537. // label14
  538. //
  539. this.label14.Location = new System.Drawing.Point(398, 71);
  540. this.label14.Name = "label14";
  541. this.label14.Size = new System.Drawing.Size(45, 23);
  542. this.label14.TabIndex = 18;
  543. this.label14.Text = "字号:";
  544. //
  545. // label13
  546. //
  547. this.label13.Location = new System.Drawing.Point(281, 74);
  548. this.label13.Name = "label13";
  549. this.label13.Size = new System.Drawing.Size(45, 23);
  550. this.label13.TabIndex = 17;
  551. this.label13.Text = "字体:";
  552. //
  553. // clxLenRBF
  554. //
  555. this.clxLenRBF.AutoSize = true;
  556. this.clxLenRBF.Location = new System.Drawing.Point(166, 71);
  557. this.clxLenRBF.Name = "clxLenRBF";
  558. this.clxLenRBF.Size = new System.Drawing.Size(14, 13);
  559. this.clxLenRBF.TabIndex = 16;
  560. this.clxLenRBF.TabStop = true;
  561. this.clxLenRBF.UseVisualStyleBackColor = true;
  562. this.clxLenRBF.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  563. //
  564. // clxLenRBT
  565. //
  566. this.clxLenRBT.AutoSize = true;
  567. this.clxLenRBT.Checked = true;
  568. this.clxLenRBT.Location = new System.Drawing.Point(125, 71);
  569. this.clxLenRBT.Name = "clxLenRBT";
  570. this.clxLenRBT.Size = new System.Drawing.Size(14, 13);
  571. this.clxLenRBT.TabIndex = 15;
  572. this.clxLenRBT.TabStop = true;
  573. this.clxLenRBT.UseVisualStyleBackColor = true;
  574. //
  575. // label12
  576. //
  577. this.label12.Location = new System.Drawing.Point(18, 73);
  578. this.label12.Name = "label12";
  579. this.label12.Size = new System.Drawing.Size(113, 23);
  580. this.label12.TabIndex = 14;
  581. this.label12.Text = "显示测量线长度:";
  582. //
  583. // label11
  584. //
  585. this.label11.Location = new System.Drawing.Point(258, 46);
  586. this.label11.Name = "label11";
  587. this.label11.Size = new System.Drawing.Size(117, 23);
  588. this.label11.TabIndex = 12;
  589. this.label11.Text = "字体颜色:";
  590. //
  591. // label9
  592. //
  593. this.label9.Location = new System.Drawing.Point(282, 18);
  594. this.label9.Name = "label9";
  595. this.label9.Size = new System.Drawing.Size(46, 23);
  596. this.label9.TabIndex = 6;
  597. this.label9.Text = "线宽:";
  598. //
  599. // label8
  600. //
  601. this.label8.Location = new System.Drawing.Point(18, 17);
  602. this.label8.Name = "label8";
  603. this.label8.Size = new System.Drawing.Size(46, 23);
  604. this.label8.TabIndex = 3;
  605. this.label8.Text = "颜色:";
  606. //
  607. // groupBox5
  608. //
  609. this.groupBox5.Controls.Add(this.pictureBox);
  610. this.groupBox5.Location = new System.Drawing.Point(12, 352);
  611. this.groupBox5.Name = "groupBox5";
  612. this.groupBox5.Size = new System.Drawing.Size(509, 148);
  613. this.groupBox5.TabIndex = 5;
  614. this.groupBox5.TabStop = false;
  615. this.groupBox5.Text = "预览";
  616. //
  617. // pictureBox
  618. //
  619. this.pictureBox.Location = new System.Drawing.Point(99, 20);
  620. this.pictureBox.Name = "pictureBox";
  621. this.pictureBox.Size = new System.Drawing.Size(306, 122);
  622. this.pictureBox.TabIndex = 0;
  623. this.pictureBox.TabStop = false;
  624. //
  625. // groupBox1
  626. //
  627. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  628. | System.Windows.Forms.AnchorStyles.Right)));
  629. this.groupBox1.Controls.Add(this.styleComboBox);
  630. this.groupBox1.Controls.Add(this.label1);
  631. this.groupBox1.Controls.Add(this.button4);
  632. this.groupBox1.Controls.Add(this.button3);
  633. this.groupBox1.Controls.Add(this.button2);
  634. this.groupBox1.Controls.Add(this.button1);
  635. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  636. this.groupBox1.Name = "groupBox1";
  637. this.groupBox1.Size = new System.Drawing.Size(509, 58);
  638. this.groupBox1.TabIndex = 2;
  639. this.groupBox1.TabStop = false;
  640. this.groupBox1.Text = "操作";
  641. //
  642. // styleComboBox
  643. //
  644. this.styleComboBox.FormattingEnabled = true;
  645. this.styleComboBox.Location = new System.Drawing.Point(99, 21);
  646. this.styleComboBox.Name = "styleComboBox";
  647. this.styleComboBox.Size = new System.Drawing.Size(80, 20);
  648. this.styleComboBox.TabIndex = 22;
  649. //
  650. // label1
  651. //
  652. this.label1.Location = new System.Drawing.Point(8, 24);
  653. this.label1.Name = "label1";
  654. this.label1.Size = new System.Drawing.Size(101, 23);
  655. this.label1.TabIndex = 9;
  656. this.label1.Text = "当前操作样式:";
  657. //
  658. // button4
  659. //
  660. this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
  661. this.button4.Location = new System.Drawing.Point(185, 20);
  662. this.button4.Name = "button4";
  663. this.button4.Size = new System.Drawing.Size(75, 23);
  664. this.button4.TabIndex = 3;
  665. this.button4.Text = "删除";
  666. this.button4.UseVisualStyleBackColor = true;
  667. this.button4.Click += new System.EventHandler(this.Button4_Click);
  668. //
  669. // button3
  670. //
  671. this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
  672. this.button3.Location = new System.Drawing.Point(266, 21);
  673. this.button3.Name = "button3";
  674. this.button3.Size = new System.Drawing.Size(75, 23);
  675. this.button3.TabIndex = 2;
  676. this.button3.Text = "另存为";
  677. this.button3.UseVisualStyleBackColor = true;
  678. this.button3.Click += new System.EventHandler(this.Button3_Click);
  679. //
  680. // button2
  681. //
  682. this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  683. this.button2.Location = new System.Drawing.Point(428, 21);
  684. this.button2.Name = "button2";
  685. this.button2.Size = new System.Drawing.Size(75, 23);
  686. this.button2.TabIndex = 1;
  687. this.button2.Text = "应用";
  688. this.button2.UseVisualStyleBackColor = true;
  689. this.button2.Click += new System.EventHandler(this.Button2_Click);
  690. //
  691. // button1
  692. //
  693. this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  694. this.button1.Location = new System.Drawing.Point(347, 21);
  695. this.button1.Name = "button1";
  696. this.button1.Size = new System.Drawing.Size(75, 23);
  697. this.button1.TabIndex = 0;
  698. this.button1.Text = "保存";
  699. this.button1.UseVisualStyleBackColor = true;
  700. this.button1.Click += new System.EventHandler(this.Button1_Click);
  701. //
  702. // WorkTypeSettingDialog
  703. //
  704. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  705. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  706. this.ClientSize = new System.Drawing.Size(533, 512);
  707. this.Controls.Add(this.groupBox1);
  708. this.Controls.Add(this.groupBox5);
  709. this.Controls.Add(this.groupBox4);
  710. this.Controls.Add(this.groupBox3);
  711. this.Controls.Add(this.groupBox2);
  712. this.Name = "WorkTypeSettingDialog";
  713. this.Text = "工型设置";
  714. this.Controls.SetChildIndex(this.groupBox2, 0);
  715. this.Controls.SetChildIndex(this.groupBox3, 0);
  716. this.Controls.SetChildIndex(this.groupBox4, 0);
  717. this.Controls.SetChildIndex(this.groupBox5, 0);
  718. this.Controls.SetChildIndex(this.groupBox1, 0);
  719. this.groupBox2.ResumeLayout(false);
  720. this.groupBox2.PerformLayout();
  721. ((System.ComponentModel.ISupportInitialize)(this.fzxLineWidthNumeric)).EndInit();
  722. this.groupBox3.ResumeLayout(false);
  723. this.groupBox3.PerformLayout();
  724. ((System.ComponentModel.ISupportInitialize)(this.ljxLineWidthNumeric)).EndInit();
  725. this.groupBox4.ResumeLayout(false);
  726. this.groupBox4.PerformLayout();
  727. this.panel1.ResumeLayout(false);
  728. this.panel1.PerformLayout();
  729. ((System.ComponentModel.ISupportInitialize)(this.clxLineWidthNumeric)).EndInit();
  730. ((System.ComponentModel.ISupportInitialize)(this.fontSizeNumeric)).EndInit();
  731. this.groupBox5.ResumeLayout(false);
  732. ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
  733. this.groupBox1.ResumeLayout(false);
  734. this.ResumeLayout(false);
  735. }
  736. #endregion
  737. #region InitializeComponent2
  738. /// <summary>
  739. /// 初始化组件
  740. /// </summary>
  741. private void InitializeComponent2()
  742. {
  743. this.colorsFormljx = new ColorsForm();
  744. this.colorsFormljx.StartPosition = FormStartPosition.CenterScreen;
  745. this.colorsFormljx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  746. this.colorsFormfzx = new ColorsForm();
  747. this.colorsFormfzx.StartPosition = FormStartPosition.CenterScreen;
  748. this.colorsFormfzx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  749. this.colorsFormclx = new ColorsForm();
  750. this.colorsFormclx.StartPosition = FormStartPosition.CenterScreen;
  751. this.colorsFormclx.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  752. this.colorsFormfont = new ColorsForm();
  753. this.colorsFormfont.StartPosition = FormStartPosition.CenterScreen;
  754. this.colorsFormfont.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  755. }
  756. #endregion
  757. /// <summary>
  758. /// 连接线Panel被点击
  759. /// </summary>
  760. /// <param name="sender"></param>
  761. /// <param name="e"></param>
  762. private void ljxColorPanel_Click(object sender, EventArgs e)
  763. {
  764. this.colorsFormljx.UserPrimaryColor = ColorBgra.FromColor(this.ljxColourPanel.BackColor);
  765. this.colorsFormljx.setSaveBtn_Click(new System.EventHandler(this.ljxColorChanged));
  766. this.colorsFormljx.ShowDialog();
  767. }
  768. /// <summary>
  769. /// 连接线Panel的调色板颜色改变
  770. /// </summary>
  771. /// <param name="sender"></param>
  772. /// <param name="e"></param>
  773. private void ljxColorChanged(object sender, EventArgs e)
  774. {
  775. this.ljxColourPanel.BackColor = this.colorsFormljx.UserPrimaryColor.ToColor();
  776. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  777. this.colorsFormljx.Close();
  778. }
  779. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  780. {
  781. }
  782. /// <summary>
  783. /// 测量线Panel被点击
  784. /// </summary>
  785. /// <param name="sender"></param>
  786. /// <param name="e"></param>
  787. private void clxColorPanel_Click(object sender, EventArgs e)
  788. {
  789. this.colorsFormclx.UserPrimaryColor = ColorBgra.FromColor(this.clxColourPanel.BackColor);
  790. this.colorsFormclx.setSaveBtn_Click(new System.EventHandler(this.clxColorChanged));
  791. this.colorsFormclx.ShowDialog();
  792. }
  793. /// <summary>
  794. /// 测量线Panel的调色板颜色改变
  795. /// </summary>
  796. /// <param name="sender"></param>
  797. /// <param name="e"></param>
  798. private void clxColorChanged(object sender, EventArgs e)
  799. {
  800. this.clxColourPanel.BackColor = this.colorsFormclx.UserPrimaryColor.ToColor();
  801. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  802. this.colorsFormclx.Close();
  803. }
  804. /// <summary>
  805. /// 处理控件
  806. /// </summary>
  807. private void InitializeControl()
  808. {
  809. this.pictureBox.Paint += new PaintEventHandler(this.pictureBox_Paint);
  810. }
  811. /// <summary>
  812. /// pictureBox的绘制事件
  813. /// </summary>
  814. /// <param name="sender"></param>
  815. /// <param name="e"></param>
  816. private void pictureBox_Paint(object sender, PaintEventArgs e)
  817. {
  818. WorkTypeStyleModel model = this.workTypeStyleModel;
  819. Graphics gps = e.Graphics;
  820. Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value));
  821. gps.DrawLine(measurePen, 150, 20 + model.guideLineWidth / 2, 150, 80 - model.connectLineWidth / 2);
  822. if (model.guideShowFlag == 1)
  823. {
  824. Pen guidePen = new Pen(Color.FromArgb(model.guideColour), Convert.ToInt32(model.guideLineWidth));
  825. gps.DrawLine(guidePen, 50, 20, 250, 20);
  826. }
  827. if (model.connectShowFlag == 1) {
  828. Pen connectPen = new Pen(Color.FromArgb(model.connectColour), model.connectLineWidth);
  829. gps.DrawLine(connectPen, 50, 80, 250, 80);
  830. }
  831. }
  832. /// <summary>
  833. /// 应用按钮被点击
  834. /// </summary>
  835. /// <param name="sender"></param>
  836. /// <param name="e"></param>
  837. private void Button2_Click(object sender, EventArgs e)
  838. {
  839. /*//预览展示
  840. Graphics gps = pictureBox.CreateGraphics();
  841. // gps.Clear(Color.Empty);
  842. Pen guidePen = new Pen(this.fzxColourPanel.BackColor , Convert.ToInt32(this.fzxLineWidthNumeric.Value));
  843. Pen measurePen = new Pen(this.clxColourPanel.BackColor, Convert.ToInt32(this.clxLineWidthNumeric.Value));
  844. Pen connectPen = new Pen(this.ljxColourPanel.BackColor, Convert.ToInt32(this.ljxLineWidthNumeric.Value));
  845. gps.DrawLine(measurePen, 150, 20 + Convert.ToInt32(this.fzxLineWidthNumeric.Value)/2, 150, 80 - Convert.ToInt32(this.ljxLineWidthNumeric.Value)/2);
  846. gps.DrawLine(guidePen, 50, 20, 250, 20);
  847. gps.DrawLine(connectPen, 50, 80, 250, 80);*/
  848. //检查数据
  849. this.checkData();
  850. this.pictureBox.Invalidate();
  851. Startup.instance.workTypeStyleModel = this.workTypeStyleModel;
  852. }
  853. /// <summary>
  854. /// 检查数据并且赋值到model中
  855. /// </summary>
  856. private void checkData() {
  857. UpDownBase fzxLineWidthup = (UpDownBase)this.fzxLineWidthNumeric;
  858. if (string.IsNullOrEmpty(fzxLineWidthup.Text)) {
  859. this.fzxLineWidthNumeric.Value = 1;
  860. }
  861. UpDownBase ljxLineWidthup = (UpDownBase)this.ljxLineWidthNumeric;
  862. if (string.IsNullOrEmpty(ljxLineWidthup.Text))
  863. {
  864. this.ljxLineWidthNumeric.Value = 1;
  865. }
  866. UpDownBase clxLineWidthup = (UpDownBase)this.clxLineWidthNumeric;
  867. if (string.IsNullOrEmpty(clxLineWidthup.Text))
  868. {
  869. this.clxLineWidthNumeric.Value = 1;
  870. }
  871. UpDownBase fontSizeWidthup = (UpDownBase)this.fontSizeNumeric;
  872. if (string.IsNullOrEmpty(fontSizeWidthup.Text))
  873. {
  874. this.fontSizeNumeric.Value = 1;
  875. }
  876. /* if (string.IsNullOrEmpty(fontComboBox.Text)) {
  877. fontComboBox.Text = this.workTypeStyleModel.font;
  878. }*/
  879. //辅助线设置赋值
  880. this.workTypeStyleModel.guideColour = Convert.ToInt32(this.fzxColourPanel.BackColor.ToArgb());
  881. this.workTypeStyleModel.guideLineWidth = Convert.ToInt32(this.fzxLineWidthNumeric.Value);
  882. if (this.fzxRBF.Checked)
  883. {
  884. this.workTypeStyleModel.guideShowFlag = 0;
  885. }
  886. else
  887. {
  888. this.workTypeStyleModel.guideShowFlag = 1;
  889. }
  890. //连接线设置赋值
  891. this.workTypeStyleModel.connectColour = Convert.ToInt32(this.ljxColourPanel.BackColor.ToArgb());
  892. this.workTypeStyleModel.connectLineWidth = Convert.ToInt32(this.ljxLineWidthNumeric.Value);
  893. if (this.ljxRBF.Checked)
  894. {
  895. this.workTypeStyleModel.connectShowFlag = 0;
  896. }
  897. else
  898. {
  899. this.workTypeStyleModel.connectShowFlag = 1;
  900. }
  901. //测量线设置
  902. this.workTypeStyleModel.measureColour = Convert.ToInt32(this.clxColourPanel.BackColor.ToArgb());
  903. this.workTypeStyleModel.measureLineWidth = Convert.ToInt32(this.clxLineWidthNumeric.Value);
  904. if (this.clxRangeRBF.Checked)
  905. {
  906. this.workTypeStyleModel.measureRangeShowFlag = 0;
  907. }
  908. else
  909. {
  910. this.workTypeStyleModel.measureRangeShowFlag = 1;
  911. }
  912. if (this.clxLenRBF.Checked)
  913. {
  914. this.workTypeStyleModel.measureLengthShowFlag = 0;
  915. }
  916. else
  917. {
  918. this.workTypeStyleModel.measureLengthShowFlag = 1;
  919. }
  920. this.workTypeStyleModel.fontColour = Convert.ToInt32(this.fontColourPanel.BackColor.ToArgb());
  921. this.workTypeStyleModel.font = this.fontComboBox.Text;
  922. this.workTypeStyleModel.fontSize = Convert.ToInt32(this.fontSizeNumeric.Value);
  923. }
  924. /// <summary>
  925. /// 保存按钮被点击
  926. /// </summary>
  927. /// <param name="sender"></param>
  928. /// <param name="e"></param>
  929. private void Button1_Click(object sender, EventArgs e)
  930. {
  931. //调用检查方法
  932. this.checkData();
  933. //以下保存xml文件信息
  934. string workTypeStyleModelXml = XmlSerializeHelper.XmlSerialize<WorkTypeStyleModel>(this.workTypeStyleModel);
  935. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml";
  936. FileOperationHelper.WriteStringToFile(workTypeStyleModelXml, filePath, FileMode.Create);
  937. }
  938. /// <summary>
  939. /// 另存为
  940. /// </summary>
  941. /// <param name="sender"></param>
  942. /// <param name="e"></param>
  943. private void Button3_Click(object sender, EventArgs e)
  944. {
  945. dialog = new CreateNameDialog(this);
  946. dialog.Text = PdnResources.GetString("Menu.Set.Watermarksettings.Newstyle.text");
  947. dialog.StartPosition = FormStartPosition.CenterParent;
  948. dialog.ShowDialog();
  949. }
  950. /// <summary>
  951. /// 初始化数据
  952. /// </summary>
  953. private void InitializeData()
  954. {
  955. this.fontsItems.Clear();
  956. //绑定字体数据
  957. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  958. foreach (FontFamily fontFamily in fonts.Families)
  959. {
  960. fontsItems.Add(fontFamily.Name);
  961. }
  962. this.fontComboBox.DataSource = fontsItems;
  963. //绑定样式默认数据
  964. /*this.comboBox11.Text = this.measureStyleModel.measureLine.font;
  965. this.numericUpDown21.Value = this.measureStyleModel.measureLine.fontSize;
  966. this.textPanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.textColor);
  967. this.linePanel.BackColor = Color.FromArgb(this.measureStyleModel.measureLine.lineColor);
  968. this.numericUpDown11.Value = this.measureStyleModel.measureLine.lineWidth;
  969. this.comboBox21.Text = this.measureStyleModel.measureLine.lineStyle;*/
  970. //绑定样式下拉 todo
  971. if (initflag++ == 0)
  972. {
  973. InitializeStyleName();
  974. }
  975. //辅助线设置赋值
  976. this.fzxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.guideColour);
  977. this.fzxLineWidthNumeric.Value = this.workTypeStyleModel.guideLineWidth;
  978. if (this.workTypeStyleModel.guideShowFlag == 0)
  979. {
  980. this.fzxRBF.Checked = true;
  981. }
  982. else
  983. {
  984. this.fzxRBT.Checked = true;
  985. }
  986. //连接线设置赋值
  987. this.ljxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.connectColour);
  988. this.ljxLineWidthNumeric.Value = this.workTypeStyleModel.connectLineWidth;
  989. if (this.workTypeStyleModel.connectShowFlag == 0)
  990. {
  991. this.ljxRBF.Checked = true;
  992. }
  993. else
  994. {
  995. this.ljxRBT.Checked = true;
  996. }
  997. //测量线设置
  998. this.clxColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.measureColour);
  999. this.clxLineWidthNumeric.Value = this.workTypeStyleModel.measureLineWidth;
  1000. if (this.workTypeStyleModel.measureRangeShowFlag == 0)
  1001. {
  1002. this.clxRangeRBF.Checked = true;
  1003. }
  1004. else
  1005. {
  1006. this.clxRangeRBT.Checked = true;
  1007. }
  1008. if (this.workTypeStyleModel.measureLengthShowFlag == 0)
  1009. {
  1010. this.clxLenRBF.Checked = true;
  1011. }
  1012. else
  1013. {
  1014. this.clxLenRBT.Checked = true;
  1015. }
  1016. this.fontColourPanel.BackColor = Color.FromArgb(this.workTypeStyleModel.fontColour);
  1017. this.fontComboBox.Text = this.workTypeStyleModel.font;
  1018. this.fontSizeNumeric.Value = this.workTypeStyleModel.fontSize;
  1019. }
  1020. /// <summary>
  1021. /// 调色板回调函数
  1022. /// </summary>
  1023. /// <param name="sender"></param>
  1024. /// <param name="ce"></param>
  1025. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1026. {
  1027. }
  1028. /// <summary>
  1029. /// 辅助线Panel被点击
  1030. /// </summary>
  1031. /// <param name="sender"></param>
  1032. /// <param name="e"></param>
  1033. private void fzxColorPanel_Click(object sender, EventArgs e)
  1034. {
  1035. this.colorsFormfzx.UserPrimaryColor = ColorBgra.FromColor(this.fzxColourPanel.BackColor);
  1036. this.colorsFormfzx.setSaveBtn_Click(new System.EventHandler(this.fzxColorChanged));
  1037. this.colorsFormfzx.ShowDialog();
  1038. }
  1039. /// <summary>
  1040. /// 辅助线Panel的调色板颜色改变
  1041. /// </summary>
  1042. /// <param name="sender"></param>
  1043. /// <param name="e"></param>
  1044. private void fzxColorChanged(object sender, EventArgs e)
  1045. {
  1046. this.fzxColourPanel.BackColor = this.colorsFormfzx.UserPrimaryColor.ToColor();
  1047. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1048. this.colorsFormfzx.Close();
  1049. }
  1050. /// <summary>
  1051. /// 字体颜色Panel被点击
  1052. /// </summary>
  1053. /// <param name="sender"></param>
  1054. /// <param name="e"></param>
  1055. private void fontColorPanel_Click(object sender, EventArgs e)
  1056. {
  1057. this.colorsFormfont.UserPrimaryColor = ColorBgra.FromColor(this.fontColourPanel.BackColor);
  1058. this.colorsFormfont.setSaveBtn_Click(new System.EventHandler(this.fontColorChanged));
  1059. this.colorsFormfont.ShowDialog();
  1060. }
  1061. /// <summary>
  1062. /// 字体颜色Panel的调色板颜色改变
  1063. /// </summary>
  1064. /// <param name="sender"></param>
  1065. /// <param name="e"></param>
  1066. private void fontColorChanged(object sender, EventArgs e)
  1067. {
  1068. this.fontColourPanel.BackColor = this.colorsFormfont.UserPrimaryColor.ToColor();
  1069. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  1070. this.colorsFormfont.Close();
  1071. }
  1072. /// <summary>
  1073. /// 绑定样式下拉
  1074. /// </summary>
  1075. private void InitializeStyleName()
  1076. {
  1077. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\");
  1078. files.Clear();
  1079. foreach (string fileName in fileNames)
  1080. {
  1081. string name = fileName.Substring(0, fileName.LastIndexOf("."));
  1082. files.Add(name);
  1083. }
  1084. this.styleComboBox.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
  1085. this.styleComboBox.DataSource = null;
  1086. this.styleComboBox.DataSource = files;
  1087. string nowModelName = Startup.instance.configModel.Watermark.Substring(0, Startup.instance.configModel.Watermark.LastIndexOf("."));
  1088. this.styleComboBox.SelectedIndex = files.FindIndex(a => a.Equals(nowModelName));
  1089. this.workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1090. // InitializeData();
  1091. this.styleComboBox.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
  1092. }
  1093. /// <summary>
  1094. /// 删除按钮
  1095. /// </summary>
  1096. /// <param name="sender"></param>
  1097. /// <param name="e"></param>
  1098. private void Button4_Click(object sender, EventArgs e)
  1099. {
  1100. if ("Default".Equals(this.styleComboBox.Text))
  1101. {
  1102. MessageBox.Show(PdnResources.GetString("Menu.efaultstylecannotbedelete.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1103. return;
  1104. }
  1105. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.nfirmthedeleti.Text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1106. if (dr == DialogResult.OK)
  1107. {
  1108. int newIndex = 0;
  1109. int selectIndex = this.styleComboBox.SelectedIndex;
  1110. int tall = files.Count - 1;
  1111. if (selectIndex < tall)
  1112. {
  1113. newIndex = selectIndex;
  1114. }
  1115. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.Text + ".xml";
  1116. FileInfo fileInfo = new FileInfo(filePath);
  1117. fileInfo.Delete();
  1118. InitializeStyleName();
  1119. this.styleComboBox.SelectedIndex = newIndex;
  1120. workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1121. InitializeData();
  1122. }
  1123. else if (dr == DialogResult.Cancel)
  1124. {
  1125. }
  1126. }
  1127. /// <summary>
  1128. /// 弹出另存为框点击保存效果
  1129. /// </summary>
  1130. /// <param name="name"></param>
  1131. public override void GetCreateName(string name)
  1132. {
  1133. string currentcomboBox = this.styleComboBox.Text;
  1134. this.newName = name;
  1135. if (files.Contains(this.newName))
  1136. {
  1137. MessageBox.Show(PdnResources.GetString("Menu.Stylenamecannotberepeated.text"), PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1138. return;
  1139. }
  1140. CopyConfigAndRename();
  1141. InitializeStyleName();
  1142. this.styleComboBox.Text = currentcomboBox;
  1143. dialog.Close();
  1144. }
  1145. /// <summary>
  1146. /// 另存配置文件
  1147. /// </summary>
  1148. private void CopyConfigAndRename()
  1149. {
  1150. /*if (this.checkBox1.Checked)
  1151. {
  1152. this.watermarkModel.bold = 1;
  1153. }
  1154. else
  1155. {
  1156. this.watermarkModel.bold = 2;
  1157. }
  1158. if (this.checkBox2.Checked)
  1159. {
  1160. this.watermarkModel.italic = 1;
  1161. }
  1162. else
  1163. {
  1164. this.watermarkModel.italic = 2;
  1165. }
  1166. this.watermarkModel.position = this.comboBox2.SelectedIndex + 1;
  1167. this.watermarkModel.typeface = this.comboBox3.Text;
  1168. this.watermarkModel.fontSize = Int32.Parse(this.comboBox4.Text);*/
  1169. //检查保存类型
  1170. // this.checkSaveModel();
  1171. //另存为
  1172. //调用检查方法
  1173. this.checkData();
  1174. string stageModelXml = XmlSerializeHelper.XmlSerialize<WorkTypeStyleModel>(this.workTypeStyleModel);
  1175. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.newName + ".xml";
  1176. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  1177. }
  1178. /// <summary>
  1179. /// 当前操作样式
  1180. /// </summary>
  1181. /// <param name="sender"></param>
  1182. /// <param name="e"></param>
  1183. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  1184. {
  1185. workTypeStyleModel = XmlSerializeHelper.DESerializer<WorkTypeStyleModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkType\\" + this.styleComboBox.SelectedItem.ToString() + ".xml", FileMode.Open));
  1186. InitializeData();
  1187. }
  1188. private void ClxRangeRBT_CheckedChanged(object sender, EventArgs e)
  1189. {
  1190. }
  1191. }
  1192. }