ProjectEngineering.cs 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765
  1. using Microsoft.WindowsAPICodePack.Shell;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.Base.SettingModel;
  5. using PaintDotNet.CustomControl;
  6. using PaintDotNet.DbOpreate.DbBll;
  7. using PaintDotNet.DbOpreate.DbModel;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Drawing;
  12. using System.Drawing.Imaging;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Windows.Forms;
  16. using static PaintDotNet.Base.Functionodel.AnalyzeSettingModel;
  17. namespace PaintDotNet.Instrument
  18. {
  19. /// <summary>
  20. /// 项目工程
  21. /// </summary>
  22. internal class ProjectEngineering : FloatingToolForm
  23. {
  24. #region 控件
  25. private Panel panel3;
  26. private ToolTip toolTip1;
  27. private IContainer components;
  28. private Button button8;
  29. private Button button7;
  30. private Button button6;
  31. private Button button5;
  32. private Button button4;
  33. private Button button3;
  34. private Button button2;
  35. private Button button1;
  36. private TreeView treeView1;
  37. private ListView listView1;
  38. private GroupBox groupBox1;
  39. private GroupBox groupBox2;
  40. private GroupBox groupBox3;
  41. private Label label1;
  42. private Label label2;
  43. private Label label3;
  44. private Label label4;
  45. private Label label5;
  46. private Label label6;
  47. private Label label8;
  48. private Label label7;
  49. private Label label12;
  50. private Label label11;
  51. private Label label10;
  52. private Label label9;
  53. private DataGridView dataGridView1;
  54. private ImageList imageList1;
  55. private void InitializeLanguageText()
  56. {
  57. this.groupBox1.Text = PdnResources.GetString("Menu.thebasicinformationofproject.text");
  58. this.label2.Text = PdnResources.GetString("Menu.Ratingdate.text") + ":";
  59. this.label1.Text = PdnResources.GetString("Menu.projectnumber.text") + ":";
  60. this.groupBox2.Text = PdnResources.GetString("Menu.Inspectioninformation.text");
  61. this.label6.Text = PdnResources.GetString("Menu.Inspectiondate.text") + ":";
  62. this.label5.Text = PdnResources.GetString("Menu.inspectiondepartment.text") + ":";
  63. this.label4.Text = PdnResources.GetString("Menu.Contactperson.text") + ":";
  64. this.label3.Text = PdnResources.GetString("Menu.Sender.text") + ":";
  65. this.groupBox3.Text = PdnResources.GetString("Menu.other.text");
  66. this.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
  67. }
  68. private void InitializeComponent()
  69. {
  70. this.components = new System.ComponentModel.Container();
  71. this.panel3 = new System.Windows.Forms.Panel();
  72. this.button8 = new System.Windows.Forms.Button();
  73. this.button7 = new System.Windows.Forms.Button();
  74. this.button6 = new System.Windows.Forms.Button();
  75. this.button5 = new System.Windows.Forms.Button();
  76. this.button4 = new System.Windows.Forms.Button();
  77. this.button3 = new System.Windows.Forms.Button();
  78. this.button2 = new System.Windows.Forms.Button();
  79. this.button1 = new System.Windows.Forms.Button();
  80. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  81. this.treeView1 = new System.Windows.Forms.TreeView();
  82. this.listView1 = new System.Windows.Forms.ListView();
  83. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  84. this.groupBox1 = new System.Windows.Forms.GroupBox();
  85. this.label8 = new System.Windows.Forms.Label();
  86. this.label7 = new System.Windows.Forms.Label();
  87. this.label2 = new System.Windows.Forms.Label();
  88. this.label1 = new System.Windows.Forms.Label();
  89. this.groupBox2 = new System.Windows.Forms.GroupBox();
  90. this.label12 = new System.Windows.Forms.Label();
  91. this.label11 = new System.Windows.Forms.Label();
  92. this.label10 = new System.Windows.Forms.Label();
  93. this.label9 = new System.Windows.Forms.Label();
  94. this.label6 = new System.Windows.Forms.Label();
  95. this.label5 = new System.Windows.Forms.Label();
  96. this.label4 = new System.Windows.Forms.Label();
  97. this.label3 = new System.Windows.Forms.Label();
  98. this.groupBox3 = new System.Windows.Forms.GroupBox();
  99. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  100. this.panel3.SuspendLayout();
  101. this.groupBox1.SuspendLayout();
  102. this.groupBox2.SuspendLayout();
  103. this.groupBox3.SuspendLayout();
  104. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  105. this.SuspendLayout();
  106. //
  107. // panel3
  108. //
  109. this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  110. this.panel3.Controls.Add(this.button8);
  111. this.panel3.Controls.Add(this.button7);
  112. this.panel3.Controls.Add(this.button6);
  113. this.panel3.Controls.Add(this.button5);
  114. this.panel3.Controls.Add(this.button4);
  115. this.panel3.Controls.Add(this.button3);
  116. this.panel3.Controls.Add(this.button2);
  117. this.panel3.Controls.Add(this.button1);
  118. this.panel3.Location = new System.Drawing.Point(13, 12);
  119. this.panel3.Name = "panel3";
  120. this.panel3.Size = new System.Drawing.Size(255, 37);
  121. this.panel3.TabIndex = 0;
  122. //
  123. // button8
  124. //
  125. this.button8.Location = new System.Drawing.Point(222, 5);
  126. this.button8.Name = "button8";
  127. this.button8.Size = new System.Drawing.Size(25, 25);
  128. this.button8.TabIndex = 13;
  129. this.button8.UseVisualStyleBackColor = true;
  130. this.button8.Click += new System.EventHandler(this.button8_click);
  131. //
  132. // button7
  133. //
  134. this.button7.Location = new System.Drawing.Point(191, 5);
  135. this.button7.Name = "button7";
  136. this.button7.Size = new System.Drawing.Size(25, 25);
  137. this.button7.TabIndex = 14;
  138. this.button7.UseVisualStyleBackColor = true;
  139. this.button7.Click += new System.EventHandler(this.button7_click);
  140. //
  141. // button6
  142. //
  143. this.button6.Location = new System.Drawing.Point(160, 5);
  144. this.button6.Name = "button6";
  145. this.button6.Size = new System.Drawing.Size(25, 25);
  146. this.button6.TabIndex = 15;
  147. this.button6.UseVisualStyleBackColor = true;
  148. this.button6.Click += new System.EventHandler(this.button6_click);
  149. //
  150. // button5
  151. //
  152. this.button5.Location = new System.Drawing.Point(129, 5);
  153. this.button5.Name = "button5";
  154. this.button5.Size = new System.Drawing.Size(25, 25);
  155. this.button5.TabIndex = 16;
  156. this.button5.UseVisualStyleBackColor = true;
  157. this.button5.Click += new System.EventHandler(this.button5_click);
  158. //
  159. // button4
  160. //
  161. this.button4.Location = new System.Drawing.Point(98, 5);
  162. this.button4.Name = "button4";
  163. this.button4.Size = new System.Drawing.Size(25, 25);
  164. this.button4.TabIndex = 18;
  165. this.button4.UseVisualStyleBackColor = true;
  166. this.button4.Click += new System.EventHandler(this.button4_click);
  167. //
  168. // button3
  169. //
  170. this.button3.Location = new System.Drawing.Point(67, 5);
  171. this.button3.Name = "button3";
  172. this.button3.Size = new System.Drawing.Size(25, 25);
  173. this.button3.TabIndex = 20;
  174. this.button3.UseVisualStyleBackColor = true;
  175. this.button3.Click += new System.EventHandler(this.button3_click);
  176. //
  177. // button2
  178. //
  179. this.button2.Location = new System.Drawing.Point(36, 5);
  180. this.button2.Name = "button2";
  181. this.button2.Size = new System.Drawing.Size(25, 25);
  182. this.button2.TabIndex = 19;
  183. this.button2.UseVisualStyleBackColor = true;
  184. this.button2.Click += new System.EventHandler(this.button2_click);
  185. //
  186. // button1
  187. //
  188. this.button1.Location = new System.Drawing.Point(5, 5);
  189. this.button1.Name = "button1";
  190. this.button1.Size = new System.Drawing.Size(25, 25);
  191. this.button1.TabIndex = 12;
  192. this.button1.UseVisualStyleBackColor = true;
  193. this.button1.Click += new System.EventHandler(this.button1_click);
  194. //
  195. // treeView1
  196. //
  197. this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  198. | System.Windows.Forms.AnchorStyles.Left)));
  199. this.treeView1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
  200. this.treeView1.HideSelection = false;
  201. this.treeView1.Location = new System.Drawing.Point(12, 55);
  202. this.treeView1.Name = "treeView1";
  203. this.treeView1.Size = new System.Drawing.Size(256, 445);
  204. this.treeView1.TabIndex = 3;
  205. this.treeView1.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeExpand);
  206. this.treeView1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView1_DrawNode);
  207. this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
  208. //
  209. // listView1
  210. //
  211. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  212. | System.Windows.Forms.AnchorStyles.Left)
  213. | System.Windows.Forms.AnchorStyles.Right)));
  214. this.listView1.HideSelection = false;
  215. this.listView1.LargeImageList = this.imageList1;
  216. this.listView1.Location = new System.Drawing.Point(283, 12);
  217. this.listView1.Name = "listView1";
  218. this.listView1.Size = new System.Drawing.Size(856, 371);
  219. this.listView1.TabIndex = 4;
  220. this.listView1.UseCompatibleStateImageBehavior = false;
  221. this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
  222. //
  223. // imageList1
  224. //
  225. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  226. this.imageList1.ImageSize = new System.Drawing.Size(48, 48);
  227. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  228. //
  229. // groupBox1
  230. //
  231. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  232. this.groupBox1.BackColor = System.Drawing.Color.White;
  233. this.groupBox1.Controls.Add(this.label8);
  234. this.groupBox1.Controls.Add(this.label7);
  235. this.groupBox1.Controls.Add(this.label2);
  236. this.groupBox1.Controls.Add(this.label1);
  237. this.groupBox1.Location = new System.Drawing.Point(283, 389);
  238. this.groupBox1.Name = "groupBox1";
  239. this.groupBox1.Size = new System.Drawing.Size(228, 111);
  240. this.groupBox1.TabIndex = 5;
  241. this.groupBox1.TabStop = false;
  242. this.groupBox1.Text = "项目基本信息";
  243. //
  244. // label8
  245. //
  246. this.label8.AutoSize = true;
  247. this.label8.Location = new System.Drawing.Point(81, 70);
  248. this.label8.Name = "label8";
  249. this.label8.Size = new System.Drawing.Size(41, 12);
  250. this.label8.TabIndex = 3;
  251. this.label8.Text = "label8";
  252. //
  253. // label7
  254. //
  255. this.label7.AutoSize = true;
  256. this.label7.Location = new System.Drawing.Point(79, 38);
  257. this.label7.Name = "label7";
  258. this.label7.Size = new System.Drawing.Size(41, 12);
  259. this.label7.TabIndex = 2;
  260. this.label7.Text = "label7";
  261. //
  262. // label2
  263. //
  264. this.label2.AutoSize = true;
  265. this.label2.Location = new System.Drawing.Point(7, 70);
  266. this.label2.Name = "label2";
  267. this.label2.Size = new System.Drawing.Size(65, 12);
  268. this.label2.TabIndex = 1;
  269. this.label2.Text = "评级日期:";
  270. //
  271. // label1
  272. //
  273. this.label1.AutoSize = true;
  274. this.label1.Location = new System.Drawing.Point(7, 38);
  275. this.label1.Name = "label1";
  276. this.label1.Size = new System.Drawing.Size(65, 12);
  277. this.label1.TabIndex = 0;
  278. this.label1.Text = "项目编号:";
  279. //
  280. // groupBox2
  281. //
  282. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  283. this.groupBox2.BackColor = System.Drawing.Color.White;
  284. this.groupBox2.Controls.Add(this.label12);
  285. this.groupBox2.Controls.Add(this.label11);
  286. this.groupBox2.Controls.Add(this.label10);
  287. this.groupBox2.Controls.Add(this.label9);
  288. this.groupBox2.Controls.Add(this.label6);
  289. this.groupBox2.Controls.Add(this.label5);
  290. this.groupBox2.Controls.Add(this.label4);
  291. this.groupBox2.Controls.Add(this.label3);
  292. this.groupBox2.Location = new System.Drawing.Point(517, 389);
  293. this.groupBox2.Name = "groupBox2";
  294. this.groupBox2.Size = new System.Drawing.Size(373, 111);
  295. this.groupBox2.TabIndex = 6;
  296. this.groupBox2.TabStop = false;
  297. this.groupBox2.Text = "送检信息";
  298. //
  299. // label12
  300. //
  301. this.label12.AutoSize = true;
  302. this.label12.Location = new System.Drawing.Point(251, 69);
  303. this.label12.Name = "label12";
  304. this.label12.Size = new System.Drawing.Size(47, 12);
  305. this.label12.TabIndex = 7;
  306. this.label12.Text = "label12";
  307. //
  308. // label11
  309. //
  310. this.label11.AutoEllipsis = true;
  311. this.label11.Location = new System.Drawing.Point(250, 37);
  312. this.label11.Name = "label11";
  313. this.label11.Size = new System.Drawing.Size(113, 12);
  314. this.label11.TabIndex = 6;
  315. this.label11.Text = "label11";
  316. //
  317. // label10
  318. //
  319. this.label10.AutoEllipsis = true;
  320. this.label10.Location = new System.Drawing.Point(69, 69);
  321. this.label10.Name = "label10";
  322. this.label10.Size = new System.Drawing.Size(117, 12);
  323. this.label10.TabIndex = 5;
  324. this.label10.Text = "label10";
  325. //
  326. // label9
  327. //
  328. this.label9.AutoEllipsis = true;
  329. this.label9.Location = new System.Drawing.Point(67, 37);
  330. this.label9.Name = "label9";
  331. this.label9.Size = new System.Drawing.Size(117, 12);
  332. this.label9.TabIndex = 4;
  333. this.label9.Text = "label9";
  334. //
  335. // label6
  336. //
  337. this.label6.AutoSize = true;
  338. this.label6.Location = new System.Drawing.Point(192, 69);
  339. this.label6.Name = "label6";
  340. this.label6.Size = new System.Drawing.Size(65, 12);
  341. this.label6.TabIndex = 3;
  342. this.label6.Text = "送检日期:";
  343. //
  344. // label5
  345. //
  346. this.label5.AutoSize = true;
  347. this.label5.Location = new System.Drawing.Point(7, 69);
  348. this.label5.Name = "label5";
  349. this.label5.Size = new System.Drawing.Size(65, 12);
  350. this.label5.TabIndex = 2;
  351. this.label5.Text = "送检单位:";
  352. //
  353. // label4
  354. //
  355. this.label4.AutoSize = true;
  356. this.label4.Location = new System.Drawing.Point(190, 37);
  357. this.label4.Name = "label4";
  358. this.label4.Size = new System.Drawing.Size(53, 12);
  359. this.label4.TabIndex = 1;
  360. this.label4.Text = "联系人:";
  361. //
  362. // label3
  363. //
  364. this.label3.AutoSize = true;
  365. this.label3.Location = new System.Drawing.Point(7, 37);
  366. this.label3.Name = "label3";
  367. this.label3.Size = new System.Drawing.Size(53, 12);
  368. this.label3.TabIndex = 0;
  369. this.label3.Text = "送检人:";
  370. //
  371. // groupBox3
  372. //
  373. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  374. | System.Windows.Forms.AnchorStyles.Right)));
  375. this.groupBox3.BackColor = System.Drawing.Color.White;
  376. this.groupBox3.Controls.Add(this.dataGridView1);
  377. this.groupBox3.Location = new System.Drawing.Point(896, 389);
  378. this.groupBox3.Name = "groupBox3";
  379. this.groupBox3.Size = new System.Drawing.Size(243, 111);
  380. this.groupBox3.TabIndex = 7;
  381. this.groupBox3.TabStop = false;
  382. this.groupBox3.Text = "其它";
  383. //
  384. // dataGridView1
  385. //
  386. this.dataGridView1.AllowUserToAddRows = false;
  387. this.dataGridView1.AllowUserToDeleteRows = false;
  388. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  389. | System.Windows.Forms.AnchorStyles.Left)
  390. | System.Windows.Forms.AnchorStyles.Right)));
  391. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  392. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  393. this.dataGridView1.GridColor = System.Drawing.SystemColors.Control;
  394. this.dataGridView1.Location = new System.Drawing.Point(6, 14);
  395. this.dataGridView1.MultiSelect = false;
  396. this.dataGridView1.Name = "dataGridView1";
  397. this.dataGridView1.ReadOnly = true;
  398. this.dataGridView1.RowHeadersVisible = false;
  399. this.dataGridView1.RowTemplate.Height = 23;
  400. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  401. this.dataGridView1.Size = new System.Drawing.Size(231, 91);
  402. this.dataGridView1.TabIndex = 0;
  403. //
  404. // ProjectEngineering
  405. //
  406. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  407. this.ClientSize = new System.Drawing.Size(1151, 512);
  408. this.Controls.Add(this.groupBox3);
  409. this.Controls.Add(this.groupBox2);
  410. this.Controls.Add(this.groupBox1);
  411. this.Controls.Add(this.listView1);
  412. this.Controls.Add(this.treeView1);
  413. this.Controls.Add(this.panel3);
  414. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
  415. this.MinimumSize = new System.Drawing.Size(295, 39);
  416. this.Name = "ProjectEngineering";
  417. this.Text = "项目工程";
  418. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProjectEngineering_FormClosing);
  419. this.Controls.SetChildIndex(this.panel3, 0);
  420. this.Controls.SetChildIndex(this.treeView1, 0);
  421. this.Controls.SetChildIndex(this.listView1, 0);
  422. this.Controls.SetChildIndex(this.groupBox1, 0);
  423. this.Controls.SetChildIndex(this.groupBox2, 0);
  424. this.Controls.SetChildIndex(this.groupBox3, 0);
  425. this.panel3.ResumeLayout(false);
  426. this.groupBox1.ResumeLayout(false);
  427. this.groupBox1.PerformLayout();
  428. this.groupBox2.ResumeLayout(false);
  429. this.groupBox2.PerformLayout();
  430. this.groupBox3.ResumeLayout(false);
  431. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  432. this.ResumeLayout(false);
  433. }
  434. #endregion
  435. /// <summary>
  436. /// 主控件
  437. /// </summary>
  438. private AppWorkspace appWorkspace;
  439. /// <summary>
  440. /// 常规操作路径
  441. /// </summary>
  442. private string NormalOperationPath = Startup.instance.configModel.NormalOperation;
  443. /// <summary>
  444. /// 通用分析路径
  445. /// </summary>
  446. private string GeneralAnalysisPath = Startup.instance.configModel.GeneralAnalysis;
  447. /// <summary>
  448. /// 专用分析路径
  449. /// </summary>
  450. private string DedicatedAnalysisPath = Startup.instance.configModel.DedicatedAnalysis;
  451. /// <summary>
  452. /// 三个根节点
  453. /// </summary>
  454. private TreeNode anime1, anime2, anime3, anime4;
  455. /// <summary>
  456. /// 新建文件夹窗口
  457. /// </summary>
  458. private CreateNameDialog createNameDialog;
  459. /// <summary>
  460. /// 新建项目窗口
  461. /// </summary>
  462. private CreateProjectDialog createProjectDialog;
  463. /// <summary>
  464. /// 1新建文件夹 2搜索
  465. /// </summary>
  466. private int createType = 1;
  467. /// <summary>
  468. /// 节点信息类,用于判断节点类型
  469. /// </summary>
  470. private class NodeInfo
  471. {
  472. /// <summary>
  473. /// 根节点类型 1常规 2通用 3专用 4搜索
  474. /// </summary>
  475. public int rootType;
  476. /// <summary>
  477. /// 文件夹类型 1文件夹 2项目 3内置不允许删除
  478. /// </summary>
  479. public int folderType;
  480. /// <summary>
  481. /// tag,用于拼接好的存储路径等
  482. /// </summary>
  483. public string tag;
  484. /// <summary>
  485. /// 数据库的主键(通用、专用及其下的内容)
  486. /// </summary>
  487. public int id;
  488. }
  489. public class NodeItem
  490. {
  491. /// <summary>
  492. /// 父级id
  493. /// </summary>
  494. public int parentId;
  495. /// <summary>
  496. /// 完整路径
  497. /// </summary>
  498. public string path;
  499. /// <summary>
  500. /// 项目编号
  501. /// </summary>
  502. public string code;
  503. }
  504. public ProjectEngineering(AppWorkspace appWorkspace)
  505. {
  506. this.appWorkspace = appWorkspace;
  507. InitializeComponent();
  508. InitializeLanguageText();
  509. InitializeButtonBackgroudImage();
  510. InitializeToolTipAndEvent();
  511. InitializeTreeViewRootData();
  512. InitializeTreeViewDetailData();
  513. InitListViewHeader();
  514. ClearLabelAndDataGridView();
  515. InitGridHeader();
  516. }
  517. private void InitializeButtonBackgroudImage()
  518. {
  519. this.button1.FlatStyle = FlatStyle.Flat;
  520. this.button1.FlatAppearance.BorderSize = 0;
  521. this.button1.BackgroundImageLayout = ImageLayout.Center;
  522. this.button1.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Folder.png").Reference;
  523. this.button2.FlatStyle = FlatStyle.Flat;
  524. this.button2.FlatAppearance.BorderSize = 0;
  525. this.button2.BackgroundImageLayout = ImageLayout.Center;
  526. this.button2.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Project.png").Reference;
  527. this.button3.FlatStyle = FlatStyle.Flat;
  528. this.button3.FlatAppearance.BorderSize = 0;
  529. this.button3.BackgroundImageLayout = ImageLayout.Center;
  530. this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Search.png").Reference;
  531. this.button4.FlatStyle = FlatStyle.Flat;
  532. this.button4.FlatAppearance.BorderSize = 0;
  533. this.button4.BackgroundImageLayout = ImageLayout.Center;
  534. this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Refresh.png").Reference;
  535. this.button5.FlatStyle = FlatStyle.Flat;
  536. this.button5.FlatAppearance.BorderSize = 0;
  537. this.button5.BackgroundImageLayout = ImageLayout.Center;
  538. this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Delete.png").Reference;
  539. this.button6.FlatStyle = FlatStyle.Flat;
  540. this.button6.FlatAppearance.BorderSize = 0;
  541. this.button6.BackgroundImageLayout = ImageLayout.Center;
  542. this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.FullScreen.png").Reference;
  543. this.button7.FlatStyle = FlatStyle.Flat;
  544. this.button7.FlatAppearance.BorderSize = 0;
  545. this.button7.BackgroundImageLayout = ImageLayout.Center;
  546. this.button7.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.ListMode.png").Reference;
  547. this.button8.FlatStyle = FlatStyle.Flat;
  548. this.button8.FlatAppearance.BorderSize = 0;
  549. this.button8.BackgroundImageLayout = ImageLayout.Center;
  550. this.button8.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.PicMode.png").Reference;
  551. }
  552. private void ClearLabelAndDataGridView()
  553. {
  554. this.label7.Text = "";
  555. this.label8.Text = "";
  556. this.label9.Text = "";
  557. this.label10.Text = "";
  558. this.label11.Text = "";
  559. this.label12.Text = "";
  560. this.dataGridView1.Rows.Clear();
  561. }
  562. /// <summary>
  563. /// 初始化右侧表头
  564. /// </summary>
  565. private void InitListViewHeader()
  566. {
  567. /*ColumnHeader header = new ColumnHeader();
  568. header.Text = "缩略图";
  569. header.Width = this.listView1.Width / 3 - 7;
  570. this.listView1.Columns.Add(header);*/
  571. ColumnHeader header = new ColumnHeader();
  572. header.Text = PdnResources.GetString("Menu.name.text");
  573. header.Width = this.listView1.Width / 3 - 7;
  574. this.listView1.Columns.Add(header);
  575. header = new ColumnHeader();
  576. header.Text = PdnResources.GetString("Menu.user.text");
  577. header.Width = this.listView1.Width / 3 - 7;
  578. this.listView1.Columns.Add(header);
  579. header = new ColumnHeader();
  580. header.Text = PdnResources.GetString("Menu.Createtime.text");
  581. header.Width = this.listView1.Width / 3 - 7;
  582. this.listView1.Columns.Add(header);
  583. this.listView1.View = View.Details;
  584. }
  585. /// <summary>
  586. /// 初始化项目工程树形菜单
  587. /// </summary>
  588. private void InitializeTreeViewRootData()
  589. {
  590. NodeInfo info1 = new NodeInfo();
  591. info1.rootType = 1;
  592. info1.tag = NormalOperationPath;
  593. anime1 = new TreeNode();
  594. anime1.Text = PdnResources.GetString("Menu.Normaloperation.text");
  595. anime1.Tag = info1;
  596. this.treeView1.Nodes.Add(anime1);
  597. NodeInfo info2 = new NodeInfo();
  598. info2.rootType = 2;
  599. info2.tag = GeneralAnalysisPath;
  600. anime2 = new TreeNode();
  601. anime2.Text = PdnResources.GetString("Menu.GeneralAnalysis.Text");
  602. anime2.Tag = info2;
  603. this.treeView1.Nodes.Add(anime2);
  604. NodeInfo info3 = new NodeInfo();
  605. info3.rootType = 3;
  606. info3.tag = DedicatedAnalysisPath;
  607. anime3 = new TreeNode();
  608. anime3.Text = PdnResources.GetString("Menu.DedicatedAnalysis.Text");
  609. anime3.Tag = info3;
  610. this.treeView1.Nodes.Add(anime3);
  611. NodeInfo info4 = new NodeInfo();
  612. info4.rootType = 4;
  613. anime4 = new TreeNode();
  614. anime4.Text = PdnResources.GetString("Menu.searchresults.text");
  615. anime4.Tag = info4;
  616. this.treeView1.Nodes.Add(anime4);
  617. }
  618. /// <summary>
  619. /// 初始化项目工程详细菜单
  620. /// </summary>
  621. public void InitializeTreeViewDetailData()
  622. {
  623. this.NormalOperationPath = Startup.instance.configModel.NormalOperation;
  624. this.GeneralAnalysisPath = Startup.instance.configModel.GeneralAnalysis;
  625. this.DedicatedAnalysisPath = Startup.instance.configModel.DedicatedAnalysis;
  626. this.treeView1.Nodes[0].Nodes.Clear();
  627. this.treeView1.Nodes[1].Nodes.Clear();
  628. this.treeView1.Nodes[2].Nodes.Clear();
  629. this.listView1.Items.Clear();
  630. if (NormalOperationPath != null && !NormalOperationPath.Equals(""))
  631. {
  632. if (!System.IO.Directory.Exists(NormalOperationPath))
  633. {
  634. string root = System.IO.Directory.GetDirectoryRoot(NormalOperationPath);
  635. if (System.IO.Directory.Exists(root))
  636. System.IO.Directory.CreateDirectory(NormalOperationPath);
  637. }
  638. else
  639. {
  640. InitializeTreeViewDetailDataThree(anime1);
  641. }
  642. }
  643. if (GeneralAnalysisPath != null && !GeneralAnalysisPath.Equals(""))
  644. {
  645. if (!System.IO.Directory.Exists(GeneralAnalysisPath))
  646. {
  647. string root = System.IO.Directory.GetDirectoryRoot(GeneralAnalysisPath);
  648. if (System.IO.Directory.Exists(root))
  649. System.IO.Directory.CreateDirectory(GeneralAnalysisPath);
  650. }
  651. else
  652. {
  653. InitializeGeneralAnalysisTreeViewDetailData(anime2);
  654. }
  655. }
  656. if (DedicatedAnalysisPath != null && !DedicatedAnalysisPath.Equals(""))
  657. {
  658. if (!System.IO.Directory.Exists(DedicatedAnalysisPath))
  659. {
  660. string root = System.IO.Directory.GetDirectoryRoot(DedicatedAnalysisPath);
  661. if (System.IO.Directory.Exists(root))
  662. System.IO.Directory.CreateDirectory(DedicatedAnalysisPath);
  663. }
  664. else
  665. {
  666. InitializeDedicatedAnalysisPathTreeViewDetailData(anime3);
  667. }
  668. }
  669. }
  670. /// <summary>
  671. /// 常规操作
  672. /// </summary>
  673. /// <param name="anime1"></param>
  674. private void InitializeTreeViewDetailDataThree(TreeNode treeNode)
  675. {
  676. List<string> dirs = new List<string>(Directory.GetDirectories(NormalOperationPath, "*", System.IO.SearchOption.TopDirectoryOnly));
  677. foreach (var dir in dirs)
  678. {
  679. try
  680. {
  681. this.anime1.Nodes.Add(this.AddFolderTreeNode(1, dir, 0));
  682. }
  683. catch (Exception)
  684. {
  685. }
  686. }
  687. }
  688. /// <summary>
  689. /// 通用分析
  690. /// </summary>
  691. private void InitializeGeneralAnalysisTreeViewDetailData(TreeNode treeNode)
  692. {
  693. List<mic_project> mic_Projects = mic_project_BLL.FindAllByParentId(1);
  694. if (mic_Projects != null && mic_Projects.Count > 0)
  695. {
  696. foreach (mic_project mic_Project in mic_Projects)
  697. {
  698. if (mic_Project.project_path == null)
  699. {
  700. this.anime2.Nodes.Add(this.AddProjectTreeNode(3, 2, GeneralAnalysisPath + "\\" + PdnResources.GetString(mic_Project.project_name), mic_Project));
  701. }
  702. else
  703. {
  704. this.anime2.Nodes.Add(this.AddProjectTreeNode(3, 2, GeneralAnalysisPath + "\\" + mic_Project.project_name, mic_Project));
  705. }
  706. }
  707. }
  708. }
  709. /// <summary>
  710. /// 专用分析
  711. /// </summary>
  712. private void InitializeDedicatedAnalysisPathTreeViewDetailData(TreeNode treeNode)
  713. {
  714. List<mic_project> mic_Projects = mic_project_BLL.FindAllByParentId(2);
  715. if (mic_Projects != null && mic_Projects.Count > 0)
  716. {
  717. foreach (mic_project mic_Project in mic_Projects)
  718. {
  719. if (mic_Project.project_path == null)
  720. {
  721. this.anime3.Nodes.Add(this.AddProjectTreeNode(3, 3, DedicatedAnalysisPath + "\\" + PdnResources.GetString(mic_Project.project_name), mic_Project));
  722. }
  723. else
  724. {
  725. this.anime3.Nodes.Add(this.AddProjectTreeNode(3, 3, DedicatedAnalysisPath + "\\" + mic_Project.project_name, mic_Project));
  726. }
  727. }
  728. }
  729. }
  730. public TreeNode TreeNode
  731. {
  732. get
  733. {
  734. return this.treeView1.SelectedNode;
  735. }
  736. }
  737. /// <summary>
  738. /// 初始化提示信息及按钮事件
  739. /// </summary>
  740. private void InitializeToolTipAndEvent()
  741. {
  742. this.toolTip1 = new ToolTip();
  743. this.toolTip1.SetToolTip(this.button1, PdnResources.GetString("Menu.Newfolder.Text"));
  744. this.toolTip1.SetToolTip(this.button2, PdnResources.GetString("Menu.Newproject.Text"));
  745. this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Itemsearch.Text"));
  746. this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Refresh.text"));
  747. this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Delete.Text"));
  748. this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Fullscreen.Text"));
  749. this.toolTip1.SetToolTip(this.button7, PdnResources.GetString("Menu.tool.Templatemanent.Listmode.text"));
  750. this.toolTip1.SetToolTip(this.button8, PdnResources.GetString("Menu.tool.Templategement.Thumbnailmode.text"));
  751. this.toolTip1.ShowAlways = true;
  752. }
  753. /// <summary>
  754. /// 新建文件夹
  755. /// </summary>
  756. /// <param name="sender"></param>
  757. /// <param name="e"></param>
  758. private void button1_click(object sender, EventArgs e)
  759. {
  760. if (this.treeView1.SelectedNode == null)
  761. {
  762. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text"));
  763. return;
  764. }
  765. if (this.treeView1.SelectedNode.Index == 0 && this.treeView1.SelectedNode.Parent==null)
  766. {
  767. if (NormalOperationPath == null || NormalOperationPath.Equals(""))
  768. {
  769. MessageBox.Show(PdnResources.GetString("Menu.Pleasesavepathorchivefilefirst.Text"));
  770. return;
  771. }
  772. }
  773. this.createType = 1;
  774. this.createNameDialog = new CreateNameDialog(this);
  775. this.createNameDialog.Text = PdnResources.GetString("Menu.Newfolder.Text");
  776. this.createNameDialog.StartPosition = FormStartPosition.CenterScreen;
  777. this.createNameDialog.ShowDialog();
  778. }
  779. /// <summary>
  780. /// 新建项目
  781. /// </summary>
  782. /// <param name="sender"></param>
  783. /// <param name="e"></param>
  784. private void button2_click(object sender, EventArgs e)
  785. {
  786. if (this.treeView1.SelectedNode == null)
  787. {
  788. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text"));
  789. return;
  790. }
  791. this.createProjectDialog = new CreateProjectDialog(this);
  792. this.createProjectDialog.parentId = ((NodeInfo)this.treeView1.SelectedNode.Tag).id;
  793. this.createProjectDialog.Text = PdnResources.GetString("Menu.Newproject.Text");
  794. this.createProjectDialog.StartPosition = FormStartPosition.CenterScreen;
  795. this.createProjectDialog.ShowDialog();
  796. }
  797. /// <summary>
  798. /// 新建文件夹的结果函数
  799. /// </summary>
  800. /// <param name="name"></param>
  801. public override void GetCreateName(string name)
  802. {
  803. if(this.createType==1)
  804. {
  805. //如果是常规操作
  806. if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1)
  807. {
  808. string newPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + name;
  809. if (!System.IO.Directory.Exists(newPath))
  810. {
  811. System.IO.Directory.CreateDirectory(newPath);
  812. this.treeView1.SelectedNode.Nodes.Add(this.AddFolderTreeNode(1, newPath, 0));
  813. //this.treeView1.Nodes[0].Nodes.Clear();
  814. //InitializeTreeViewDetailDataThree(anime1);
  815. }
  816. else
  817. {
  818. MessageBox.Show("已经存在同名文件夹");
  819. }
  820. }
  821. //如果是通用、专用分析
  822. else
  823. {
  824. //文件夹内可以建文件夹,项目内不允许建文件夹
  825. //如果不是项目,则允许创建文件夹
  826. if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 1 || ((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3)
  827. {
  828. string parentPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag;
  829. if (!System.IO.Directory.Exists(parentPath))
  830. {
  831. System.IO.Directory.CreateDirectory(parentPath);
  832. }
  833. string newPath = parentPath + "\\" + name;
  834. if (!System.IO.Directory.Exists(newPath))
  835. {
  836. //创建文件夹
  837. System.IO.Directory.CreateDirectory(newPath);
  838. //添加到数据库
  839. mic_project project = new mic_project();
  840. project.parent_id = ((NodeInfo)this.treeView1.SelectedNode.Tag).id;
  841. project.project_name = name;
  842. project.project_path = newPath;
  843. project.project_type = 3;
  844. mic_project_BLL.Add(project);
  845. this.treeView1.SelectedNode.Nodes.Add(this.AddFolderTreeNode(((NodeInfo)this.treeView1.SelectedNode.Tag).rootType, newPath, project.id));
  846. }
  847. else
  848. {
  849. MessageBox.Show("已经存在同名文件夹");
  850. }
  851. }
  852. }
  853. }
  854. //如果是进行搜索
  855. else if(this.createType == 2)
  856. {
  857. //先清空搜索节点的数据
  858. this.treeView1.Nodes[3].Nodes.Clear();
  859. //搜索
  860. if (!string.IsNullOrEmpty(name))
  861. {
  862. List<mic_project_info> infos = mic_project_info_BLL.FindAllByKey(name);
  863. if (infos!=null && infos.Count>0)
  864. {
  865. int[] arr = infos.Select(a => a.project_id).ToArray();
  866. List<mic_project> mic_Projects = mic_project_BLL.FindAllByIds(arr);
  867. if (mic_Projects!=null && mic_Projects.Count>0)
  868. {
  869. foreach (mic_project mic_Project in mic_Projects)
  870. {
  871. this.anime4.Nodes.Add(this.AddProjectTreeNode(2, 4, mic_Project.project_path, mic_Project));
  872. }
  873. }
  874. }
  875. else
  876. {
  877. MessageBox.Show("没有搜索结果");
  878. }
  879. }
  880. if(this.treeView1.Nodes[3].Nodes.Count>0)
  881. {
  882. this.treeView1.Nodes[3].Expand();
  883. }
  884. }
  885. this.createNameDialog.Close();
  886. }
  887. /// <summary>
  888. /// 新建项目的结果函数
  889. /// </summary>
  890. public override void CreateProjectName(AnalyzeSettingModel model, int id)
  891. {
  892. if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType > 1)
  893. {
  894. //文件夹内可以建项目,项目内不能建项目
  895. if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 1 || ((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3)
  896. {
  897. string parentPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag;
  898. if (!System.IO.Directory.Exists(parentPath))
  899. {
  900. System.IO.Directory.CreateDirectory(parentPath);
  901. }
  902. string newPath = parentPath + "\\" + model.itemNumber;
  903. if (!System.IO.Directory.Exists(newPath))
  904. {
  905. //创建文件夹
  906. System.IO.Directory.CreateDirectory(newPath);
  907. //获取数据
  908. mic_project project = mic_project_BLL.FindDefault(id);
  909. project.project_path = newPath;
  910. mic_project_BLL.Update(project);
  911. this.treeView1.SelectedNode.Nodes.Add(this.AddProjectTreeNode(2, ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType, newPath, project));
  912. }
  913. else
  914. {
  915. MessageBox.Show("已经存在同名项目");
  916. }
  917. }
  918. }
  919. if (createProjectDialog != null && !createProjectDialog.IsDisposed)
  920. createProjectDialog.Close();
  921. }
  922. /// <summary>
  923. /// 搜索
  924. /// </summary>
  925. /// <param name="sender"></param>
  926. /// <param name="e"></param>
  927. private void button3_click(object sender, EventArgs e)
  928. {
  929. this.createType = 2;
  930. this.createNameDialog = new CreateNameDialog(this);
  931. this.createNameDialog.Text = PdnResources.GetString("Menu.Itemsearch.Text");
  932. this.createNameDialog.StartPosition = FormStartPosition.CenterScreen;
  933. this.createNameDialog.ShowDialog();
  934. }
  935. /// <summary>
  936. /// 刷新
  937. /// </summary>
  938. /// <param name="sender"></param>
  939. /// <param name="e"></param>
  940. private void button4_click(object sender, EventArgs e)
  941. {
  942. this.InitializeTreeViewDetailData();
  943. }
  944. /// <summary>
  945. /// 删除
  946. /// </summary>
  947. /// <param name="sender"></param>
  948. /// <param name="e"></param>
  949. private void button5_click(object sender, EventArgs e)
  950. {
  951. if (this.treeView1.SelectedNode == null)
  952. {
  953. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text"));
  954. return;
  955. }
  956. if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1)
  957. {
  958. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousurethecurrentfolder.Text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
  959. {
  960. //删除文件夹及其内部的文件
  961. FileOperationHelper.DeleteFolder(((NodeInfo)this.treeView1.SelectedNode.Tag).tag);
  962. //移除node
  963. this.treeView1.SelectedNode.Remove();
  964. }
  965. }
  966. else if(((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 2 || ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 3)
  967. {
  968. if (this.treeView1.SelectedNode.Parent == null)
  969. {
  970. MessageBox.Show(PdnResources.GetString("Menu.easeselectanothernodeTherootno.Text"));
  971. }
  972. else
  973. {
  974. if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3)
  975. {
  976. MessageBox.Show(PdnResources.GetString("Menu.eselectnothernodeStandardnodecannotbedele.Text"));
  977. }
  978. else
  979. {
  980. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousurethecurrentfolder.Text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
  981. {
  982. NodeInfo info = ((NodeInfo)this.treeView1.SelectedNode.Tag);
  983. //删除数据库
  984. this.RecursionDelDbData(info.id);
  985. //删除文件夹及其内部的文件
  986. FileOperationHelper.DeleteFolder(info.tag);
  987. //移除node
  988. this.treeView1.SelectedNode.Remove();
  989. }
  990. }
  991. }
  992. }
  993. else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 4)
  994. {
  995. MessageBox.Show(PdnResources.GetString("Menu.Searchandsearchresutsnodescannotbedeleted.Text"));
  996. }
  997. }
  998. /// <summary>
  999. /// 递归删除数据库内容
  1000. /// </summary>
  1001. /// <param name="id"></param>
  1002. private void RecursionDelDbData(int id)
  1003. {
  1004. mic_project project = mic_project_BLL.FindDefault(id);
  1005. mic_project_info project_info = mic_project_info_BLL.FindByProjectCode(project.project_name);
  1006. if (project_info != null)
  1007. {
  1008. List<mic_project_info_item> items = mic_project_info_item_BLL.FindAllByInfoId(project_info.id);
  1009. foreach (mic_project_info_item item in items)
  1010. {
  1011. mic_project_info_item_BLL.Del(item.id);
  1012. }
  1013. mic_project_info_BLL.Del(project_info.id);
  1014. }
  1015. mic_project_BLL.Del(project.id);
  1016. List<mic_project> projects = mic_project_BLL.FindAllByParentId(id);
  1017. if (projects!=null && projects.Count>0)
  1018. {
  1019. foreach (mic_project p in projects)
  1020. {
  1021. this.RecursionDelDbData(p.id);
  1022. }
  1023. }
  1024. }
  1025. /// <summary>
  1026. /// 全屏
  1027. /// </summary>
  1028. /// <param name="sender"></param>
  1029. /// <param name="e"></param>
  1030. private void button6_click(object sender, EventArgs e)
  1031. {
  1032. if(this.WindowState == FormWindowState.Maximized)
  1033. {
  1034. this.WindowState = FormWindowState.Normal;
  1035. }
  1036. else
  1037. {
  1038. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  1039. this.WindowState = FormWindowState.Maximized;
  1040. }
  1041. }
  1042. /// <summary>
  1043. /// 列表模式
  1044. /// </summary>
  1045. /// <param name="sender"></param>
  1046. /// <param name="e"></param>
  1047. private void button7_click(object sender, EventArgs e)
  1048. {
  1049. this.listView1.View = View.Details;
  1050. }
  1051. /// <summary>
  1052. ///
  1053. /// </summary>
  1054. /// <param name="sender"></param>
  1055. /// <param name="e"></param>
  1056. private void button8_click(object sender, EventArgs e)
  1057. {
  1058. this.listView1.View = View.LargeIcon;
  1059. }
  1060. /// <summary>
  1061. /// 左侧节点点击事件,需要刷新右侧listview内容
  1062. /// </summary>
  1063. /// <param name="sender"></param>
  1064. /// <param name="e"></param>
  1065. private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  1066. {
  1067. this.listView1.Items.Clear();
  1068. this.imageList1.Images.Clear();
  1069. //如果是常规操作,则不允许建立项目,不允许删除,从文件夹读取内容
  1070. if (e.Node.Index==0 && e.Node.Parent==null)
  1071. {
  1072. this.button1.Enabled = true;
  1073. this.button2.Enabled = false;
  1074. this.button5.Enabled = false;
  1075. this.showFileList(e.Node.Tag);
  1076. }
  1077. //如果是抖索结果,则什么都不允许操作
  1078. else if (e.Node.Index == 3 && e.Node.Parent == null)
  1079. {
  1080. this.button1.Enabled = false;
  1081. this.button2.Enabled = false;
  1082. this.button5.Enabled = false;
  1083. }
  1084. //如果是常规操作下的文件夹,从文件夹读取内容
  1085. else if(((NodeInfo)e.Node.Tag).rootType == 1)
  1086. {
  1087. this.button1.Enabled = true;
  1088. this.button2.Enabled = false;
  1089. this.button5.Enabled = true;
  1090. this.showFileList(e.Node.Tag);
  1091. }
  1092. else
  1093. {
  1094. //如果是通用分析和专用分析根节点,就什么都不干
  1095. if (e.Node.Parent==null)
  1096. {
  1097. this.button1.Enabled = false;
  1098. this.button2.Enabled = false;
  1099. this.button5.Enabled = false;
  1100. }
  1101. //如果是通用分析或专用下内置的标准,则不读取内容
  1102. else if (((NodeInfo)e.Node.Tag).folderType == 3)
  1103. {
  1104. this.button1.Enabled = true;
  1105. this.button2.Enabled = true;
  1106. this.button5.Enabled = false;
  1107. }
  1108. //如果是通用分析或专用下的文件夹,则从文件夹读取内容
  1109. else if (((NodeInfo)e.Node.Tag).folderType == 1)
  1110. {
  1111. this.button1.Enabled = true;
  1112. this.button2.Enabled = true;
  1113. this.button5.Enabled = true;
  1114. this.showFileList(e.Node.Tag);
  1115. }
  1116. //如果是通用分析或专用下的项目,则从文件夹读取内容
  1117. else if (((NodeInfo)e.Node.Tag).folderType == 2)
  1118. {
  1119. this.button1.Enabled = false;
  1120. this.button2.Enabled = false;
  1121. this.button5.Enabled = true;
  1122. this.showFileList(e.Node.Tag);
  1123. this.showProjectDetail(e.Node.Tag);
  1124. }
  1125. //如果是常规操作下,则从文件夹里面读
  1126. else
  1127. {
  1128. this.button1.Enabled = true;
  1129. this.button2.Enabled = false;
  1130. this.button5.Enabled = true;
  1131. this.showFileList(e.Node.Tag);
  1132. }
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 读取文件夹的内容,展示在右侧listview中
  1137. /// </summary>
  1138. /// <param name="info"></param>
  1139. private void showFileList(Object info)
  1140. {
  1141. NodeInfo nodeInfo = (NodeInfo)info;
  1142. string path = nodeInfo.tag;
  1143. if (path!=null && !path.Equals(""))
  1144. {
  1145. if (!System.IO.Directory.Exists(path))
  1146. {
  1147. MessageBox.Show(PdnResources.GetString("Menu.Thefolderdoesnotexistorwasremo.Text"));
  1148. return;
  1149. }
  1150. /*if (nodeInfo.folderType == 3)
  1151. {
  1152. if (!System.IO.Directory.Exists(path))
  1153. {
  1154. System.IO.Directory.CreateDirectory(path);
  1155. }
  1156. }*/
  1157. DirectoryInfo TheFolder = new DirectoryInfo(path);
  1158. int j = 0;
  1159. foreach (FileInfo NextFile in TheFolder.GetFiles())
  1160. {
  1161. /*if (NextFile.Extension.Equals(".doc") || NextFile.Extension.Equals(".docx"))
  1162. {
  1163. this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeWordA.png").Reference);
  1164. }
  1165. else if (NextFile.Extension.Equals(".xls") || NextFile.Extension.Equals(".xlsx"))
  1166. {
  1167. this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeExcelA.png").Reference);
  1168. }
  1169. else
  1170. {
  1171. this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeOtherA.png").Reference);
  1172. }*/
  1173. ShellFile shellFile = ShellFile.FromFilePath(NextFile.FullName);
  1174. this.imageList1.Images.Add("img" + j, shellFile.Thumbnail.SmallBitmap);
  1175. this.listView1.Items.Add(NextFile.Name, j);
  1176. this.listView1.Items[j].ImageIndex = j;
  1177. this.listView1.Items[j].SubItems.Add(FileOperationHelper.ReadFileOwner(NextFile.FullName));
  1178. this.listView1.Items[j].SubItems.Add(NextFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));
  1179. j++;
  1180. }
  1181. }
  1182. }
  1183. /// <summary>
  1184. /// 从数据库获取项目详细信息
  1185. /// </summary>
  1186. /// <param name="info"></param>
  1187. private void showProjectDetail(Object info)
  1188. {
  1189. int id = ((NodeInfo)info).id;
  1190. mic_project project = mic_project_BLL.FindDefault(id);
  1191. mic_project_info project_info = mic_project_info_BLL.FindByProjectCodeAndProjectId(project.project_name, project.id);
  1192. this.ClearLabelAndDataGridView();
  1193. if (project_info!=null)
  1194. {
  1195. this.label7.Text = project_info.project_code;
  1196. this.label8.Text = project_info.project_rating.ToString();
  1197. this.label9.Text = project_info.project_sender;
  1198. this.label11.Text = project_info.project_contact;
  1199. this.label10.Text = project_info.project_company;
  1200. this.label12.Text = project_info.project_date.ToString();
  1201. List<mic_project_info_item> items = mic_project_info_item_BLL.FindAllByInfoId(project_info.id);
  1202. if (items!=null && items.Count>0)
  1203. {
  1204. foreach (mic_project_info_item item in items)
  1205. {
  1206. DataGridViewRow row = new DataGridViewRow();
  1207. row.Cells.Add(CreateTextBoxCell(item.item_key, "name"));
  1208. row.Cells.Add(CreateTextBoxCell(item.item_value, "content"));
  1209. this.dataGridView1.Rows.Add(row);
  1210. }
  1211. this.dataGridView1.ClearSelection();
  1212. }
  1213. }
  1214. }
  1215. /// <summary>
  1216. /// 添加内容单元格
  1217. /// </summary>
  1218. /// <param name="text"></param>
  1219. /// <param name="tag"></param>
  1220. /// <returns></returns>
  1221. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  1222. {
  1223. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1224. textboxcell.Value = text;
  1225. textboxcell.Tag = tag;
  1226. return textboxcell;
  1227. }
  1228. /// <summary>
  1229. /// 初始化表头
  1230. /// </summary>
  1231. private void InitGridHeader()
  1232. {
  1233. this.dataGridView1.ColumnHeadersHeight = 25;
  1234. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1235. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1236. h1.Width = 200;
  1237. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1238. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1239. h2.Width = 200;
  1240. this.dataGridView1.Columns.Add(h1);
  1241. this.dataGridView1.Columns.Add(h2);
  1242. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1243. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.name.text")));
  1244. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.content.text")));
  1245. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1246. this.dataGridView1.Columns[0].ReadOnly = true;
  1247. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1248. this.dataGridView1.Columns[1].ReadOnly = true;
  1249. this.dataGridView1.AllowUserToResizeRows = false;
  1250. this.dataGridView1.AllowUserToResizeColumns = false;
  1251. }
  1252. /// <summary>
  1253. /// listview1的双击事件,如果在item上,则尝试打开文件
  1254. /// </summary>
  1255. /// <param name="sender"></param>
  1256. /// <param name="e"></param>
  1257. private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
  1258. {
  1259. try
  1260. {
  1261. ListViewHitTestInfo info = this.listView1.HitTest(e.X, e.Y);
  1262. if (info.Item != null)
  1263. {
  1264. string path = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag;
  1265. if (info.Item.Text.IndexOf("jpg") > 0 || info.Item.Text.IndexOf("png") > 0
  1266. || info.Item.Text.IndexOf("BMP") > 0)
  1267. {
  1268. //Image img = new Bitmap(path + "\\" + info.Item.Text);
  1269. //Document document = Document.FromImage(img);
  1270. OpenCvSharp.Mat imageMat = new OpenCvSharp.Mat(path + "\\" + info.Item.Text);
  1271. Document document = Document.FromImageMat(imageMat);
  1272. DocumentWorkspace documentWorkspace = this.appWorkspace.AddNewDocumentWorkspace();
  1273. documentWorkspace.fileText = info.Item.Text;
  1274. documentWorkspace.Document = document;
  1275. //判断是否存在xml,进行读取
  1276. PicConfigModel configModel = null;
  1277. string fileName = path + "\\" + info.Item.Text;
  1278. string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml";
  1279. //如果xml存在
  1280. if (System.IO.File.Exists(xmlPath))
  1281. {
  1282. configModel = XmlSerializeHelper.DESerializer<PicConfigModel>(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open));
  1283. documentWorkspace.RuleAttribute(configModel);
  1284. if (configModel != null)
  1285. {
  1286. this.appWorkspace.RestoreLabelAndMeasure(configModel, documentWorkspace);
  1287. }
  1288. }
  1289. //如果不存在,则判断
  1290. //(1)是否自动添加ZEN标尺
  1291. //(2)是否自动添加AxioVision标尺
  1292. else
  1293. {
  1294. documentWorkspace.xmlSaveModel = Startup.instance.ruleDB;
  1295. documentWorkspace.InitRulerInfo();
  1296. }
  1297. this.appWorkspace.ActiveDocumentWorkspace = documentWorkspace;
  1298. }
  1299. else if (info.Item.Text.IndexOf(".xlsx") > 0 || info.Item.Text.IndexOf(".docx") > 0
  1300. || info.Item.Text.IndexOf(".xls") > 0 || info.Item.Text.IndexOf(".doc") > 0)
  1301. {
  1302. if (!OfficeFileHandleHelper.OpenOfficeFile(path + "\\" + info.Item.Text))
  1303. MessageBox.Show(PdnResources.GetString("Menu.Fileopenfailed.Text"));
  1304. }
  1305. //MessageBox.Show(info.Item.Text);
  1306. }
  1307. }
  1308. catch(Exception)
  1309. {
  1310. }
  1311. }
  1312. /// <summary>
  1313. /// 将要展开节点时的事件
  1314. /// </summary>
  1315. /// <param name="sender"></param>
  1316. /// <param name="e"></param>
  1317. private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
  1318. {
  1319. //如果不是顶级节点
  1320. if(e.Node.Parent != null)
  1321. {
  1322. if(e.Node.Nodes.Count==1)
  1323. {
  1324. if(((NodeInfo)e.Node.Tag).rootType == 1)
  1325. {
  1326. List<string> dirs = new List<string>(Directory.GetDirectories(((NodeInfo)e.Node.Tag).tag, "*", System.IO.SearchOption.TopDirectoryOnly));
  1327. foreach (var dir in dirs)
  1328. {
  1329. try
  1330. {
  1331. NodeInfo nodeInfo = new NodeInfo();
  1332. nodeInfo.rootType = ((NodeInfo)e.Node.Tag).rootType;
  1333. nodeInfo.folderType = 1;
  1334. nodeInfo.tag = dir;
  1335. TreeNode node = new TreeNode();
  1336. node.Text = Path.GetFileName(dir);
  1337. node.Tag = nodeInfo;
  1338. if (Directory.GetDirectories(dir).Length > 0)
  1339. {
  1340. TreeNode temp = new TreeNode();
  1341. temp.Text = "";
  1342. node.Nodes.Add(temp);
  1343. }
  1344. e.Node.Nodes.Add(node);
  1345. }
  1346. catch (Exception)
  1347. {
  1348. }
  1349. }
  1350. }
  1351. else if (((NodeInfo)e.Node.Tag).rootType == 2 || ((NodeInfo)e.Node.Tag).rootType == 3)
  1352. {
  1353. //从数据库读取下级
  1354. List<mic_project> list = mic_project_BLL.FindAllByParentId(((NodeInfo)e.Node.Tag).id);
  1355. if(list!=null && list.Count>0)
  1356. {
  1357. foreach (mic_project p in list)
  1358. {
  1359. int folderType = (p.project_type == 4)? 2 : 1;
  1360. e.Node.Nodes.Add(this.AddProjectTreeNode(folderType, ((NodeInfo)e.Node.Tag).rootType, p.project_path, p));
  1361. }
  1362. }
  1363. }
  1364. e.Node.Nodes.RemoveAt(0);
  1365. }
  1366. }
  1367. }
  1368. /// <summary>
  1369. /// 绘制节点事件
  1370. /// </summary>
  1371. /// <param name="sender"></param>
  1372. /// <param name="e"></param>
  1373. private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
  1374. {
  1375. if ((e.State & TreeNodeStates.Selected) != 0)
  1376. {
  1377. //绿底白字
  1378. e.Graphics.FillRectangle(Brushes.Green, e.Node.Bounds);
  1379. Font nodeFont = e.Node.NodeFont;
  1380. if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
  1381. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
  1382. }
  1383. else
  1384. {
  1385. e.DrawDefault = true;
  1386. }
  1387. if ((e.State & TreeNodeStates.Focused) != 0)
  1388. {
  1389. using (Pen focusPen = new Pen(Color.Black))
  1390. {
  1391. focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  1392. Rectangle focusBounds = e.Node.Bounds;
  1393. focusBounds.Size = new System.Drawing.Size(focusBounds.Width - 1,
  1394. focusBounds.Height - 1);
  1395. e.Graphics.DrawRectangle(focusPen, focusBounds);
  1396. }
  1397. }
  1398. }
  1399. /// <summary>
  1400. /// 添加到工程
  1401. /// </summary>
  1402. public void AddToProject()
  1403. {
  1404. if(((NodeInfo)this.treeView1.SelectedNode.Tag).tag==null || ((NodeInfo)this.treeView1.SelectedNode.Tag).tag.Equals(""))
  1405. {
  1406. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text") + PdnResources.GetString("Menu.Set.Generalsettings.Thearchivefilesavesthepath.text"));
  1407. return;
  1408. }
  1409. //如果选择的节点是常规操作,选择什么路径就存储到什么路径
  1410. if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1)
  1411. {
  1412. this.saveBitmapToFolder();
  1413. //刷新节点
  1414. this.listView1.Items.Clear();
  1415. this.imageList1.Images.Clear();
  1416. this.showFileList(this.treeView1.SelectedNode.Tag);
  1417. }
  1418. //如果选择的节点是通用分析、专用分析
  1419. else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 2 || ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 3)
  1420. {
  1421. if (this.treeView1.SelectedNode.Parent==null)
  1422. {
  1423. MessageBox.Show(PdnResources.GetString("Menu.selewhichcannotbetoredintheroot.Text"));
  1424. }
  1425. else
  1426. {
  1427. if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType==3)
  1428. {
  1429. MessageBox.Show(PdnResources.GetString("Menu.selectanothernodewhtbestoredinhestan.Text"));
  1430. }
  1431. else
  1432. {
  1433. this.saveBitmapToFolder();
  1434. //刷新节点
  1435. this.listView1.Items.Clear();
  1436. this.imageList1.Images.Clear();
  1437. this.showFileList(this.treeView1.SelectedNode.Tag);
  1438. }
  1439. }
  1440. }
  1441. //如果选择的节点是搜索结果,则提示用户,不能添加到这里
  1442. else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 4)
  1443. {
  1444. MessageBox.Show(PdnResources.GetString("Menu.dwhichcannotbestoredinthesearchresu.Text"));
  1445. }
  1446. }
  1447. private void saveBitmapToFolder()
  1448. {
  1449. if (this.appWorkspace.ActiveDocumentWorkspace == null)
  1450. return;
  1451. using (Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap())
  1452. {
  1453. //获取文件后缀名
  1454. string extension = Path.GetExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName());
  1455. //获取不带后缀的文件名
  1456. string noExtension = Path.GetFileNameWithoutExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName());
  1457. using (Bitmap dstBitmap = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), bitmap.PixelFormat))
  1458. {
  1459. //保存图片
  1460. ImageCodecInfo icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Jpeg);
  1461. if (extension.Equals(".jpg"))
  1462. {
  1463. icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Jpeg);
  1464. }
  1465. else if (extension.Equals(".bmp"))
  1466. {
  1467. icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Bmp);
  1468. }
  1469. else if (extension.Equals(".tiff"))
  1470. {
  1471. icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Tiff);
  1472. }
  1473. EncoderParameters parms = new EncoderParameters(1);
  1474. EncoderParameter parm = new EncoderParameter(Encoder.Quality, 100L);
  1475. parms.Param[0] = parm;
  1476. dstBitmap.Save(((NodeInfo)this.treeView1.SelectedNode.Tag).tag +"\\"+ this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName(), icf, parms);
  1477. //组织配置文件的数据
  1478. PicConfigModel picConfigModel = new PicConfigModel();
  1479. picConfigModel.rule = new PicConfigModel.Rule();
  1480. if (this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel != null && this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length != 0)
  1481. {
  1482. picConfigModel.rule.ruler_name = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_name;
  1483. picConfigModel.rule.gain_multiple = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.gain_multiple;
  1484. picConfigModel.rule.pixel_length = (int)this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length;
  1485. picConfigModel.rule.physical_length = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.physical_length;
  1486. picConfigModel.rule.ruler_units = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_units;
  1487. }
  1488. //按路径和名称保存xml文件
  1489. string userInfoXml = XmlSerializeHelper.XmlSerialize<PicConfigModel>(picConfigModel);
  1490. //xml保存路径
  1491. string filePath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + noExtension + ".xml";
  1492. //保存xml
  1493. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create);
  1494. }
  1495. }
  1496. }
  1497. /// <summary>
  1498. /// 添加文件夹类型的node节点
  1499. /// </summary>
  1500. /// <param name="rootType"></param>
  1501. /// <param name="dir"></param>
  1502. /// <returns></returns>
  1503. private TreeNode AddFolderTreeNode(int rootType, string dir, int id)
  1504. {
  1505. NodeInfo info = new NodeInfo();
  1506. info.rootType = rootType;
  1507. info.folderType = 1;
  1508. info.tag = dir;
  1509. info.id = id;
  1510. TreeNode node = new TreeNode();
  1511. node.Text = Path.GetFileName(dir);
  1512. node.Tag = info;
  1513. if (Directory.GetDirectories(dir).Length > 0)
  1514. {
  1515. TreeNode temp = new TreeNode();
  1516. temp.Text = "";
  1517. node.Nodes.Add(temp);
  1518. }
  1519. return node;
  1520. }
  1521. private void ProjectEngineering_FormClosing(object sender, FormClosingEventArgs e)
  1522. {
  1523. this.appWorkspace.toolBar.RefreshBtnSelect(false, "OpenProject");
  1524. this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "OpenProject");
  1525. }
  1526. /// <summary>
  1527. /// 添加项目类型的node节点
  1528. /// </summary>
  1529. /// <param name="rootType"></param>
  1530. /// <param name="dir"></param>
  1531. /// <returns></returns>
  1532. private TreeNode AddProjectTreeNode(int folderType, int rootType, string path, mic_project mic_Project)
  1533. {
  1534. NodeInfo info = new NodeInfo();
  1535. info.rootType = rootType;
  1536. info.folderType = folderType;
  1537. info.tag = path;
  1538. info.id = mic_Project.id;
  1539. TreeNode node = new TreeNode();
  1540. if (mic_Project.project_path == null)
  1541. {
  1542. node.Text = PdnResources.GetString(mic_Project.project_name);
  1543. }
  1544. else
  1545. {
  1546. node.Text = mic_Project.project_name;
  1547. }
  1548. node.Tag = info;
  1549. if (folderType==3 && !System.IO.Directory.Exists(path))
  1550. System.IO.Directory.CreateDirectory(path);
  1551. //这里应该判断是否再数据库中有下级
  1552. if(mic_project_BLL.FindCountByParentId(mic_Project.id)>0)
  1553. //if (Directory.GetDirectories(path).Length > 0)
  1554. {
  1555. TreeNode temp = new TreeNode();
  1556. temp.Text = "";
  1557. node.Nodes.Add(temp);
  1558. }
  1559. return node;
  1560. }
  1561. /// <summary>
  1562. /// 获取存储路径
  1563. /// </summary>
  1564. /// <param name="type">1通用分析 2专用分析</param>
  1565. /// <param name="analysis">分析的名称</param>
  1566. /// <returns></returns>
  1567. public NodeItem GetProjectPath(int type, string analysis, string originPath)
  1568. {
  1569. // TODO ZYH 这里数据库内应该存储多语言的key,创建的文件夹也应该是相应位置
  1570. //获取数据库信息
  1571. string languagePath = PdnResources.GetString(analysis);
  1572. if (string.IsNullOrEmpty(languagePath)) return null;
  1573. mic_project mic_Project = mic_project_BLL.FindItenByNameAndPath(Path.GetFileName(originPath), originPath);
  1574. if (mic_Project == null)
  1575. {
  1576. MessageBox.Show("项目目录不存在,请检查!");
  1577. return null;
  1578. }
  1579. //创建一个编号
  1580. int num = Startup.instance.configModel.ProjectCodeNum;
  1581. int addNum = 1000000 + num;
  1582. string code = "P" + addNum;
  1583. //获取路径
  1584. //string parentPath = "";
  1585. //if (type == 1) parentPath = GeneralAnalysisPath;
  1586. //if (type == 2) parentPath = DedicatedAnalysisPath;
  1587. //创建相应文件夹
  1588. //string path = parentPath + "\\" + PdnResources.GetString(analysis) + "\\" + code;
  1589. string path = originPath + "\\" + code;
  1590. if (!System.IO.Directory.Exists(path))
  1591. {
  1592. System.IO.Directory.CreateDirectory(path);
  1593. }
  1594. //更新配置文件编号+1
  1595. Startup.instance.configModel.ProjectCodeNum += 1;
  1596. string configXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(Startup.instance.configModel);
  1597. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  1598. FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create);
  1599. NodeItem info = new NodeItem();
  1600. info.path = path;
  1601. info.code = code;
  1602. info.parentId = mic_Project.id;
  1603. return info;
  1604. }
  1605. /// <summary>
  1606. /// 通用专用分析,插入到数据库,添加节点
  1607. /// </summary>
  1608. /// <param name="analyzeSettingModel">分析的model</param>
  1609. /// <param name="folder">项目编号</param>
  1610. public void InsertIntoDB(AnalyzeSettingModel analyzeSettingModel, NodeItem item)
  1611. {
  1612. //添加目录主表
  1613. mic_project mic_Project = new mic_project();
  1614. mic_Project.parent_id = item.parentId;
  1615. mic_Project.project_name = item.code;
  1616. mic_Project.project_path = item.path;
  1617. mic_Project.project_type = 4;
  1618. mic_project_BLL.Add(mic_Project);
  1619. //添加项目主表
  1620. mic_project_info mic_Project_Info = new mic_project_info();
  1621. mic_Project_Info.project_code = item.code;
  1622. mic_Project_Info.project_company = analyzeSettingModel.inspectionDepartment;
  1623. mic_Project_Info.project_contact = analyzeSettingModel.contact;
  1624. mic_Project_Info.project_date = analyzeSettingModel.inspectionDate;
  1625. mic_Project_Info.project_id = mic_Project.id;
  1626. mic_Project_Info.project_rating = analyzeSettingModel.ratingDate;
  1627. mic_Project_Info.project_sender = analyzeSettingModel.inspectionPerson;
  1628. mic_project_info_BLL.Add(mic_Project_Info);
  1629. //添加项目子表
  1630. if (analyzeSettingModel.otherList!=null && analyzeSettingModel.otherList.Count>0)
  1631. {
  1632. foreach (OthersInfo othersInfo in analyzeSettingModel.otherList)
  1633. {
  1634. mic_project_info_item s = new mic_project_info_item();
  1635. s.info_id = mic_Project_Info.id;
  1636. s.item_key = othersInfo.name;
  1637. s.item_value = othersInfo.content;
  1638. mic_project_info_item_BLL.Add(s);
  1639. }
  1640. }
  1641. }
  1642. }
  1643. }