PetroleumGeologyStandardDialog.cs 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759
  1. using OpenCvSharp;
  2. using PaintDotNet.Annotation;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Base;
  5. using PaintDotNet.Base.CommTool;
  6. using PaintDotNet.Base.Functionodel;
  7. using PaintDotNet.Base.SettingModel;
  8. using PaintDotNet.CustomControl;
  9. using PaintDotNet.Data.Action;
  10. using PaintDotNet.Data.Param;
  11. using PaintDotNet.DbOpreate.DbModel;
  12. using PaintDotNet.Instrument;
  13. using System;
  14. using System.Collections;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Drawing;
  19. using System.Drawing.Drawing2D;
  20. using System.IO;
  21. using System.Windows.Forms;
  22. using Point = System.Drawing.Point;
  23. namespace PaintDotNet.DedicatedAnalysis.PetroleumGeology
  24. {
  25. internal class PetroleumGeologyStandardDialog : PdnBaseForm
  26. {
  27. protected Mat testMat;
  28. #region 属性
  29. /// <summary>
  30. /// 主控件
  31. /// </summary>
  32. private AppWorkspace appWorkspace;
  33. /// <summary>
  34. /// 公共按钮
  35. /// </summary>
  36. private CommonControlButtons commonControlButtons;
  37. /// <summary>
  38. /// 图像面板
  39. /// </summary>
  40. protected DocumentWorkspaceWindow documentWorkspace;
  41. /// <summary>
  42. /// 当前选择的图片
  43. /// </summary>
  44. protected Bitmap bitmap;
  45. /// <summary>
  46. /// 当前选择的图片
  47. /// </summary>
  48. protected Mat matOrg;
  49. public bool comboboxChange = true;
  50. /// <summary>
  51. /// 图形位置
  52. /// </summary>
  53. private PointF m_StartPoint = Point.Empty;
  54. protected bool m_canMove;
  55. //二值化集成1
  56. BinaryClass binaryClass;
  57. //分析结果列表的头标题
  58. /// <summary>
  59. /// PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), "网格面积", PdnResources.GetString("Menu.Numberofgrains.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text")
  60. /// </summary>
  61. List<string> contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text"), PdnResources.GetString("Menu.Numberofgrains.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text") };
  62. /// <summary>
  63. /// 保存用于生成报告的图片
  64. /// </summary>
  65. protected List<Bitmap> bitList;
  66. /// <summary>
  67. /// 储存点击保存结果后的所有原图与分析图
  68. /// </summary>
  69. protected Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  70. /// <summary>
  71. /// 中间数据
  72. /// </summary>
  73. protected List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  74. /// <summary>
  75. /// 分析结果暂存
  76. /// </summary>
  77. protected List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
  78. /// <summary>
  79. /// 全部显示
  80. /// </summary>
  81. protected bool allShow = false;
  82. private int defaultIndex = -1;
  83. #endregion
  84. #region 组件
  85. private GroupBox groupBox_operating;
  86. protected GroupBox groupBox_img;
  87. private ListView lstView_img;
  88. private ImageList imageList_img;
  89. private IContainer components;
  90. protected GroupBox groupBox_review;
  91. protected GroupBox groupBox_report;
  92. private Label label_resultPrecision;
  93. private Button button_exportResults;
  94. private Button button_generateReport;
  95. protected GroupBox groupBox6groupBox_analysisResult2;
  96. protected GroupBox groupBox_analysisResult1;
  97. private ToolTip toolTip_GrainSizeDetails;
  98. private Button button_setting;
  99. private CheckBox checkBox_generateReport_opensetting;
  100. protected DataGridView dataGridView2;
  101. protected ListView listView2;
  102. private Button button16;
  103. private Button button12;
  104. private Button button11;
  105. private NumericUpDown numericUpDown1_0;
  106. private Button button1;
  107. private DataGridViewTextBoxColumn Column1;
  108. private DataGridViewTextBoxColumn Column2;
  109. private DataGridViewTextBoxColumn Column3;
  110. private DataGridViewTextBoxColumn Column4;
  111. private DataGridViewTextBoxColumn Column5;
  112. private BinaryControl bc;
  113. private Button btn_saveresult;
  114. #endregion
  115. #region 构造函数
  116. public PetroleumGeologyStandardDialog(AppWorkspace appWorkspace, string dialogText, bool isAreaType)
  117. {
  118. this.appWorkspace = appWorkspace;
  119. this.Text = dialogText;
  120. this.Icon = PdnInfo.AppIcon;
  121. this.Load += new System.EventHandler(this.PetroleumGeologyStandardDialog_Load);
  122. InitializeComponent();
  123. InitializeCustomControl();
  124. InitializeLanguageText();
  125. Initialize();
  126. SubclassInitialize();
  127. binaryClass = new BinaryClass();
  128. //二值化集成2
  129. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  130. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"), PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text") }
  131. , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
  132. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  133. //初始化头
  134. this.listView2.View = View.Details;
  135. ColumnHeader header0 = new ColumnHeader();
  136. header0.Text = "";
  137. header0.Width = 180;
  138. this.listView2.Columns.Add(header0);
  139. this.button11.Visible = true;
  140. this.button16.Visible = false;
  141. SetAnalyzeModelFromXml(getTemplateName());
  142. }
  143. public PetroleumGeologyStandardDialog()
  144. {
  145. InitializeComponent();
  146. }
  147. #endregion
  148. #region 初始化组件
  149. private void InitializeLanguageText()
  150. {
  151. this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
  152. this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  153. this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
  154. this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
  155. this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  156. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  157. this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
  158. this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text");
  159. this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
  160. this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  161. this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  162. this.Column2.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.holearea.text");
  163. this.Column3.HeaderText = PdnResources.GetString("Menu.Thethroatwidth.text");
  164. this.Column4.HeaderText = PdnResources.GetString("Menu.Apparentdiameterofparticle.text");
  165. this.Column5.HeaderText = PdnResources.GetString("Menu.Gradeclassification.text");
  166. this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
  167. this.button11.Text = PdnResources.GetString("Menu.Showall.text");
  168. this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  169. this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  170. }
  171. private void InitializeCustomControl()
  172. {
  173. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  174. //
  175. // bc
  176. //
  177. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  178. this.bc.BinaryChecked = false;
  179. this.bc.BinaryStyle = 1;
  180. this.bc.Location = new System.Drawing.Point(175, 69);
  181. this.bc.Name = "bc";
  182. this.bc.OriginChecked = false;
  183. this.bc.scope1End = 0D;
  184. this.bc.scope1Start = 0D;
  185. this.bc.scope2End = 0D;
  186. this.bc.scope2Start = 0D;
  187. this.bc.scope3End = 0D;
  188. this.bc.scope3Start = 0D;
  189. this.bc.Size = new System.Drawing.Size(360, 292);
  190. this.bc.TabIndex = 35;
  191. this.Controls.Add(this.bc);
  192. this.Controls.SetChildIndex(this.bc, 0);
  193. }
  194. private void InitializeComponent()
  195. {
  196. this.components = new System.ComponentModel.Container();
  197. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  198. this.groupBox_operating = new System.Windows.Forms.GroupBox();
  199. this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
  200. this.button_setting = new System.Windows.Forms.Button();
  201. this.btn_saveresult = new System.Windows.Forms.Button();
  202. this.groupBox_img = new System.Windows.Forms.GroupBox();
  203. this.lstView_img = new System.Windows.Forms.ListView();
  204. this.imageList_img = new System.Windows.Forms.ImageList(this.components);
  205. this.groupBox_review = new System.Windows.Forms.GroupBox();
  206. this.groupBox_report = new System.Windows.Forms.GroupBox();
  207. this.button1 = new System.Windows.Forms.Button();
  208. this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
  209. this.label_resultPrecision = new System.Windows.Forms.Label();
  210. this.button_exportResults = new System.Windows.Forms.Button();
  211. this.button_generateReport = new System.Windows.Forms.Button();
  212. this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
  213. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  214. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  215. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  216. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  217. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  218. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  219. this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
  220. this.button11 = new System.Windows.Forms.Button();
  221. this.listView2 = new System.Windows.Forms.ListView();
  222. this.button16 = new System.Windows.Forms.Button();
  223. this.button12 = new System.Windows.Forms.Button();
  224. this.toolTip_GrainSizeDetails = new System.Windows.Forms.ToolTip(this.components);
  225. this.groupBox_operating.SuspendLayout();
  226. this.groupBox_img.SuspendLayout();
  227. this.groupBox_report.SuspendLayout();
  228. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
  229. this.groupBox6groupBox_analysisResult2.SuspendLayout();
  230. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  231. this.groupBox_analysisResult1.SuspendLayout();
  232. this.SuspendLayout();
  233. //
  234. // groupBox_operating
  235. //
  236. this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  237. | System.Windows.Forms.AnchorStyles.Right)));
  238. this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
  239. this.groupBox_operating.Controls.Add(this.button_setting);
  240. this.groupBox_operating.Controls.Add(this.btn_saveresult);
  241. this.groupBox_operating.Location = new System.Drawing.Point(13, 12);
  242. this.groupBox_operating.Name = "groupBox_operating";
  243. this.groupBox_operating.Size = new System.Drawing.Size(1102, 53);
  244. this.groupBox_operating.TabIndex = 12;
  245. this.groupBox_operating.TabStop = false;
  246. //
  247. // checkBox_generateReport_opensetting
  248. //
  249. this.checkBox_generateReport_opensetting.AutoSize = true;
  250. this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  251. this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
  252. this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
  253. this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(132, 16);
  254. this.checkBox_generateReport_opensetting.TabIndex = 6;
  255. this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
  256. //
  257. // button_setting
  258. //
  259. this.button_setting.Location = new System.Drawing.Point(6, 20);
  260. this.button_setting.Name = "button_setting";
  261. this.button_setting.Size = new System.Drawing.Size(75, 23);
  262. this.button_setting.TabIndex = 4;
  263. this.button_setting.UseVisualStyleBackColor = true;
  264. this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
  265. //
  266. // btn_saveresult
  267. //
  268. this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  269. this.btn_saveresult.Location = new System.Drawing.Point(992, 20);
  270. this.btn_saveresult.Name = "btn_saveresult";
  271. this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
  272. this.btn_saveresult.TabIndex = 2;
  273. this.btn_saveresult.UseVisualStyleBackColor = true;
  274. this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
  275. //
  276. // groupBox_img
  277. //
  278. this.groupBox_img.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  279. | System.Windows.Forms.AnchorStyles.Left)));
  280. this.groupBox_img.Controls.Add(this.lstView_img);
  281. this.groupBox_img.Location = new System.Drawing.Point(13, 72);
  282. this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
  283. this.groupBox_img.Name = "groupBox_img";
  284. this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
  285. this.groupBox_img.Size = new System.Drawing.Size(158, 552);
  286. this.groupBox_img.TabIndex = 13;
  287. this.groupBox_img.TabStop = false;
  288. //
  289. // lstView_img
  290. //
  291. this.lstView_img.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  292. | System.Windows.Forms.AnchorStyles.Left)
  293. | System.Windows.Forms.AnchorStyles.Right)));
  294. this.lstView_img.HideSelection = false;
  295. this.lstView_img.LargeImageList = this.imageList_img;
  296. this.lstView_img.Location = new System.Drawing.Point(8, 26);
  297. this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
  298. this.lstView_img.MultiSelect = false;
  299. this.lstView_img.Name = "lstView_img";
  300. this.lstView_img.Size = new System.Drawing.Size(140, 518);
  301. this.lstView_img.TabIndex = 0;
  302. this.lstView_img.UseCompatibleStateImageBehavior = false;
  303. this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  304. //
  305. // imageList_img
  306. //
  307. this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  308. this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
  309. this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
  310. //
  311. // groupBox_review
  312. //
  313. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  314. | System.Windows.Forms.AnchorStyles.Left)
  315. | System.Windows.Forms.AnchorStyles.Right)));
  316. this.groupBox_review.Location = new System.Drawing.Point(519, 72);
  317. this.groupBox_review.Name = "groupBox_review";
  318. this.groupBox_review.Size = new System.Drawing.Size(597, 552);
  319. this.groupBox_review.TabIndex = 30;
  320. this.groupBox_review.TabStop = false;
  321. //
  322. // groupBox_report
  323. //
  324. this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  325. this.groupBox_report.Controls.Add(this.button1);
  326. this.groupBox_report.Controls.Add(this.numericUpDown1_0);
  327. this.groupBox_report.Controls.Add(this.label_resultPrecision);
  328. this.groupBox_report.Controls.Add(this.button_exportResults);
  329. this.groupBox_report.Controls.Add(this.button_generateReport);
  330. this.groupBox_report.Location = new System.Drawing.Point(974, 630);
  331. this.groupBox_report.Name = "groupBox_report";
  332. this.groupBox_report.Size = new System.Drawing.Size(142, 188);
  333. this.groupBox_report.TabIndex = 33;
  334. this.groupBox_report.TabStop = false;
  335. //
  336. // button1
  337. //
  338. this.button1.Location = new System.Drawing.Point(29, 102);
  339. this.button1.Name = "button1";
  340. this.button1.Size = new System.Drawing.Size(75, 23);
  341. this.button1.TabIndex = 23;
  342. this.button1.UseVisualStyleBackColor = true;
  343. this.button1.Click += new System.EventHandler(this.button1_Click);
  344. //
  345. // numericUpDown1_0
  346. //
  347. this.numericUpDown1_0.Location = new System.Drawing.Point(63, 150);
  348. this.numericUpDown1_0.Maximum = new decimal(new int[] {
  349. 10,
  350. 0,
  351. 0,
  352. 0});
  353. this.numericUpDown1_0.Name = "numericUpDown1_0";
  354. this.numericUpDown1_0.Size = new System.Drawing.Size(56, 21);
  355. this.numericUpDown1_0.TabIndex = 22;
  356. this.numericUpDown1_0.Value = new decimal(new int[] {
  357. 2,
  358. 0,
  359. 0,
  360. 0});
  361. this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
  362. //
  363. // label_resultPrecision
  364. //
  365. this.label_resultPrecision.AutoSize = true;
  366. this.label_resultPrecision.Location = new System.Drawing.Point(26, 154);
  367. this.label_resultPrecision.Name = "label_resultPrecision";
  368. this.label_resultPrecision.Size = new System.Drawing.Size(29, 12);
  369. this.label_resultPrecision.TabIndex = 3;
  370. //
  371. // button_exportResults
  372. //
  373. this.button_exportResults.Location = new System.Drawing.Point(29, 63);
  374. this.button_exportResults.Name = "button_exportResults";
  375. this.button_exportResults.Size = new System.Drawing.Size(75, 23);
  376. this.button_exportResults.TabIndex = 1;
  377. this.button_exportResults.UseVisualStyleBackColor = true;
  378. this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
  379. //
  380. // button_generateReport
  381. //
  382. this.button_generateReport.Location = new System.Drawing.Point(29, 24);
  383. this.button_generateReport.Name = "button_generateReport";
  384. this.button_generateReport.Size = new System.Drawing.Size(75, 23);
  385. this.button_generateReport.TabIndex = 0;
  386. this.button_generateReport.UseVisualStyleBackColor = true;
  387. this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
  388. //
  389. // groupBox6groupBox_analysisResult2
  390. //
  391. this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  392. | System.Windows.Forms.AnchorStyles.Right)));
  393. this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView2);
  394. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 630);
  395. this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
  396. this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(719, 188);
  397. this.groupBox6groupBox_analysisResult2.TabIndex = 32;
  398. this.groupBox6groupBox_analysisResult2.TabStop = false;
  399. //
  400. // dataGridView2
  401. //
  402. this.dataGridView2.AllowUserToAddRows = false;
  403. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  404. this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  405. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  406. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  407. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
  408. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  409. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  410. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  411. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  412. this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  413. this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  414. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  415. this.Column1,
  416. this.Column2,
  417. this.Column3,
  418. this.Column4,
  419. this.Column5});
  420. this.dataGridView2.Location = new System.Drawing.Point(13, 17);
  421. this.dataGridView2.Name = "dataGridView2";
  422. this.dataGridView2.ReadOnly = true;
  423. this.dataGridView2.RowHeadersVisible = false;
  424. this.dataGridView2.RowTemplate.Height = 23;
  425. this.dataGridView2.Size = new System.Drawing.Size(693, 160);
  426. this.dataGridView2.TabIndex = 16;
  427. //
  428. // Column1
  429. //
  430. this.Column1.Name = "Column1";
  431. this.Column1.ReadOnly = true;
  432. //
  433. // Column2
  434. //
  435. this.Column2.Name = "Column2";
  436. this.Column2.ReadOnly = true;
  437. //
  438. // Column3
  439. //
  440. this.Column3.Name = "Column3";
  441. this.Column3.ReadOnly = true;
  442. //
  443. // Column4
  444. //
  445. this.Column4.Name = "Column4";
  446. this.Column4.ReadOnly = true;
  447. //
  448. // Column5
  449. //
  450. this.Column5.Name = "Column5";
  451. this.Column5.ReadOnly = true;
  452. //
  453. // groupBox_analysisResult1
  454. //
  455. this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  456. this.groupBox_analysisResult1.Controls.Add(this.button11);
  457. this.groupBox_analysisResult1.Controls.Add(this.listView2);
  458. this.groupBox_analysisResult1.Controls.Add(this.button16);
  459. this.groupBox_analysisResult1.Controls.Add(this.button12);
  460. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 630);
  461. this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
  462. this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 188);
  463. this.groupBox_analysisResult1.TabIndex = 31;
  464. this.groupBox_analysisResult1.TabStop = false;
  465. //
  466. // button11
  467. //
  468. this.button11.BackColor = System.Drawing.SystemColors.Control;
  469. this.button11.Location = new System.Drawing.Point(19, 22);
  470. this.button11.Name = "button11";
  471. this.button11.Size = new System.Drawing.Size(63, 26);
  472. this.button11.TabIndex = 27;
  473. this.button11.UseVisualStyleBackColor = false;
  474. this.button11.Click += new System.EventHandler(this.button11_Click);
  475. //
  476. // listView2
  477. //
  478. this.listView2.FullRowSelect = true;
  479. this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
  480. this.listView2.HideSelection = false;
  481. this.listView2.Location = new System.Drawing.Point(19, 58);
  482. this.listView2.Name = "listView2";
  483. this.listView2.Size = new System.Drawing.Size(181, 124);
  484. this.listView2.TabIndex = 26;
  485. this.listView2.UseCompatibleStateImageBehavior = false;
  486. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
  487. //
  488. // button16
  489. //
  490. this.button16.BackColor = System.Drawing.SystemColors.Control;
  491. this.button16.Location = new System.Drawing.Point(19, 21);
  492. this.button16.Name = "button16";
  493. this.button16.Size = new System.Drawing.Size(93, 26);
  494. this.button16.TabIndex = 25;
  495. this.button16.UseVisualStyleBackColor = false;
  496. this.button16.Click += new System.EventHandler(this.button16_Click);
  497. //
  498. // button12
  499. //
  500. this.button12.BackColor = System.Drawing.SystemColors.Control;
  501. this.button12.Location = new System.Drawing.Point(149, 21);
  502. this.button12.Name = "button12";
  503. this.button12.Size = new System.Drawing.Size(52, 26);
  504. this.button12.TabIndex = 24;
  505. this.button12.UseVisualStyleBackColor = false;
  506. this.button12.Click += new System.EventHandler(this.button12_Click);
  507. //
  508. // PetroleumGeologyStandardDialog
  509. //
  510. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  511. this.ClientSize = new System.Drawing.Size(1127, 830);
  512. this.Controls.Add(this.groupBox_report);
  513. this.Controls.Add(this.groupBox6groupBox_analysisResult2);
  514. this.Controls.Add(this.groupBox_analysisResult1);
  515. this.Controls.Add(this.groupBox_review);
  516. this.Controls.Add(this.groupBox_img);
  517. this.Controls.Add(this.groupBox_operating);
  518. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  519. this.Name = "PetroleumGeologyStandardDialog";
  520. this.Controls.SetChildIndex(this.groupBox_operating, 0);
  521. this.Controls.SetChildIndex(this.groupBox_img, 0);
  522. this.Controls.SetChildIndex(this.groupBox_review, 0);
  523. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  524. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  525. this.Controls.SetChildIndex(this.groupBox_report, 0);
  526. this.groupBox_operating.ResumeLayout(false);
  527. this.groupBox_operating.PerformLayout();
  528. this.groupBox_img.ResumeLayout(false);
  529. this.groupBox_report.ResumeLayout(false);
  530. this.groupBox_report.PerformLayout();
  531. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
  532. this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
  533. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  534. this.groupBox_analysisResult1.ResumeLayout(false);
  535. this.ResumeLayout(false);
  536. }
  537. private void ShowImgEvent(object sender, EventArgs e)
  538. {
  539. lstView_img.Focus();
  540. if (this.defaultIndex != -1)
  541. {
  542. this.lstView_img.Items[defaultIndex].Focused = true;
  543. this.lstView_img.Items[defaultIndex].Selected = true;
  544. }
  545. }
  546. public void Initialize()
  547. {
  548. //初始化图片列表
  549. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  550. {
  551. this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  552. this.lstView_img.Items.Add("", i);
  553. this.lstView_img.Items[i].ImageIndex = i;
  554. this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  555. this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  556. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  557. {
  558. defaultIndex = i;
  559. }
  560. }
  561. this.Shown += ShowImgEvent;
  562. //
  563. //初始化图像控件
  564. //
  565. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  566. this.documentWorkspace.Cursor = Cursors.Default;
  567. this.documentWorkspace.Dock = DockStyle.Fill;
  568. this.documentWorkspace.HookMouseEvents();
  569. this.documentWorkspace.AuxiliaryLineEnabled = false;
  570. this.documentWorkspace.Visible = true;
  571. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  572. this.documentWorkspace.panel.Paint += Panel_Paint;
  573. this.documentWorkspace.panel.MouseMove += onMouseMove;
  574. this.documentWorkspace.panel.MouseUp += onMouseUp;
  575. this.groupBox_review.Controls.Add(this.documentWorkspace);
  576. //
  577. //初始化操作按钮
  578. //
  579. this.commonControlButtons = new CommonControlButtons();
  580. this.commonControlButtons.Dock = DockStyle.Top;
  581. this.commonControlButtons.Height = 30;
  582. this.commonControlButtons.HideZoomToWindowAndActualSize();
  583. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  584. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  585. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  586. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  587. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  588. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  589. groupBox_review.Controls.Add(this.commonControlButtons);
  590. }
  591. #endregion
  592. #region 事件
  593. #region 公共按钮
  594. private void zoomInButton_Click(object sender, EventArgs e)
  595. {
  596. this.documentWorkspace.ZoomIn();
  597. }
  598. private void zoomOutButton_Click(object sender, EventArgs e)
  599. {
  600. this.documentWorkspace.ZoomOut();
  601. }
  602. private void zoomToWindowButton_Click(object sender, EventArgs e)
  603. {
  604. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  605. }
  606. private void actualSizeButton_Click(object sender, EventArgs e)
  607. {
  608. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  609. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  610. }
  611. private void pointerButton_Click(object sender, EventArgs e)
  612. {
  613. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  614. }
  615. private void mobileModeButton_Click(object sender, EventArgs e)
  616. {
  617. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  618. }
  619. #endregion
  620. /// <summary>
  621. /// 设置
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. private void button_setting_Click(object sender, EventArgs e)
  626. {
  627. string templateName = getTemplateName();
  628. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);
  629. if (metallographicMethodSetDialog.hasModule)
  630. {
  631. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  632. metallographicMethodSetDialog.ShowDialog();
  633. }
  634. else
  635. {
  636. metallographicMethodSetDialog = null;
  637. }
  638. }
  639. private void btn_saveresult_Click(object sender, EventArgs e)
  640. {
  641. buildListBox_analysisResult();
  642. }
  643. private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
  644. {
  645. if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
  646. {
  647. //this.documentWorkspace.Document = Document.FromImage(this.documentItems[this.lstView_img.FocusedItem.Index].bitmap);
  648. //this.documentWorkspace.Visible = true;
  649. //this.documentWorkspace.activeTool = DrawToolType.InclusionNoEffect;
  650. //this.documentWorkspace.GraphicsList = this.documentItems[this.lstView_img.FocusedItem.Index].graphicsList;
  651. //this.documentWorkspace.PhaseModels = new List<PhaseModel>();
  652. //this.documentWorkspace.PhaseModels.AddRange(this.documentItems[this.lstView_img.FocusedItem.Index].phaseModels);
  653. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  654. //if (this.documentWorkspace.PhaseModels[0].mat != null)
  655. //{
  656. // this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  657. // if (!this.checkBox10.Checked)
  658. // {
  659. // toApplyBinary = false;
  660. // this.checkBox10.Checked = true;
  661. // }
  662. //}
  663. //else
  664. //{
  665. // this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  666. // this.applyButtonImpl(sender, e);
  667. //}
  668. //if (!this.documentWorkspace.PhaseModels[0].choise)
  669. // this.checkBox10.Checked = false;、、###################
  670. bool existViewFlag = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.IsExsitView();
  671. if (!existViewFlag)
  672. {
  673. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  674. }
  675. else
  676. {
  677. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetFullSizeWithRegion());
  678. }
  679. //二值化集成4
  680. binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  681. //if (this.checkBox1.Checked)
  682. //{
  683. // this.applyDect();
  684. //}
  685. refreshWhileImgChanged();
  686. }
  687. }
  688. #region 矩形拖动
  689. /// <summary>
  690. /// 鼠标按下
  691. /// </summary>
  692. /// <param name="drawArea"></param>
  693. /// <param name="e"></param>
  694. protected virtual void OnMouseDown(object sender, MouseEventArgs e)
  695. {
  696. // 换算后的点
  697. //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  698. }
  699. /// <summary>
  700. /// 移动
  701. /// </summary>
  702. /// <param name="sender"></param>
  703. /// <param name="e"></param>
  704. protected virtual void onMouseMove(object sender, MouseEventArgs e)
  705. {
  706. //this.documentWorkspace.Refresh();
  707. //// 换算后的点
  708. //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  709. }
  710. /// <summary>
  711. /// 鼠标抬起
  712. /// </summary>
  713. /// <param name="sender"></param>
  714. /// <param name="e"></param>
  715. private void onMouseUp(object sender, MouseEventArgs e)
  716. {
  717. m_canMove = false;
  718. }
  719. #endregion
  720. /// <summary>
  721. /// 画布绘制
  722. /// </summary>
  723. /// <param name="sender"></param>
  724. /// <param name="e"></param>
  725. private void Panel_Paint(object sender, PaintEventArgs e)
  726. {
  727. if (this.documentWorkspace.CompositionSurface != null)
  728. {
  729. //
  730. // 以下是计算绘制图片的位置和大小并绘制图片
  731. //
  732. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  733. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  734. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  735. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  736. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  737. //
  738. // 以下是绘制网格、标注、测量、视场等开始
  739. //
  740. e.Graphics.TranslateTransform(x, y);
  741. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  742. Draw(e.Graphics);
  743. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  744. e.Graphics.TranslateTransform(-x, -y);
  745. }
  746. }
  747. /// <summary>
  748. /// 绘制
  749. /// </summary>
  750. private void Draw(Graphics graphics)
  751. {
  752. // 抗锯齿
  753. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  754. drawSubclass(graphics);
  755. }
  756. #endregion
  757. #region 内部方法
  758. /// <summary>
  759. /// 导出项目
  760. /// </summary>
  761. /// <param name="sender"></param>
  762. /// <param name="e"></param>
  763. private void button1_Click(object sender, EventArgs e)
  764. {
  765. if (this.listView2.Items.Count == 0)
  766. {
  767. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  768. return;
  769. }
  770. if (this.checkBox_generateReport_opensetting.Checked)
  771. this.button_setting.PerformClick();
  772. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  773. {
  774. //获取项目工程内的文件夹路径
  775. ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, getProjectEngineeringName(), this.analyzeSettingModel.savePath);
  776. if (nodeItem == null) return;
  777. //获取word书签与excel单元格的关系,以字典方式存储
  778. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  779. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  780. if (mic_module_infos != null && mic_module_infos.Count > 0)
  781. {
  782. foreach (mic_module_infos info in mic_module_infos)
  783. {
  784. tagInfos.Add(info.tag_name, info.cell_position);
  785. }
  786. }
  787. //分析结果
  788. List<List<string>> analysisContent = new List<List<string>>();
  789. analysisContent.Add(contentHead);
  790. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  791. {
  792. List<string> content = new List<string>();
  793. for (int i = 0; i < contentHead.Count; i++)
  794. {
  795. content.Add(item.Cells[i].Value.ToString());
  796. }
  797. analysisContent.Add(content);
  798. }
  799. //图片
  800. bitList = new List<Bitmap>();
  801. //中间数据
  802. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  803. if (this.allShow)
  804. {
  805. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  806. {
  807. bitList.Add(kv.Value[0]);
  808. bitList.Add(kv.Value[1]);
  809. }
  810. //中间数据
  811. foreach (ExportProjectModel model in this.tempDataModel)
  812. {
  813. ExportProjectModel tempModel = new ExportProjectModel();
  814. tempModel.tagName = model.tagName;
  815. tempModel.picName = model.picName;
  816. tempModel.dataList = model.dataList;
  817. exportModel.Add(tempModel);
  818. }
  819. }
  820. else
  821. {
  822. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  823. {
  824. foreach (ListViewItem item in this.listView2.SelectedItems)
  825. {
  826. if (bitDic.ContainsKey(item.Name))
  827. {
  828. bitList.Add(bitDic[item.Name][0]);
  829. bitList.Add(bitDic[item.Name][1]);
  830. }
  831. else if (bitDic.ContainsKey(item.Tag.ToString()))
  832. {
  833. bitList.Add(bitDic[item.Tag.ToString()][0]);
  834. bitList.Add(bitDic[item.Tag.ToString()][1]);
  835. }
  836. }
  837. //中间数据
  838. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  839. {
  840. foreach (ExportProjectModel model in this.tempDataModel)
  841. {
  842. if (model.tagName.Equals(rowItem.Name))
  843. {
  844. ExportProjectModel tempModel = new ExportProjectModel();
  845. tempModel.tagName = model.tagName;
  846. tempModel.picName = model.picName;
  847. tempModel.dataList = model.dataList;
  848. exportModel.Add(tempModel);
  849. break;
  850. }
  851. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  852. {
  853. ExportProjectModel tempModel = new ExportProjectModel();
  854. tempModel.tagName = model.tagName;
  855. tempModel.picName = model.picName;
  856. tempModel.dataList = model.dataList;
  857. exportModel.Add(tempModel);
  858. break;
  859. }
  860. }
  861. }
  862. }
  863. else if (this.listView2.Items.Count > 0)
  864. {
  865. ListViewItem rowItem = this.listView2.Items[0];
  866. if (bitDic.ContainsKey(rowItem.Name))
  867. {
  868. bitList.Add(bitDic[rowItem.Name][0]);
  869. bitList.Add(bitDic[rowItem.Name][1]);
  870. }
  871. else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
  872. {
  873. bitList.Add(bitDic[rowItem.Tag.ToString()][0]);
  874. bitList.Add(bitDic[rowItem.Tag.ToString()][1]);
  875. }
  876. //中间数据
  877. foreach (ExportProjectModel model in this.tempDataModel)
  878. {
  879. if (model.tagName.Equals(rowItem.Name))
  880. {
  881. ExportProjectModel tempModel = new ExportProjectModel();
  882. tempModel.tagName = model.tagName;
  883. tempModel.picName = model.picName;
  884. tempModel.dataList = model.dataList;
  885. exportModel.Add(tempModel);
  886. break;
  887. }
  888. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  889. {
  890. ExportProjectModel tempModel = new ExportProjectModel();
  891. tempModel.tagName = model.tagName;
  892. tempModel.picName = model.picName;
  893. tempModel.dataList = model.dataList;
  894. exportModel.Add(tempModel);
  895. break;
  896. }
  897. }
  898. }
  899. }
  900. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
  901. //保存项目信息到数据库
  902. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
  903. }
  904. else
  905. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  906. }
  907. /// <summary>
  908. /// 导出结果
  909. /// </summary>
  910. /// <param name="sender"></param>
  911. /// <param name="e"></param>
  912. private void button_exportResults_Click(object sender, EventArgs e)
  913. {
  914. if (this.listView2.Items.Count > 0)
  915. {
  916. SaveFileDialog exe = new SaveFileDialog();
  917. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  918. exe.FilterIndex = 0;
  919. exe.RestoreDirectory = true;
  920. //exe.CreatePrompt = true;
  921. exe.Title = "Export Excel File";
  922. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  923. exe.FileName = this.Text + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  924. DialogResult dr = exe.ShowDialog();
  925. if (dr != DialogResult.OK)
  926. {
  927. return;
  928. }
  929. DataTable dtb = new DataTable();
  930. foreach (var item in this.contentHead)
  931. {
  932. dtb.Columns.Add(item);
  933. }
  934. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  935. {
  936. DataRow dataRow = dtb.NewRow();
  937. for (int k = 0; k < this.contentHead.Count; k++)
  938. {
  939. dataRow[this.contentHead[k]] = this.dataGridView2.Rows[i].Cells[k].Value;
  940. }
  941. dtb.Rows.Add(dataRow);
  942. }
  943. List<DataTable> list = new List<DataTable>();
  944. list.Add(dtb);
  945. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);
  946. }
  947. else
  948. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  949. }
  950. //二值化集成3
  951. // 二值化相关方法
  952. /// <summary>
  953. /// 添加参数改变的监听
  954. /// </summary>
  955. /// <param name="sender"></param>
  956. /// <param name="e"></param>
  957. private void PetroleumGeologyStandardDialog_Load(object sender, EventArgs e)
  958. {
  959. this.binaryClass.loadParams();
  960. }
  961. private bool bcBinaryChecked()
  962. {
  963. return bc != null && bc.BinaryChecked;
  964. }
  965. private bool bcOriginChecked()
  966. {
  967. return bc != null && bc.OriginChecked;
  968. }
  969. /// <summary>
  970. /// 参数改变时,重新处理图像
  971. /// </summary>
  972. /// <param name="sender"></param>
  973. /// <param name="e"></param>
  974. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  975. {
  976. this.documentWorkspace.Refresh();
  977. }
  978. /// <summary>
  979. /// 显示原图/原图+二值图
  980. /// </summary>
  981. /// <param name="sender"></param>
  982. /// <param name="e"></param>
  983. private void bcOriginCheckedChanged(object sender, EventArgs e)
  984. {
  985. if (!bcOriginChecked())
  986. {
  987. if (bcBinaryChecked())
  988. this.documentWorkspace.PhaseModels[0].choise = true;
  989. }
  990. else
  991. {
  992. this.documentWorkspace.PhaseModels[0].choise = false;
  993. }
  994. this.documentWorkspace.Refresh();
  995. }
  996. #endregion
  997. #region 可调用方法
  998. /// <summary>
  999. /// 自动分割
  1000. /// </summary>
  1001. /// <param name="thresholdValue">阈值(μm)</param>
  1002. protected void autoSegmentAction(int thresholdValue)
  1003. {
  1004. //int matValue = 10;// (int)(thresholdValue / this.physical_length);
  1005. Action912 action912 = new Action912();
  1006. if (testMat != null)
  1007. testMat.Dispose();
  1008. testMat = new Mat();
  1009. if (this.documentWorkspace.PhaseModels.Count > 0 && this.documentWorkspace.PhaseModels[0].choise == true && this.documentWorkspace.PhaseModels[0].mat != null)
  1010. {
  1011. PhaseModel phasesCopy = new PhaseModel();
  1012. phasesCopy.mat = this.documentWorkspace.PhaseModels[0].mat.Clone();
  1013. phasesCopy.color = Color.Red/*panel2.BackColor*/.ToArgb();
  1014. action912.PerformProcess(phasesCopy, 1).CopyTo(testMat);
  1015. }
  1016. else
  1017. {
  1018. OpenCvSharp.Mat mat = action912.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  1019. if (mat != null)
  1020. mat.CopyTo(testMat);
  1021. //Document doc = Document.FromMat(mat);
  1022. //this.documentWorkspace.Document = doc;
  1023. //this.documentWorkspace.Refresh();
  1024. }
  1025. //标记所有骨架相交的点
  1026. //testMat
  1027. //PointF point = linePointList[iguidePoint];
  1028. //if (point.X > 0 && point.X < surfaceWidth - 1
  1029. // && point.Y > 0 && point.Y < surfaceHeight - 1)
  1030. this.documentWorkspace.Refresh();
  1031. }
  1032. private int GetBoundryCountDOfBinary(Point point, Mat mat)
  1033. {
  1034. int count = 0;
  1035. bool firstValueOnBoundry = false;
  1036. bool lastValueOnBoundry = false;
  1037. Vec4b vec4B = mat.At<Vec4b>(point.Y - 1, point.X - 1);
  1038. if (vec4B.Item3 != 0)
  1039. {
  1040. count++;
  1041. firstValueOnBoundry = true;
  1042. lastValueOnBoundry = true;
  1043. }
  1044. vec4B = mat.At<Vec4b>(point.Y - 1, point.X);
  1045. if (vec4B.Item3 != 0)
  1046. {
  1047. if (!lastValueOnBoundry)
  1048. count++;
  1049. lastValueOnBoundry = true;
  1050. }
  1051. else lastValueOnBoundry = false;
  1052. vec4B = mat.At<Vec4b>(point.Y - 1, point.X + 1);
  1053. if (vec4B.Item3 != 0)
  1054. {
  1055. if (!lastValueOnBoundry)
  1056. count++;
  1057. lastValueOnBoundry = true;
  1058. }
  1059. else lastValueOnBoundry = false;
  1060. vec4B = mat.At<Vec4b>(point.Y, point.X + 1);
  1061. if (vec4B.Item3 != 0)
  1062. {
  1063. if (!lastValueOnBoundry)
  1064. count++;
  1065. lastValueOnBoundry = true;
  1066. }
  1067. else lastValueOnBoundry = false;
  1068. vec4B = mat.At<Vec4b>(point.Y + 1, point.X + 1);
  1069. if (vec4B.Item3 != 0)
  1070. {
  1071. if (!lastValueOnBoundry)
  1072. count++;
  1073. lastValueOnBoundry = true;
  1074. }
  1075. else lastValueOnBoundry = false;
  1076. vec4B = mat.At<Vec4b>(point.Y + 1, point.X);
  1077. if (vec4B.Item3 != 0)
  1078. {
  1079. if (!lastValueOnBoundry)
  1080. count++;
  1081. lastValueOnBoundry = true;
  1082. }
  1083. else lastValueOnBoundry = false;
  1084. vec4B = mat.At<Vec4b>(point.Y + 1, point.X - 1);
  1085. if (vec4B.Item3 != 0)
  1086. {
  1087. if (!lastValueOnBoundry)
  1088. count++;
  1089. lastValueOnBoundry = true;
  1090. }
  1091. else lastValueOnBoundry = false;
  1092. vec4B = mat.At<Vec4b>(point.Y, point.X - 1);
  1093. if (vec4B.Item3 != 0)
  1094. {
  1095. if (!lastValueOnBoundry && !firstValueOnBoundry)
  1096. count++;
  1097. }
  1098. return count;
  1099. }
  1100. /// <summary>
  1101. /// 是否显示原图
  1102. /// </summary>
  1103. /// <returns></returns>
  1104. protected Boolean showOrimat()
  1105. {
  1106. return bcOriginChecked();
  1107. }
  1108. /// <summary>
  1109. /// 是否能取到二值的结果
  1110. /// </summary>
  1111. /// <returns></returns>
  1112. protected Boolean getBinaryChecked()
  1113. {
  1114. return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
  1115. }
  1116. /// <summary>
  1117. /// 返回当前选择的图片内容
  1118. /// </summary>
  1119. /// <returns></returns>
  1120. protected DocumentWorkspace getCurrentWorkspace()
  1121. {
  1122. return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index];
  1123. }
  1124. /// <summary>
  1125. /// 返回当前选择的图片tag
  1126. /// </summary>
  1127. /// <returns></returns>
  1128. protected string getCurrentWorkTag()
  1129. {
  1130. return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem.Index/*lstView_img.SelectedItems[0].Index*/];
  1131. }
  1132. #endregion
  1133. #region 需继承方法
  1134. /// <summary>
  1135. /// 图片索引改变后调用的事件
  1136. /// </summary>
  1137. protected virtual void refreshWhileImgChanged()
  1138. {
  1139. }
  1140. protected virtual void refreshPhaseModelChoise()
  1141. {
  1142. }
  1143. protected virtual void buildListBox_analysisResult()
  1144. {
  1145. //this.listBox_analysisResult.Items.Clear();
  1146. ////foreach (var item in analysisResults.Keys)
  1147. ////{
  1148. //// this.listBox_analysisResult.Items.Add(new LocalListViewItem(item, item.GetFriendlyName()));
  1149. ////}
  1150. ////buildListView_analysisResult();
  1151. }
  1152. protected virtual void SubclassInitialize()
  1153. {
  1154. throw new NotImplementedException();
  1155. }
  1156. //unused
  1157. protected virtual void initColorSetting()
  1158. {
  1159. }
  1160. //unused
  1161. protected virtual void initDisplaySetting()
  1162. {
  1163. }
  1164. /// <summary>
  1165. /// 报告模板命名
  1166. /// </summary>
  1167. /// <returns></returns>
  1168. protected virtual string getTemplateName()
  1169. {
  1170. throw new NotImplementedException();
  1171. }
  1172. /// <summary>
  1173. /// 项目工程内的文件夹路径名称
  1174. /// </summary>
  1175. /// <returns></returns>
  1176. protected virtual string getProjectEngineeringName()
  1177. {
  1178. throw new NotImplementedException();
  1179. }
  1180. protected virtual void drawSubclass(Graphics graphics)
  1181. {
  1182. if (showOrimat())
  1183. return;
  1184. if (testMat != null && testMat.Width > 0 && testMat.Height > 0)
  1185. {
  1186. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(testMat), 0, 0);
  1187. }
  1188. }
  1189. #endregion
  1190. #region 内部类
  1191. internal class LocalListViewItem
  1192. {
  1193. public DocumentWorkspace Value { get; }
  1194. public string Display { get; }
  1195. public LocalListViewItem(DocumentWorkspace Value, string Display)
  1196. {
  1197. this.Value = Value;
  1198. this.Display = Display;
  1199. }
  1200. }
  1201. internal class DocumentItem
  1202. {
  1203. public Bitmap bitmap;
  1204. public GraphicsList graphicsList;
  1205. public List<PhaseModel> phaseModels;
  1206. //public AnalysisResult analysisResult;
  1207. public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
  1208. {
  1209. this.bitmap = bitmap;
  1210. this.graphicsList = graphicsList;
  1211. this.phaseModels = phaseModels;
  1212. }
  1213. }
  1214. #endregion
  1215. /// <summary>
  1216. /// 使用圆心及半径得到圆的轮廓
  1217. /// </summary>
  1218. /// <param name="center">圆心</param>
  1219. /// <param name="radius">半径</param>
  1220. /// <returns></returns>
  1221. public OpenCvSharp.Point[] roundOutline(Point center, int radius)
  1222. {
  1223. if (radius < 1) radius = 1;
  1224. Mat mat = new Mat((int)(radius * 2.1), (int)(radius * 2.1), MatType.CV_8UC1, new Scalar(0, 0, 0));
  1225. OpenCvSharp.Point point = new OpenCvSharp.Point(mat.Cols / 2, mat.Rows / 2);
  1226. Cv2.Circle(mat, point, radius, new Scalar(255, 255, 255), -1);
  1227. OpenCvSharp.Point[][] contours;
  1228. HierarchyIndex[] hierarchy;
  1229. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  1230. OpenCvSharp.Point[] roundOutline = contours[0];
  1231. for (int i = 0; i < roundOutline.Length; i++)
  1232. {
  1233. roundOutline[i].X = roundOutline[i].X - point.X + center.X;
  1234. roundOutline[i].Y = roundOutline[i].Y - point.Y + center.Y;
  1235. }
  1236. return roundOutline;
  1237. }
  1238. private void button16_Click(object sender, EventArgs e)
  1239. {
  1240. this.button11.Visible = true;
  1241. this.button16.Visible = false;
  1242. this.button11.Focus();
  1243. this.allShow = false;
  1244. if (this.listView2.SelectedItems.Count <= 0)
  1245. return;
  1246. this.dataGridView2.Rows.Clear();
  1247. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1248. {
  1249. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1250. foreach (var dataTable in this.dataTables)
  1251. {
  1252. if (this.listView2.SelectedItems.Count > 0)
  1253. {
  1254. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1255. dataTable1 = dataTable;
  1256. }
  1257. else
  1258. {
  1259. if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
  1260. dataTable1 = dataTable;
  1261. }
  1262. }
  1263. DataGridViewRow dgvr = new DataGridViewRow();
  1264. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1265. {
  1266. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1267. }
  1268. for (int c = 0; c < dataTable1.Columns.Count; c++)
  1269. {
  1270. dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
  1271. }
  1272. this.dataGridView2.Rows.Add(dgvr);
  1273. }
  1274. this.RefreshDataGridView4();
  1275. }
  1276. /// <summary>
  1277. /// 刷新分析结果数据
  1278. /// </summary>
  1279. protected void RefreshDataGridView4()
  1280. {
  1281. if (!this.allShow)
  1282. {
  1283. if (this.listView2.SelectedItems.Count > 0)
  1284. {
  1285. this.dataGridView2.Rows.Clear();
  1286. for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
  1287. {
  1288. int dataTableIndex = 0;
  1289. for (int i = 0; i < this.dataTables.Count; i++)
  1290. {
  1291. if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
  1292. dataTableIndex = i;
  1293. }
  1294. if (this.dataTables.Count > dataTableIndex && this.dataTables[dataTableIndex].Rows.Count > 0)
  1295. {
  1296. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  1297. {
  1298. DataGridViewRow dgvr = new DataGridViewRow();
  1299. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1300. {
  1301. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1302. }
  1303. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  1304. {
  1305. if (c == 2 || c == 3)
  1306. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  1307. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1308. else if (c == 4)
  1309. {
  1310. double outValue;
  1311. if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  1312. this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue))
  1313. {
  1314. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1315. }
  1316. else
  1317. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  1318. }
  1319. else
  1320. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  1321. }
  1322. this.dataGridView2.Rows.Add(dgvr);
  1323. }
  1324. }
  1325. }
  1326. }
  1327. else if (this.listView2.Items.Count > 0)
  1328. {
  1329. this.dataGridView2.Rows.Clear();
  1330. var firstTag = this.listView2.Items[0].Tag;
  1331. int dataTableIndex = 0;
  1332. for (int i = 0; i < this.dataTables.Count; i++)
  1333. {
  1334. if (this.dataTables[i].TableName.Equals(firstTag))
  1335. dataTableIndex = i;
  1336. }
  1337. if (this.dataTables[dataTableIndex].Rows.Count > 0)
  1338. {
  1339. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  1340. {
  1341. DataGridViewRow dgvr = new DataGridViewRow();
  1342. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1343. {
  1344. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1345. }
  1346. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  1347. {
  1348. if (c == 2 || c == 3)
  1349. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  1350. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1351. else if (c == 4)
  1352. {
  1353. double outValue;
  1354. if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  1355. this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue))
  1356. {
  1357. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1358. }
  1359. else
  1360. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  1361. }
  1362. else
  1363. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  1364. }
  1365. this.dataGridView2.Rows.Add(dgvr);
  1366. }
  1367. }
  1368. }
  1369. }
  1370. else
  1371. {
  1372. this.dataGridView2.Rows.Clear();
  1373. DataTable dataTable = new DataTable();
  1374. for (int i = this.dataTables.Count - 1; i >= 0; i--)
  1375. {
  1376. dataTable = this.dataTables[i];
  1377. for (int r = 0; r < dataTable.Rows.Count; r++)
  1378. {
  1379. DataGridViewRow dgvr = new DataGridViewRow();
  1380. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1381. {
  1382. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1383. }
  1384. for (int c = 0; c < dataTable.Columns.Count; c++)
  1385. {
  1386. if (c == 2 || c == 3)
  1387. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
  1388. dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1389. else if (c == 4)
  1390. {
  1391. double outValue;
  1392. if (double.TryParse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
  1393. dataTable.Rows[r][c].ToString(), out outValue))
  1394. {
  1395. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  1396. }
  1397. else
  1398. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  1399. }
  1400. else
  1401. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  1402. }
  1403. this.dataGridView2.Rows.Add(dgvr);
  1404. }
  1405. }
  1406. }
  1407. }
  1408. /// <summary>
  1409. /// 切换分析结果
  1410. /// </summary>
  1411. /// <param name="sender"></param>
  1412. /// <param name="e"></param>
  1413. private void listview2_SelectedIndexChanged(object sender, EventArgs e)
  1414. {
  1415. if (!this.allShow)
  1416. {
  1417. if (this.listView2.SelectedItems.Count <= 0)
  1418. return;
  1419. this.dataGridView2.Rows.Clear();
  1420. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1421. {
  1422. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1423. foreach (var dataTable in this.dataTables)
  1424. {
  1425. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1426. dataTable1 = dataTable;
  1427. }
  1428. DataGridViewRow dgvr = new DataGridViewRow();
  1429. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1430. {
  1431. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1432. }
  1433. for (int c = 0; c < dataTable1.Columns.Count; c++)
  1434. {
  1435. dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
  1436. }
  1437. this.dataGridView2.Rows.Add(dgvr);
  1438. }
  1439. this.RefreshDataGridView4();
  1440. }
  1441. }
  1442. /// <summary>
  1443. /// 全部显示
  1444. /// </summary>
  1445. /// <param name="sender"></param>
  1446. /// <param name="e"></param>
  1447. private void button11_Click(object sender, EventArgs e)
  1448. {
  1449. if (this.listView2.Items.Count > 0)
  1450. {
  1451. this.button11.Visible = false;
  1452. this.button16.Visible = true;
  1453. this.button16.Focus();
  1454. this.allShow = true;
  1455. this.dataGridView2.Rows.Clear();
  1456. for (int i = 0; i < this.dataTables.Count; i++)
  1457. {
  1458. DataGridViewRow dgvr = new DataGridViewRow();
  1459. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1460. {
  1461. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1462. }
  1463. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  1464. {
  1465. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  1466. }
  1467. this.dataGridView2.Rows.Add(dgvr);
  1468. }
  1469. this.RefreshDataGridView4();
  1470. }
  1471. else
  1472. {
  1473. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  1474. }
  1475. }
  1476. private void button12_Click(object sender, EventArgs e)
  1477. {
  1478. if (this.listView2.Items.Count > 0)
  1479. {
  1480. if (this.listView2.SelectedItems.Count > 0)
  1481. {
  1482. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1483. if (dr == DialogResult.OK)
  1484. {
  1485. if (this.listView2.SelectedItems.Count <= 0)
  1486. return;
  1487. for (int i = this.listView2.SelectedItems.Count - 1; i >= 0; i--)
  1488. {
  1489. int selectIndex = this.listView2.SelectedItems[i].Index;
  1490. foreach (var dataTable in this.dataTables)
  1491. {
  1492. if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
  1493. {
  1494. this.dataTables.Remove(dataTable);
  1495. break;
  1496. }
  1497. }
  1498. if (bitDic.ContainsKey((string)this.listView2.SelectedItems[i].Tag))
  1499. bitDic.Remove((string)this.listView2.SelectedItems[i].Tag);
  1500. foreach (ExportProjectModel model in this.tempDataModel)
  1501. {
  1502. if (model.tagName.Equals((string)this.listView2.SelectedItems[i].Tag))
  1503. {
  1504. this.tempDataModel.Remove(model);
  1505. break;
  1506. }
  1507. }
  1508. this.listView2.Items.RemoveAt(selectIndex);
  1509. }
  1510. if (this.listView2.Items.Count == 0)
  1511. this.dataGridView2.Rows.Clear();
  1512. else
  1513. RefreshDataGridView4();
  1514. }
  1515. }
  1516. else
  1517. {
  1518. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
  1519. }
  1520. }
  1521. else
  1522. {
  1523. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  1524. }
  1525. }
  1526. private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
  1527. {
  1528. this.RefreshDataGridView4();
  1529. }
  1530. /// <summary>
  1531. /// 生成报告
  1532. /// </summary>
  1533. /// <param name="sender"></param>
  1534. /// <param name="e"></param>
  1535. private void button_generateReport_Click(object sender, EventArgs e)
  1536. {
  1537. if (this.listView2.Items.Count == 0)
  1538. {
  1539. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1540. return;
  1541. }
  1542. if (this.checkBox_generateReport_opensetting.Checked)
  1543. this.button_setting.PerformClick();
  1544. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1545. {
  1546. //获取word书签与excel单元格的关系,以字典方式存储
  1547. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1548. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1549. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1550. {
  1551. foreach (mic_module_infos info in mic_module_infos)
  1552. {
  1553. tagInfos.Add(info.tag_name, info.cell_position);
  1554. }
  1555. }
  1556. //分析结果
  1557. List<List<string>> analysisContent = new List<List<string>>();
  1558. analysisContent.Add(contentHead);
  1559. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1560. {
  1561. List<string> content = new List<string>();
  1562. for (int i = 0; i < contentHead.Count; i++)
  1563. {
  1564. content.Add(item.Cells[i].Value.ToString());
  1565. }
  1566. analysisContent.Add(content);
  1567. }
  1568. //图片
  1569. bitList = new List<Bitmap>();
  1570. if (this.allShow)
  1571. {
  1572. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1573. {
  1574. bitList.Add(kv.Value[0]);
  1575. bitList.Add(kv.Value[1]);
  1576. }
  1577. }
  1578. else
  1579. {
  1580. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1581. {
  1582. foreach (ListViewItem item in this.listView2.SelectedItems)
  1583. {
  1584. if (bitDic.ContainsKey(item.Name))
  1585. {
  1586. bitList.Add(bitDic[item.Name][0]);
  1587. bitList.Add(bitDic[item.Name][1]);
  1588. }
  1589. else if (bitDic.ContainsKey(item.Tag.ToString()))
  1590. {
  1591. bitList.Add(bitDic[item.Tag.ToString()][0]);
  1592. bitList.Add(bitDic[item.Tag.ToString()][1]);
  1593. }
  1594. }
  1595. }
  1596. else if (this.listView2.Items.Count > 0)
  1597. {
  1598. ListViewItem item = this.listView2.Items[0];
  1599. if (bitDic.ContainsKey(item.Name))
  1600. {
  1601. bitList.Add(bitDic[item.Name][0]);
  1602. bitList.Add(bitDic[item.Name][1]);
  1603. }
  1604. else if (bitDic.ContainsKey(item.Tag.ToString()))
  1605. {
  1606. bitList.Add(bitDic[item.Tag.ToString()][0]);
  1607. bitList.Add(bitDic[item.Tag.ToString()][1]);
  1608. }
  1609. }
  1610. }
  1611. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1612. }
  1613. else
  1614. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1615. }
  1616. }
  1617. }