MeasureListSettingDialog.cs 57 KB

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