SpecialMeasureAreaDialog.cs 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760
  1. using OpenCvSharp;
  2. using OpenCvSharp.Extensions;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.CustomControl;
  5. using PaintDotNet.Data.Param;
  6. using PaintDotNet.DbOpreate.DbModel;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Data.SQLite;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using PaintDotNet.Base.CommTool;
  18. using PaintDotNet.DbOpreate.DbBll;
  19. using PaintDotNet.GeneralAnalysis.Special;
  20. using System.IO;
  21. using PaintDotNet.Instrument;
  22. using Metis.ParameterSet;
  23. namespace PaintDotNet.GeneralAnalysis
  24. {
  25. /// <summary>
  26. /// 专项测量-面积含量
  27. /// </summary>
  28. internal class SpecialMeasureAreaDialog : PdnBaseForm
  29. {
  30. #region
  31. /// <summary>
  32. /// Required designer variable.
  33. /// </summary>
  34. private System.ComponentModel.IContainer components = null;
  35. /// <summary>
  36. /// Clean up any resources being used.
  37. /// </summary>
  38. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  39. protected override void Dispose(bool disposing)
  40. {
  41. if (disposing && (components != null))
  42. {
  43. components.Dispose();
  44. }
  45. base.Dispose(disposing);
  46. }
  47. #region Windows Form Designer generated code
  48. private void InitializeLanguageText()
  49. {
  50. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  51. this.btnSave.Text = PdnResources.GetString("Menu.Saveresult.text");
  52. this.btnSetting.Text = PdnResources.GetString("Menu.Setting.Text");
  53. this.chkOpenSetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  54. this.btnMeasure.Text = PdnResources.GetString("Menu.Startmeasuring.text");
  55. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  56. this.groupBox4.Text = PdnResources.GetString("Menu.Preview.text");
  57. this.groupBox3.Text = PdnResources.GetString("Menu.Resultspreview.text");
  58. this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.view.text");
  59. this.Column2.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
  60. this.Column3.HeaderText = PdnResources.GetString("Menu.proportion.text");
  61. this.Column4.HeaderText = PdnResources.GetString("Menu.Phasecontent.text");
  62. this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Specialmeasurement.Averageandlevel.text");
  63. this.name.HeaderText = PdnResources.GetString("Menu.Levelname.text");
  64. this.minValue.HeaderText = PdnResources.GetString("Menu.Begintovalue.Text");
  65. this.maxValue.HeaderText = PdnResources.GetString("Menu.Theendvalu.Text");
  66. this.label4.Text = PdnResources.GetString("Menu.Correspondinglevel.text") + ":";
  67. this.label3.Text = PdnResources.GetString("Menu.Phasecontent.text") + ":";
  68. this.label2.Text = PdnResources.GetString("Menu.proportion.text") + ":";
  69. this.label1.Text = PdnResources.GetString("Menu.Phasearea.text") + ":";
  70. this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
  71. this.btnResultDel.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  72. this.btnAllShow.Text = PdnResources.GetString("Menu.Showall.text");
  73. this.label5.Text = PdnResources.GetString("Menu.Decimal.text");
  74. this.btnExport.Text = PdnResources.GetString("Menu.Exportresults.text");
  75. this.pic.HeaderText = PdnResources.GetString("Menu.picture.Text");
  76. this.view.HeaderText = PdnResources.GetString("Menu.view.text");
  77. this.area.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
  78. this.scale.HeaderText = PdnResources.GetString("Menu.proportion.text");
  79. this.has.HeaderText = PdnResources.GetString("Menu.Phasecontent.text");
  80. this.Column1.HeaderText = PdnResources.GetString("Menu.Correspondinglevel.text");
  81. this.btnCreate.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  82. this.btnExportProject.Text = PdnResources.GetString("Menu.Exportproject.text");
  83. this.Text = PdnResources.GetString("Menu.Generalanalysis.Specialmeasurement.Specialmecontent.text");
  84. }
  85. /// <summary>
  86. /// Required method for Designer support - do not modify
  87. /// the contents of this method with the code editor.
  88. /// </summary>
  89. private void InitializeComponent()
  90. {
  91. this.components = new System.ComponentModel.Container();
  92. this.groupBox1 = new System.Windows.Forms.GroupBox();
  93. this.btnSave = new System.Windows.Forms.Button();
  94. this.btnSetting = new System.Windows.Forms.Button();
  95. this.chkOpenSetting = new System.Windows.Forms.CheckBox();
  96. this.btnMeasure = new System.Windows.Forms.Button();
  97. this.cmbSpecial = new System.Windows.Forms.ComboBox();
  98. this.groupBox2 = new System.Windows.Forms.GroupBox();
  99. this.lstPic = new System.Windows.Forms.ListView();
  100. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  101. this.groupBox4 = new System.Windows.Forms.GroupBox();
  102. this.pnlTools = new System.Windows.Forms.Panel();
  103. this.pnlShow = new System.Windows.Forms.Panel();
  104. this.groupBox3 = new System.Windows.Forms.GroupBox();
  105. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  106. this.groupBox5 = new System.Windows.Forms.GroupBox();
  107. this.lblLevel = new System.Windows.Forms.Label();
  108. this.lblContent = new System.Windows.Forms.Label();
  109. this.lblRate = new System.Windows.Forms.Label();
  110. this.lblArea = new System.Windows.Forms.Label();
  111. this.dgvLevelList = new System.Windows.Forms.DataGridView();
  112. this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  113. this.minValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
  114. this.maxValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
  115. this.label4 = new System.Windows.Forms.Label();
  116. this.label3 = new System.Windows.Forms.Label();
  117. this.label2 = new System.Windows.Forms.Label();
  118. this.label1 = new System.Windows.Forms.Label();
  119. this.groupBox8 = new System.Windows.Forms.GroupBox();
  120. this.btnExportProject = new System.Windows.Forms.Button();
  121. this.lstResult = new System.Windows.Forms.ListView();
  122. this.btnResultDel = new System.Windows.Forms.Button();
  123. this.btnAllShow = new System.Windows.Forms.Button();
  124. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  125. this.label5 = new System.Windows.Forms.Label();
  126. this.btnExport = new System.Windows.Forms.Button();
  127. this.dgvResult = new System.Windows.Forms.DataGridView();
  128. this.pic = new System.Windows.Forms.DataGridViewTextBoxColumn();
  129. this.view = new System.Windows.Forms.DataGridViewTextBoxColumn();
  130. this.area = new System.Windows.Forms.DataGridViewTextBoxColumn();
  131. this.scale = new System.Windows.Forms.DataGridViewTextBoxColumn();
  132. this.has = new System.Windows.Forms.DataGridViewTextBoxColumn();
  133. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  134. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  135. this.btnCreate = new System.Windows.Forms.Button();
  136. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  137. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  138. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  139. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  140. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  141. this.groupBox1.SuspendLayout();
  142. this.groupBox2.SuspendLayout();
  143. this.groupBox4.SuspendLayout();
  144. this.groupBox3.SuspendLayout();
  145. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  146. this.groupBox5.SuspendLayout();
  147. ((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).BeginInit();
  148. this.groupBox8.SuspendLayout();
  149. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  150. ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit();
  151. this.SuspendLayout();
  152. //
  153. // groupBox1
  154. //
  155. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  156. | System.Windows.Forms.AnchorStyles.Right)));
  157. this.groupBox1.Controls.Add(this.btnSave);
  158. this.groupBox1.Controls.Add(this.btnSetting);
  159. this.groupBox1.Controls.Add(this.chkOpenSetting);
  160. this.groupBox1.Controls.Add(this.btnMeasure);
  161. this.groupBox1.Controls.Add(this.cmbSpecial);
  162. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  163. this.groupBox1.Name = "groupBox1";
  164. this.groupBox1.Size = new System.Drawing.Size(1241, 73);
  165. this.groupBox1.TabIndex = 1;
  166. this.groupBox1.TabStop = false;
  167. this.groupBox1.Text = "操作";
  168. //
  169. // btnSave
  170. //
  171. this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  172. this.btnSave.Location = new System.Drawing.Point(1122, 24);
  173. this.btnSave.Name = "btnSave";
  174. this.btnSave.Size = new System.Drawing.Size(101, 35);
  175. this.btnSave.TabIndex = 4;
  176. this.btnSave.Text = "保存结果";
  177. this.btnSave.UseVisualStyleBackColor = true;
  178. this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
  179. //
  180. // btnSetting
  181. //
  182. this.btnSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  183. this.btnSetting.Location = new System.Drawing.Point(1018, 24);
  184. this.btnSetting.Name = "btnSetting";
  185. this.btnSetting.Size = new System.Drawing.Size(85, 35);
  186. this.btnSetting.TabIndex = 3;
  187. this.btnSetting.Text = "设置";
  188. this.btnSetting.UseVisualStyleBackColor = true;
  189. this.btnSetting.Click += new System.EventHandler(this.btnSetting_Click);
  190. //
  191. // chkOpenSetting
  192. //
  193. this.chkOpenSetting.AutoSize = true;
  194. this.chkOpenSetting.Checked = true;
  195. this.chkOpenSetting.CheckState = System.Windows.Forms.CheckState.Checked;
  196. this.chkOpenSetting.Location = new System.Drawing.Point(389, 31);
  197. this.chkOpenSetting.Name = "chkOpenSetting";
  198. this.chkOpenSetting.Size = new System.Drawing.Size(132, 16);
  199. this.chkOpenSetting.TabIndex = 2;
  200. this.chkOpenSetting.Text = "生成报告时打开设置";
  201. this.chkOpenSetting.UseVisualStyleBackColor = true;
  202. this.chkOpenSetting.CheckedChanged += new System.EventHandler(this.chkOpenSetting_CheckedChanged);
  203. //
  204. // btnMeasure
  205. //
  206. this.btnMeasure.Location = new System.Drawing.Point(268, 24);
  207. this.btnMeasure.Name = "btnMeasure";
  208. this.btnMeasure.Size = new System.Drawing.Size(115, 35);
  209. this.btnMeasure.TabIndex = 1;
  210. this.btnMeasure.Text = "开始测量";
  211. this.btnMeasure.UseVisualStyleBackColor = true;
  212. this.btnMeasure.Click += new System.EventHandler(this.btnMeasure_Click);
  213. //
  214. // cmbSpecial
  215. //
  216. this.cmbSpecial.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  217. this.cmbSpecial.FormattingEnabled = true;
  218. this.cmbSpecial.Location = new System.Drawing.Point(17, 29);
  219. this.cmbSpecial.Name = "cmbSpecial";
  220. this.cmbSpecial.Size = new System.Drawing.Size(231, 20);
  221. this.cmbSpecial.TabIndex = 0;
  222. this.cmbSpecial.SelectedIndexChanged += new System.EventHandler(this.cmbSpecial_SelectedIndexChanged);
  223. //
  224. // groupBox2
  225. //
  226. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  227. | System.Windows.Forms.AnchorStyles.Left)));
  228. this.groupBox2.Controls.Add(this.lstPic);
  229. this.groupBox2.Location = new System.Drawing.Point(12, 91);
  230. this.groupBox2.Name = "groupBox2";
  231. this.groupBox2.Size = new System.Drawing.Size(201, 513);
  232. this.groupBox2.TabIndex = 2;
  233. this.groupBox2.TabStop = false;
  234. this.groupBox2.Text = "图像索引";
  235. //
  236. // lstPic
  237. //
  238. this.lstPic.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  239. | System.Windows.Forms.AnchorStyles.Left)));
  240. this.lstPic.HideSelection = false;
  241. this.lstPic.LargeImageList = this.imageList1;
  242. this.lstPic.Location = new System.Drawing.Point(17, 27);
  243. this.lstPic.MultiSelect = false;
  244. this.lstPic.Name = "lstPic";
  245. this.lstPic.Size = new System.Drawing.Size(166, 467);
  246. this.lstPic.TabIndex = 0;
  247. this.lstPic.UseCompatibleStateImageBehavior = false;
  248. this.lstPic.SelectedIndexChanged += new System.EventHandler(this.lstPic_SelectedIndexChanged);
  249. //
  250. // imageList1
  251. //
  252. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  253. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  254. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  255. //
  256. // groupBox4
  257. //
  258. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  259. | System.Windows.Forms.AnchorStyles.Left)
  260. | System.Windows.Forms.AnchorStyles.Right)));
  261. this.groupBox4.Controls.Add(this.pnlTools);
  262. this.groupBox4.Controls.Add(this.pnlShow);
  263. this.groupBox4.Location = new System.Drawing.Point(594, 91);
  264. this.groupBox4.Name = "groupBox4";
  265. this.groupBox4.Size = new System.Drawing.Size(659, 513);
  266. this.groupBox4.TabIndex = 4;
  267. this.groupBox4.TabStop = false;
  268. this.groupBox4.Text = "预览";
  269. //
  270. // pnlTools
  271. //
  272. this.pnlTools.Location = new System.Drawing.Point(6, 22);
  273. this.pnlTools.Name = "pnlTools";
  274. this.pnlTools.Size = new System.Drawing.Size(305, 32);
  275. this.pnlTools.TabIndex = 2;
  276. //
  277. // pnlShow
  278. //
  279. this.pnlShow.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  280. | System.Windows.Forms.AnchorStyles.Left)
  281. | System.Windows.Forms.AnchorStyles.Right)));
  282. this.pnlShow.Location = new System.Drawing.Point(6, 60);
  283. this.pnlShow.Name = "pnlShow";
  284. this.pnlShow.Size = new System.Drawing.Size(647, 447);
  285. this.pnlShow.TabIndex = 0;
  286. //
  287. // groupBox3
  288. //
  289. this.groupBox3.Controls.Add(this.dataGridView1);
  290. this.groupBox3.Location = new System.Drawing.Point(219, 91);
  291. this.groupBox3.Name = "groupBox3";
  292. this.groupBox3.Size = new System.Drawing.Size(369, 251);
  293. this.groupBox3.TabIndex = 5;
  294. this.groupBox3.TabStop = false;
  295. this.groupBox3.Text = "结果预览";
  296. //
  297. // dataGridView1
  298. //
  299. this.dataGridView1.AllowUserToAddRows = false;
  300. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  301. this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
  302. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  303. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  304. this.dataGridViewTextBoxColumn1,
  305. this.Column2,
  306. this.Column3,
  307. this.Column4});
  308. this.dataGridView1.Location = new System.Drawing.Point(6, 24);
  309. this.dataGridView1.Name = "dataGridView1";
  310. this.dataGridView1.RowHeadersVisible = false;
  311. this.dataGridView1.RowHeadersWidth = 51;
  312. this.dataGridView1.RowTemplate.Height = 27;
  313. this.dataGridView1.Size = new System.Drawing.Size(359, 221);
  314. this.dataGridView1.TabIndex = 1;
  315. //
  316. // groupBox5
  317. //
  318. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  319. | System.Windows.Forms.AnchorStyles.Left)));
  320. this.groupBox5.Controls.Add(this.lblLevel);
  321. this.groupBox5.Controls.Add(this.lblContent);
  322. this.groupBox5.Controls.Add(this.lblRate);
  323. this.groupBox5.Controls.Add(this.lblArea);
  324. this.groupBox5.Controls.Add(this.dgvLevelList);
  325. this.groupBox5.Controls.Add(this.label4);
  326. this.groupBox5.Controls.Add(this.label3);
  327. this.groupBox5.Controls.Add(this.label2);
  328. this.groupBox5.Controls.Add(this.label1);
  329. this.groupBox5.Location = new System.Drawing.Point(219, 348);
  330. this.groupBox5.Name = "groupBox5";
  331. this.groupBox5.Size = new System.Drawing.Size(369, 256);
  332. this.groupBox5.TabIndex = 6;
  333. this.groupBox5.TabStop = false;
  334. this.groupBox5.Text = "平均值及级别";
  335. //
  336. // lblLevel
  337. //
  338. this.lblLevel.AutoSize = true;
  339. this.lblLevel.Location = new System.Drawing.Point(275, 58);
  340. this.lblLevel.Name = "lblLevel";
  341. this.lblLevel.Size = new System.Drawing.Size(11, 12);
  342. this.lblLevel.TabIndex = 8;
  343. this.lblLevel.Text = "0";
  344. //
  345. // lblContent
  346. //
  347. this.lblContent.AutoEllipsis = true;
  348. this.lblContent.Location = new System.Drawing.Point(114, 58);
  349. this.lblContent.Name = "lblContent";
  350. this.lblContent.Size = new System.Drawing.Size(53, 12);
  351. this.lblContent.TabIndex = 7;
  352. this.lblContent.Text = "0";
  353. //
  354. // lblRate
  355. //
  356. this.lblRate.AutoSize = true;
  357. this.lblRate.Location = new System.Drawing.Point(275, 30);
  358. this.lblRate.Name = "lblRate";
  359. this.lblRate.Size = new System.Drawing.Size(11, 12);
  360. this.lblRate.TabIndex = 6;
  361. this.lblRate.Text = "0";
  362. //
  363. // lblArea
  364. //
  365. this.lblArea.AutoEllipsis = true;
  366. this.lblArea.Location = new System.Drawing.Point(114, 30);
  367. this.lblArea.Name = "lblArea";
  368. this.lblArea.Size = new System.Drawing.Size(83, 12);
  369. this.lblArea.TabIndex = 5;
  370. this.lblArea.Text = "0";
  371. //
  372. // dgvLevelList
  373. //
  374. this.dgvLevelList.AllowUserToAddRows = false;
  375. this.dgvLevelList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  376. | System.Windows.Forms.AnchorStyles.Left)));
  377. this.dgvLevelList.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  378. this.dgvLevelList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  379. this.dgvLevelList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  380. this.name,
  381. this.minValue,
  382. this.maxValue});
  383. this.dgvLevelList.Location = new System.Drawing.Point(6, 87);
  384. this.dgvLevelList.Name = "dgvLevelList";
  385. this.dgvLevelList.ReadOnly = true;
  386. this.dgvLevelList.RowHeadersVisible = false;
  387. this.dgvLevelList.RowHeadersWidth = 51;
  388. this.dgvLevelList.RowTemplate.Height = 27;
  389. this.dgvLevelList.Size = new System.Drawing.Size(357, 163);
  390. this.dgvLevelList.TabIndex = 4;
  391. //
  392. // name
  393. //
  394. this.name.MinimumWidth = 6;
  395. this.name.Name = "name";
  396. this.name.ReadOnly = true;
  397. //
  398. // minValue
  399. //
  400. this.minValue.MinimumWidth = 6;
  401. this.minValue.Name = "minValue";
  402. this.minValue.ReadOnly = true;
  403. //
  404. // maxValue
  405. //
  406. this.maxValue.MinimumWidth = 6;
  407. this.maxValue.Name = "maxValue";
  408. this.maxValue.ReadOnly = true;
  409. //
  410. // label4
  411. //
  412. this.label4.AutoSize = true;
  413. this.label4.Location = new System.Drawing.Point(173, 58);
  414. this.label4.Name = "label4";
  415. this.label4.Size = new System.Drawing.Size(65, 12);
  416. this.label4.TabIndex = 3;
  417. this.label4.Text = "对应级别:";
  418. //
  419. // label3
  420. //
  421. this.label3.AutoSize = true;
  422. this.label3.Location = new System.Drawing.Point(26, 58);
  423. this.label3.Name = "label3";
  424. this.label3.Size = new System.Drawing.Size(53, 12);
  425. this.label3.TabIndex = 2;
  426. this.label3.Text = "相含量:";
  427. //
  428. // label2
  429. //
  430. this.label2.AutoSize = true;
  431. this.label2.Location = new System.Drawing.Point(203, 30);
  432. this.label2.Name = "label2";
  433. this.label2.Size = new System.Drawing.Size(41, 12);
  434. this.label2.TabIndex = 1;
  435. this.label2.Text = "比例:";
  436. //
  437. // label1
  438. //
  439. this.label1.AutoSize = true;
  440. this.label1.Location = new System.Drawing.Point(26, 30);
  441. this.label1.Name = "label1";
  442. this.label1.Size = new System.Drawing.Size(53, 12);
  443. this.label1.TabIndex = 0;
  444. this.label1.Text = "相面积:";
  445. //
  446. // groupBox8
  447. //
  448. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  449. | System.Windows.Forms.AnchorStyles.Right)));
  450. this.groupBox8.Controls.Add(this.btnExportProject);
  451. this.groupBox8.Controls.Add(this.lstResult);
  452. this.groupBox8.Controls.Add(this.btnResultDel);
  453. this.groupBox8.Controls.Add(this.btnAllShow);
  454. this.groupBox8.Controls.Add(this.numericUpDown1);
  455. this.groupBox8.Controls.Add(this.label5);
  456. this.groupBox8.Controls.Add(this.btnExport);
  457. this.groupBox8.Controls.Add(this.dgvResult);
  458. this.groupBox8.Controls.Add(this.btnCreate);
  459. this.groupBox8.Location = new System.Drawing.Point(13, 610);
  460. this.groupBox8.Name = "groupBox8";
  461. this.groupBox8.Size = new System.Drawing.Size(1240, 202);
  462. this.groupBox8.TabIndex = 8;
  463. this.groupBox8.TabStop = false;
  464. this.groupBox8.Text = "分析结果";
  465. //
  466. // btnExportProject
  467. //
  468. this.btnExportProject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  469. this.btnExportProject.Location = new System.Drawing.Point(1114, 100);
  470. this.btnExportProject.Name = "btnExportProject";
  471. this.btnExportProject.Size = new System.Drawing.Size(115, 32);
  472. this.btnExportProject.TabIndex = 9;
  473. this.btnExportProject.Text = "导出项目";
  474. this.btnExportProject.UseVisualStyleBackColor = true;
  475. this.btnExportProject.Click += new System.EventHandler(this.btnExportProject_Click);
  476. //
  477. // lstResult
  478. //
  479. this.lstResult.HideSelection = false;
  480. this.lstResult.Location = new System.Drawing.Point(17, 57);
  481. this.lstResult.Name = "lstResult";
  482. this.lstResult.Size = new System.Drawing.Size(164, 131);
  483. this.lstResult.TabIndex = 8;
  484. this.lstResult.UseCompatibleStateImageBehavior = false;
  485. this.lstResult.View = System.Windows.Forms.View.Tile;
  486. this.lstResult.SelectedIndexChanged += new System.EventHandler(this.lstResult_SelectedIndexChanged);
  487. //
  488. // btnResultDel
  489. //
  490. this.btnResultDel.Location = new System.Drawing.Point(120, 19);
  491. this.btnResultDel.Name = "btnResultDel";
  492. this.btnResultDel.Size = new System.Drawing.Size(61, 32);
  493. this.btnResultDel.TabIndex = 7;
  494. this.btnResultDel.Text = "删除";
  495. this.btnResultDel.UseVisualStyleBackColor = true;
  496. this.btnResultDel.Click += new System.EventHandler(this.btnResultDel_Click);
  497. //
  498. // btnAllShow
  499. //
  500. this.btnAllShow.Location = new System.Drawing.Point(17, 19);
  501. this.btnAllShow.Name = "btnAllShow";
  502. this.btnAllShow.Size = new System.Drawing.Size(97, 32);
  503. this.btnAllShow.TabIndex = 0;
  504. this.btnAllShow.Text = "全部显示";
  505. this.btnAllShow.UseVisualStyleBackColor = true;
  506. this.btnAllShow.Click += new System.EventHandler(this.btnAllShow_Click);
  507. //
  508. // numericUpDown1
  509. //
  510. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  511. this.numericUpDown1.Location = new System.Drawing.Point(1160, 153);
  512. this.numericUpDown1.Maximum = new decimal(new int[] {
  513. 10,
  514. 0,
  515. 0,
  516. 0});
  517. this.numericUpDown1.Name = "numericUpDown1";
  518. this.numericUpDown1.Size = new System.Drawing.Size(62, 21);
  519. this.numericUpDown1.TabIndex = 6;
  520. this.numericUpDown1.Value = new decimal(new int[] {
  521. 2,
  522. 0,
  523. 0,
  524. 0});
  525. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  526. //
  527. // label5
  528. //
  529. this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  530. this.label5.AutoSize = true;
  531. this.label5.Location = new System.Drawing.Point(1117, 158);
  532. this.label5.Name = "label5";
  533. this.label5.Size = new System.Drawing.Size(41, 12);
  534. this.label5.TabIndex = 5;
  535. this.label5.Text = "小数:";
  536. //
  537. // btnExport
  538. //
  539. this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  540. this.btnExport.Location = new System.Drawing.Point(1114, 62);
  541. this.btnExport.Name = "btnExport";
  542. this.btnExport.Size = new System.Drawing.Size(116, 32);
  543. this.btnExport.TabIndex = 1;
  544. this.btnExport.Text = "导出结果";
  545. this.btnExport.UseVisualStyleBackColor = true;
  546. this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
  547. //
  548. // dgvResult
  549. //
  550. this.dgvResult.AllowUserToAddRows = false;
  551. this.dgvResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  552. | System.Windows.Forms.AnchorStyles.Right)));
  553. this.dgvResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  554. this.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  555. this.dgvResult.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  556. this.pic,
  557. this.view,
  558. this.area,
  559. this.scale,
  560. this.has,
  561. this.Column1,
  562. this.Column5});
  563. this.dgvResult.Location = new System.Drawing.Point(212, 24);
  564. this.dgvResult.Name = "dgvResult";
  565. this.dgvResult.ReadOnly = true;
  566. this.dgvResult.RowHeadersVisible = false;
  567. this.dgvResult.RowHeadersWidth = 51;
  568. this.dgvResult.RowTemplate.Height = 27;
  569. this.dgvResult.Size = new System.Drawing.Size(871, 164);
  570. this.dgvResult.TabIndex = 0;
  571. //
  572. // pic
  573. //
  574. this.pic.MinimumWidth = 6;
  575. this.pic.Name = "pic";
  576. this.pic.ReadOnly = true;
  577. //
  578. // view
  579. //
  580. this.view.MinimumWidth = 6;
  581. this.view.Name = "view";
  582. this.view.ReadOnly = true;
  583. //
  584. // area
  585. //
  586. this.area.MinimumWidth = 6;
  587. this.area.Name = "area";
  588. this.area.ReadOnly = true;
  589. //
  590. // scale
  591. //
  592. this.scale.MinimumWidth = 6;
  593. this.scale.Name = "scale";
  594. this.scale.ReadOnly = true;
  595. //
  596. // has
  597. //
  598. this.has.MinimumWidth = 6;
  599. this.has.Name = "has";
  600. this.has.ReadOnly = true;
  601. //
  602. // Column1
  603. //
  604. this.Column1.MinimumWidth = 6;
  605. this.Column1.Name = "Column1";
  606. this.Column1.ReadOnly = true;
  607. //
  608. // Column5
  609. //
  610. this.Column5.HeaderText = "tag";
  611. this.Column5.MinimumWidth = 6;
  612. this.Column5.Name = "Column5";
  613. this.Column5.ReadOnly = true;
  614. this.Column5.Visible = false;
  615. //
  616. // btnCreate
  617. //
  618. this.btnCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  619. this.btnCreate.Location = new System.Drawing.Point(1114, 24);
  620. this.btnCreate.Name = "btnCreate";
  621. this.btnCreate.Size = new System.Drawing.Size(115, 32);
  622. this.btnCreate.TabIndex = 0;
  623. this.btnCreate.Text = "生成报告";
  624. this.btnCreate.UseVisualStyleBackColor = true;
  625. this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click);
  626. //
  627. // Column4
  628. //
  629. this.Column4.MinimumWidth = 6;
  630. this.Column4.Name = "Column4";
  631. //
  632. // Column3
  633. //
  634. this.Column3.MinimumWidth = 6;
  635. this.Column3.Name = "Column3";
  636. //
  637. // Column2
  638. //
  639. this.Column2.MinimumWidth = 6;
  640. this.Column2.Name = "Column2";
  641. //
  642. // dataGridViewTextBoxColumn1
  643. //
  644. this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
  645. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  646. //
  647. // SpecialMeasureAreaDialog
  648. //
  649. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  650. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  651. this.ClientSize = new System.Drawing.Size(1265, 824);
  652. this.Controls.Add(this.groupBox8);
  653. this.Controls.Add(this.groupBox5);
  654. this.Controls.Add(this.groupBox3);
  655. this.Controls.Add(this.groupBox4);
  656. this.Controls.Add(this.groupBox2);
  657. this.Controls.Add(this.groupBox1);
  658. this.Name = "SpecialMeasureAreaDialog";
  659. this.Text = "专项测量 - 面积含量";
  660. this.Controls.SetChildIndex(this.groupBox1, 0);
  661. this.Controls.SetChildIndex(this.groupBox2, 0);
  662. this.Controls.SetChildIndex(this.groupBox4, 0);
  663. this.Controls.SetChildIndex(this.groupBox3, 0);
  664. this.Controls.SetChildIndex(this.groupBox5, 0);
  665. this.Controls.SetChildIndex(this.groupBox8, 0);
  666. this.groupBox1.ResumeLayout(false);
  667. this.groupBox1.PerformLayout();
  668. this.groupBox2.ResumeLayout(false);
  669. this.groupBox4.ResumeLayout(false);
  670. this.groupBox3.ResumeLayout(false);
  671. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  672. this.groupBox5.ResumeLayout(false);
  673. this.groupBox5.PerformLayout();
  674. ((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).EndInit();
  675. this.groupBox8.ResumeLayout(false);
  676. this.groupBox8.PerformLayout();
  677. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  678. ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit();
  679. this.ResumeLayout(false);
  680. }
  681. #endregion
  682. private System.Windows.Forms.GroupBox groupBox1;
  683. private System.Windows.Forms.Button btnSave;
  684. private System.Windows.Forms.Button btnSetting;
  685. private System.Windows.Forms.CheckBox chkOpenSetting;
  686. private System.Windows.Forms.Button btnMeasure;
  687. private System.Windows.Forms.ComboBox cmbSpecial;
  688. private System.Windows.Forms.GroupBox groupBox2;
  689. private System.Windows.Forms.ListView lstPic;
  690. private System.Windows.Forms.GroupBox groupBox4;
  691. private System.Windows.Forms.Panel pnlTools;
  692. private System.Windows.Forms.Panel pnlShow;
  693. private System.Windows.Forms.GroupBox groupBox3;
  694. private System.Windows.Forms.GroupBox groupBox5;
  695. private System.Windows.Forms.Label label4;
  696. private System.Windows.Forms.Label label3;
  697. private System.Windows.Forms.Label label2;
  698. private System.Windows.Forms.Label label1;
  699. private System.Windows.Forms.DataGridView dgvLevelList;
  700. private System.Windows.Forms.DataGridViewTextBoxColumn name;
  701. private System.Windows.Forms.DataGridViewTextBoxColumn minValue;
  702. private System.Windows.Forms.DataGridViewTextBoxColumn maxValue;
  703. private System.Windows.Forms.GroupBox groupBox8;
  704. private System.Windows.Forms.Button btnExport;
  705. private System.Windows.Forms.Button btnCreate;
  706. private System.Windows.Forms.DataGridView dgvResult;
  707. private System.Windows.Forms.DataGridView dataGridView1;
  708. private System.Windows.Forms.NumericUpDown numericUpDown1;
  709. private System.Windows.Forms.Label label5;
  710. private System.Windows.Forms.ImageList imageList1;
  711. private System.Windows.Forms.Label lblArea;
  712. private System.Windows.Forms.Label lblRate;
  713. private System.Windows.Forms.Label lblLevel;
  714. private System.Windows.Forms.Label lblContent;
  715. private System.Windows.Forms.Button btnResultDel;
  716. private System.Windows.Forms.Button btnAllShow;
  717. private System.Windows.Forms.DataGridViewTextBoxColumn pic;
  718. private System.Windows.Forms.DataGridViewTextBoxColumn view;
  719. private System.Windows.Forms.DataGridViewTextBoxColumn area;
  720. private System.Windows.Forms.DataGridViewTextBoxColumn scale;
  721. private System.Windows.Forms.DataGridViewTextBoxColumn has;
  722. private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
  723. private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
  724. private System.Windows.Forms.ListView lstResult;
  725. private System.Windows.Forms.Button btnExportProject;
  726. #endregion
  727. private AppWorkspace appWorkspace;
  728. private DocumentWorkspaceWindow m_documentWorkspace;
  729. private SQLiteHelper m_sqlHelper;
  730. private DataTable m_specialList;
  731. private DataTable m_levelList;
  732. private SpecialItem m_specialItem = SpecialItem.AREA;
  733. private int m_specialSelectedIndex = 0;
  734. private string m_specialId;
  735. /// <summary>
  736. /// 原图
  737. /// </summary>
  738. private Mat imageMat;
  739. /// <summary>
  740. /// 原图带原相测量等
  741. /// </summary>
  742. private Bitmap m_originalBit;
  743. private ArtworkControlButtons m_controlButtons;
  744. private List<MeasureAreaResult> polyphaseAnalysisResults = new List<MeasureAreaResult>();
  745. private List<PolyphaseAnalysisResult> mainPolyphaseAnalysisResults = new List<PolyphaseAnalysisResult>();
  746. private bool m_isMeasure;
  747. private string m_level;
  748. private bool m_showAll;
  749. // 小数位
  750. int decnum = 2;
  751. private List<Bitmap> bitList = new List<Bitmap>();
  752. /// <summary>
  753. /// 储存点击保存结果后的所有原图与分析图
  754. /// </summary>
  755. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  756. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  757. private DataGridViewTextBoxColumn Column2;
  758. private DataGridViewTextBoxColumn Column3;
  759. private DataGridViewTextBoxColumn Column4;
  760. private ToolTip toolTip1;
  761. private int defaultIndex = -1;
  762. /// <summary>
  763. /// 中间数据
  764. /// </summary>
  765. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  766. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  767. public SpecialMeasureAreaDialog(AppWorkspace workspace)
  768. {
  769. appWorkspace = workspace;
  770. m_sqlHelper = new SQLiteHelper(); //连接数据库
  771. m_sqlHelper.Connect();
  772. InitializeComponent();
  773. InitializeLanguageText();
  774. InitLblText();
  775. InitPicList();
  776. InitSpecialCmb();
  777. InitDocumentView();
  778. SetAnalyzeModelFromXml("Template.Manager.item2.SpecialArea");
  779. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  780. }
  781. private void ShowImgEvent(object sender, EventArgs e)
  782. {
  783. lstPic.Focus();
  784. if (this.defaultIndex != -1)
  785. {
  786. this.lstPic.Items[defaultIndex].Focused = true;
  787. this.lstPic.Items[defaultIndex].Selected = true;
  788. getLastData();
  789. }
  790. }
  791. /// <summary>
  792. /// 初始化图片列表数据
  793. /// </summary>
  794. public void InitPicList()
  795. {
  796. //初始化图片列表
  797. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  798. {
  799. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  800. this.lstPic.Items.Add("", i);
  801. this.lstPic.Items[i].ImageIndex = i;
  802. this.lstPic.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  803. this.lstPic.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  804. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  805. {
  806. defaultIndex = i;
  807. }
  808. }
  809. this.Shown += ShowImgEvent;
  810. }
  811. /// <summary>
  812. /// 初始化专项数据
  813. /// </summary>
  814. public void InitSpecialCmb()
  815. {
  816. cmbSpecial.Items.Clear();
  817. string select_sql = "select * from mic_special_definition where delete_flag = 0 and special_type = ? "; //查询的SQL语句
  818. SQLiteParameter[] para = new SQLiteParameter[1];
  819. para[0] = new SQLiteParameter("special_type", m_specialItem);
  820. m_specialList = m_sqlHelper.ExecuteDataTable(select_sql, para); //执行查询操作,结果存放在dt中
  821. this.cmbSpecial.Items.Clear();
  822. if (m_specialList.Rows.Count > 0)
  823. {
  824. for (int i = 0; i < m_specialList.Rows.Count; ++i)
  825. {
  826. this.cmbSpecial.Items.Add(m_specialList.Rows[i]["special_name"].ToString());
  827. }
  828. this.cmbSpecial.SelectedIndex = m_specialSelectedIndex;
  829. m_specialId = m_specialList.Rows[m_specialSelectedIndex]["id"].ToString();
  830. }
  831. }
  832. public void InitLblText()
  833. {
  834. lblArea.Text = "0";
  835. lblRate.Text = "0";
  836. lblContent.Text = "0";
  837. lblLevel.Text = "";
  838. }
  839. /// <summary>
  840. /// 初始化DocumentView
  841. /// </summary>
  842. public void InitDocumentView()
  843. {
  844. this.m_documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  845. this.m_documentWorkspace.AppWorkspaceTop = appWorkspace;
  846. this.m_documentWorkspace.Visible = true;
  847. this.m_documentWorkspace.Dock = DockStyle.Fill;
  848. this.pnlShow.Controls.Add(this.m_documentWorkspace);
  849. this.m_documentWorkspace.ContinuousDrawingMeasure = true;
  850. InitDocumentViewTools();
  851. }
  852. #region 初始化DocumentView工具
  853. public void InitDocumentViewTools()
  854. {
  855. this.m_controlButtons = new ArtworkControlButtons();
  856. this.m_controlButtons.Dock = DockStyle.Top;
  857. this.m_controlButtons.Height = 30;
  858. this.m_controlButtons.HideZoomToWindowAndActualSize();
  859. this.m_controlButtons.HideMovingDirection();
  860. this.pnlTools.Controls.Add(m_controlButtons);
  861. this.m_controlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  862. this.m_controlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  863. this.m_controlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  864. this.m_controlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  865. }
  866. private void mobileModeButton_Click(object sender, EventArgs e)
  867. {
  868. this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  869. }
  870. private void pointerButton_Click(object sender, EventArgs e)
  871. {
  872. this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  873. }
  874. private void zoomOutButton_Click(object sender, EventArgs e)
  875. {
  876. if (this.m_documentWorkspace.CompositionSurface != null)
  877. this.m_documentWorkspace.ZoomOut();
  878. }
  879. private void zoomInButton_Click(object sender, EventArgs e)
  880. {
  881. if (this.m_documentWorkspace.CompositionSurface != null)
  882. this.m_documentWorkspace.ZoomIn();
  883. }
  884. #endregion
  885. private void lstPic_SelectedIndexChanged(object sender, EventArgs e)
  886. {
  887. this.Measure();
  888. }
  889. private void Measure()
  890. {
  891. if (this.lstPic.FocusedItem != null && this.lstPic.FocusedItem.Selected)
  892. {
  893. InitLblText();
  894. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  895. Document document = Document.FromImageMat(imageMat.Clone());
  896. this.m_documentWorkspace.Document = document;
  897. this.m_documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GraphicsList;
  898. this.m_documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].phaseModels;
  899. // 选择了图片
  900. Bitmap m_bitmap = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  901. m_originalBit = m_bitmap.Clone(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height), m_bitmap.PixelFormat);
  902. Graphics graphics = Graphics.FromImage(m_originalBit);
  903. Draw(graphics);
  904. this.applyButtonImpl();
  905. }
  906. }
  907. /// <summary>
  908. /// 参数改变时,重新处理图像
  909. /// </summary>
  910. private void applyButtonImpl()
  911. {
  912. if (this.lstPic.FocusedItem != null)
  913. {
  914. //拼接中间数据
  915. List<List<string>> dataList = new List<List<string>>();
  916. List<string> columnName = new List<string>();
  917. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  918. columnName.Add(PdnResources.GetString("Menu.viewname.text"));
  919. columnName.Add(PdnResources.GetString("Menu.area.text"));
  920. dataList.Add(columnName);
  921. string imgName = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetFriendlyName();
  922. string tag = this.imageList1.Images.Keys[this.lstPic.SelectedItems[0].Index];
  923. dataGridView1.Rows.Clear();
  924. mainPolyphaseAnalysisResults.Clear();
  925. int selectIndex = this.lstPic.FocusedItem.Index;
  926. double unitLength;
  927. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  928. unitLength = this.appWorkspace.DocumentWorkspaces[selectIndex].GetRuler(MeasurementUnit.Micron);
  929. //判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
  930. if (this.appWorkspace.DocumentWorkspaces[selectIndex].GraphicsList.IsExsitView())
  931. {
  932. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
  933. {
  934. PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
  935. if (pModel.choise)
  936. {
  937. Color pColor = new Color();
  938. pColor = Color.FromArgb(pModel.color);
  939. Mat front = pModel.mat;
  940. //相总面积
  941. double phaseAmount = AnalysisTools.GetPointsFromMat(front);
  942. //视图中相面积
  943. Bitmap frontTarget = this.m_documentWorkspace.GetFullSizeWithRegion(front.ToBitmap());
  944. //frontTarget.Save("D:\\1-1.bmp");
  945. //获取视图中相的点合计
  946. //int frontAmount = AnalysisTools.GetPointsFromMat(PaintDotNet.Camera.Tools.ToMat(frontTarget));
  947. Mat background = this.imageMat.Clone();
  948. Mat roi = new Mat(background, new Rect(0, 0, background.Width, background.Height));
  949. Mat mask = Mat.FromImageData(front.ToBytes(), ImreadModes.Grayscale);
  950. front.CopyTo(roi, mask);
  951. Bitmap target = this.m_documentWorkspace.GetFullSizeWithRegion(background.ToBitmap());
  952. Mat targetMat = PaintDotNet.Camera.Tools.ToMat(target);
  953. //获取合并后视场内的点合计
  954. int allAmount = AnalysisTools.GetPointsFromMat(targetMat);
  955. int picAmount = AnalysisTools.GetPointsFromMat(background);
  956. double cRate = 0f;
  957. cRate = (double)phaseAmount / allAmount;
  958. //计算面积
  959. double cArea = phaseAmount;
  960. //计算相含量
  961. double fRate = (double)phaseAmount / picAmount;
  962. //dataGridView1.Rows.Add(this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name, cArea, cRate, fRate);
  963. PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
  964. pResult.GraphName = this.lstPic.FocusedItem.Text;
  965. pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
  966. pResult.PolyphaseArea = cArea * unitLength * unitLength;
  967. pResult.PolyphaseRate = cRate * 100;
  968. pResult.PolyphaseAllRate = fRate * 100;
  969. mainPolyphaseAnalysisResults.Add(pResult);
  970. dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
  971. // 中间数据
  972. List<string> strList = new List<string>();
  973. strList.Add(i.ToString());
  974. strList.Add(pResult.PolyphaseName);
  975. strList.Add(pResult.PolyphaseArea.ToString());
  976. dataList.Add(strList);
  977. }
  978. }
  979. }
  980. else
  981. {
  982. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
  983. {
  984. PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
  985. if (pModel.choise)
  986. {
  987. Color pColor = new Color();
  988. pColor = Color.FromArgb(pModel.color);
  989. double phaseArea = AnalysisTools.GetPointsFromMat(pModel.mat);
  990. Mat sourceMat = this.imageMat.Clone();
  991. int picAmount = AnalysisTools.GetPointsFromMat(sourceMat);
  992. //计算面积
  993. double cRate = (double)phaseArea / picAmount;
  994. PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
  995. pResult.GraphName = this.lstPic.FocusedItem.Text;
  996. pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
  997. pResult.PolyphaseArea = phaseArea * unitLength * unitLength;
  998. pResult.PolyphaseRate = cRate * 100;
  999. pResult.PolyphaseAllRate = cRate * 100;
  1000. mainPolyphaseAnalysisResults.Add(pResult);
  1001. dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
  1002. // 中间数据
  1003. List<string> strList = new List<string>();
  1004. strList.Add(i.ToString());
  1005. strList.Add(pResult.PolyphaseName);
  1006. strList.Add(pResult.PolyphaseArea.ToString());
  1007. dataList.Add(strList);
  1008. }
  1009. }
  1010. }
  1011. // 中间数据
  1012. bool isExist = false;//是否已存在进行替换
  1013. int modelIndex = -1;//要替换的下标
  1014. for (int j = 0; j < tempDataModel.Count; j++)
  1015. {
  1016. if (tempDataModel[j].tagName.Equals(tag))
  1017. {
  1018. isExist = true;
  1019. modelIndex = j;
  1020. break;
  1021. }
  1022. }
  1023. if (isExist && modelIndex > -1)
  1024. tempDataModel[modelIndex].dataList = dataList;
  1025. else
  1026. {
  1027. ExportProjectModel newModel = new ExportProjectModel();
  1028. newModel.tagName = tag;
  1029. newModel.picName = imgName;
  1030. newModel.dataList = dataList;
  1031. tempDataModel.Add(newModel);
  1032. }
  1033. show_avg();
  1034. }
  1035. }
  1036. private void show_avg()
  1037. {
  1038. if (lstPic.FocusedItem != null)
  1039. {
  1040. var results = mainPolyphaseAnalysisResults.Where(p => p.GraphName.Equals(lstPic.FocusedItem.Text));
  1041. if (results.Count() > 0)
  1042. {
  1043. lblArea.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseArea), decnum);
  1044. lblRate.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseRate), decnum);
  1045. lblContent.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseAllRate), decnum);
  1046. if (m_levelList != null && m_levelList.Rows.Count > 0)
  1047. {
  1048. m_level = "";
  1049. for (int i = 0; i < m_levelList.Rows.Count; ++i)
  1050. {
  1051. decimal avg = decimal.Parse(lblContent.Text);
  1052. decimal minValue = decimal.Parse(m_levelList.Rows[i]["minValue"].ToString());
  1053. decimal maxValue = decimal.Parse(m_levelList.Rows[i]["maxValue"].ToString());
  1054. if (avg >= minValue && avg < maxValue)
  1055. {
  1056. m_level = m_levelList.Rows[i]["name"].ToString();
  1057. break;
  1058. }
  1059. }
  1060. lblLevel.Text = m_level;
  1061. if (m_level.Equals(""))
  1062. {
  1063. //MessageBox.Show("没有对应的级别信息");
  1064. }
  1065. }
  1066. }
  1067. }
  1068. }
  1069. private void cmbSpecial_SelectedIndexChanged(object sender, EventArgs e)
  1070. {
  1071. this.InitSpecialLevelList();
  1072. this.Measure();
  1073. }
  1074. /// <summary>
  1075. /// 初始化专项级别列表
  1076. /// </summary>
  1077. public void InitSpecialLevelList()
  1078. {
  1079. m_specialId = m_specialList.Rows[this.cmbSpecial.SelectedIndex]["id"].ToString();
  1080. dgvLevelList.AutoGenerateColumns = false;
  1081. dgvLevelList.AllowUserToAddRows = false;
  1082. dgvLevelList.ReadOnly = true;
  1083. this.dgvLevelList.Rows.Clear();
  1084. string select_sql = "select * from mic_special_definition_info where special_id = '" + m_specialId + "'"; //查询的SQL语句
  1085. m_levelList = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  1086. if (m_levelList.Rows.Count > 0)
  1087. {
  1088. dgvLevelList.Rows.Add(m_levelList.Rows.Count);
  1089. for (int i = 0; i < m_levelList.Rows.Count; ++i)
  1090. {
  1091. dgvLevelList.Rows[i].Cells["name"].Value = m_levelList.Rows[i]["name"].ToString();
  1092. dgvLevelList.Rows[i].Cells["minValue"].Value = m_levelList.Rows[i]["minValue"];
  1093. dgvLevelList.Rows[i].Cells["maxValue"].Value = m_levelList.Rows[i]["maxValue"];
  1094. }
  1095. }
  1096. }
  1097. /// <summary>
  1098. /// 小数位数变化
  1099. /// </summary>
  1100. /// <param name="sender"></param>
  1101. /// <param name="e"></param>
  1102. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1103. {
  1104. decnum = (int)numericUpDown1.Value;
  1105. RefreshDataGridView1();
  1106. RefreshDgvResult();
  1107. show_avg();
  1108. }
  1109. private void RefreshDataGridView1()
  1110. {
  1111. dataGridView1.Rows.Clear();
  1112. for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
  1113. {
  1114. PolyphaseAnalysisResult pResult = mainPolyphaseAnalysisResults[i];
  1115. dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
  1116. }
  1117. }
  1118. private void btnAllShow_Click(object sender, EventArgs e)
  1119. {
  1120. m_showAll = true;
  1121. RefreshDgvResult();
  1122. }
  1123. private void btnResultDel_Click(object sender, EventArgs e)
  1124. {
  1125. if (this.lstResult.SelectedItems != null && this.lstResult.SelectedItems.Count > 0)
  1126. {
  1127. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallmeasurementsimage.Text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1128. if (dr == DialogResult.OK)
  1129. {
  1130. foreach (ListViewItem item in this.lstResult.Items)
  1131. {
  1132. if (item.Selected)
  1133. {
  1134. this.lstResult.Items.Remove(item);
  1135. this.polyphaseAnalysisResults.RemoveAll(u => u.Tag == item.Name.ToString());
  1136. if (bitDic.ContainsKey(item.Name.ToString()))
  1137. {
  1138. bitDic[item.Name.ToString()].Clear();
  1139. }
  1140. }
  1141. }
  1142. //RefreshDgvResult();
  1143. }
  1144. }
  1145. }
  1146. private void RefreshDgvResult()
  1147. {
  1148. dgvResult.Rows.Clear();
  1149. if (m_showAll)
  1150. {
  1151. for (int i = 0; i < polyphaseAnalysisResults.Count; i++)
  1152. {
  1153. MeasureAreaResult aResult = polyphaseAnalysisResults[i];
  1154. dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), aResult.Level, aResult.Tag);
  1155. }
  1156. }
  1157. else
  1158. {
  1159. if (this.lstResult.SelectedItems != null && this.lstResult.SelectedItems.Count > 0)
  1160. {
  1161. for (int i = 0; i < this.lstResult.SelectedItems.Count; i++)
  1162. {
  1163. string tag = this.lstResult.SelectedItems[i].Name.ToString();
  1164. List<MeasureAreaResult> findResults = polyphaseAnalysisResults.FindAll(item => item.Tag.Equals(tag));
  1165. for (int j = 0; j < findResults.Count; j++)
  1166. {
  1167. MeasureAreaResult aResult = findResults[j];
  1168. dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), aResult.Level, aResult.Tag);
  1169. }
  1170. }
  1171. }
  1172. }
  1173. }
  1174. private void lstResult_SelectedIndexChanged(object sender, EventArgs e)
  1175. {
  1176. m_showAll = false;
  1177. RefreshDgvResult();
  1178. }
  1179. private void btnSave_Click(object sender, EventArgs e)
  1180. {
  1181. if (!m_isMeasure)
  1182. {
  1183. MessageBox.Show(PdnResources.GetString("Menu.tyetmeasured.Text"));
  1184. return;
  1185. }
  1186. if (lstPic.SelectedItems.Count == 0)
  1187. {
  1188. MessageBox.Show(PdnResources.GetString("Menu.selectthepictureyoanttomeasure.Text"));
  1189. return;
  1190. }
  1191. if (this.lstPic.FocusedItem != null && this.lstPic.SelectedItems.Count > 0)
  1192. {
  1193. string tag = this.imageList1.Images.Keys[this.lstPic.SelectedItems[0].Index];
  1194. string imgName = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetFriendlyName();
  1195. if (mainPolyphaseAnalysisResults.Count <= 0)
  1196. {
  1197. MessageBox.Show(PdnResources.GetString("Menu.hereisnofieldo.Text"));
  1198. return;
  1199. }
  1200. if (polyphaseAnalysisResults.FindAll(item => item.Tag.Equals(tag)).Count == 0)
  1201. {
  1202. ListViewItem listViewItem = new ListViewItem();
  1203. listViewItem.Name = tag;
  1204. listViewItem.SubItems[0].Text = imgName;
  1205. this.lstResult.Items.Add(listViewItem);
  1206. this.lstResult.SelectedItems.Clear();
  1207. this.lstResult.Items[this.lstResult.Items.Count - 1].Selected = true;
  1208. //保存处理后的图片
  1209. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1210. List<Bitmap> tempBit = new List<Bitmap>();
  1211. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1212. originalBit.Tag = pantographRatio;
  1213. tempBit.Add(originalBit);
  1214. for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
  1215. {
  1216. PolyphaseAnalysisResult aResult = mainPolyphaseAnalysisResults[i];
  1217. dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), m_level, tag);
  1218. MeasureAreaResult areaResult = new MeasureAreaResult();
  1219. areaResult.GraphName = aResult.GraphName;
  1220. areaResult.PolyphaseName = aResult.PolyphaseName;
  1221. areaResult.PolyphaseArea = aResult.PolyphaseArea;
  1222. areaResult.PolyphaseRate = aResult.PolyphaseRate;
  1223. areaResult.PolyphaseAllRate = aResult.PolyphaseAllRate;
  1224. areaResult.Level = m_level;
  1225. areaResult.Tag = tag;
  1226. polyphaseAnalysisResults.Add(areaResult);
  1227. PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].phaseModels[i];
  1228. Bitmap processedBit = BitmapConverter.ToBitmap(pModel.mat);
  1229. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1230. Graphics graphics = Graphics.FromImage(newBit);
  1231. graphics.DrawImage(processedBit, new PointF(0, 0));
  1232. //Bitmap newBit = BitmapConverter.ToBitmap(pModel.mat);
  1233. newBit.Tag = pantographRatio;
  1234. tempBit.Add(newBit);
  1235. }
  1236. //Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1237. //Graphics graphics = Graphics.FromImage(newBit);
  1238. //Draw(graphics);
  1239. //tempBit.Add(newBit);
  1240. if (bitDic.ContainsKey(tag))
  1241. {
  1242. bitDic[tag].Clear();
  1243. bitDic[tag] = tempBit;
  1244. }
  1245. else
  1246. {
  1247. bitDic.Add(tag, tempBit);
  1248. }
  1249. }
  1250. else
  1251. {
  1252. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1253. }
  1254. //if (m_level == null || m_level.Equals(""))
  1255. //{
  1256. // MessageBox.Show(PdnResources.GetString("Menu.tnocorrespondinglevel.Text"));
  1257. //}
  1258. //else
  1259. //{
  1260. // MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
  1261. //}
  1262. }
  1263. }
  1264. private void Draw(Graphics graphics)
  1265. {
  1266. if (this.m_documentWorkspace.GraphicsList.Count > 0)
  1267. {
  1268. this.m_documentWorkspace.GraphicsList.Draw(graphics);
  1269. }
  1270. if (this.m_documentWorkspace.phaseModels.Count > 0)
  1271. {
  1272. foreach (PhaseModel model in this.m_documentWorkspace.phaseModels)
  1273. {
  1274. if (model.choise && model.mat != null)
  1275. {
  1276. Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
  1277. graphics.DrawImage(map, 0, 0, map.Width, map.Height);
  1278. }
  1279. }
  1280. }
  1281. }
  1282. private void btnMeasure_Click(object sender, EventArgs e)
  1283. {
  1284. if(cmbSpecial.SelectedItem == null || m_levelList == null || m_levelList.Rows.Count <= 0)
  1285. {
  1286. MessageBox.Show(PdnResources.GetString("Menu.efirstse.Text"));
  1287. return;
  1288. }
  1289. m_isMeasure = !m_isMeasure;
  1290. UpdateMeasureUIAndState();
  1291. }
  1292. private void UpdateMeasureUIAndState()
  1293. {
  1294. if (m_isMeasure)
  1295. {
  1296. if(polyphaseAnalysisResults.Count > 0)
  1297. {
  1298. if(m_specialSelectedIndex != this.cmbSpecial.SelectedIndex)
  1299. {
  1300. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.learthelastmeasuremen.Text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1301. if (dr == DialogResult.OK)
  1302. {
  1303. this.lstResult.Items.Clear();
  1304. this.polyphaseAnalysisResults.Clear();
  1305. this.bitDic.Clear();
  1306. this.dgvResult.Rows.Clear();
  1307. }
  1308. else
  1309. {
  1310. m_isMeasure = false;
  1311. return;
  1312. }
  1313. }
  1314. }
  1315. m_specialSelectedIndex = this.cmbSpecial.SelectedIndex;
  1316. btnMeasure.Text = PdnResources.GetString("Menu.Stopmeasure.text");
  1317. cmbSpecial.Enabled = false;
  1318. }
  1319. else
  1320. {
  1321. btnMeasure.Text = PdnResources.GetString("Menu.Startmeasuring.text");
  1322. cmbSpecial.Enabled = true;
  1323. }
  1324. }
  1325. private void chkOpenSetting_CheckedChanged(object sender, EventArgs e)
  1326. {
  1327. }
  1328. private void OpenSettingDialog()
  1329. {
  1330. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.SpecialArea");
  1331. if (recombinationRateSetDialog.hasModule)
  1332. {
  1333. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1334. recombinationRateSetDialog.ShowDialog();
  1335. }
  1336. else
  1337. {
  1338. recombinationRateSetDialog = null;
  1339. }
  1340. }
  1341. private void btnSetting_Click(object sender, EventArgs e)
  1342. {
  1343. OpenSettingDialog();
  1344. }
  1345. /// <summary>
  1346. /// 生成报告
  1347. /// </summary>
  1348. /// <param name="sender"></param>
  1349. /// <param name="e"></param>
  1350. private void btnCreate_Click(object sender, EventArgs e)
  1351. {
  1352. if (this.dgvResult.Rows.Count <= 0)
  1353. {
  1354. MessageBox.Show(PdnResources.GetString("Menu.nodata.text"));
  1355. return;
  1356. }
  1357. if (chkOpenSetting.Checked)
  1358. {
  1359. OpenSettingDialog();
  1360. }
  1361. this.bitList.Clear();
  1362. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1363. {
  1364. //获取word书签与excel单元格的关系,以字典方式存储
  1365. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1366. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1367. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1368. {
  1369. foreach (mic_module_infos info in mic_module_infos)
  1370. {
  1371. tagInfos.Add(info.tag_name, info.cell_position);
  1372. }
  1373. }
  1374. List<List<string>> analysisContent = new List<List<string>>();
  1375. for (int i = 0; i < this.dgvResult.Rows.Count; i++)
  1376. {
  1377. List<string> content1 = new List<string>();
  1378. if (i == 0)
  1379. {
  1380. content1.Add(this.dgvResult.Columns[0].HeaderText);
  1381. content1.Add(this.dgvResult.Columns[1].HeaderText);
  1382. content1.Add(this.dgvResult.Columns[2].HeaderText);
  1383. content1.Add(this.dgvResult.Columns[3].HeaderText);
  1384. content1.Add(this.dgvResult.Columns[4].HeaderText);
  1385. content1.Add(this.dgvResult.Columns[5].HeaderText);
  1386. analysisContent.Add(content1);
  1387. }
  1388. content1 = new List<string>();
  1389. content1.Add(this.dgvResult.Rows[i].Cells[0].Value.ToString());
  1390. content1.Add(this.dgvResult.Rows[i].Cells[1].Value.ToString());
  1391. content1.Add(this.dgvResult.Rows[i].Cells[2].Value.ToString());
  1392. content1.Add(this.dgvResult.Rows[i].Cells[3].Value.ToString());
  1393. content1.Add(this.dgvResult.Rows[i].Cells[4].Value.ToString());
  1394. content1.Add(this.dgvResult.Rows[i].Cells[5].Value.ToString());
  1395. analysisContent.Add(content1);
  1396. //图片
  1397. string tag = this.dgvResult.Rows[i].Cells[6].Value.ToString();
  1398. if (bitDic.ContainsKey(tag))
  1399. {
  1400. bitList.Add(bitDic[tag][0]);
  1401. bitList.Add(bitDic[tag][1]);
  1402. }
  1403. }
  1404. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1405. }
  1406. else
  1407. {
  1408. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1409. }
  1410. }
  1411. /// <summary>
  1412. /// 导出结果
  1413. /// </summary>
  1414. /// <param name="sender"></param>
  1415. /// <param name="e"></param>
  1416. private void btnExport_Click(object sender, EventArgs e)
  1417. {
  1418. if (this.dgvResult.Rows.Count > 0)
  1419. {
  1420. SaveFileDialog exe = new SaveFileDialog();
  1421. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1422. exe.FilterIndex = 0;
  1423. exe.RestoreDirectory = true;
  1424. exe.Title = "Export Excel File";
  1425. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1426. exe.FileName = PdnResources.GetString("Menu.cialsurveyresultsofareacontentsurv.Text") + DateTime.Now.ToString("yyyyMMddhhmmss");
  1427. DialogResult dr = exe.ShowDialog();
  1428. if (dr == DialogResult.OK)
  1429. {
  1430. DataTable dtb = new DataTable();
  1431. for (int i = 0; i < this.dgvResult.Columns.Count-1; i++)
  1432. {
  1433. dtb.Columns.Add(this.dgvResult.Columns[i].HeaderText);
  1434. }
  1435. for (int r = 0; r < this.dgvResult.Rows.Count; r++)
  1436. {
  1437. DataRow dataRow = dtb.NewRow();
  1438. for (int c = 0; c < this.dgvResult.Rows[r].Cells.Count - 1; c++)
  1439. {
  1440. dataRow[this.dgvResult.Columns[c].HeaderText] = this.dgvResult.Rows[r].Cells[c].Value;
  1441. }
  1442. dtb.Rows.Add(dataRow);
  1443. }
  1444. List<DataTable> list = new List<DataTable>();
  1445. list.Add(dtb);
  1446. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1447. }
  1448. }
  1449. else
  1450. {
  1451. MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
  1452. }
  1453. }
  1454. /// <summary>
  1455. /// 导出项目
  1456. /// </summary>
  1457. /// <param name="sender"></param>
  1458. /// <param name="e"></param>
  1459. private void btnExportProject_Click(object sender, EventArgs e)
  1460. {
  1461. try
  1462. {
  1463. if (this.analyzeSettingModel == null)
  1464. {
  1465. MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text"));
  1466. return;
  1467. }
  1468. //获取项目工程内的文件夹路径
  1469. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.SpecialMeasure.Text", this.analyzeSettingModel.savePath);
  1470. if (item == null)
  1471. {
  1472. return;
  1473. }
  1474. bitList.Clear();
  1475. //向文件夹内保存图片和报告
  1476. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1477. {
  1478. //获取word书签与excel单元格的关系,以字典方式存储
  1479. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1480. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1481. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1482. {
  1483. foreach (mic_module_infos info in mic_module_infos)
  1484. {
  1485. tagInfos.Add(info.tag_name, info.cell_position);
  1486. }
  1487. }
  1488. List<ExportProjectModel> dataModel = new List<ExportProjectModel>();
  1489. List<List<string>> analysisContent = new List<List<string>>();
  1490. for (int i = 0; i < this.dgvResult.Rows.Count; i++)
  1491. {
  1492. List<string> content1 = new List<string>();
  1493. if (i == 0)
  1494. {
  1495. content1.Add(this.dgvResult.Columns[0].HeaderText);
  1496. content1.Add(this.dgvResult.Columns[1].HeaderText);
  1497. content1.Add(this.dgvResult.Columns[2].HeaderText);
  1498. content1.Add(this.dgvResult.Columns[3].HeaderText);
  1499. content1.Add(this.dgvResult.Columns[4].HeaderText);
  1500. content1.Add(this.dgvResult.Columns[5].HeaderText);
  1501. analysisContent.Add(content1);
  1502. }
  1503. content1 = new List<string>();
  1504. content1.Add(this.dgvResult.Rows[i].Cells[0].Value.ToString());
  1505. content1.Add(this.dgvResult.Rows[i].Cells[1].Value.ToString());
  1506. content1.Add(this.dgvResult.Rows[i].Cells[2].Value.ToString());
  1507. content1.Add(this.dgvResult.Rows[i].Cells[3].Value.ToString());
  1508. content1.Add(this.dgvResult.Rows[i].Cells[4].Value.ToString());
  1509. content1.Add(this.dgvResult.Rows[i].Cells[5].Value.ToString());
  1510. analysisContent.Add(content1);
  1511. //图片
  1512. string tag = this.dgvResult.Rows[i].Cells[6].Value.ToString();
  1513. if (bitDic.ContainsKey(tag))
  1514. {
  1515. bitList.Add(bitDic[tag][0]);
  1516. bitList.Add(bitDic[tag][1]);
  1517. }
  1518. // 中间数据
  1519. foreach (ExportProjectModel data in tempDataModel)
  1520. {
  1521. if (data.tagName.Equals(tag))
  1522. {
  1523. dataModel.Add(data);
  1524. }
  1525. }
  1526. }
  1527. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, dataModel, bitList, tagInfos, item.path, item.code);
  1528. }
  1529. else
  1530. {
  1531. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1532. return;
  1533. }
  1534. //保存项目信息到数据库
  1535. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  1536. }
  1537. catch (Exception)
  1538. {
  1539. }
  1540. }
  1541. /// <summary>
  1542. /// 获取上次操作参数
  1543. /// </summary>
  1544. private void getLastData()
  1545. {
  1546. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1547. if (!System.IO.File.Exists(filePath))
  1548. {
  1549. generalAnalysisModel = new GeneralAnalysisModel();
  1550. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1551. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1552. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1553. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1554. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1555. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1556. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1557. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1558. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1559. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1560. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1561. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1562. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1563. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1564. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1565. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1566. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1567. }
  1568. else
  1569. {
  1570. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1571. if (generalAnalysisModel.SpecialMeasureAreaModels == null)
  1572. {
  1573. generalAnalysisModel.SpecialMeasureAreaModels = new GeneralAnalysisModel.SpecialMeasureAreaModel();
  1574. }
  1575. if (generalAnalysisModel.SpecialMeasureAreaModels.hasUsed)
  1576. {
  1577. if (cmbSpecial.Items.Count >= (generalAnalysisModel.SpecialMeasureAreaModels.parameter1 - 1))
  1578. {
  1579. cmbSpecial.SelectedIndex = generalAnalysisModel.SpecialMeasureAreaModels.parameter1;
  1580. }
  1581. else
  1582. {
  1583. cmbSpecial.SelectedIndex = 0;
  1584. }
  1585. chkOpenSetting.Checked = generalAnalysisModel.SpecialMeasureAreaModels.parameter2;
  1586. numericUpDown1.Value = generalAnalysisModel.SpecialMeasureAreaModels.parameter3;
  1587. }
  1588. }
  1589. }
  1590. /// <summary>
  1591. /// 保存上次操作参数
  1592. /// </summary>
  1593. private void saveLastData(object sender, EventArgs e)
  1594. {
  1595. if (generalAnalysisModel.SpecialMeasureAreaModels == null)
  1596. {
  1597. generalAnalysisModel.SpecialMeasureAreaModels = new GeneralAnalysisModel.SpecialMeasureAreaModel();
  1598. }
  1599. generalAnalysisModel.SpecialMeasureAreaModels.hasUsed = true;
  1600. generalAnalysisModel.SpecialMeasureAreaModels.parameter1 = cmbSpecial.SelectedIndex;
  1601. generalAnalysisModel.SpecialMeasureAreaModels.parameter2 = chkOpenSetting.Checked;
  1602. generalAnalysisModel.SpecialMeasureAreaModels.parameter3 = (int)numericUpDown1.Value;
  1603. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1604. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1605. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1606. }
  1607. }
  1608. }