ProjectEngineering.cs 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764
  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. DocumentWorkspace documentWorkspace = this.appWorkspace.AddNewDocumentWorkspace();
  1271. documentWorkspace.fileText = info.Item.Text;
  1272. documentWorkspace.Document = document;
  1273. //判断是否存在xml,进行读取
  1274. PicConfigModel configModel = null;
  1275. string fileName = path + "\\" + info.Item.Text;
  1276. string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml";
  1277. //如果xml存在
  1278. if (System.IO.File.Exists(xmlPath))
  1279. {
  1280. configModel = XmlSerializeHelper.DESerializer<PicConfigModel>(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open));
  1281. documentWorkspace.RuleAttribute(configModel);
  1282. if (configModel != null)
  1283. {
  1284. this.appWorkspace.RestoreLabelAndMeasure(configModel, documentWorkspace);
  1285. }
  1286. }
  1287. //如果不存在,则判断
  1288. //(1)是否自动添加ZEN标尺
  1289. //(2)是否自动添加AxioVision标尺
  1290. else
  1291. {
  1292. documentWorkspace.xmlSaveModel = Startup.instance.ruleDB;
  1293. documentWorkspace.InitRulerInfo();
  1294. }
  1295. this.appWorkspace.ActiveDocumentWorkspace = documentWorkspace;
  1296. }
  1297. else if (info.Item.Text.IndexOf(".xlsx") > 0 || info.Item.Text.IndexOf(".docx") > 0
  1298. || info.Item.Text.IndexOf(".xls") > 0 || info.Item.Text.IndexOf(".doc") > 0)
  1299. {
  1300. if (!OfficeFileHandleHelper.OpenOfficeFile(path + "\\" + info.Item.Text))
  1301. MessageBox.Show(PdnResources.GetString("Menu.Fileopenfailed.Text"));
  1302. }
  1303. //MessageBox.Show(info.Item.Text);
  1304. }
  1305. }
  1306. catch(Exception)
  1307. {
  1308. }
  1309. }
  1310. /// <summary>
  1311. /// 将要展开节点时的事件
  1312. /// </summary>
  1313. /// <param name="sender"></param>
  1314. /// <param name="e"></param>
  1315. private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
  1316. {
  1317. //如果不是顶级节点
  1318. if(e.Node.Parent != null)
  1319. {
  1320. if(e.Node.Nodes.Count==1)
  1321. {
  1322. if(((NodeInfo)e.Node.Tag).rootType == 1)
  1323. {
  1324. List<string> dirs = new List<string>(Directory.GetDirectories(((NodeInfo)e.Node.Tag).tag, "*", System.IO.SearchOption.TopDirectoryOnly));
  1325. foreach (var dir in dirs)
  1326. {
  1327. try
  1328. {
  1329. NodeInfo nodeInfo = new NodeInfo();
  1330. nodeInfo.rootType = ((NodeInfo)e.Node.Tag).rootType;
  1331. nodeInfo.folderType = 1;
  1332. nodeInfo.tag = dir;
  1333. TreeNode node = new TreeNode();
  1334. node.Text = Path.GetFileName(dir);
  1335. node.Tag = nodeInfo;
  1336. if (Directory.GetDirectories(dir).Length > 0)
  1337. {
  1338. TreeNode temp = new TreeNode();
  1339. temp.Text = "";
  1340. node.Nodes.Add(temp);
  1341. }
  1342. e.Node.Nodes.Add(node);
  1343. }
  1344. catch (Exception)
  1345. {
  1346. }
  1347. }
  1348. }
  1349. else if (((NodeInfo)e.Node.Tag).rootType == 2 || ((NodeInfo)e.Node.Tag).rootType == 3)
  1350. {
  1351. //从数据库读取下级
  1352. List<mic_project> list = mic_project_BLL.FindAllByParentId(((NodeInfo)e.Node.Tag).id);
  1353. if(list!=null && list.Count>0)
  1354. {
  1355. foreach (mic_project p in list)
  1356. {
  1357. int folderType = (p.project_type == 4)? 2 : 1;
  1358. e.Node.Nodes.Add(this.AddProjectTreeNode(folderType, ((NodeInfo)e.Node.Tag).rootType, p.project_path, p));
  1359. }
  1360. }
  1361. }
  1362. e.Node.Nodes.RemoveAt(0);
  1363. }
  1364. }
  1365. }
  1366. /// <summary>
  1367. /// 绘制节点事件
  1368. /// </summary>
  1369. /// <param name="sender"></param>
  1370. /// <param name="e"></param>
  1371. private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
  1372. {
  1373. if ((e.State & TreeNodeStates.Selected) != 0)
  1374. {
  1375. //绿底白字
  1376. e.Graphics.FillRectangle(Brushes.Green, e.Node.Bounds);
  1377. Font nodeFont = e.Node.NodeFont;
  1378. if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
  1379. e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0));
  1380. }
  1381. else
  1382. {
  1383. e.DrawDefault = true;
  1384. }
  1385. if ((e.State & TreeNodeStates.Focused) != 0)
  1386. {
  1387. using (Pen focusPen = new Pen(Color.Black))
  1388. {
  1389. focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  1390. Rectangle focusBounds = e.Node.Bounds;
  1391. focusBounds.Size = new System.Drawing.Size(focusBounds.Width - 1,
  1392. focusBounds.Height - 1);
  1393. e.Graphics.DrawRectangle(focusPen, focusBounds);
  1394. }
  1395. }
  1396. }
  1397. /// <summary>
  1398. /// 添加到工程
  1399. /// </summary>
  1400. public void AddToProject()
  1401. {
  1402. if(((NodeInfo)this.treeView1.SelectedNode.Tag).tag==null || ((NodeInfo)this.treeView1.SelectedNode.Tag).tag.Equals(""))
  1403. {
  1404. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text") + PdnResources.GetString("Menu.Set.Generalsettings.Thearchivefilesavesthepath.text"));
  1405. return;
  1406. }
  1407. //如果选择的节点是常规操作,选择什么路径就存储到什么路径
  1408. if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1)
  1409. {
  1410. this.saveBitmapToFolder();
  1411. //刷新节点
  1412. this.listView1.Items.Clear();
  1413. this.imageList1.Images.Clear();
  1414. this.showFileList(this.treeView1.SelectedNode.Tag);
  1415. }
  1416. //如果选择的节点是通用分析、专用分析
  1417. else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 2 || ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 3)
  1418. {
  1419. if (this.treeView1.SelectedNode.Parent==null)
  1420. {
  1421. MessageBox.Show(PdnResources.GetString("Menu.selewhichcannotbetoredintheroot.Text"));
  1422. }
  1423. else
  1424. {
  1425. if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType==3)
  1426. {
  1427. MessageBox.Show(PdnResources.GetString("Menu.selectanothernodewhtbestoredinhestan.Text"));
  1428. }
  1429. else
  1430. {
  1431. this.saveBitmapToFolder();
  1432. //刷新节点
  1433. this.listView1.Items.Clear();
  1434. this.imageList1.Images.Clear();
  1435. this.showFileList(this.treeView1.SelectedNode.Tag);
  1436. }
  1437. }
  1438. }
  1439. //如果选择的节点是搜索结果,则提示用户,不能添加到这里
  1440. else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 4)
  1441. {
  1442. MessageBox.Show(PdnResources.GetString("Menu.dwhichcannotbestoredinthesearchresu.Text"));
  1443. }
  1444. }
  1445. private void saveBitmapToFolder()
  1446. {
  1447. if (this.appWorkspace.ActiveDocumentWorkspace == null)
  1448. return;
  1449. using (Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap())
  1450. {
  1451. //获取文件后缀名
  1452. string extension = Path.GetExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName());
  1453. //获取不带后缀的文件名
  1454. string noExtension = Path.GetFileNameWithoutExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName());
  1455. using (Bitmap dstBitmap = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), bitmap.PixelFormat))
  1456. {
  1457. //保存图片
  1458. ImageCodecInfo icf = GdiPlusFileType.GetImageCodecInfo(ImageFormat.Jpeg);
  1459. if (extension.Equals(".jpg"))
  1460. {
  1461. icf = GdiPlusFileType.GetImageCodecInfo(ImageFormat.Jpeg);
  1462. }
  1463. else if (extension.Equals(".bmp"))
  1464. {
  1465. icf = GdiPlusFileType.GetImageCodecInfo(ImageFormat.Bmp);
  1466. }
  1467. else if (extension.Equals(".tiff"))
  1468. {
  1469. icf = GdiPlusFileType.GetImageCodecInfo(ImageFormat.Tiff);
  1470. }
  1471. EncoderParameters parms = new EncoderParameters(1);
  1472. EncoderParameter parm = new EncoderParameter(Encoder.Quality, 100L);
  1473. parms.Param[0] = parm;
  1474. dstBitmap.Save(((NodeInfo)this.treeView1.SelectedNode.Tag).tag +"\\"+ this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName(), icf, parms);
  1475. //组织配置文件的数据
  1476. PicConfigModel picConfigModel = new PicConfigModel();
  1477. picConfigModel.rule = new PicConfigModel.Rule();
  1478. if (this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel != null && this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length != 0)
  1479. {
  1480. picConfigModel.rule.ruler_name = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_name;
  1481. picConfigModel.rule.gain_multiple = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.gain_multiple;
  1482. picConfigModel.rule.pixel_length = (int)this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length;
  1483. picConfigModel.rule.physical_length = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.physical_length;
  1484. picConfigModel.rule.ruler_units = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_units;
  1485. }
  1486. //按路径和名称保存xml文件
  1487. string userInfoXml = XmlSerializeHelper.XmlSerialize<PicConfigModel>(picConfigModel);
  1488. //xml保存路径
  1489. string filePath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + noExtension + ".xml";
  1490. //保存xml
  1491. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create);
  1492. }
  1493. }
  1494. }
  1495. /// <summary>
  1496. /// 添加文件夹类型的node节点
  1497. /// </summary>
  1498. /// <param name="rootType"></param>
  1499. /// <param name="dir"></param>
  1500. /// <returns></returns>
  1501. private TreeNode AddFolderTreeNode(int rootType, string dir, int id)
  1502. {
  1503. NodeInfo info = new NodeInfo();
  1504. info.rootType = rootType;
  1505. info.folderType = 1;
  1506. info.tag = dir;
  1507. info.id = id;
  1508. TreeNode node = new TreeNode();
  1509. node.Text = Path.GetFileName(dir);
  1510. node.Tag = info;
  1511. if (Directory.GetDirectories(dir).Length > 0)
  1512. {
  1513. TreeNode temp = new TreeNode();
  1514. temp.Text = "";
  1515. node.Nodes.Add(temp);
  1516. }
  1517. return node;
  1518. }
  1519. private void ProjectEngineering_FormClosing(object sender, FormClosingEventArgs e)
  1520. {
  1521. this.appWorkspace.toolBar.RefreshBtnSelect(false, "OpenProject");
  1522. this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "OpenProject");
  1523. }
  1524. /// <summary>
  1525. /// 添加项目类型的node节点
  1526. /// </summary>
  1527. /// <param name="rootType"></param>
  1528. /// <param name="dir"></param>
  1529. /// <returns></returns>
  1530. private TreeNode AddProjectTreeNode(int folderType, int rootType, string path, mic_project mic_Project)
  1531. {
  1532. NodeInfo info = new NodeInfo();
  1533. info.rootType = rootType;
  1534. info.folderType = folderType;
  1535. info.tag = path;
  1536. info.id = mic_Project.id;
  1537. TreeNode node = new TreeNode();
  1538. if (mic_Project.project_path == null)
  1539. {
  1540. node.Text = PdnResources.GetString(mic_Project.project_name);
  1541. }
  1542. else
  1543. {
  1544. node.Text = mic_Project.project_name;
  1545. }
  1546. node.Tag = info;
  1547. if (folderType==3 && !System.IO.Directory.Exists(path))
  1548. System.IO.Directory.CreateDirectory(path);
  1549. //这里应该判断是否再数据库中有下级
  1550. if(mic_project_BLL.FindCountByParentId(mic_Project.id)>0)
  1551. //if (Directory.GetDirectories(path).Length > 0)
  1552. {
  1553. TreeNode temp = new TreeNode();
  1554. temp.Text = "";
  1555. node.Nodes.Add(temp);
  1556. }
  1557. return node;
  1558. }
  1559. /// <summary>
  1560. /// 获取存储路径
  1561. /// </summary>
  1562. /// <param name="type">1通用分析 2专用分析</param>
  1563. /// <param name="analysis">分析的名称</param>
  1564. /// <returns></returns>
  1565. public NodeItem GetProjectPath(int type, string analysis, string originPath)
  1566. {
  1567. // TODO ZYH 这里数据库内应该存储多语言的key,创建的文件夹也应该是相应位置
  1568. //获取数据库信息
  1569. string languagePath = PdnResources.GetString(analysis);
  1570. if (string.IsNullOrEmpty(languagePath)) return null;
  1571. mic_project mic_Project = mic_project_BLL.FindItenByNameAndPath(Path.GetFileName(originPath), originPath);
  1572. if (mic_Project == null)
  1573. {
  1574. MessageBox.Show("项目目录不存在,请检查!");
  1575. return null;
  1576. }
  1577. //创建一个编号
  1578. int num = Startup.instance.configModel.ProjectCodeNum;
  1579. int addNum = 1000000 + num;
  1580. string code = "P" + addNum;
  1581. //获取路径
  1582. //string parentPath = "";
  1583. //if (type == 1) parentPath = GeneralAnalysisPath;
  1584. //if (type == 2) parentPath = DedicatedAnalysisPath;
  1585. //创建相应文件夹
  1586. //string path = parentPath + "\\" + PdnResources.GetString(analysis) + "\\" + code;
  1587. string path = originPath + "\\" + code;
  1588. if (!System.IO.Directory.Exists(path))
  1589. {
  1590. System.IO.Directory.CreateDirectory(path);
  1591. }
  1592. //更新配置文件编号+1
  1593. Startup.instance.configModel.ProjectCodeNum += 1;
  1594. string configXml = XmlSerializeHelper.XmlSerialize<ConfigModel>(Startup.instance.configModel);
  1595. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml";
  1596. FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create);
  1597. NodeItem info = new NodeItem();
  1598. info.path = path;
  1599. info.code = code;
  1600. info.parentId = mic_Project.id;
  1601. return info;
  1602. }
  1603. /// <summary>
  1604. /// 通用专用分析,插入到数据库,添加节点
  1605. /// </summary>
  1606. /// <param name="analyzeSettingModel">分析的model</param>
  1607. /// <param name="folder">项目编号</param>
  1608. public void InsertIntoDB(AnalyzeSettingModel analyzeSettingModel, NodeItem item)
  1609. {
  1610. //添加目录主表
  1611. mic_project mic_Project = new mic_project();
  1612. mic_Project.parent_id = item.parentId;
  1613. mic_Project.project_name = item.code;
  1614. mic_Project.project_path = item.path;
  1615. mic_Project.project_type = 4;
  1616. mic_project_BLL.Add(mic_Project);
  1617. //添加项目主表
  1618. mic_project_info mic_Project_Info = new mic_project_info();
  1619. mic_Project_Info.project_code = item.code;
  1620. mic_Project_Info.project_company = analyzeSettingModel.inspectionDepartment;
  1621. mic_Project_Info.project_contact = analyzeSettingModel.contact;
  1622. mic_Project_Info.project_date = analyzeSettingModel.inspectionDate;
  1623. mic_Project_Info.project_id = mic_Project.id;
  1624. mic_Project_Info.project_rating = analyzeSettingModel.ratingDate;
  1625. mic_Project_Info.project_sender = analyzeSettingModel.inspectionPerson;
  1626. mic_project_info_BLL.Add(mic_Project_Info);
  1627. //添加项目子表
  1628. if (analyzeSettingModel.otherList!=null && analyzeSettingModel.otherList.Count>0)
  1629. {
  1630. foreach (OthersInfo othersInfo in analyzeSettingModel.otherList)
  1631. {
  1632. mic_project_info_item s = new mic_project_info_item();
  1633. s.info_id = mic_Project_Info.id;
  1634. s.item_key = othersInfo.name;
  1635. s.item_value = othersInfo.content;
  1636. mic_project_info_item_BLL.Add(s);
  1637. }
  1638. }
  1639. }
  1640. }
  1641. }