GridSettingDialog.cs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. using PaintDotNet.Base.CommTool;
  2. using PaintDotNet.CustomControl;
  3. using PaintDotNet.Base.SettingModel;
  4. using System;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Windows.Forms;
  8. using System.Collections.Generic;
  9. namespace PaintDotNet.Setting
  10. {
  11. /// <summary>
  12. /// 设置->网格设置
  13. ///已弃用
  14. /// </summary>
  15. internal partial class GridSettingDialog : PdnBaseForm
  16. {
  17. private System.Windows.Forms.GroupBox groupBox1;
  18. private System.Windows.Forms.Button button1;
  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.Label label1;
  23. private System.Windows.Forms.Label label3;
  24. private System.Windows.Forms.Label label4;
  25. private System.Windows.Forms.ComboBox comboBox1;
  26. private System.Windows.Forms.Label label5;
  27. private System.Windows.Forms.Label label6;
  28. private System.Windows.Forms.ComboBox comboBox2;
  29. private System.Windows.Forms.Label label7;
  30. private System.Windows.Forms.Panel gridPanel;
  31. private System.Windows.Forms.Panel rectPanel;
  32. private System.Windows.Forms.Label label8;
  33. private System.Windows.Forms.Label label10;
  34. private System.Windows.Forms.Label label9;
  35. private System.Windows.Forms.ComboBox comboBox4;
  36. private System.Windows.Forms.ComboBox comboBox3;
  37. private System.Windows.Forms.Panel circularPanel;
  38. private System.Windows.Forms.Label label11;
  39. private System.Windows.Forms.Label label12;
  40. private System.Windows.Forms.ComboBox comboBox5;
  41. private System.Windows.Forms.ComboBox comboBox6;
  42. private System.Windows.Forms.Label label13;
  43. private System.Windows.Forms.ColorDialog colorDialog1;
  44. private UserTextBox userTextBox1;
  45. private UserTextBox userTextBox2;
  46. private UserTextBox userTextBox3;
  47. /// <summary>
  48. /// 主控件
  49. /// </summary>
  50. private AppWorkspace appWorkspace;
  51. /// <summary>
  52. /// 网格设置的model
  53. /// </summary>
  54. private GridModel gridModel = Startup.instance.gridModel;
  55. /// <summary>
  56. /// 单位标尺
  57. /// </summary>
  58. private double unitLength = 1;
  59. /// <summary>
  60. /// 网格调色板
  61. /// </summary>
  62. PaintDotNet.ColorsForm colorsFormGrid;
  63. /// <summary>
  64. /// 矩形调色板
  65. /// </summary>
  66. PaintDotNet.ColorsForm colorsFormRect;
  67. private ComboBox comboBox7;
  68. private ColorDialog colorDialog2;
  69. private GroupBox groupBox5;
  70. private Button button5;
  71. private Button button4;
  72. private Button button3;
  73. private DataGridView dataGridView1;
  74. private DataGridViewTextBoxColumn Column1;
  75. private Label label2;
  76. private TextBox textBox1;
  77. /// <summary>
  78. /// 圆形调色板
  79. /// </summary>
  80. PaintDotNet.ColorsForm colorsFormCircular;
  81. private Button btnSaveAs;
  82. private Button btnSave;
  83. private Button btnDel;
  84. /// <summary>
  85. /// 网格样式的增改删,0-添加、1-修改、2-删除
  86. /// </summary>
  87. private int operation = -1;
  88. public GridSettingDialog(AppWorkspace appWorkspace)
  89. {
  90. this.appWorkspace = appWorkspace;
  91. InitializeComponent();
  92. InitializeLanguageText();
  93. InitializeButtonBackgroudImage();
  94. InitParameterData();
  95. InitializationDataGridView();
  96. InitializeComponent2();
  97. UnitData();
  98. }
  99. #region Windows Form Designer generated code
  100. private void InitializeLanguageText()
  101. {
  102. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  103. //this.button2.Text = PdnResources.GetString("Menu.cancel.text");
  104. this.button1.Text = PdnResources.GetString("Menu.application.text");
  105. this.groupBox2.Text = PdnResources.GetString("Menu.Setting.GridSetting.Text");
  106. this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
  107. this.label6.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":";
  108. this.label5.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":";
  109. this.label4.Text = PdnResources.GetString("Menu.Set.Gridsettings.Numberofverticalgrids.text") + ":";
  110. this.label3.Text = PdnResources.GetString("Menu.Set.Gridsettings.Numberofhorizontalgrids.text") + ":";
  111. this.label1.Text = PdnResources.GetString("Menu.Set.Gridsettings.Gridsidelength.text") + ":";
  112. this.groupBox3.Text = PdnResources.GetString("Menu.Set.Gridsettings.Rectsettings.text");
  113. this.label8.Text = PdnResources.GetString("Menu.color.text") + ":";
  114. this.label10.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":";
  115. this.label9.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":";
  116. this.groupBox4.Text = PdnResources.GetString("Menu.Set.Gridsettings.roundsetting.text");
  117. this.label11.Text = PdnResources.GetString("Menu.color.text") + ":";
  118. this.label12.Text = PdnResources.GetString("Menu.Set.Gridsettings.grist.text") + ":";
  119. this.label13.Text = PdnResources.GetString("Menu.Set.Gridsettings.Linear.text") + ":";
  120. this.Text = PdnResources.GetString("Menu.Setting.GridSetting.Text");
  121. }
  122. /// <summary>
  123. /// Required method for Designer support - do not modify
  124. /// the contents of this method with the code editor.
  125. /// </summary>
  126. private void InitializeComponent()
  127. {
  128. this.groupBox1 = new System.Windows.Forms.GroupBox();
  129. this.btnSaveAs = new System.Windows.Forms.Button();
  130. this.btnSave = new System.Windows.Forms.Button();
  131. this.btnDel = new System.Windows.Forms.Button();
  132. this.button1 = new System.Windows.Forms.Button();
  133. this.groupBox2 = new System.Windows.Forms.GroupBox();
  134. this.textBox1 = new System.Windows.Forms.TextBox();
  135. this.label2 = new System.Windows.Forms.Label();
  136. this.comboBox7 = new System.Windows.Forms.ComboBox();
  137. this.userTextBox3 = new PaintDotNet.CustomControl.UserTextBox();
  138. this.userTextBox2 = new PaintDotNet.CustomControl.UserTextBox();
  139. this.userTextBox1 = new PaintDotNet.CustomControl.UserTextBox();
  140. this.gridPanel = new System.Windows.Forms.Panel();
  141. this.label7 = new System.Windows.Forms.Label();
  142. this.label6 = new System.Windows.Forms.Label();
  143. this.comboBox2 = new System.Windows.Forms.ComboBox();
  144. this.comboBox1 = new System.Windows.Forms.ComboBox();
  145. this.label5 = new System.Windows.Forms.Label();
  146. this.label4 = new System.Windows.Forms.Label();
  147. this.label3 = new System.Windows.Forms.Label();
  148. this.label1 = new System.Windows.Forms.Label();
  149. this.groupBox3 = new System.Windows.Forms.GroupBox();
  150. this.rectPanel = new System.Windows.Forms.Panel();
  151. this.label8 = new System.Windows.Forms.Label();
  152. this.label10 = new System.Windows.Forms.Label();
  153. this.label9 = new System.Windows.Forms.Label();
  154. this.comboBox4 = new System.Windows.Forms.ComboBox();
  155. this.comboBox3 = new System.Windows.Forms.ComboBox();
  156. this.groupBox4 = new System.Windows.Forms.GroupBox();
  157. this.circularPanel = new System.Windows.Forms.Panel();
  158. this.label11 = new System.Windows.Forms.Label();
  159. this.label12 = new System.Windows.Forms.Label();
  160. this.comboBox5 = new System.Windows.Forms.ComboBox();
  161. this.comboBox6 = new System.Windows.Forms.ComboBox();
  162. this.label13 = new System.Windows.Forms.Label();
  163. this.colorDialog1 = new System.Windows.Forms.ColorDialog();
  164. this.colorDialog2 = new System.Windows.Forms.ColorDialog();
  165. this.groupBox5 = new System.Windows.Forms.GroupBox();
  166. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  167. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  168. this.button5 = new System.Windows.Forms.Button();
  169. this.button4 = new System.Windows.Forms.Button();
  170. this.button3 = new System.Windows.Forms.Button();
  171. this.groupBox1.SuspendLayout();
  172. this.groupBox2.SuspendLayout();
  173. this.groupBox3.SuspendLayout();
  174. this.groupBox4.SuspendLayout();
  175. this.groupBox5.SuspendLayout();
  176. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  177. this.SuspendLayout();
  178. //
  179. // groupBox1
  180. //
  181. this.groupBox1.Controls.Add(this.btnSaveAs);
  182. this.groupBox1.Controls.Add(this.btnSave);
  183. this.groupBox1.Controls.Add(this.btnDel);
  184. this.groupBox1.Controls.Add(this.button1);
  185. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  186. this.groupBox1.Name = "groupBox1";
  187. this.groupBox1.Size = new System.Drawing.Size(691, 58);
  188. this.groupBox1.TabIndex = 1;
  189. this.groupBox1.TabStop = false;
  190. this.groupBox1.Text = "操作";
  191. //
  192. // btnSaveAs
  193. //
  194. this.btnSaveAs.Anchor = System.Windows.Forms.AnchorStyles.Right;
  195. this.btnSaveAs.Location = new System.Drawing.Point(520, 20);
  196. this.btnSaveAs.Name = "btnSaveAs";
  197. this.btnSaveAs.Size = new System.Drawing.Size(75, 23);
  198. this.btnSaveAs.TabIndex = 3;
  199. this.btnSaveAs.Text = "另存为";
  200. this.btnSaveAs.UseVisualStyleBackColor = true;
  201. this.btnSaveAs.Click += new System.EventHandler(this.btnSaveAs_Click);
  202. //
  203. // btnSave
  204. //
  205. this.btnSave.Anchor = System.Windows.Forms.AnchorStyles.Right;
  206. this.btnSave.Location = new System.Drawing.Point(439, 20);
  207. this.btnSave.Name = "btnSave";
  208. this.btnSave.Size = new System.Drawing.Size(75, 23);
  209. this.btnSave.TabIndex = 2;
  210. this.btnSave.Text = "保存";
  211. this.btnSave.UseVisualStyleBackColor = true;
  212. this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
  213. //
  214. // btnDel
  215. //
  216. this.btnDel.Anchor = System.Windows.Forms.AnchorStyles.Right;
  217. this.btnDel.Location = new System.Drawing.Point(358, 20);
  218. this.btnDel.Name = "btnDel";
  219. this.btnDel.Size = new System.Drawing.Size(75, 23);
  220. this.btnDel.TabIndex = 1;
  221. this.btnDel.Text = "删除";
  222. this.btnDel.UseVisualStyleBackColor = true;
  223. this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
  224. //
  225. // button1
  226. //
  227. this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  228. this.button1.Location = new System.Drawing.Point(601, 20);
  229. this.button1.Name = "button1";
  230. this.button1.Size = new System.Drawing.Size(75, 23);
  231. this.button1.TabIndex = 0;
  232. this.button1.Text = "激活";
  233. this.button1.UseVisualStyleBackColor = true;
  234. this.button1.Click += new System.EventHandler(this.button1_Click);
  235. //
  236. // groupBox2
  237. //
  238. this.groupBox2.Controls.Add(this.textBox1);
  239. this.groupBox2.Controls.Add(this.label2);
  240. this.groupBox2.Controls.Add(this.comboBox7);
  241. this.groupBox2.Controls.Add(this.userTextBox3);
  242. this.groupBox2.Controls.Add(this.userTextBox2);
  243. this.groupBox2.Controls.Add(this.userTextBox1);
  244. this.groupBox2.Controls.Add(this.gridPanel);
  245. this.groupBox2.Controls.Add(this.label7);
  246. this.groupBox2.Controls.Add(this.label6);
  247. this.groupBox2.Controls.Add(this.comboBox2);
  248. this.groupBox2.Controls.Add(this.comboBox1);
  249. this.groupBox2.Controls.Add(this.label5);
  250. this.groupBox2.Controls.Add(this.label4);
  251. this.groupBox2.Controls.Add(this.label3);
  252. this.groupBox2.Controls.Add(this.label1);
  253. this.groupBox2.Location = new System.Drawing.Point(195, 77);
  254. this.groupBox2.Name = "groupBox2";
  255. this.groupBox2.Size = new System.Drawing.Size(508, 207);
  256. this.groupBox2.TabIndex = 2;
  257. this.groupBox2.TabStop = false;
  258. this.groupBox2.Text = "网格设置";
  259. //
  260. // textBox1
  261. //
  262. this.textBox1.Location = new System.Drawing.Point(107, 13);
  263. this.textBox1.Name = "textBox1";
  264. this.textBox1.Size = new System.Drawing.Size(342, 21);
  265. this.textBox1.TabIndex = 20;
  266. //
  267. // label2
  268. //
  269. this.label2.AutoSize = true;
  270. this.label2.Location = new System.Drawing.Point(59, 18);
  271. this.label2.Name = "label2";
  272. this.label2.Size = new System.Drawing.Size(41, 12);
  273. this.label2.TabIndex = 16;
  274. this.label2.Text = "名称:";
  275. //
  276. // comboBox7
  277. //
  278. this.comboBox7.FormattingEnabled = true;
  279. this.comboBox7.Items.AddRange(new object[] {
  280. "px",
  281. "μm"});
  282. this.comboBox7.Location = new System.Drawing.Point(400, 42);
  283. this.comboBox7.Name = "comboBox7";
  284. this.comboBox7.Size = new System.Drawing.Size(49, 20);
  285. this.comboBox7.TabIndex = 2;
  286. //
  287. // userTextBox3
  288. //
  289. this.userTextBox3.Location = new System.Drawing.Point(107, 100);
  290. this.userTextBox3.Name = "userTextBox3";
  291. this.userTextBox3.Size = new System.Drawing.Size(342, 21);
  292. this.userTextBox3.TabIndex = 15;
  293. //
  294. // userTextBox2
  295. //
  296. this.userTextBox2.Location = new System.Drawing.Point(107, 72);
  297. this.userTextBox2.Name = "userTextBox2";
  298. this.userTextBox2.Size = new System.Drawing.Size(342, 21);
  299. this.userTextBox2.TabIndex = 14;
  300. //
  301. // userTextBox1
  302. //
  303. this.userTextBox1.Location = new System.Drawing.Point(107, 42);
  304. this.userTextBox1.Name = "userTextBox1";
  305. this.userTextBox1.Size = new System.Drawing.Size(287, 21);
  306. this.userTextBox1.TabIndex = 13;
  307. //
  308. // gridPanel
  309. //
  310. this.gridPanel.BackColor = System.Drawing.Color.Transparent;
  311. this.gridPanel.Location = new System.Drawing.Point(107, 182);
  312. this.gridPanel.Name = "gridPanel";
  313. this.gridPanel.Size = new System.Drawing.Size(72, 21);
  314. this.gridPanel.TabIndex = 12;
  315. this.gridPanel.Click += new System.EventHandler(this.gridColorPanel_Click);
  316. //
  317. // label7
  318. //
  319. this.label7.AutoSize = true;
  320. this.label7.Location = new System.Drawing.Point(59, 186);
  321. this.label7.Name = "label7";
  322. this.label7.Size = new System.Drawing.Size(41, 12);
  323. this.label7.TabIndex = 11;
  324. this.label7.Text = "颜色:";
  325. //
  326. // label6
  327. //
  328. this.label6.AutoSize = true;
  329. this.label6.Location = new System.Drawing.Point(59, 159);
  330. this.label6.Name = "label6";
  331. this.label6.Size = new System.Drawing.Size(41, 12);
  332. this.label6.TabIndex = 10;
  333. this.label6.Text = "粗细:";
  334. //
  335. // comboBox2
  336. //
  337. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  338. this.comboBox2.FormattingEnabled = true;
  339. this.comboBox2.Location = new System.Drawing.Point(107, 155);
  340. this.comboBox2.Name = "comboBox2";
  341. this.comboBox2.Size = new System.Drawing.Size(341, 20);
  342. this.comboBox2.TabIndex = 9;
  343. //
  344. // comboBox1
  345. //
  346. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  347. this.comboBox1.FormattingEnabled = true;
  348. this.comboBox1.Location = new System.Drawing.Point(107, 128);
  349. this.comboBox1.Name = "comboBox1";
  350. this.comboBox1.Size = new System.Drawing.Size(341, 20);
  351. this.comboBox1.TabIndex = 8;
  352. //
  353. // label5
  354. //
  355. this.label5.AutoSize = true;
  356. this.label5.Location = new System.Drawing.Point(59, 132);
  357. this.label5.Name = "label5";
  358. this.label5.Size = new System.Drawing.Size(41, 12);
  359. this.label5.TabIndex = 7;
  360. this.label5.Text = "线形:";
  361. //
  362. // label4
  363. //
  364. this.label4.AutoSize = true;
  365. this.label4.Location = new System.Drawing.Point(11, 104);
  366. this.label4.Name = "label4";
  367. this.label4.Size = new System.Drawing.Size(89, 12);
  368. this.label4.TabIndex = 6;
  369. this.label4.Text = "垂直网格数量:";
  370. //
  371. // label3
  372. //
  373. this.label3.AutoSize = true;
  374. this.label3.Location = new System.Drawing.Point(11, 76);
  375. this.label3.Name = "label3";
  376. this.label3.Size = new System.Drawing.Size(89, 12);
  377. this.label3.TabIndex = 3;
  378. this.label3.Text = "水平网格数量:";
  379. //
  380. // label1
  381. //
  382. this.label1.AutoSize = true;
  383. this.label1.Location = new System.Drawing.Point(35, 46);
  384. this.label1.Name = "label1";
  385. this.label1.Size = new System.Drawing.Size(65, 12);
  386. this.label1.TabIndex = 0;
  387. this.label1.Text = "网格边长:";
  388. //
  389. // groupBox3
  390. //
  391. this.groupBox3.Controls.Add(this.rectPanel);
  392. this.groupBox3.Controls.Add(this.label8);
  393. this.groupBox3.Controls.Add(this.label10);
  394. this.groupBox3.Controls.Add(this.label9);
  395. this.groupBox3.Controls.Add(this.comboBox4);
  396. this.groupBox3.Controls.Add(this.comboBox3);
  397. this.groupBox3.Location = new System.Drawing.Point(195, 290);
  398. this.groupBox3.Name = "groupBox3";
  399. this.groupBox3.Size = new System.Drawing.Size(508, 100);
  400. this.groupBox3.TabIndex = 3;
  401. this.groupBox3.TabStop = false;
  402. this.groupBox3.Text = "矩形设置";
  403. //
  404. // rectPanel
  405. //
  406. this.rectPanel.BackColor = System.Drawing.Color.Transparent;
  407. this.rectPanel.Location = new System.Drawing.Point(107, 73);
  408. this.rectPanel.Name = "rectPanel";
  409. this.rectPanel.Size = new System.Drawing.Size(72, 21);
  410. this.rectPanel.TabIndex = 18;
  411. this.rectPanel.Click += new System.EventHandler(this.rectColorPanel_Click);
  412. //
  413. // label8
  414. //
  415. this.label8.AutoSize = true;
  416. this.label8.Location = new System.Drawing.Point(59, 77);
  417. this.label8.Name = "label8";
  418. this.label8.Size = new System.Drawing.Size(41, 12);
  419. this.label8.TabIndex = 17;
  420. this.label8.Text = "颜色:";
  421. //
  422. // label10
  423. //
  424. this.label10.AutoSize = true;
  425. this.label10.Location = new System.Drawing.Point(59, 23);
  426. this.label10.Name = "label10";
  427. this.label10.Size = new System.Drawing.Size(41, 12);
  428. this.label10.TabIndex = 13;
  429. this.label10.Text = "线形:";
  430. //
  431. // label9
  432. //
  433. this.label9.AutoSize = true;
  434. this.label9.Location = new System.Drawing.Point(59, 50);
  435. this.label9.Name = "label9";
  436. this.label9.Size = new System.Drawing.Size(41, 12);
  437. this.label9.TabIndex = 16;
  438. this.label9.Text = "粗细:";
  439. //
  440. // comboBox4
  441. //
  442. this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  443. this.comboBox4.FormattingEnabled = true;
  444. this.comboBox4.Location = new System.Drawing.Point(107, 46);
  445. this.comboBox4.Name = "comboBox4";
  446. this.comboBox4.Size = new System.Drawing.Size(341, 20);
  447. this.comboBox4.TabIndex = 14;
  448. //
  449. // comboBox3
  450. //
  451. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  452. this.comboBox3.FormattingEnabled = true;
  453. this.comboBox3.Location = new System.Drawing.Point(107, 19);
  454. this.comboBox3.Name = "comboBox3";
  455. this.comboBox3.Size = new System.Drawing.Size(341, 20);
  456. this.comboBox3.TabIndex = 15;
  457. //
  458. // groupBox4
  459. //
  460. this.groupBox4.Controls.Add(this.circularPanel);
  461. this.groupBox4.Controls.Add(this.label11);
  462. this.groupBox4.Controls.Add(this.label12);
  463. this.groupBox4.Controls.Add(this.comboBox5);
  464. this.groupBox4.Controls.Add(this.comboBox6);
  465. this.groupBox4.Controls.Add(this.label13);
  466. this.groupBox4.Location = new System.Drawing.Point(195, 397);
  467. this.groupBox4.Name = "groupBox4";
  468. this.groupBox4.Size = new System.Drawing.Size(508, 100);
  469. this.groupBox4.TabIndex = 4;
  470. this.groupBox4.TabStop = false;
  471. this.groupBox4.Text = "圆形设置";
  472. //
  473. // circularPanel
  474. //
  475. this.circularPanel.BackColor = System.Drawing.Color.Transparent;
  476. this.circularPanel.Location = new System.Drawing.Point(105, 72);
  477. this.circularPanel.Name = "circularPanel";
  478. this.circularPanel.Size = new System.Drawing.Size(72, 21);
  479. this.circularPanel.TabIndex = 18;
  480. this.circularPanel.Click += new System.EventHandler(this.circularColorPanel_Click);
  481. //
  482. // label11
  483. //
  484. this.label11.AutoSize = true;
  485. this.label11.Location = new System.Drawing.Point(57, 76);
  486. this.label11.Name = "label11";
  487. this.label11.Size = new System.Drawing.Size(41, 12);
  488. this.label11.TabIndex = 17;
  489. this.label11.Text = "颜色:";
  490. //
  491. // label12
  492. //
  493. this.label12.AutoSize = true;
  494. this.label12.Location = new System.Drawing.Point(57, 49);
  495. this.label12.Name = "label12";
  496. this.label12.Size = new System.Drawing.Size(41, 12);
  497. this.label12.TabIndex = 16;
  498. this.label12.Text = "粗细:";
  499. //
  500. // comboBox5
  501. //
  502. this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  503. this.comboBox5.FormattingEnabled = true;
  504. this.comboBox5.Location = new System.Drawing.Point(105, 18);
  505. this.comboBox5.Name = "comboBox5";
  506. this.comboBox5.Size = new System.Drawing.Size(341, 20);
  507. this.comboBox5.TabIndex = 15;
  508. //
  509. // comboBox6
  510. //
  511. this.comboBox6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  512. this.comboBox6.FormattingEnabled = true;
  513. this.comboBox6.Location = new System.Drawing.Point(105, 44);
  514. this.comboBox6.Name = "comboBox6";
  515. this.comboBox6.Size = new System.Drawing.Size(341, 20);
  516. this.comboBox6.TabIndex = 14;
  517. //
  518. // label13
  519. //
  520. this.label13.AutoSize = true;
  521. this.label13.Location = new System.Drawing.Point(57, 22);
  522. this.label13.Name = "label13";
  523. this.label13.Size = new System.Drawing.Size(41, 12);
  524. this.label13.TabIndex = 13;
  525. this.label13.Text = "线形:";
  526. //
  527. // groupBox5
  528. //
  529. this.groupBox5.Controls.Add(this.dataGridView1);
  530. this.groupBox5.Controls.Add(this.button5);
  531. this.groupBox5.Controls.Add(this.button4);
  532. this.groupBox5.Controls.Add(this.button3);
  533. this.groupBox5.Location = new System.Drawing.Point(12, 77);
  534. this.groupBox5.Name = "groupBox5";
  535. this.groupBox5.Size = new System.Drawing.Size(175, 420);
  536. this.groupBox5.TabIndex = 5;
  537. this.groupBox5.TabStop = false;
  538. this.groupBox5.Text = "预览";
  539. //
  540. // dataGridView1
  541. //
  542. this.dataGridView1.AllowUserToAddRows = false;
  543. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  544. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
  545. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  546. this.dataGridView1.ColumnHeadersVisible = false;
  547. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  548. this.Column1});
  549. this.dataGridView1.Location = new System.Drawing.Point(7, 49);
  550. this.dataGridView1.MultiSelect = false;
  551. this.dataGridView1.Name = "dataGridView1";
  552. this.dataGridView1.RowHeadersVisible = false;
  553. this.dataGridView1.RowTemplate.Height = 23;
  554. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  555. this.dataGridView1.Size = new System.Drawing.Size(162, 364);
  556. this.dataGridView1.TabIndex = 5;
  557. this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
  558. //
  559. // Column1
  560. //
  561. this.Column1.HeaderText = "Column1";
  562. this.Column1.Name = "Column1";
  563. //
  564. // button5
  565. //
  566. this.button5.Location = new System.Drawing.Point(138, 18);
  567. this.button5.Name = "button5";
  568. this.button5.Size = new System.Drawing.Size(30, 25);
  569. this.button5.TabIndex = 3;
  570. this.button5.UseVisualStyleBackColor = true;
  571. this.button5.Click += new System.EventHandler(this.button5_Click);
  572. //
  573. // button4
  574. //
  575. this.button4.Location = new System.Drawing.Point(104, 18);
  576. this.button4.Name = "button4";
  577. this.button4.Size = new System.Drawing.Size(30, 25);
  578. this.button4.TabIndex = 2;
  579. this.button4.UseVisualStyleBackColor = true;
  580. this.button4.Click += new System.EventHandler(this.button4_Click);
  581. //
  582. // button3
  583. //
  584. this.button3.Location = new System.Drawing.Point(70, 18);
  585. this.button3.Name = "button3";
  586. this.button3.Size = new System.Drawing.Size(30, 25);
  587. this.button3.TabIndex = 1;
  588. this.button3.UseVisualStyleBackColor = true;
  589. this.button3.Click += new System.EventHandler(this.button3_Click);
  590. //
  591. // GridSettingDialog
  592. //
  593. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  594. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  595. this.ClientSize = new System.Drawing.Size(712, 512);
  596. this.Controls.Add(this.groupBox5);
  597. this.Controls.Add(this.groupBox4);
  598. this.Controls.Add(this.groupBox3);
  599. this.Controls.Add(this.groupBox2);
  600. this.Controls.Add(this.groupBox1);
  601. this.MaximizeBox = false;
  602. this.MinimizeBox = false;
  603. this.Name = "GridSettingDialog";
  604. this.Text = "网格设置";
  605. this.Controls.SetChildIndex(this.groupBox1, 0);
  606. this.Controls.SetChildIndex(this.groupBox2, 0);
  607. this.Controls.SetChildIndex(this.groupBox3, 0);
  608. this.Controls.SetChildIndex(this.groupBox4, 0);
  609. this.Controls.SetChildIndex(this.groupBox5, 0);
  610. this.groupBox1.ResumeLayout(false);
  611. this.groupBox2.ResumeLayout(false);
  612. this.groupBox2.PerformLayout();
  613. this.groupBox3.ResumeLayout(false);
  614. this.groupBox3.PerformLayout();
  615. this.groupBox4.ResumeLayout(false);
  616. this.groupBox4.PerformLayout();
  617. this.groupBox5.ResumeLayout(false);
  618. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  619. this.ResumeLayout(false);
  620. }
  621. #endregion
  622. #region InitializeComponent2
  623. /// <summary>
  624. /// 初始化组件
  625. /// </summary>
  626. private void InitializeComponent2()
  627. {
  628. //this.textBox1.Text = gridModel.gridName;
  629. this.userTextBox1.Text = gridModel.grid.ActualLength.ToString();
  630. this.userTextBox2.Text = gridModel.grid.HorizontalNum.ToString();
  631. this.userTextBox3.Text = gridModel.grid.VerticalNum.ToString();
  632. this.comboBox1.SelectedIndex = gridModel.grid.DashStyle;
  633. this.comboBox2.SelectedIndex = gridModel.grid.Thickness - 1;
  634. this.gridPanel.BackColor = Color.FromArgb(gridModel.grid.Color);
  635. this.comboBox3.SelectedIndex = gridModel.rectangle.DashStyle;
  636. this.comboBox4.SelectedIndex = gridModel.rectangle.Thickness - 1;
  637. this.rectPanel.BackColor = Color.FromArgb(gridModel.rectangle.Color);
  638. this.comboBox5.SelectedIndex = gridModel.round.DashStyle;
  639. this.comboBox6.SelectedIndex = gridModel.round.Thickness - 1;
  640. this.circularPanel.BackColor = Color.FromArgb(gridModel.round.Color);
  641. this.colorsFormGrid = new ColorsForm();
  642. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  643. this.colorsFormGrid.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  644. this.colorsFormRect = new ColorsForm();
  645. this.colorsFormRect.StartPosition = FormStartPosition.CenterScreen;
  646. this.colorsFormRect.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  647. this.colorsFormCircular = new ColorsForm();
  648. this.colorsFormCircular.StartPosition = FormStartPosition.CenterScreen;
  649. this.colorsFormCircular.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  650. //this.groupBox2.Enabled = false;
  651. //this.groupBox3.Enabled = false;
  652. //this.groupBox4.Enabled = false;
  653. }
  654. #endregion
  655. /// <summary>
  656. /// 给下拉集合赋值
  657. /// </summary>
  658. private void InitParameterData()
  659. {
  660. this.comboBox1.Items.AddRange(InvariantData.dashStyles);
  661. this.comboBox2.Items.AddRange(InvariantData.thinkness);
  662. this.comboBox3.Items.AddRange(InvariantData.dashStyles);
  663. this.comboBox4.Items.AddRange(InvariantData.thinkness);
  664. this.comboBox5.Items.AddRange(InvariantData.dashStyles);
  665. this.comboBox6.Items.AddRange(InvariantData.thinkness);
  666. }
  667. private void InitializeButtonBackgroudImage()
  668. {
  669. this.button3.FlatStyle = FlatStyle.Flat;
  670. this.button3.FlatAppearance.BorderSize = 0;
  671. this.button3.BackgroundImageLayout = ImageLayout.Center;
  672. this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
  673. this.button4.FlatStyle = FlatStyle.Flat;
  674. this.button4.FlatAppearance.BorderSize = 0;
  675. this.button4.BackgroundImageLayout = ImageLayout.Center;
  676. this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
  677. this.button5.FlatStyle = FlatStyle.Flat;
  678. this.button5.FlatAppearance.BorderSize = 0;
  679. this.button5.BackgroundImageLayout = ImageLayout.Center;
  680. this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
  681. }
  682. /// <summary>
  683. /// 网格样式列表初始化
  684. /// </summary>
  685. private void InitializationDataGridView()
  686. {
  687. this.dataGridView1.Rows.Clear();
  688. //keyValuePairs.Clear();
  689. int serveNameID = 0;
  690. this.dataGridView1.ReadOnly = true;
  691. List<string> fileNames = FileOperationHelper.GetFileList(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\");
  692. if (fileNames.Count > 0)
  693. {
  694. for (int i = 0; i < fileNames.Count; i++)
  695. {
  696. GridModel gselectRidModel = XmlSerializeHelper.DESerializer<GridModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + fileNames[i], FileMode.Open));
  697. DataGridViewRow row = new DataGridViewRow();
  698. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  699. {
  700. row.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  701. }
  702. row.Cells[0].Value = gselectRidModel.gridName;
  703. if (gselectRidModel.gridName.Equals(Startup.instance.configModel.GridName))
  704. {
  705. serveNameID = i;
  706. }
  707. this.dataGridView1.Rows.Add(row);
  708. }
  709. if (operation != 2)
  710. {
  711. this.dataGridView1.CurrentCell = this.dataGridView1[0, serveNameID];
  712. }
  713. else
  714. {
  715. this.dataGridView1.CurrentCell = this.dataGridView1[0, 0];
  716. }
  717. RefreshDataGridView();
  718. }
  719. }
  720. /// <summary>
  721. /// 单位设置初始化
  722. /// </summary>
  723. private void UnitData()
  724. {
  725. //
  726. //获取系统标尺-微米
  727. //
  728. this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  729. if (gridModel.grid.Unit == 6)
  730. {
  731. comboBox7.Text = "px";
  732. }
  733. else if (gridModel.grid.Unit == 4)
  734. {
  735. comboBox7.Text = "μm";
  736. }
  737. }
  738. private void button1_Click(object sender, EventArgs e)
  739. {
  740. if (this.userTextBox1.Text.Equals(""))
  741. {
  742. MessageBox.Show(PdnResources.GetString("Menu.eedgelengthofthegridcannotbeemptw.Text"));
  743. return;
  744. }
  745. if (this.userTextBox2.Text.Equals(""))
  746. {
  747. MessageBox.Show(PdnResources.GetString("Menu.henumberofhorizontalgridscanno.Text"));
  748. return;
  749. }
  750. if (this.userTextBox3.Text.Equals(""))
  751. {
  752. MessageBox.Show(PdnResources.GetString("Menu.henumberofverticalgridscannotbenu.Text"));
  753. return;
  754. }
  755. //临时model,根据应用场景运用
  756. GridModel temporarygridModel = new GridModel();
  757. temporarygridModel.grid = new GridModel.Grid();
  758. temporarygridModel.rectangle = new GridModel.Rectangle();
  759. temporarygridModel.round = new GridModel.Round();
  760. temporarygridModel.gridName = this.textBox1.Text;
  761. if ("px".Equals(comboBox7.Text))
  762. {
  763. temporarygridModel.grid.SideLength = int.Parse(this.userTextBox1.Text);
  764. }
  765. else if ("μm".Equals(comboBox7.Text))
  766. {
  767. temporarygridModel.grid.SideLength = int.Parse((double.Parse(this.userTextBox1.Text) / unitLength).ToString("F0"));
  768. }
  769. temporarygridModel.grid.HorizontalNum = int.Parse(this.userTextBox2.Text);
  770. temporarygridModel.grid.VerticalNum = int.Parse(this.userTextBox3.Text);
  771. temporarygridModel.grid.DashStyle = this.comboBox1.SelectedIndex;
  772. temporarygridModel.grid.Thickness = this.comboBox2.SelectedIndex + 1;
  773. temporarygridModel.grid.Color = this.gridPanel.BackColor.ToArgb();
  774. if ("px".Equals(comboBox7.Text))
  775. {
  776. temporarygridModel.grid.Unit = (int)MeasurementUnit.Pixel;
  777. }
  778. else if ("μm".Equals(comboBox7.Text))
  779. {
  780. temporarygridModel.grid.Unit = (int)MeasurementUnit.Micron;
  781. }
  782. temporarygridModel.rectangle.DashStyle = this.comboBox3.SelectedIndex;
  783. temporarygridModel.rectangle.Thickness = this.comboBox4.SelectedIndex + 1;
  784. temporarygridModel.rectangle.Color = this.rectPanel.BackColor.ToArgb();
  785. temporarygridModel.round.DashStyle = this.comboBox5.SelectedIndex;
  786. temporarygridModel.round.Thickness = this.comboBox6.SelectedIndex + 1;
  787. temporarygridModel.round.Color = this.circularPanel.BackColor.ToArgb();
  788. temporarygridModel.grid.ActualLength = int.Parse(this.userTextBox1.Text);
  789. //if (operation == 0)
  790. //{
  791. // gridModel.xmlName = "Grid" + (maxValue + 1).ToString();
  792. //}
  793. //if (operation == 1)
  794. //{
  795. // gridModel.xmlName = keyValuePairs[this.dataGridView1.CurrentCell.Value.ToString()];
  796. //}
  797. string userInfoXml = XmlSerializeHelper.XmlSerialize<GridModel>(temporarygridModel);
  798. //选中标尺保存到默认标尺(网格样式列表为空时用)
  799. if (operation == -1)
  800. {
  801. Startup.instance.gridModel = temporarygridModel;
  802. Startup.instance.configModel.GridName = this.textBox1.Text;
  803. string configXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(Startup.instance.configModel);
  804. string configPath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  805. FileOperationHelper.WriteStringToFile(configXml, configPath, FileMode.Create);
  806. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Grid.xml";
  807. if (!FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create))
  808. {
  809. MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text"));
  810. }
  811. if (appWorkspace.ActiveDocumentWorkspace != null)
  812. {
  813. appWorkspace.ActiveDocumentWorkspace.Refresh();
  814. }
  815. }
  816. //添加
  817. if (operation == 0)
  818. {
  819. //保存到xml
  820. string gridFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.textBox1.Text + ".xml";
  821. if (System.IO.File.Exists(gridFilePath))
  822. {
  823. MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text"));
  824. return;
  825. }
  826. else
  827. {
  828. if (!FileOperationHelper.WriteStringToFile(userInfoXml, gridFilePath, FileMode.Create))
  829. {
  830. MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text"));
  831. }
  832. InitializationDataGridView();
  833. }
  834. this.button1.Text = PdnResources.GetString("Menu.application.text");
  835. }
  836. //修改
  837. if (operation == 1)
  838. {
  839. string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value + ".xml";
  840. System.IO.File.Delete(updateName);
  841. //FileOperationHelper.DeleteFolder(updateName);
  842. //保存到xml
  843. string gridFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.textBox1.Text + ".xml";
  844. if (System.IO.File.Exists(gridFilePath))
  845. {
  846. MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text"));
  847. return;
  848. }
  849. if (!FileOperationHelper.WriteStringToFile(userInfoXml, gridFilePath, FileMode.Create))
  850. {
  851. MessageBox.Show(PdnResources.GetString("Menu.idinformationsavin.Text"));
  852. }
  853. InitializationDataGridView();
  854. //this.dataGridView1.CurrentCell.Value = this.textBox1.Text;
  855. this.groupBox2.Enabled = false;
  856. this.groupBox3.Enabled = false;
  857. this.groupBox4.Enabled = false;
  858. this.button1.Text = PdnResources.GetString("Menu.application.text");
  859. }
  860. operation = -1;
  861. }
  862. /// <summary>
  863. /// 调色板回调函数
  864. /// </summary>
  865. /// <param name="sender"></param>
  866. /// <param name="ce"></param>
  867. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  868. {
  869. }
  870. /// <summary>
  871. /// 网格Panel被点击
  872. /// </summary>
  873. /// <param name="sender"></param>
  874. /// <param name="e"></param>
  875. private void gridColorPanel_Click(object sender, EventArgs e)
  876. {
  877. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.gridPanel.BackColor);
  878. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  879. this.colorsFormGrid.ShowDialog();
  880. }
  881. /// <summary>
  882. /// 网格Panel的调色板颜色改变
  883. /// </summary>
  884. /// <param name="sender"></param>
  885. /// <param name="e"></param>
  886. private void gridColorChanged(object sender, EventArgs e)
  887. {
  888. this.gridPanel.BackColor = this.colorsFormGrid.UserPrimaryColor.ToColor();
  889. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  890. this.colorsFormGrid.Close();
  891. }
  892. /// <summary>
  893. /// 矩形Panel被点击
  894. /// </summary>
  895. /// <param name="sender"></param>
  896. /// <param name="e"></param>
  897. private void rectColorPanel_Click(object sender, EventArgs e)
  898. {
  899. this.colorsFormRect.UserPrimaryColor = ColorBgra.FromColor(this.rectPanel.BackColor);
  900. this.colorsFormRect.setSaveBtn_Click(new System.EventHandler(this.rectColorChanged));
  901. this.colorsFormRect.ShowDialog();
  902. }
  903. /// <summary>
  904. /// 矩形Panel的调色板颜色改变
  905. /// </summary>
  906. /// <param name="sender"></param>
  907. /// <param name="e"></param>
  908. private void rectColorChanged(object sender, EventArgs e)
  909. {
  910. this.rectPanel.BackColor = this.colorsFormRect.UserPrimaryColor.ToColor();
  911. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  912. this.colorsFormRect.Close();
  913. }
  914. /// <summary>
  915. /// 圆形Panel被点击
  916. /// </summary>
  917. /// <param name="sender"></param>
  918. /// <param name="e"></param>
  919. private void circularColorPanel_Click(object sender, EventArgs e)
  920. {
  921. this.colorsFormCircular.UserPrimaryColor = ColorBgra.FromColor(this.circularPanel.BackColor);
  922. this.colorsFormCircular.setSaveBtn_Click(new System.EventHandler(this.circularColorChanged));
  923. this.colorsFormCircular.ShowDialog();
  924. }
  925. /// <summary>
  926. /// 圆形Panel的调色板颜色改变
  927. /// </summary>
  928. /// <param name="sender"></param>
  929. /// <param name="e"></param>
  930. private void circularColorChanged(object sender, EventArgs e)
  931. {
  932. this.circularPanel.BackColor = this.colorsFormCircular.UserPrimaryColor.ToColor();
  933. // this.measureStyleModel.backColor = this.colorsForm.UserPrimaryColor.ToColor().ToArgb();
  934. this.colorsFormCircular.Close();
  935. }
  936. private string serveName = string.Empty;
  937. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  938. {
  939. RefreshDataGridView();
  940. }
  941. /// <summary>
  942. /// 刷新网格样式列表
  943. /// </summary>
  944. private void RefreshDataGridView()
  945. {
  946. if (this.dataGridView1.SelectedRows.Count > 0 && this.dataGridView1.CurrentCell != null)
  947. {
  948. serveName = this.dataGridView1.CurrentCell.Value.ToString();
  949. //string selectName = this.dataGridView1.CurrentCell.Value.ToString() + ".xml";
  950. GridModel gselectRidModel = XmlSerializeHelper.DESerializer<GridModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + serveName + ".xml", FileMode.Open));
  951. this.textBox1.Text = serveName;
  952. //网格
  953. this.userTextBox1.Text = gselectRidModel.grid.ActualLength.ToString();
  954. this.userTextBox2.Text = gselectRidModel.grid.HorizontalNum.ToString();
  955. this.userTextBox3.Text = gselectRidModel.grid.VerticalNum.ToString();
  956. this.comboBox1.SelectedIndex = gselectRidModel.grid.DashStyle;
  957. this.comboBox1.Text = gselectRidModel.grid.Thickness.ToString();
  958. this.gridPanel.BackColor = Color.FromArgb(gselectRidModel.grid.Color);
  959. //矩形
  960. this.comboBox3.SelectedIndex = gselectRidModel.rectangle.DashStyle;
  961. this.comboBox4.Text = gselectRidModel.rectangle.Thickness.ToString();
  962. this.rectPanel.BackColor = Color.FromArgb(gselectRidModel.rectangle.Color);
  963. //圆形
  964. this.comboBox5.SelectedIndex = gselectRidModel.round.DashStyle;
  965. this.comboBox6.Text = gselectRidModel.round.Thickness.ToString();
  966. this.circularPanel.BackColor = Color.FromArgb(gselectRidModel.round.Color);
  967. if (gselectRidModel.grid.Unit == 6)
  968. {
  969. comboBox7.Text = "px";
  970. }
  971. else if (gselectRidModel.grid.Unit == 4)
  972. {
  973. comboBox7.Text = "μm";
  974. }
  975. this.groupBox2.Enabled = false;
  976. this.groupBox3.Enabled = false;
  977. this.groupBox4.Enabled = false;
  978. }
  979. }
  980. //添加网格样式
  981. private void button3_Click(object sender, EventArgs e)
  982. {
  983. this.button1.Text = PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText");
  984. this.textBox1.Text = "Grid";
  985. this.textBox1.Focus();
  986. //this.userTextBox2.Focus();
  987. //this.userTextBox3.Focus();
  988. this.dataGridView1.ClearSelection();
  989. operation = 0;
  990. this.groupBox2.Enabled = true;
  991. this.groupBox3.Enabled = true;
  992. this.groupBox4.Enabled = true;
  993. }
  994. //修改网格样式
  995. private void button4_Click(object sender, EventArgs e)
  996. {
  997. if (this.dataGridView1.Rows.Count > 0)
  998. {
  999. this.button1.Text = PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText");
  1000. this.textBox1.Focus();
  1001. operation = 1;
  1002. this.groupBox2.Enabled = true;
  1003. this.groupBox3.Enabled = true;
  1004. this.groupBox4.Enabled = true;
  1005. }
  1006. }
  1007. //删除网格样式
  1008. private void button5_Click(object sender, EventArgs e)
  1009. {
  1010. if (this.dataGridView1.Rows.Count > 1)
  1011. {
  1012. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text") + "?", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1013. if (dr == DialogResult.OK)
  1014. {
  1015. operation = 2;
  1016. string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value.ToString() + ".xml";
  1017. System.IO.File.Delete(updateName);
  1018. InitializationDataGridView();
  1019. operation = -1;
  1020. }
  1021. }
  1022. }
  1023. /// <summary>
  1024. /// 删除网格样式
  1025. /// </summary>
  1026. /// <param name="sender"></param>
  1027. /// <param name="e"></param>
  1028. private void btnDel_Click(object sender, EventArgs e)
  1029. {
  1030. if (this.dataGridView1.Rows.Count > 1)
  1031. {
  1032. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text") + "?", PdnResources.GetString("Menu.ensure.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1033. if (dr == DialogResult.OK)
  1034. {
  1035. operation = 2;
  1036. string updateName = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GridConfig\\" + this.dataGridView1.CurrentCell.Value.ToString() + ".xml";
  1037. System.IO.File.Delete(updateName);
  1038. InitializationDataGridView();
  1039. operation = -1;
  1040. }
  1041. }
  1042. }
  1043. /// <summary>
  1044. /// 保存
  1045. /// </summary>
  1046. /// <param name="sender"></param>
  1047. /// <param name="e"></param>
  1048. private void btnSave_Click(object sender, EventArgs e)
  1049. {
  1050. }
  1051. /// <summary>
  1052. /// 另存为、新增
  1053. /// </summary>
  1054. /// <param name="sender"></param>
  1055. /// <param name="e"></param>
  1056. private void btnSaveAs_Click(object sender, EventArgs e)
  1057. {
  1058. }
  1059. }
  1060. }