GridSettingDialog.cs 50 KB

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