MeasureListSettingDialog.cs 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. using PaintDotNet.Base.Functionodel;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.CustomControl;
  4. using PaintDotNet.DbOpreate.DbBll;
  5. using PaintDotNet.DbOpreate.DbModel;
  6. using PaintDotNet.Base.SettingModel;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using System.Windows.Forms;
  18. using static PaintDotNet.Base.Functionodel.AnalyzeSettingModel;
  19. using APIDialogs = Microsoft.WindowsAPICodePack.Dialogs;
  20. using System.Drawing.Imaging;
  21. using System.Runtime.Serialization.Formatters.Binary;
  22. using OpenCvSharp.Extensions;
  23. namespace PaintDotNet
  24. {
  25. /// <summary>
  26. /// 通用分析模板设置页
  27. /// </summary>
  28. internal class MeasureListSettingDialog : PdnBaseForm
  29. {
  30. #region 控件
  31. private GroupBox groupBox1;
  32. private Button button2;
  33. private Button button1;
  34. private GroupBox groupBox2;
  35. private ComboBox comboBox1;
  36. private Label label3;
  37. private Label label2;
  38. private Label label1;
  39. private GroupBox groupBox3;
  40. private GroupBox groupBox4;
  41. private GroupBox groupBox5;
  42. private Button button3;
  43. private TextBox textBox1;
  44. private Label label6;
  45. private Label label5;
  46. private Label label4;
  47. private TextBox textBox2;
  48. private Label label8;
  49. private Label label7;
  50. private Label label12;
  51. private TextBox textBox6;
  52. private Label label11;
  53. private TextBox textBox5;
  54. private Label label10;
  55. private TextBox textBox4;
  56. private Label label9;
  57. private DataGridView dataGridView1;
  58. private TextBox textBox9;
  59. private Label label14;
  60. private TextBox textBox8;
  61. private Label label13;
  62. private Button button4;
  63. private DateTimePicker dateTimePicker1;
  64. private DateTimePicker dateTimePicker2;
  65. private GroupBox groupBox6;
  66. private Button button5;
  67. #endregion
  68. /// <summary>
  69. /// 数据库对应字段
  70. /// </summary>
  71. private string languageName;
  72. /// <summary>
  73. /// 数据库对应list
  74. /// </summary>
  75. private List<mic_template_infos> infosList;
  76. /// <summary>
  77. /// 功能路径名称,因需递归作为全局对象
  78. /// </summary>
  79. private string functionPathMsg;
  80. /// <summary>
  81. /// 分类名称,主要供书签使用
  82. /// </summary>
  83. private string analyzeClassify;
  84. /// <summary>
  85. /// 调用当前窗口的对象
  86. /// </summary>
  87. private PdnBaseForm pdnBaseForm;
  88. /// <summary>
  89. /// 在打开窗体时辅助判断是否存在报告模板文件
  90. /// </summary>
  91. public bool hasModule = false;
  92. /// <summary>
  93. /// xml对应文件路径
  94. /// </summary>
  95. private string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\" + "AnalyzeSavedModel.xml";
  96. /// <summary>
  97. /// xml对象
  98. /// </summary>
  99. private AnalyzeSavedModel analyzeSavedModel;
  100. /// <summary>
  101. /// 当前分析分类的数据
  102. /// </summary>
  103. private AnalyzeSavedModel.ModelItem analyzeModel;
  104. /// <summary>
  105. /// 主控件
  106. /// </summary>
  107. private AppWorkspace appWorkspace;
  108. /// <summary>
  109. /// 导出数据
  110. /// </summary>
  111. private DataTable dataTable;
  112. public MeasureListSettingDialog(PdnBaseForm form, string languageName, AppWorkspace appWorkspace, DataTable dataTable)
  113. {
  114. this.languageName = languageName;
  115. this.pdnBaseForm = form;
  116. this.appWorkspace = appWorkspace;
  117. this.dataTable = dataTable;
  118. infosList = mic_template_infos_BLL.FindAll();//查询出所有模板分类对象
  119. InitializeComponent();
  120. InitializeLanguageText();
  121. InitGridHeader();
  122. InitOtherInfo();
  123. InitLastTimeInfo();
  124. if (this.languageName.Equals("Template.Manager.item1.MeasureListAll"))
  125. {
  126. this.groupBox4.Visible = false;
  127. this.groupBox5.Visible = false;
  128. this.groupBox6.Visible = false;
  129. this.button5.Visible = false;
  130. this.Height = 279;
  131. }
  132. else
  133. {
  134. this.groupBox4.Visible = true;
  135. this.groupBox5.Visible = true;
  136. this.groupBox6.Visible = true;
  137. this.button5.Visible = true;
  138. this.Height = 670;
  139. }
  140. if (this.languageName == "Template.Manager.item2.AtlasComparison")
  141. this.button5.Enabled = false;
  142. }
  143. #region 初始化
  144. private void InitializeLanguageText()
  145. {
  146. this.button5.Text = PdnResources.GetString("Menu.Configurehebookmark.Text");
  147. this.label3.Text = PdnResources.GetString("Menu.Pleaseselectthetemplateyoucanuse.Text") + ":";
  148. this.label2.Text = PdnResources.GetString("Menu.nothing.Text");
  149. this.label1.Text = PdnResources.GetString("Menu.Thefunctionpath.Text") + ":";
  150. this.groupBox3.Text = PdnResources.GetString("Menu.Itemstoragepathselection.Text");
  151. this.label6.Text = PdnResources.GetString("Menu.nothing.Text");
  152. this.label5.Text = PdnResources.GetString("Menu.Thespecificpath.Text") + ":";
  153. this.label4.Text = PdnResources.GetString("Menu.Storagepath.Text") + ":";
  154. this.groupBox4.Text = PdnResources.GetString("Menu.thebasicinformationofproject.text");
  155. this.label8.Text = PdnResources.GetString("Menu.projectnumber.text") + ":";
  156. this.label7.Text = PdnResources.GetString("Menu.Ratingdate.text") + ":";
  157. this.groupBox5.Text = PdnResources.GetString("Menu.Ratingdate.text");
  158. this.label12.Text = PdnResources.GetString("Menu.Inspectiondate.text") + ":";
  159. this.label11.Text = PdnResources.GetString("Menu.Contactperson.text") + ":";
  160. this.label10.Text = PdnResources.GetString("Menu.inspectiondepartment.text") + ":";
  161. this.label9.Text = PdnResources.GetString("Menu.Sender.text") + ":";
  162. this.groupBox6.Text = PdnResources.GetString("Menu.other.text");
  163. this.label14.Text = PdnResources.GetString("Menu.name.text") + ":";
  164. this.label13.Text = PdnResources.GetString("Menu.content.text") + ":";
  165. this.button4.Text = PdnResources.GetString("Menu.Addto.text");
  166. this.Text = PdnResources.GetString("Menu.Analysisofsetting.Text");
  167. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  168. if (this.languageName.Equals("Template.Manager.item1.MeasureListAll"))
  169. this.button2.Text = PdnResources.GetString("Menu.Exportresults.text");
  170. else
  171. this.button2.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  172. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  173. this.groupBox2.Text = PdnResources.GetString("Menu.Reporttemplateselection.Text");
  174. }
  175. private void InitializeComponent()
  176. {
  177. this.groupBox1 = new System.Windows.Forms.GroupBox();
  178. this.button2 = new System.Windows.Forms.Button();
  179. this.button1 = new System.Windows.Forms.Button();
  180. this.groupBox2 = new System.Windows.Forms.GroupBox();
  181. this.button5 = new System.Windows.Forms.Button();
  182. this.comboBox1 = new System.Windows.Forms.ComboBox();
  183. this.label3 = new System.Windows.Forms.Label();
  184. this.label2 = new System.Windows.Forms.Label();
  185. this.label1 = new System.Windows.Forms.Label();
  186. this.groupBox3 = new System.Windows.Forms.GroupBox();
  187. this.button3 = new System.Windows.Forms.Button();
  188. this.textBox1 = new System.Windows.Forms.TextBox();
  189. this.label6 = new System.Windows.Forms.Label();
  190. this.label5 = new System.Windows.Forms.Label();
  191. this.label4 = new System.Windows.Forms.Label();
  192. this.groupBox4 = new System.Windows.Forms.GroupBox();
  193. this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
  194. this.textBox2 = new System.Windows.Forms.TextBox();
  195. this.label8 = new System.Windows.Forms.Label();
  196. this.label7 = new System.Windows.Forms.Label();
  197. this.groupBox5 = new System.Windows.Forms.GroupBox();
  198. this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
  199. this.label12 = new System.Windows.Forms.Label();
  200. this.textBox6 = new System.Windows.Forms.TextBox();
  201. this.label11 = new System.Windows.Forms.Label();
  202. this.textBox5 = new System.Windows.Forms.TextBox();
  203. this.label10 = new System.Windows.Forms.Label();
  204. this.textBox4 = new System.Windows.Forms.TextBox();
  205. this.label9 = new System.Windows.Forms.Label();
  206. this.groupBox6 = new System.Windows.Forms.GroupBox();
  207. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  208. this.textBox9 = new System.Windows.Forms.TextBox();
  209. this.label14 = new System.Windows.Forms.Label();
  210. this.textBox8 = new System.Windows.Forms.TextBox();
  211. this.label13 = new System.Windows.Forms.Label();
  212. this.button4 = new System.Windows.Forms.Button();
  213. this.groupBox1.SuspendLayout();
  214. this.groupBox2.SuspendLayout();
  215. this.groupBox3.SuspendLayout();
  216. this.groupBox4.SuspendLayout();
  217. this.groupBox5.SuspendLayout();
  218. this.groupBox6.SuspendLayout();
  219. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  220. this.SuspendLayout();
  221. //
  222. // groupBox1
  223. //
  224. this.groupBox1.Controls.Add(this.button2);
  225. this.groupBox1.Controls.Add(this.button1);
  226. this.groupBox1.Location = new System.Drawing.Point(12, 4);
  227. this.groupBox1.Name = "groupBox1";
  228. this.groupBox1.Size = new System.Drawing.Size(542, 49);
  229. this.groupBox1.TabIndex = 0;
  230. this.groupBox1.TabStop = false;
  231. this.groupBox1.Text = "操作";
  232. //
  233. // button2
  234. //
  235. this.button2.BackColor = System.Drawing.SystemColors.Control;
  236. this.button2.Location = new System.Drawing.Point(416, 12);
  237. this.button2.Name = "button2";
  238. this.button2.Size = new System.Drawing.Size(111, 30);
  239. this.button2.TabIndex = 1;
  240. this.button2.Text = "生成报告";
  241. this.button2.UseVisualStyleBackColor = false;
  242. this.button2.Click += new System.EventHandler(this.button2_Click);
  243. //
  244. // button1
  245. //
  246. this.button1.BackColor = System.Drawing.SystemColors.Control;
  247. this.button1.Location = new System.Drawing.Point(334, 12);
  248. this.button1.Name = "button1";
  249. this.button1.Size = new System.Drawing.Size(76, 30);
  250. this.button1.TabIndex = 0;
  251. this.button1.Text = "关闭";
  252. this.button1.UseVisualStyleBackColor = false;
  253. this.button1.Click += new System.EventHandler(this.button1_Click);
  254. //
  255. // groupBox2
  256. //
  257. this.groupBox2.Controls.Add(this.button5);
  258. this.groupBox2.Controls.Add(this.comboBox1);
  259. this.groupBox2.Controls.Add(this.label3);
  260. this.groupBox2.Controls.Add(this.label2);
  261. this.groupBox2.Controls.Add(this.label1);
  262. this.groupBox2.Location = new System.Drawing.Point(12, 56);
  263. this.groupBox2.Name = "groupBox2";
  264. this.groupBox2.Size = new System.Drawing.Size(542, 90);
  265. this.groupBox2.TabIndex = 1;
  266. this.groupBox2.TabStop = false;
  267. this.groupBox2.Text = "报告模板选择";
  268. //
  269. // button5
  270. //
  271. this.button5.Location = new System.Drawing.Point(467, 57);
  272. this.button5.Name = "button5";
  273. this.button5.Size = new System.Drawing.Size(65, 20);
  274. this.button5.TabIndex = 4;
  275. this.button5.Text = "配置书签";
  276. this.button5.UseVisualStyleBackColor = true;
  277. this.button5.Click += new System.EventHandler(this.button5_Click);
  278. //
  279. // comboBox1
  280. //
  281. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  282. this.comboBox1.FormattingEnabled = true;
  283. this.comboBox1.Location = new System.Drawing.Point(163, 56);
  284. this.comboBox1.Name = "comboBox1";
  285. this.comboBox1.Size = new System.Drawing.Size(298, 20);
  286. this.comboBox1.TabIndex = 3;
  287. //
  288. // label3
  289. //
  290. this.label3.AutoSize = true;
  291. this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
  292. this.label3.Location = new System.Drawing.Point(17, 61);
  293. this.label3.Name = "label3";
  294. this.label3.Size = new System.Drawing.Size(125, 12);
  295. this.label3.TabIndex = 2;
  296. this.label3.Text = "请选择可使用的模板:";
  297. //
  298. // label2
  299. //
  300. this.label2.AutoSize = true;
  301. this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
  302. this.label2.Location = new System.Drawing.Point(163, 26);
  303. this.label2.Name = "label2";
  304. this.label2.Size = new System.Drawing.Size(107, 12);
  305. this.label2.TabIndex = 1;
  306. this.label2.Text = "通用分析-多相含量";
  307. //
  308. // label1
  309. //
  310. this.label1.AutoSize = true;
  311. this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
  312. this.label1.Location = new System.Drawing.Point(17, 26);
  313. this.label1.Name = "label1";
  314. this.label1.Size = new System.Drawing.Size(65, 12);
  315. this.label1.TabIndex = 0;
  316. this.label1.Text = "功能路径:";
  317. //
  318. // groupBox3
  319. //
  320. this.groupBox3.Controls.Add(this.button3);
  321. this.groupBox3.Controls.Add(this.textBox1);
  322. this.groupBox3.Controls.Add(this.label6);
  323. this.groupBox3.Controls.Add(this.label5);
  324. this.groupBox3.Controls.Add(this.label4);
  325. this.groupBox3.Location = new System.Drawing.Point(12, 162);
  326. this.groupBox3.Name = "groupBox3";
  327. this.groupBox3.Size = new System.Drawing.Size(542, 77);
  328. this.groupBox3.TabIndex = 1;
  329. this.groupBox3.TabStop = false;
  330. this.groupBox3.Text = "项目储存路径选择";
  331. //
  332. // button3
  333. //
  334. this.button3.BackColor = System.Drawing.SystemColors.Window;
  335. this.button3.Font = new System.Drawing.Font("宋体", 6F);
  336. this.button3.Location = new System.Drawing.Point(498, 45);
  337. this.button3.Name = "button3";
  338. this.button3.Size = new System.Drawing.Size(29, 21);
  339. this.button3.TabIndex = 5;
  340. this.button3.Text = "...";
  341. this.button3.UseVisualStyleBackColor = false;
  342. this.button3.Click += new System.EventHandler(this.button3_Click);
  343. //
  344. // textBox1
  345. //
  346. this.textBox1.Location = new System.Drawing.Point(103, 45);
  347. this.textBox1.Name = "textBox1";
  348. this.textBox1.ReadOnly = true;
  349. this.textBox1.Size = new System.Drawing.Size(400, 21);
  350. this.textBox1.TabIndex = 4;
  351. //
  352. // label6
  353. //
  354. this.label6.AutoSize = true;
  355. this.label6.ForeColor = System.Drawing.SystemColors.ControlText;
  356. this.label6.Location = new System.Drawing.Point(101, 25);
  357. this.label6.Name = "label6";
  358. this.label6.Size = new System.Drawing.Size(0, 12);
  359. this.label6.TabIndex = 3;
  360. //
  361. // label5
  362. //
  363. this.label5.AutoSize = true;
  364. this.label5.ForeColor = System.Drawing.SystemColors.ControlText;
  365. this.label5.Location = new System.Drawing.Point(18, 51);
  366. this.label5.Name = "label5";
  367. this.label5.Size = new System.Drawing.Size(65, 12);
  368. this.label5.TabIndex = 2;
  369. this.label5.Text = "具体路径:";
  370. //
  371. // label4
  372. //
  373. this.label4.AutoSize = true;
  374. this.label4.ForeColor = System.Drawing.SystemColors.ControlText;
  375. this.label4.Location = new System.Drawing.Point(18, 25);
  376. this.label4.Name = "label4";
  377. this.label4.Size = new System.Drawing.Size(65, 12);
  378. this.label4.TabIndex = 1;
  379. this.label4.Text = "储存路径:";
  380. //
  381. // groupBox4
  382. //
  383. this.groupBox4.Controls.Add(this.dateTimePicker1);
  384. this.groupBox4.Controls.Add(this.textBox2);
  385. this.groupBox4.Controls.Add(this.label8);
  386. this.groupBox4.Controls.Add(this.label7);
  387. this.groupBox4.Location = new System.Drawing.Point(12, 240);
  388. this.groupBox4.Name = "groupBox4";
  389. this.groupBox4.Size = new System.Drawing.Size(542, 60);
  390. this.groupBox4.TabIndex = 1;
  391. this.groupBox4.TabStop = false;
  392. this.groupBox4.Text = "项目基本信息";
  393. //
  394. // dateTimePicker1
  395. //
  396. this.dateTimePicker1.Location = new System.Drawing.Point(346, 24);
  397. this.dateTimePicker1.Name = "dateTimePicker1";
  398. this.dateTimePicker1.Size = new System.Drawing.Size(165, 21);
  399. this.dateTimePicker1.TabIndex = 6;
  400. //
  401. // textBox2
  402. //
  403. this.textBox2.Location = new System.Drawing.Point(92, 24);
  404. this.textBox2.Name = "textBox2";
  405. this.textBox2.Size = new System.Drawing.Size(165, 21);
  406. this.textBox2.TabIndex = 5;
  407. //
  408. // label8
  409. //
  410. this.label8.AutoSize = true;
  411. this.label8.ForeColor = System.Drawing.SystemColors.ControlText;
  412. this.label8.Location = new System.Drawing.Point(18, 28);
  413. this.label8.Name = "label8";
  414. this.label8.Size = new System.Drawing.Size(65, 12);
  415. this.label8.TabIndex = 4;
  416. this.label8.Text = "项目编号:";
  417. //
  418. // label7
  419. //
  420. this.label7.AutoSize = true;
  421. this.label7.ForeColor = System.Drawing.SystemColors.ControlText;
  422. this.label7.Location = new System.Drawing.Point(283, 28);
  423. this.label7.Name = "label7";
  424. this.label7.Size = new System.Drawing.Size(65, 12);
  425. this.label7.TabIndex = 3;
  426. this.label7.Text = "评级日期:";
  427. //
  428. // groupBox5
  429. //
  430. this.groupBox5.Controls.Add(this.dateTimePicker2);
  431. this.groupBox5.Controls.Add(this.label12);
  432. this.groupBox5.Controls.Add(this.textBox6);
  433. this.groupBox5.Controls.Add(this.label11);
  434. this.groupBox5.Controls.Add(this.textBox5);
  435. this.groupBox5.Controls.Add(this.label10);
  436. this.groupBox5.Controls.Add(this.textBox4);
  437. this.groupBox5.Controls.Add(this.label9);
  438. this.groupBox5.Location = new System.Drawing.Point(12, 301);
  439. this.groupBox5.Name = "groupBox5";
  440. this.groupBox5.Size = new System.Drawing.Size(542, 90);
  441. this.groupBox5.TabIndex = 1;
  442. this.groupBox5.TabStop = false;
  443. this.groupBox5.Text = "评级日期";
  444. //
  445. // dateTimePicker2
  446. //
  447. this.dateTimePicker2.Location = new System.Drawing.Point(346, 58);
  448. this.dateTimePicker2.Name = "dateTimePicker2";
  449. this.dateTimePicker2.Size = new System.Drawing.Size(165, 21);
  450. this.dateTimePicker2.TabIndex = 14;
  451. //
  452. // label12
  453. //
  454. this.label12.AutoSize = true;
  455. this.label12.ForeColor = System.Drawing.SystemColors.ControlText;
  456. this.label12.Location = new System.Drawing.Point(283, 62);
  457. this.label12.Name = "label12";
  458. this.label12.Size = new System.Drawing.Size(53, 12);
  459. this.label12.TabIndex = 13;
  460. this.label12.Text = "送检日期";
  461. //
  462. // textBox6
  463. //
  464. this.textBox6.Location = new System.Drawing.Point(346, 23);
  465. this.textBox6.Name = "textBox6";
  466. this.textBox6.Size = new System.Drawing.Size(165, 21);
  467. this.textBox6.TabIndex = 12;
  468. //
  469. // label11
  470. //
  471. this.label11.AutoSize = true;
  472. this.label11.ForeColor = System.Drawing.SystemColors.ControlText;
  473. this.label11.Location = new System.Drawing.Point(283, 28);
  474. this.label11.Name = "label11";
  475. this.label11.Size = new System.Drawing.Size(53, 12);
  476. this.label11.TabIndex = 11;
  477. this.label11.Text = "联系人:";
  478. //
  479. // textBox5
  480. //
  481. this.textBox5.Location = new System.Drawing.Point(92, 58);
  482. this.textBox5.Name = "textBox5";
  483. this.textBox5.Size = new System.Drawing.Size(165, 21);
  484. this.textBox5.TabIndex = 10;
  485. //
  486. // label10
  487. //
  488. this.label10.AutoSize = true;
  489. this.label10.ForeColor = System.Drawing.SystemColors.ControlText;
  490. this.label10.Location = new System.Drawing.Point(18, 62);
  491. this.label10.Name = "label10";
  492. this.label10.Size = new System.Drawing.Size(65, 12);
  493. this.label10.TabIndex = 9;
  494. this.label10.Text = "送检单位:";
  495. //
  496. // textBox4
  497. //
  498. this.textBox4.Location = new System.Drawing.Point(92, 23);
  499. this.textBox4.Name = "textBox4";
  500. this.textBox4.Size = new System.Drawing.Size(165, 21);
  501. this.textBox4.TabIndex = 8;
  502. //
  503. // label9
  504. //
  505. this.label9.AutoSize = true;
  506. this.label9.ForeColor = System.Drawing.SystemColors.ControlText;
  507. this.label9.Location = new System.Drawing.Point(18, 28);
  508. this.label9.Name = "label9";
  509. this.label9.Size = new System.Drawing.Size(53, 12);
  510. this.label9.TabIndex = 7;
  511. this.label9.Text = "送检人:";
  512. //
  513. // groupBox6
  514. //
  515. this.groupBox6.Controls.Add(this.dataGridView1);
  516. this.groupBox6.Controls.Add(this.textBox9);
  517. this.groupBox6.Controls.Add(this.label14);
  518. this.groupBox6.Controls.Add(this.textBox8);
  519. this.groupBox6.Controls.Add(this.label13);
  520. this.groupBox6.Controls.Add(this.button4);
  521. this.groupBox6.Location = new System.Drawing.Point(12, 393);
  522. this.groupBox6.Name = "groupBox6";
  523. this.groupBox6.Size = new System.Drawing.Size(542, 226);
  524. this.groupBox6.TabIndex = 1;
  525. this.groupBox6.TabStop = false;
  526. this.groupBox6.Text = "其他";
  527. //
  528. // dataGridView1
  529. //
  530. this.dataGridView1.AllowUserToAddRows = false;
  531. this.dataGridView1.AllowUserToDeleteRows = false;
  532. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  533. | System.Windows.Forms.AnchorStyles.Right)));
  534. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  535. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  536. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  537. this.dataGridView1.Location = new System.Drawing.Point(16, 68);
  538. this.dataGridView1.MultiSelect = false;
  539. this.dataGridView1.Name = "dataGridView1";
  540. this.dataGridView1.RowHeadersVisible = false;
  541. this.dataGridView1.RowTemplate.Height = 23;
  542. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  543. this.dataGridView1.Size = new System.Drawing.Size(511, 148);
  544. this.dataGridView1.TabIndex = 19;
  545. this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
  546. //
  547. // textBox9
  548. //
  549. this.textBox9.Location = new System.Drawing.Point(55, 30);
  550. this.textBox9.Name = "textBox9";
  551. this.textBox9.Size = new System.Drawing.Size(165, 21);
  552. this.textBox9.TabIndex = 18;
  553. //
  554. // label14
  555. //
  556. this.label14.AutoSize = true;
  557. this.label14.ForeColor = System.Drawing.SystemColors.ControlText;
  558. this.label14.Location = new System.Drawing.Point(14, 34);
  559. this.label14.Name = "label14";
  560. this.label14.Size = new System.Drawing.Size(41, 12);
  561. this.label14.TabIndex = 17;
  562. this.label14.Text = "名称:";
  563. //
  564. // textBox8
  565. //
  566. this.textBox8.Location = new System.Drawing.Point(268, 30);
  567. this.textBox8.Name = "textBox8";
  568. this.textBox8.Size = new System.Drawing.Size(165, 21);
  569. this.textBox8.TabIndex = 16;
  570. //
  571. // label13
  572. //
  573. this.label13.AutoSize = true;
  574. this.label13.ForeColor = System.Drawing.SystemColors.ControlText;
  575. this.label13.Location = new System.Drawing.Point(228, 34);
  576. this.label13.Name = "label13";
  577. this.label13.Size = new System.Drawing.Size(41, 12);
  578. this.label13.TabIndex = 15;
  579. this.label13.Text = "内容:";
  580. //
  581. // button4
  582. //
  583. this.button4.BackColor = System.Drawing.SystemColors.Control;
  584. this.button4.Location = new System.Drawing.Point(451, 25);
  585. this.button4.Name = "button4";
  586. this.button4.Size = new System.Drawing.Size(76, 30);
  587. this.button4.TabIndex = 2;
  588. this.button4.Text = "添加";
  589. this.button4.UseVisualStyleBackColor = false;
  590. this.button4.Click += new System.EventHandler(this.button4_Click);
  591. //
  592. // MeasureListSettingDialog
  593. //
  594. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  595. this.BackColor = System.Drawing.SystemColors.Control;
  596. this.ClientSize = new System.Drawing.Size(566, 631);
  597. this.Controls.Add(this.groupBox6);
  598. this.Controls.Add(this.groupBox5);
  599. this.Controls.Add(this.groupBox4);
  600. this.Controls.Add(this.groupBox3);
  601. this.Controls.Add(this.groupBox2);
  602. this.Controls.Add(this.groupBox1);
  603. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  604. this.MaximizeBox = false;
  605. this.MinimizeBox = false;
  606. this.Name = "MeasureListSettingDialog";
  607. this.Controls.SetChildIndex(this.groupBox1, 0);
  608. this.Controls.SetChildIndex(this.groupBox2, 0);
  609. this.Controls.SetChildIndex(this.groupBox3, 0);
  610. this.Controls.SetChildIndex(this.groupBox4, 0);
  611. this.Controls.SetChildIndex(this.groupBox5, 0);
  612. this.Controls.SetChildIndex(this.groupBox6, 0);
  613. this.groupBox1.ResumeLayout(false);
  614. this.groupBox2.ResumeLayout(false);
  615. this.groupBox2.PerformLayout();
  616. this.groupBox3.ResumeLayout(false);
  617. this.groupBox3.PerformLayout();
  618. this.groupBox4.ResumeLayout(false);
  619. this.groupBox4.PerformLayout();
  620. this.groupBox5.ResumeLayout(false);
  621. this.groupBox5.PerformLayout();
  622. this.groupBox6.ResumeLayout(false);
  623. this.groupBox6.PerformLayout();
  624. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  625. this.ResumeLayout(false);
  626. }
  627. /// <summary>
  628. /// 初始化表头
  629. /// </summary>
  630. private void InitGridHeader()
  631. {
  632. this.dataGridView1.ColumnHeadersHeight = 25;
  633. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  634. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  635. h1.Width = 200;
  636. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  637. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  638. h2.Width = 200;
  639. DataGridViewButtonColumn h3 = new DataGridViewButtonColumn();
  640. h3.Width = 90;
  641. this.dataGridView1.Columns.Add(h1);
  642. this.dataGridView1.Columns.Add(h2);
  643. this.dataGridView1.Columns.Add(h3);
  644. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  645. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.name.text")));
  646. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.content.text")));
  647. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.operation.text")));
  648. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  649. this.dataGridView1.Columns[0].ReadOnly = true;
  650. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  651. this.dataGridView1.Columns[1].ReadOnly = true;
  652. this.dataGridView1.AllowUserToResizeRows = false;
  653. this.dataGridView1.AllowUserToResizeColumns = false;
  654. }
  655. /// <summary>
  656. /// 初始化其他信息
  657. /// </summary>
  658. private void InitOtherInfo()
  659. {
  660. //设置功能路径名称
  661. if (this.languageName.Contains("Template.Manager"))
  662. functionPathMsg = PdnResources.GetString(this.languageName);
  663. else
  664. functionPathMsg = this.languageName;
  665. this.analyzeClassify = functionPathMsg;
  666. this.Text = this.analyzeClassify + PdnResources.GetString("Menu.Thereportisset.Text");
  667. getFullLanguagePath(this.languageName);
  668. this.label2.Text = functionPathMsg;
  669. //设置模板下拉菜单
  670. mic_template_infos infoModel = infosList.Find(a => a.language_name == this.languageName);
  671. string filePath = Application.StartupPath + "\\ModuleManage" + infoModel.template_path.Replace('/', '\\');//获取文档路径
  672. if (Directory.Exists(filePath))
  673. {
  674. string[] fileNames = Directory.GetFiles(filePath);
  675. Dictionary<string, string> moduleInfo = new Dictionary<string, string>();
  676. for (int i = 0; i < fileNames.Count(); i++)
  677. {
  678. //编辑时产生的临时文件,不统计
  679. if (Path.GetFileName(fileNames[i]).Contains("~$"))
  680. continue;
  681. if (this.languageName.Equals("Template.Manager.item1.MeasureListAll"))
  682. {
  683. //判断是excel文件
  684. if (FileOperationHelper.IsFileWordOrExcel(fileNames[i]) == 2)
  685. moduleInfo.Add(Path.GetFileNameWithoutExtension(fileNames[i]), fileNames[i]);
  686. }
  687. else
  688. {
  689. //判断是word文件
  690. if (FileOperationHelper.IsFileWordOrExcel(fileNames[i]) == 1)
  691. moduleInfo.Add(Path.GetFileNameWithoutExtension(fileNames[i]), fileNames[i]);
  692. }
  693. }
  694. //绑定下拉菜单
  695. if (moduleInfo.Count > 0)
  696. {
  697. BindingSource bs = new BindingSource();
  698. bs.DataSource = moduleInfo;
  699. this.comboBox1.DataSource = bs;
  700. this.comboBox1.ValueMember = "Value";
  701. this.comboBox1.DisplayMember = "Key";
  702. hasModule = true;
  703. }
  704. else
  705. MessageBox.Show(PdnResources.GetString("Menu.Therearenoatefirst.text"));
  706. }
  707. else
  708. MessageBox.Show(PdnResources.GetString("Menu.Therearenoatefirst.text"));
  709. //设置存储路径
  710. string[] savePathArr = infoModel.template_path.Split('/');//拆分以获取路径根目录的名称
  711. ConfigModel configModel = Startup.instance.configModel;
  712. if (savePathArr[1].Equals("Conventional"))
  713. this.label6.Text = configModel.NormalOperation;
  714. else if (savePathArr[1].Equals("Universal"))
  715. this.label6.Text = configModel.GeneralAnalysis;
  716. else if (savePathArr[1].Equals("Dedicated"))
  717. this.label6.Text = configModel.DedicatedAnalysis;
  718. else
  719. this.label6.Text = PdnResources.GetString("Menu.Pathacquisitionerror.Text");
  720. if (string.IsNullOrEmpty(this.label6.Text))
  721. this.label6.Text = PdnResources.GetString("Menu.Thestoragepathisnotset.Text");
  722. }
  723. /// <summary>
  724. /// 加载之前保存的信息
  725. /// </summary>
  726. private void InitLastTimeInfo()
  727. {
  728. if (this.hasModule && System.IO.File.Exists(filePath))
  729. {
  730. analyzeSavedModel = XmlSerializeHelper.DESerializer<AnalyzeSavedModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  731. if (analyzeSavedModel.modelItems != null && analyzeSavedModel.modelItems.Count > 0)
  732. {
  733. analyzeModel = analyzeSavedModel.modelItems.Find(a => a.languageName == this.languageName);
  734. if (analyzeModel != null && analyzeModel.analyzeSettingModel != null)
  735. {
  736. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.modulePath))
  737. this.comboBox1.SelectedValue = analyzeModel.analyzeSettingModel.modulePath;
  738. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.savePath))
  739. this.textBox1.Text = analyzeModel.analyzeSettingModel.savePath;
  740. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.itemNumber))
  741. this.textBox2.Text = analyzeModel.analyzeSettingModel.itemNumber;
  742. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.inspectionPerson))
  743. this.textBox4.Text = analyzeModel.analyzeSettingModel.inspectionPerson;
  744. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.contact))
  745. this.textBox6.Text = analyzeModel.analyzeSettingModel.contact;
  746. if (!string.IsNullOrEmpty(analyzeModel.analyzeSettingModel.inspectionDepartment))
  747. this.textBox5.Text = analyzeModel.analyzeSettingModel.inspectionDepartment;
  748. if (analyzeModel.analyzeSettingModel.inspectionDate != DateTime.MinValue)
  749. this.dateTimePicker2.Value = analyzeModel.analyzeSettingModel.inspectionDate;
  750. if (analyzeModel.analyzeSettingModel.otherList != null && analyzeModel.analyzeSettingModel.otherList.Count > 0)
  751. {
  752. foreach (OthersInfo info in analyzeModel.analyzeSettingModel.otherList)
  753. {
  754. DataGridViewRow row = new DataGridViewRow();
  755. row.Cells.Add(CreateTextBoxCell(info.name, "name"));
  756. row.Cells.Add(CreateTextBoxCell(info.content, "content"));
  757. row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
  758. this.dataGridView1.Rows.Add(row);
  759. }
  760. this.dataGridView1.ClearSelection();
  761. }
  762. }
  763. }
  764. }
  765. }
  766. #endregion
  767. /// <summary>
  768. /// 递归拼接功能路径的全称
  769. /// </summary>
  770. /// <param name="name"></param>
  771. private void getFullLanguagePath(string name)
  772. {//Template.Manager.item3.GrainSizeCutOff6394Method
  773. mic_template_infos infoModel = infosList.Find(a => a.language_name == name);
  774. //如果有上级,查询出上级的name对应的实际名称,拼接到前面,然后继续递归
  775. if (infoModel.parent_id != 0)
  776. {
  777. string parentLanguageName = infosList.Find(a => a.id == infoModel.parent_id).language_name;
  778. if (parentLanguageName.Contains("Template.Manager"))
  779. functionPathMsg = PdnResources.GetString(parentLanguageName) + "-" + functionPathMsg;
  780. else
  781. functionPathMsg = parentLanguageName + "-" + functionPathMsg;
  782. getFullLanguagePath(parentLanguageName);
  783. }
  784. }
  785. /// <summary>
  786. /// 路径选择
  787. /// </summary>
  788. /// <param name="sender"></param>
  789. /// <param name="e"></param>
  790. private void button3_Click(object sender, EventArgs e)
  791. {
  792. FolderBrowserDialog dialog = new FolderBrowserDialog();
  793. //if (!this.label6.Text.Equals("路径获取错误") && !this.label6.Text.Equals("存储路径未设置") && !this.label6.Text.Equals("无"))
  794. //{
  795. // dialog.SelectedPath = this.label6.Text + "\\" + this.analyzeClassify + "\\";
  796. //}
  797. //else
  798. //{
  799. //
  800. //}
  801. dialog.SelectedPath = this.label6.Text;
  802. if (dialog.ShowDialog() == DialogResult.OK)
  803. {
  804. this.textBox1.Text = dialog.SelectedPath;
  805. }
  806. /*APIDialogs.CommonOpenFileDialog dialog = new APIDialogs.CommonOpenFileDialog();
  807. dialog.IsFolderPicker = true;
  808. dialog.EnsurePathExists = true;
  809. if(this.label6.Text.Equals("路径获取错误") || this.label6.Text.Equals("存储路径未设置") || this.label6.Text.Equals("无"))
  810. dialog.InitialDirectory = "C:\\";
  811. else
  812. dialog.InitialDirectory = this.label6.Text;
  813. if (dialog.ShowDialog() == APIDialogs.CommonFileDialogResult.Ok)
  814. {
  815. this.textBox1.Text = dialog.FileName;
  816. }*/
  817. }
  818. /// <summary>
  819. /// 关闭按钮
  820. /// </summary>
  821. /// <param name="sender"></param>
  822. /// <param name="e"></param>
  823. private void button1_Click(object sender, EventArgs e)
  824. {
  825. this.Close();
  826. }
  827. /// <summary>
  828. /// 保存按钮
  829. /// </summary>
  830. /// <param name="sender"></param>
  831. /// <param name="e"></param>
  832. private void button2_Click(object sender, EventArgs e)
  833. {
  834. if (string.IsNullOrEmpty(this.textBox1.Text))
  835. {
  836. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaspecificstoragepath.text"));
  837. return;
  838. }
  839. if (this.comboBox1.SelectedValue == null)
  840. {
  841. MessageBox.Show(PdnResources.GetString("Menu.Therearenorecannotbesaved.text") + "!");
  842. return;
  843. }
  844. AnalyzeSettingModel model = new AnalyzeSettingModel();
  845. model.modulePath = this.comboBox1.SelectedValue.ToString();
  846. model.savePath = this.textBox1.Text;
  847. model.itemNumber = this.textBox2.Text;
  848. model.ratingDate = this.dateTimePicker1.Value;
  849. model.inspectionPerson = this.textBox4.Text;
  850. model.contact = this.textBox6.Text;
  851. model.inspectionDepartment = this.textBox5.Text;
  852. model.inspectionDate = this.dateTimePicker2.Value;
  853. model.analyzeClassify = this.analyzeClassify;
  854. if (this.dataGridView1.Rows.Count > 0)
  855. {
  856. model.otherList = new List<AnalyzeSettingModel.OthersInfo>();
  857. foreach (DataGridViewRow rowData in this.dataGridView1.Rows)
  858. {
  859. OthersInfo othersInfo = new OthersInfo();
  860. othersInfo.name = rowData.Cells[0].Value.ToString();
  861. othersInfo.content = rowData.Cells[1].Value.ToString();
  862. model.otherList.Add(othersInfo);
  863. }
  864. }
  865. if (analyzeSavedModel != null)
  866. {
  867. if (analyzeModel != null)
  868. analyzeModel.analyzeSettingModel = model;
  869. else
  870. {
  871. analyzeModel = new AnalyzeSavedModel.ModelItem();
  872. analyzeModel.languageName = this.languageName;
  873. analyzeModel.analyzeSettingModel = model;
  874. analyzeSavedModel.modelItems.Add(analyzeModel);
  875. }
  876. }
  877. else
  878. {
  879. analyzeSavedModel = new AnalyzeSavedModel();
  880. analyzeSavedModel.modelItems = new List<AnalyzeSavedModel.ModelItem>();
  881. analyzeModel = new AnalyzeSavedModel.ModelItem();
  882. analyzeModel.languageName = this.languageName;
  883. analyzeModel.analyzeSettingModel = model;
  884. analyzeSavedModel.modelItems.Add(analyzeModel);
  885. }
  886. //保存xml文件
  887. string savedModelInfo = XmlSerializeHelper.XmlSerialize<AnalyzeSavedModel>(analyzeSavedModel);
  888. if (FileOperationHelper.WriteStringToFile(savedModelInfo, filePath, FileMode.Create))
  889. {
  890. //将对象传递回调用页面
  891. this.pdnBaseForm.AnalyzeSettingModel = model;
  892. this.analyzeSettingModel = model;
  893. GeneratingReports();
  894. this.Close();
  895. }
  896. else
  897. {
  898. MessageBox.Show(PdnResources.GetString("Menu.Savefailed.text"));
  899. }
  900. }
  901. Dictionary<string, string> pNames = new Dictionary<string, string>();
  902. /// <summary>
  903. /// 保存图片到本地
  904. /// </summary>
  905. /// <param name="bitList"></param>
  906. private void SaveAllImage(List<Bitmap> bitList, string newPath, int originNum , int codeNum, string pName)
  907. {
  908. if (bitList != null && bitList.Count > 0)
  909. {
  910. for (int i = 0; i < bitList.Count; i++)
  911. {
  912. string bitPath = "";
  913. //分别为原图和处理后的图命名
  914. if (i % 2 == 0)
  915. {
  916. bitPath = newPath + "/" + "origin" + originNum + ".jpg";
  917. pNames.Add("origin" + originNum, pName);
  918. }
  919. else
  920. {
  921. bitPath = newPath + "/" + codeNum + ".jpg";
  922. pNames.Add(codeNum.ToString(), pName);
  923. }
  924. bitList[i].Save(bitPath);
  925. }
  926. }
  927. }
  928. /// <summary>
  929. /// 生成报告
  930. /// </summary>
  931. /// <param name="sender"></param>
  932. /// <param name="e"></param>
  933. private void GeneratingReports()
  934. {
  935. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  936. {
  937. //获取word书签与excel单元格的关系,以字典方式存储
  938. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  939. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  940. if (mic_module_infos != null && mic_module_infos.Count > 0)
  941. {
  942. foreach (mic_module_infos info in mic_module_infos)
  943. {
  944. tagInfos.Add(info.tag_name, info.cell_position);
  945. }
  946. }
  947. List<List<string>> analysisContent = new List<List<string>>();
  948. for (int i = 0; i < this.dataTable.Rows.Count; i++)
  949. {
  950. List<string> content1 = new List<string>();
  951. for (int c = 0; c < this.dataTable.Columns.Count; c++)
  952. {
  953. content1.Add(this.dataTable.Rows[i][c].ToString());
  954. }
  955. analysisContent.Add(content1);
  956. }
  957. if (this.languageName.Equals("Template.Manager.item1.MeasureListAll"))
  958. {
  959. int drawCount = 0;
  960. for (int i = this.appWorkspace.DocumentWorkspaces.Length - 1; i >= 0; i--)
  961. {
  962. drawCount += this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Count;
  963. }
  964. if (drawCount == 0)
  965. {
  966. MessageBox.Show("没有测量信息!");
  967. return;
  968. }
  969. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  970. System.Threading.ThreadStart copyThreadProc =
  971. delegate ()
  972. {
  973. string saveAsPath = "";
  974. if (System.IO.File.Exists(analyzeSettingModel.modulePath))
  975. {
  976. saveAsPath = analyzeSettingModel.savePath + "\\" + analyzeSettingModel.analyzeClassify //+ "分析"
  977. + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";//另存的excel文件名
  978. //如果savePath是盘符不是文件夹,会多出一个斜杠,office的saveas无法识别,固需处理一下
  979. if (saveAsPath.IndexOf("\\\\") != -1)
  980. saveAsPath = saveAsPath.Replace("\\\\", "\\");
  981. if (analysisContent != null)
  982. {
  983. try
  984. {
  985. string dictPath = Application.StartupPath + "\\temp";
  986. if(!System.IO.Directory.Exists(dictPath))
  987. {
  988. System.IO.Directory.CreateDirectory(dictPath);
  989. }
  990. DeleteFolder(dictPath);
  991. pNames = new Dictionary<string, string>();
  992. int insertIn = 0;
  993. //保存处理后的图片
  994. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  995. {
  996. if (this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Count == 0)
  997. continue;
  998. List<Bitmap> tempBit = new List<Bitmap>();
  999. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreateAliasedBitmap();
  1000. Bitmap processedBit1;
  1001. Bitmap newBit1 = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1002. if (this.appWorkspace.DocumentWorkspaces[i].PhaseModels.Count > 0)
  1003. {
  1004. foreach (var item in this.appWorkspace.DocumentWorkspaces[i].PhaseModels)
  1005. {
  1006. processedBit1 = BitmapConverter.ToBitmap(item.mat);
  1007. Graphics graphics = Graphics.FromImage(newBit1);
  1008. graphics.DrawImage(processedBit1, new PointF(0, 0));
  1009. }
  1010. }
  1011. tempBit.Add(newBit1);
  1012. Bitmap processedBit;
  1013. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1014. if(this.appWorkspace.DocumentWorkspaces[i].PhaseModels.Count > 0)
  1015. {
  1016. foreach (var item in this.appWorkspace.DocumentWorkspaces[i].PhaseModels)
  1017. {
  1018. processedBit = BitmapConverter.ToBitmap(item.mat);
  1019. Graphics graphics = Graphics.FromImage(newBit);
  1020. graphics.DrawImage(processedBit, new PointF(0, 0));
  1021. this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Draw(graphics);
  1022. }
  1023. }
  1024. else
  1025. {
  1026. processedBit = this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreateAliasedBitmap();
  1027. Graphics graphics = Graphics.FromImage(newBit);
  1028. graphics.DrawImage(processedBit, new PointF(0, 0));
  1029. this.appWorkspace.DocumentWorkspaces[i].GraphicsList.Draw(graphics);
  1030. }
  1031. tempBit.Add(newBit);
  1032. string imgName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1033. this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, imgName);
  1034. insertIn++;
  1035. }
  1036. bool su = OfficeFileHandleHelper.SaveAsExcelWithModule(analyzeSettingModel.modulePath, saveAsPath, analysisContent, dictPath, pNames);
  1037. procClass.DismissProgressAction(this);
  1038. if (su)
  1039. MessageBox.Show(PdnResources.GetString("Menu.MeasureDatafoldertoview.text"));
  1040. }
  1041. catch (Exception)
  1042. {
  1043. MessageBox.Show(PdnResources.GetString("Menu.newdefit.Text"));
  1044. }
  1045. finally
  1046. {
  1047. procClass.DismissProgressAction(this);
  1048. }
  1049. }
  1050. }
  1051. };
  1052. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(copyThreadProc), PdnResources.GetString("Menu.Tools.CreateReport.Text"));
  1053. }
  1054. else
  1055. {
  1056. List<Bitmap> bitList = new List<Bitmap>();
  1057. //保存图片,保存原路径、原文件名、原保存格式、不压缩、保存后不关闭图像
  1058. Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap();
  1059. Bitmap newBitmap;
  1060. if (this.appWorkspace.ActiveDocumentWorkspace.phaseModels != null
  1061. && this.appWorkspace.ActiveDocumentWorkspace.phaseModels.Count > 0
  1062. && this.appWorkspace.ActiveDocumentWorkspace.phaseModels[0].mat != null)
  1063. {
  1064. newBitmap = DeepClone(BitmapConverter.ToBitmap(this.appWorkspace.ActiveDocumentWorkspace.phaseModels[0].mat));
  1065. }
  1066. else
  1067. {
  1068. newBitmap = DeepClone(bitmap);
  1069. }
  1070. Graphics graphics = Graphics.FromImage(newBitmap);
  1071. //标注及测量信息嵌入图像
  1072. if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList != null && this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count > 0)
  1073. {
  1074. this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Draw(graphics);
  1075. }
  1076. bitList.Add(newBitmap);
  1077. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1078. }
  1079. }
  1080. else
  1081. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1082. }
  1083. public void DeleteFolder(string path)
  1084. {
  1085. foreach (string d in Directory.GetFileSystemEntries(path))
  1086. {
  1087. if (System.IO.File.Exists(d))
  1088. {
  1089. FileInfo fi = new FileInfo(d);
  1090. if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
  1091. fi.Attributes = FileAttributes.Normal;
  1092. System.IO.File.Delete(d);//直接删除其中的文件
  1093. }
  1094. else
  1095. {
  1096. DirectoryInfo d1 = new DirectoryInfo(d);
  1097. if (d1.GetFiles().Length != 0)
  1098. {
  1099. DeleteFolder(d1.FullName);
  1100. }
  1101. Directory.Delete(d);
  1102. }
  1103. }
  1104. }
  1105. public Bitmap DeepClone(Bitmap bitmap)
  1106. {
  1107. Bitmap dstBitmap = null;
  1108. using (MemoryStream mStream = new MemoryStream())
  1109. {
  1110. BinaryFormatter bf = new BinaryFormatter();
  1111. bf.Serialize(mStream, bitmap);
  1112. mStream.Seek(0, SeekOrigin.Begin);//指定当前流的位置为流的开头。
  1113. dstBitmap = (Bitmap)bf.Deserialize(mStream);
  1114. mStream.Close();
  1115. }
  1116. return dstBitmap;
  1117. }
  1118. /// <summary>
  1119. /// 添加按钮-其他
  1120. /// </summary>
  1121. /// <param name="sender"></param>
  1122. /// <param name="e"></param>
  1123. private void button4_Click(object sender, EventArgs e)
  1124. {
  1125. if (string.IsNullOrEmpty(this.textBox9.Text))
  1126. {
  1127. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenteranameofthephase.text"));
  1128. return;
  1129. }
  1130. if (string.IsNullOrEmpty(this.textBox8.Text))
  1131. {
  1132. MessageBox.Show(PdnResources.GetString("Menu.Pleaseentercontent.text"));
  1133. return;
  1134. }
  1135. DataGridViewRow row = new DataGridViewRow();
  1136. row.Cells.Add(CreateTextBoxCell(this.textBox9.Text, "name"));
  1137. row.Cells.Add(CreateTextBoxCell(this.textBox8.Text, "content"));
  1138. row.Cells.Add(CreateButtonCell(PdnResources.GetString("Menu.Edit.Delete.Text"), "delete"));
  1139. this.dataGridView1.Rows.Add(row);
  1140. //选中最新添加的那一条
  1141. this.dataGridView1.ClearSelection();
  1142. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Selected = true;
  1143. //清空输入框
  1144. this.textBox9.Text = "";
  1145. this.textBox8.Text = "";
  1146. }
  1147. /// <summary>
  1148. /// 添加内容单元格
  1149. /// </summary>
  1150. /// <param name="text"></param>
  1151. /// <param name="tag"></param>
  1152. /// <returns></returns>
  1153. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  1154. {
  1155. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1156. textboxcell.Value = text;
  1157. textboxcell.Tag = tag;
  1158. return textboxcell;
  1159. }
  1160. /// <summary>
  1161. /// 添加按钮单元格
  1162. /// </summary>
  1163. /// <param name="text"></param>
  1164. /// <param name="tag"></param>
  1165. /// <returns></returns>
  1166. public DataGridViewButtonCell CreateButtonCell(string text, object tag)
  1167. {
  1168. DataGridViewButtonCell buttonCell = new DataGridViewButtonCell();
  1169. buttonCell.Value = text;
  1170. buttonCell.Tag = tag;
  1171. return buttonCell;
  1172. }
  1173. /// <summary>
  1174. /// 点击datagridview的删除按钮
  1175. /// </summary>
  1176. /// <param name="sender"></param>
  1177. /// <param name="e"></param>
  1178. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  1179. {
  1180. var senderGrid = (DataGridView)sender;
  1181. if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
  1182. e.RowIndex >= 0)
  1183. this.dataGridView1.Rows.Remove(this.dataGridView1.Rows[e.RowIndex]);
  1184. }
  1185. /// <summary>
  1186. /// 配置书签按钮
  1187. /// </summary>
  1188. /// <param name="sender"></param>
  1189. /// <param name="e"></param>
  1190. private void button5_Click(object sender, EventArgs e)
  1191. {
  1192. BookmarkConfigDialog bookmarkConfigDialog = new BookmarkConfigDialog(this.analyzeClassify,this.languageName);
  1193. bookmarkConfigDialog.StartPosition = FormStartPosition.CenterParent;
  1194. bookmarkConfigDialog.ShowDialog();
  1195. }
  1196. }
  1197. }