MethodKDialog.cs 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using OpenCvSharp.Extensions;
  4. using PaintDotNet;
  5. using PaintDotNet.Annotation;
  6. using PaintDotNet.Annotation.DedicatedAnalysis;
  7. using PaintDotNet.Annotation.Enum;
  8. using PaintDotNet.Annotation.FieldView;
  9. using PaintDotNet.Base.DedicatedAnalysis.Inclusions;
  10. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
  11. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Standard.DIN50602_1985.TypesOfAssessment;
  12. using PaintDotNet.Base.Functionodel;
  13. using PaintDotNet.Base.SettingModel;
  14. using PaintDotNet.CustomControl;
  15. using PaintDotNet.DbOpreate.DbBll;
  16. using PaintDotNet.DbOpreate.DbModel;
  17. using PaintDotNet.DedicatedAnalysis.Inclusions;
  18. using PaintDotNet.Instrument;
  19. using System;
  20. using System.Collections.Generic;
  21. using System.ComponentModel;
  22. using System.Data;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.Linq;
  26. using System.Text;
  27. using System.Threading.Tasks;
  28. using System.Windows.Forms;
  29. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.InclusionsGlobalSettings;
  30. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.MethodOfAssessment;
  31. using static PaintDotNet.DedicatedAnalysis.Inclusions.InclusionsStandardDialog;
  32. namespace Metis.DedicatedAnalysis.Inclusions.New_DIN50602_1985
  33. {
  34. internal partial class MethodKDialog : PdnBaseForm
  35. {
  36. private GroupBox groupBox_operating;
  37. private CheckBox checkBox_generateReport_opensetting;
  38. private Button btn_clean_result;
  39. private Button btn_statistics;
  40. private Button btn_saveresult;
  41. private Button button4;
  42. private Button button3;
  43. private GroupBox groupBox_img;
  44. private ListView lstView_img;
  45. private GroupBox groupBox1;
  46. private GroupBox groupBox2;
  47. private GroupBox groupBox3;
  48. private GroupBox groupBox4;
  49. private Button button_setting;
  50. private GroupBox groupBox_report;
  51. private Label label1;
  52. private Button button1;
  53. private Label label_resultPrecision;
  54. private DomainUpDown domainUpDown_resultPrecision;
  55. private Button button_exportResults;
  56. private Button button_generateReport;
  57. private GroupBox groupBox6groupBox_analysisResult2;
  58. private ListView listView_analysisResult2;
  59. private ListView listView_analysisResult;
  60. private GroupBox groupBox_analysisResult1;
  61. private CheckedListBox listBox_analysisResult;
  62. private Button button_remove;
  63. private Button button_all;
  64. private Label label4;
  65. private ComboBox comboBox_rollingDirection;
  66. private Button button2;
  67. private RadioButton radioButton2;
  68. private RadioButton radioButton1;
  69. private CheckBox checkBox2;
  70. private CheckBox checkBox1;
  71. private Button button6;
  72. private Button button5;
  73. private Panel panel_color2;
  74. private Panel panel_color1;
  75. private AutoAnalysis.MeasureRangeControl measureRangeControl1;
  76. private GroupBox groupBox_review;
  77. private Label label2;
  78. private Label label3;
  79. private TextBox textBox1;
  80. private ImageList imageList_img;
  81. private IContainer components;
  82. //二值化集成1
  83. private BinaryControl bc;
  84. #region 属性
  85. /// <summary>
  86. /// 主控件
  87. /// </summary>
  88. private AppWorkspace appWorkspace;
  89. /// <summary>
  90. /// 公共按钮
  91. /// </summary>
  92. private CommonControlButtons commonControlButtons;
  93. /// <summary>
  94. /// 图像面板
  95. /// </summary>
  96. private DocumentWorkspaceWindow documentWorkspace;
  97. private Dictionary<int, DocumentItem> documentItems;
  98. /// <summary>
  99. /// 当前选择的图片
  100. /// </summary>
  101. private Mat imageMat;
  102. /// <summary>
  103. /// 初始系统参数配置值
  104. /// </summary>
  105. private BinaryExtractionModel binaryExtractionModel = new BinaryExtractionModel();
  106. /// <summary>
  107. /// 选择的评定方法
  108. /// </summary>
  109. private MethodOfAssessment methodOfAssessment;
  110. private AnalysisResult tempAnalysisResult;
  111. private Dictionary<DocumentWorkspace, AnalysisResult> analysisResults = new Dictionary<DocumentWorkspace, AnalysisResult>();
  112. protected ColorOfInclusions selectedColorOfInclusions;
  113. protected ColorOfInclusions oldSelectedColorOfInclusions;
  114. //二值化集成1
  115. private BinaryClass binaryClass;
  116. protected int menuId;
  117. protected string menuName;
  118. // 选定夹杂物类型
  119. private bool clearSelect = false;
  120. private TypesOfInclusions selectedTypesOfInclusions;
  121. // 选定夹杂物类型 操作 记录点
  122. private System.Drawing.Point? selectedTypesOfInclusionsPoint = null;
  123. private System.Drawing.RectangleF? selectedTypesOfInclusionsRectangle = null;
  124. // 视场边长
  125. private int viewNum = 710;
  126. private bool is_showRectangle = false;
  127. private bool is_showOval = false;
  128. private int is_full = 1;
  129. //局部变量
  130. private bool rbcheck = true;
  131. protected InclusionsModel inclusionsModel = new InclusionsModel();
  132. protected InclusionsModel.InclusionParameter thisParameters;
  133. protected int thisParametersIndex = -1;
  134. private bool userAll = false;
  135. private bool firstShow = true;
  136. protected int whichChecked = 0;
  137. private int autoJiaoBen = -1;
  138. private InclusionSetting inclusionSetting = new InclusionSetting();
  139. private Dictionary<string, List<PhaseModel>> dict = new Dictionary<string, List<PhaseModel>>();
  140. private bool isExportResults = false;
  141. private bool isExportReports = false;
  142. private bool isExportProjects = false;
  143. /// <summary>
  144. /// 是否脚本运行
  145. /// </summary>
  146. private Boolean initScriptValues = false;
  147. private int imgIndex = -1;
  148. private string dialogText;
  149. protected double imgPxPerUnit;
  150. private CheckBox checkBox4;
  151. private CheckBox checkBox3;
  152. private RectangleF paintRectangle;
  153. private ColorsForm oneColorsForm;
  154. private ColorsForm twoColorsForm;
  155. #endregion
  156. public MethodKDialog(AppWorkspace appWorkspace, string dialogText, PdnMenuItem menuitem)
  157. {
  158. InitializeComponent();
  159. InitializeComponent2();
  160. InitializeLanguageText();
  161. this.appWorkspace = appWorkspace;
  162. this.Shown += showImg;
  163. this.Text = dialogText;
  164. this.dialogText = dialogText;
  165. this.Icon = PdnInfo.AppIcon;
  166. this.menuId = menuitem.MenuId;
  167. this.menuName = menuitem.Text;
  168. this.binaryClass = new BinaryClass(menuId);
  169. Initialize();
  170. //二值化集成2
  171. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  172. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.binary.Text"), PdnResources.GetString("Menu.Theinclusioncolomatches.Text") }
  173. , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
  174. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  175. this.bc.checkBox10.Visible = false;
  176. this.bc.button6.Visible = false;
  177. this.bc.panel2.Visible = false;
  178. this.bc.label2.Visible = false;
  179. this.bc.setInverseStyle(2);
  180. this.bc.OnInverseClickAction();
  181. oneColorsForm = new ColorsForm();
  182. this.oneColorsForm.StartPosition = FormStartPosition.CenterParent;
  183. twoColorsForm = new ColorsForm();
  184. this.twoColorsForm.StartPosition = FormStartPosition.CenterParent;
  185. this.documentWorkspace.panel.Paint += Panel_Paint;
  186. #region [组织相信息]
  187. if (this.documentWorkspace.phaseModels.Count > 0)
  188. {
  189. PhaseModel phaseModelS = this.documentWorkspace.phaseModels[0];
  190. phaseModelS.name = "S";
  191. phaseModelS.color = this.panel_color1.BackColor.ToArgb();
  192. if (this.documentWorkspace.phaseModels.Count > 1)
  193. {
  194. PhaseModel phaseModelO = this.documentWorkspace.phaseModels[1];
  195. phaseModelO.name = "O";
  196. phaseModelO.color = this.panel_color2.BackColor.ToArgb();
  197. }
  198. else {
  199. PhaseModel phaseModelO = new PhaseModel();
  200. phaseModelO.name = "O";
  201. phaseModelO.color = this.panel_color2.BackColor.ToArgb();
  202. this.documentWorkspace.phaseModels.Add(phaseModelO);
  203. }
  204. }
  205. #endregion
  206. //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  207. }
  208. private void InitializeLanguageText()
  209. {
  210. this.label2.Text = PdnResources.GetString("Menu.view.text");
  211. this.button4.Text = PdnResources.GetString("Menu.Applyall.text");
  212. this.button3.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
  213. this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  214. this.btn_clean_result.Text = PdnResources.GetString("Menu.Clearstatistics.text");
  215. this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
  216. this.btn_statistics.Text = PdnResources.GetString("Menu.Startstatistics.text");
  217. this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
  218. this.groupBox1.Text = PdnResources.GetString("Menu.OxygenSulfur.text");
  219. this.groupBox2.Text = PdnResources.GetString("Menu.BasicSettings.text");
  220. this.button2.Text = PdnResources.GetString("Menu.More.text");
  221. this.comboBox_rollingDirection.Items.AddRange(new object[] {
  222. PdnResources.GetString("Menu.Level.text"),
  223. PdnResources.GetString("Menu.vertical.text")});
  224. this.label4.Text = PdnResources.GetString("Menu.Rollingdirection.text") + ":";
  225. this.groupBox3.Text = PdnResources.GetString("Menu.style.text");
  226. this.radioButton2.Text = PdnResources.GetString("Menu.solid.text");
  227. this.radioButton1.Text = PdnResources.GetString("Menu.ImageCollection.CameraFrame.Text");
  228. this.checkBox2.Text = PdnResources.GetString("Menu.ShowRectangle.Text");
  229. this.checkBox1.Text = PdnResources.GetString("Menu.ShowElliptical.Text");
  230. this.groupBox4.Text = PdnResources.GetString("Menu.Inclusion.Text");
  231. this.button6.Text = PdnResources.GetString("Menu.EditInclusion.Text");
  232. this.button5.Text = PdnResources.GetString("Menu.RemoveInclusions.Text");
  233. this.label1.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  234. this.button1.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
  235. this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
  236. this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  237. this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  238. this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
  239. this.bc.button4.Text = PdnResources.GetString("Menu.ScreeningIllusion.text");
  240. }
  241. #region [组件初始化]
  242. private void InitializeComponent()
  243. {
  244. this.components = new System.ComponentModel.Container();
  245. this.groupBox_operating = new System.Windows.Forms.GroupBox();
  246. this.textBox1 = new System.Windows.Forms.TextBox();
  247. this.label3 = new System.Windows.Forms.Label();
  248. this.label2 = new System.Windows.Forms.Label();
  249. this.button4 = new System.Windows.Forms.Button();
  250. this.button3 = new System.Windows.Forms.Button();
  251. this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
  252. this.btn_clean_result = new System.Windows.Forms.Button();
  253. this.button_setting = new System.Windows.Forms.Button();
  254. this.btn_statistics = new System.Windows.Forms.Button();
  255. this.btn_saveresult = new System.Windows.Forms.Button();
  256. this.imageList_img = new System.Windows.Forms.ImageList(this.components);
  257. this.groupBox_img = new System.Windows.Forms.GroupBox();
  258. this.lstView_img = new System.Windows.Forms.ListView();
  259. this.groupBox1 = new System.Windows.Forms.GroupBox();
  260. this.checkBox4 = new System.Windows.Forms.CheckBox();
  261. this.checkBox3 = new System.Windows.Forms.CheckBox();
  262. this.measureRangeControl1 = new Metis.AutoAnalysis.MeasureRangeControl();
  263. this.panel_color2 = new System.Windows.Forms.Panel();
  264. this.panel_color1 = new System.Windows.Forms.Panel();
  265. this.groupBox2 = new System.Windows.Forms.GroupBox();
  266. this.button2 = new System.Windows.Forms.Button();
  267. this.comboBox_rollingDirection = new System.Windows.Forms.ComboBox();
  268. this.label4 = new System.Windows.Forms.Label();
  269. this.groupBox3 = new System.Windows.Forms.GroupBox();
  270. this.radioButton2 = new System.Windows.Forms.RadioButton();
  271. this.radioButton1 = new System.Windows.Forms.RadioButton();
  272. this.checkBox2 = new System.Windows.Forms.CheckBox();
  273. this.checkBox1 = new System.Windows.Forms.CheckBox();
  274. this.groupBox4 = new System.Windows.Forms.GroupBox();
  275. this.button6 = new System.Windows.Forms.Button();
  276. this.button5 = new System.Windows.Forms.Button();
  277. this.groupBox_report = new System.Windows.Forms.GroupBox();
  278. this.label1 = new System.Windows.Forms.Label();
  279. this.button1 = new System.Windows.Forms.Button();
  280. this.label_resultPrecision = new System.Windows.Forms.Label();
  281. this.domainUpDown_resultPrecision = new System.Windows.Forms.DomainUpDown();
  282. this.button_exportResults = new System.Windows.Forms.Button();
  283. this.button_generateReport = new System.Windows.Forms.Button();
  284. this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
  285. this.listView_analysisResult2 = new System.Windows.Forms.ListView();
  286. this.listView_analysisResult = new System.Windows.Forms.ListView();
  287. this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
  288. this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
  289. this.button_remove = new System.Windows.Forms.Button();
  290. this.button_all = new System.Windows.Forms.Button();
  291. this.groupBox_review = new System.Windows.Forms.GroupBox();
  292. this.groupBox_operating.SuspendLayout();
  293. this.groupBox_img.SuspendLayout();
  294. this.groupBox1.SuspendLayout();
  295. this.groupBox2.SuspendLayout();
  296. this.groupBox3.SuspendLayout();
  297. this.groupBox4.SuspendLayout();
  298. this.groupBox_report.SuspendLayout();
  299. this.groupBox6groupBox_analysisResult2.SuspendLayout();
  300. this.groupBox_analysisResult1.SuspendLayout();
  301. this.SuspendLayout();
  302. //
  303. // groupBox_operating
  304. //
  305. this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  306. | System.Windows.Forms.AnchorStyles.Right)));
  307. this.groupBox_operating.Controls.Add(this.textBox1);
  308. this.groupBox_operating.Controls.Add(this.label3);
  309. this.groupBox_operating.Controls.Add(this.label2);
  310. this.groupBox_operating.Controls.Add(this.button4);
  311. this.groupBox_operating.Controls.Add(this.button3);
  312. this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
  313. this.groupBox_operating.Controls.Add(this.btn_clean_result);
  314. this.groupBox_operating.Controls.Add(this.button_setting);
  315. this.groupBox_operating.Controls.Add(this.btn_statistics);
  316. this.groupBox_operating.Controls.Add(this.btn_saveresult);
  317. this.groupBox_operating.Location = new System.Drawing.Point(3, 12);
  318. this.groupBox_operating.Name = "groupBox_operating";
  319. this.groupBox_operating.Size = new System.Drawing.Size(1170, 53);
  320. this.groupBox_operating.TabIndex = 13;
  321. this.groupBox_operating.TabStop = false;
  322. //
  323. // textBox1
  324. //
  325. this.textBox1.Location = new System.Drawing.Point(650, 19);
  326. this.textBox1.Name = "textBox1";
  327. this.textBox1.Size = new System.Drawing.Size(72, 21);
  328. this.textBox1.TabIndex = 14;
  329. this.textBox1.Text = "710";
  330. //
  331. // label3
  332. //
  333. this.label3.AutoSize = true;
  334. this.label3.Location = new System.Drawing.Point(728, 22);
  335. this.label3.Name = "label3";
  336. this.label3.Size = new System.Drawing.Size(23, 12);
  337. this.label3.TabIndex = 13;
  338. this.label3.Text = "μm";
  339. //
  340. // label2
  341. //
  342. this.label2.AutoSize = true;
  343. this.label2.Location = new System.Drawing.Point(615, 22);
  344. this.label2.Name = "label2";
  345. this.label2.Size = new System.Drawing.Size(29, 12);
  346. this.label2.TabIndex = 12;
  347. this.label2.Text = "视场";
  348. //
  349. // button4
  350. //
  351. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  352. this.button4.Location = new System.Drawing.Point(1006, 17);
  353. this.button4.Name = "button4";
  354. this.button4.Size = new System.Drawing.Size(75, 23);
  355. this.button4.TabIndex = 11;
  356. this.button4.Text = "应用全部";
  357. this.button4.UseVisualStyleBackColor = true;
  358. this.button4.Click += new System.EventHandler(this.button4_Click);
  359. //
  360. // button3
  361. //
  362. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  363. this.button3.Location = new System.Drawing.Point(1087, 17);
  364. this.button3.Name = "button3";
  365. this.button3.Size = new System.Drawing.Size(75, 23);
  366. this.button3.TabIndex = 10;
  367. this.button3.Text = "保存全部";
  368. this.button3.UseVisualStyleBackColor = true;
  369. this.button3.Click += new System.EventHandler(this.button3_Click);
  370. //
  371. // checkBox_generateReport_opensetting
  372. //
  373. this.checkBox_generateReport_opensetting.AutoSize = true;
  374. this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  375. this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
  376. this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
  377. this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(132, 16);
  378. this.checkBox_generateReport_opensetting.TabIndex = 6;
  379. this.checkBox_generateReport_opensetting.Text = "生成报告时打开设置";
  380. this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
  381. //
  382. // btn_clean_result
  383. //
  384. this.btn_clean_result.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  385. this.btn_clean_result.Location = new System.Drawing.Point(844, 17);
  386. this.btn_clean_result.Name = "btn_clean_result";
  387. this.btn_clean_result.Size = new System.Drawing.Size(75, 23);
  388. this.btn_clean_result.TabIndex = 5;
  389. this.btn_clean_result.Text = "清除统计";
  390. this.btn_clean_result.UseVisualStyleBackColor = true;
  391. this.btn_clean_result.Click += new System.EventHandler(this.btn_clean_result_Click);
  392. //
  393. // button_setting
  394. //
  395. this.button_setting.Location = new System.Drawing.Point(6, 20);
  396. this.button_setting.Name = "button_setting";
  397. this.button_setting.Size = new System.Drawing.Size(75, 23);
  398. this.button_setting.TabIndex = 4;
  399. this.button_setting.Text = "设置";
  400. this.button_setting.UseVisualStyleBackColor = true;
  401. this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
  402. //
  403. // btn_statistics
  404. //
  405. this.btn_statistics.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  406. this.btn_statistics.Location = new System.Drawing.Point(763, 17);
  407. this.btn_statistics.Name = "btn_statistics";
  408. this.btn_statistics.Size = new System.Drawing.Size(75, 23);
  409. this.btn_statistics.TabIndex = 3;
  410. this.btn_statistics.Text = "开始统计";
  411. this.btn_statistics.UseVisualStyleBackColor = true;
  412. this.btn_statistics.Click += new System.EventHandler(this.btn_statistics_Click);
  413. //
  414. // btn_saveresult
  415. //
  416. this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  417. this.btn_saveresult.Location = new System.Drawing.Point(925, 17);
  418. this.btn_saveresult.Name = "btn_saveresult";
  419. this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
  420. this.btn_saveresult.TabIndex = 2;
  421. this.btn_saveresult.Text = "保存结果";
  422. this.btn_saveresult.UseVisualStyleBackColor = true;
  423. this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
  424. //
  425. // imageList_img
  426. //
  427. this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  428. this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
  429. this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
  430. //
  431. // groupBox_img
  432. //
  433. this.groupBox_img.Controls.Add(this.lstView_img);
  434. this.groupBox_img.Location = new System.Drawing.Point(3, 72);
  435. this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
  436. this.groupBox_img.Name = "groupBox_img";
  437. this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
  438. this.groupBox_img.Size = new System.Drawing.Size(168, 526);
  439. this.groupBox_img.TabIndex = 14;
  440. this.groupBox_img.TabStop = false;
  441. //
  442. // lstView_img
  443. //
  444. this.lstView_img.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  445. | System.Windows.Forms.AnchorStyles.Left)
  446. | System.Windows.Forms.AnchorStyles.Right)));
  447. this.lstView_img.HideSelection = false;
  448. this.lstView_img.LargeImageList = this.imageList_img;
  449. this.lstView_img.Location = new System.Drawing.Point(8, 26);
  450. this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
  451. this.lstView_img.MultiSelect = false;
  452. this.lstView_img.Name = "lstView_img";
  453. this.lstView_img.Size = new System.Drawing.Size(150, 492);
  454. this.lstView_img.TabIndex = 0;
  455. this.lstView_img.UseCompatibleStateImageBehavior = false;
  456. this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  457. //
  458. // groupBox1
  459. //
  460. this.groupBox1.Controls.Add(this.checkBox4);
  461. this.groupBox1.Controls.Add(this.checkBox3);
  462. this.groupBox1.Controls.Add(this.measureRangeControl1);
  463. this.groupBox1.Controls.Add(this.panel_color2);
  464. this.groupBox1.Controls.Add(this.panel_color1);
  465. this.groupBox1.Location = new System.Drawing.Point(178, 72);
  466. this.groupBox1.Name = "groupBox1";
  467. this.groupBox1.Size = new System.Drawing.Size(360, 47);
  468. this.groupBox1.TabIndex = 37;
  469. this.groupBox1.TabStop = false;
  470. this.groupBox1.Text = "氧硫";
  471. //
  472. // checkBox4
  473. //
  474. this.checkBox4.AutoSize = true;
  475. this.checkBox4.Location = new System.Drawing.Point(209, 18);
  476. this.checkBox4.Name = "checkBox4";
  477. this.checkBox4.Size = new System.Drawing.Size(30, 16);
  478. this.checkBox4.TabIndex = 45;
  479. this.checkBox4.Text = "O";
  480. this.checkBox4.UseVisualStyleBackColor = true;
  481. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  482. //
  483. // checkBox3
  484. //
  485. this.checkBox3.AutoSize = true;
  486. this.checkBox3.Location = new System.Drawing.Point(30, 18);
  487. this.checkBox3.Name = "checkBox3";
  488. this.checkBox3.Size = new System.Drawing.Size(30, 16);
  489. this.checkBox3.TabIndex = 44;
  490. this.checkBox3.Text = "S";
  491. this.checkBox3.UseVisualStyleBackColor = true;
  492. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  493. //
  494. // measureRangeControl1
  495. //
  496. this.measureRangeControl1.Location = new System.Drawing.Point(201, 33);
  497. this.measureRangeControl1.Name = "measureRangeControl1";
  498. this.measureRangeControl1.Size = new System.Drawing.Size(8, 11);
  499. this.measureRangeControl1.TabIndex = 43;
  500. //
  501. // panel_color2
  502. //
  503. this.panel_color2.BackColor = System.Drawing.Color.Red;
  504. this.panel_color2.Location = new System.Drawing.Point(245, 17);
  505. this.panel_color2.Name = "panel_color2";
  506. this.panel_color2.Size = new System.Drawing.Size(69, 17);
  507. this.panel_color2.TabIndex = 42;
  508. this.panel_color2.Click += new System.EventHandler(this.panel_color2_Click);
  509. //
  510. // panel_color1
  511. //
  512. this.panel_color1.BackColor = System.Drawing.Color.Blue;
  513. this.panel_color1.Location = new System.Drawing.Point(66, 17);
  514. this.panel_color1.Name = "panel_color1";
  515. this.panel_color1.Size = new System.Drawing.Size(69, 17);
  516. this.panel_color1.TabIndex = 41;
  517. this.panel_color1.Click += new System.EventHandler(this.panel_color1_Click);
  518. //
  519. // groupBox2
  520. //
  521. this.groupBox2.Controls.Add(this.button2);
  522. this.groupBox2.Controls.Add(this.comboBox_rollingDirection);
  523. this.groupBox2.Controls.Add(this.label4);
  524. this.groupBox2.Location = new System.Drawing.Point(178, 417);
  525. this.groupBox2.Name = "groupBox2";
  526. this.groupBox2.Size = new System.Drawing.Size(360, 60);
  527. this.groupBox2.TabIndex = 38;
  528. this.groupBox2.TabStop = false;
  529. this.groupBox2.Text = "基础设置";
  530. //
  531. // button2
  532. //
  533. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  534. this.button2.Location = new System.Drawing.Point(279, 23);
  535. this.button2.Name = "button2";
  536. this.button2.Size = new System.Drawing.Size(75, 23);
  537. this.button2.TabIndex = 5;
  538. this.button2.Text = "更多";
  539. this.button2.UseVisualStyleBackColor = true;
  540. this.button2.Click += new System.EventHandler(this.button2_Click);
  541. //
  542. // comboBox_rollingDirection
  543. //
  544. this.comboBox_rollingDirection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  545. this.comboBox_rollingDirection.FormattingEnabled = true;
  546. this.comboBox_rollingDirection.Location = new System.Drawing.Point(90, 25);
  547. this.comboBox_rollingDirection.Name = "comboBox_rollingDirection";
  548. this.comboBox_rollingDirection.Size = new System.Drawing.Size(56, 20);
  549. this.comboBox_rollingDirection.TabIndex = 4;
  550. //
  551. // label4
  552. //
  553. this.label4.AutoSize = true;
  554. this.label4.Location = new System.Drawing.Point(19, 28);
  555. this.label4.Name = "label4";
  556. this.label4.Size = new System.Drawing.Size(65, 12);
  557. this.label4.TabIndex = 1;
  558. this.label4.Text = "轧制方向:";
  559. //
  560. // groupBox3
  561. //
  562. this.groupBox3.Controls.Add(this.radioButton2);
  563. this.groupBox3.Controls.Add(this.radioButton1);
  564. this.groupBox3.Controls.Add(this.checkBox2);
  565. this.groupBox3.Controls.Add(this.checkBox1);
  566. this.groupBox3.Location = new System.Drawing.Point(178, 483);
  567. this.groupBox3.Name = "groupBox3";
  568. this.groupBox3.Size = new System.Drawing.Size(360, 47);
  569. this.groupBox3.TabIndex = 39;
  570. this.groupBox3.TabStop = false;
  571. this.groupBox3.Text = "样式";
  572. //
  573. // radioButton2
  574. //
  575. this.radioButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  576. this.radioButton2.AutoSize = true;
  577. this.radioButton2.Checked = true;
  578. this.radioButton2.Location = new System.Drawing.Point(84, 16);
  579. this.radioButton2.Name = "radioButton2";
  580. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  581. this.radioButton2.TabIndex = 16;
  582. this.radioButton2.TabStop = true;
  583. this.radioButton2.Text = "实心";
  584. this.radioButton2.UseVisualStyleBackColor = true;
  585. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  586. //
  587. // radioButton1
  588. //
  589. this.radioButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  590. this.radioButton1.AutoSize = true;
  591. this.radioButton1.Location = new System.Drawing.Point(13, 16);
  592. this.radioButton1.Name = "radioButton1";
  593. this.radioButton1.Size = new System.Drawing.Size(47, 16);
  594. this.radioButton1.TabIndex = 15;
  595. this.radioButton1.Text = "边框";
  596. this.radioButton1.UseVisualStyleBackColor = true;
  597. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  598. //
  599. // checkBox2
  600. //
  601. this.checkBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  602. this.checkBox2.AutoSize = true;
  603. this.checkBox2.Location = new System.Drawing.Point(155, 17);
  604. this.checkBox2.Name = "checkBox2";
  605. this.checkBox2.Size = new System.Drawing.Size(84, 16);
  606. this.checkBox2.TabIndex = 14;
  607. this.checkBox2.Text = "显示矩形框";
  608. this.checkBox2.UseVisualStyleBackColor = true;
  609. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  610. //
  611. // checkBox1
  612. //
  613. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  614. this.checkBox1.AutoSize = true;
  615. this.checkBox1.Location = new System.Drawing.Point(263, 16);
  616. this.checkBox1.Name = "checkBox1";
  617. this.checkBox1.Size = new System.Drawing.Size(84, 16);
  618. this.checkBox1.TabIndex = 13;
  619. this.checkBox1.Text = "显示椭圆框";
  620. this.checkBox1.UseVisualStyleBackColor = true;
  621. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  622. //
  623. // groupBox4
  624. //
  625. this.groupBox4.Controls.Add(this.button6);
  626. this.groupBox4.Controls.Add(this.button5);
  627. this.groupBox4.Location = new System.Drawing.Point(178, 536);
  628. this.groupBox4.Name = "groupBox4";
  629. this.groupBox4.Size = new System.Drawing.Size(360, 62);
  630. this.groupBox4.TabIndex = 40;
  631. this.groupBox4.TabStop = false;
  632. this.groupBox4.Text = "夹杂物操作";
  633. //
  634. // button6
  635. //
  636. this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  637. this.button6.Location = new System.Drawing.Point(9, 20);
  638. this.button6.Name = "button6";
  639. this.button6.Size = new System.Drawing.Size(75, 23);
  640. this.button6.TabIndex = 7;
  641. this.button6.Text = "编辑夹杂物";
  642. this.button6.UseVisualStyleBackColor = true;
  643. this.button6.Click += new System.EventHandler(this.button6_Click);
  644. //
  645. // button5
  646. //
  647. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  648. this.button5.Location = new System.Drawing.Point(90, 20);
  649. this.button5.Name = "button5";
  650. this.button5.Size = new System.Drawing.Size(75, 23);
  651. this.button5.TabIndex = 6;
  652. this.button5.Text = "删除夹杂物";
  653. this.button5.UseVisualStyleBackColor = true;
  654. this.button5.Click += new System.EventHandler(this.button5_Click);
  655. //
  656. // groupBox_report
  657. //
  658. this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  659. this.groupBox_report.Controls.Add(this.label1);
  660. this.groupBox_report.Controls.Add(this.button1);
  661. this.groupBox_report.Controls.Add(this.label_resultPrecision);
  662. this.groupBox_report.Controls.Add(this.domainUpDown_resultPrecision);
  663. this.groupBox_report.Controls.Add(this.button_exportResults);
  664. this.groupBox_report.Controls.Add(this.button_generateReport);
  665. this.groupBox_report.Location = new System.Drawing.Point(1031, 597);
  666. this.groupBox_report.Name = "groupBox_report";
  667. this.groupBox_report.Size = new System.Drawing.Size(142, 188);
  668. this.groupBox_report.TabIndex = 47;
  669. this.groupBox_report.TabStop = false;
  670. //
  671. // label1
  672. //
  673. this.label1.AutoSize = true;
  674. this.label1.Location = new System.Drawing.Point(16, 144);
  675. this.label1.Name = "label1";
  676. this.label1.Size = new System.Drawing.Size(41, 12);
  677. this.label1.TabIndex = 5;
  678. this.label1.Text = "小数:";
  679. //
  680. // button1
  681. //
  682. this.button1.Location = new System.Drawing.Point(28, 104);
  683. this.button1.Name = "button1";
  684. this.button1.Size = new System.Drawing.Size(75, 23);
  685. this.button1.TabIndex = 4;
  686. this.button1.Text = "项目工程";
  687. this.button1.UseVisualStyleBackColor = true;
  688. this.button1.Click += new System.EventHandler(this.button1_Click);
  689. //
  690. // label_resultPrecision
  691. //
  692. this.label_resultPrecision.AutoSize = true;
  693. this.label_resultPrecision.Location = new System.Drawing.Point(21, 148);
  694. this.label_resultPrecision.Name = "label_resultPrecision";
  695. this.label_resultPrecision.Size = new System.Drawing.Size(0, 12);
  696. this.label_resultPrecision.TabIndex = 3;
  697. //
  698. // domainUpDown_resultPrecision
  699. //
  700. this.domainUpDown_resultPrecision.Location = new System.Drawing.Point(63, 142);
  701. this.domainUpDown_resultPrecision.Name = "domainUpDown_resultPrecision";
  702. this.domainUpDown_resultPrecision.ReadOnly = true;
  703. this.domainUpDown_resultPrecision.Size = new System.Drawing.Size(41, 21);
  704. this.domainUpDown_resultPrecision.TabIndex = 2;
  705. this.domainUpDown_resultPrecision.Text = "2";
  706. //
  707. // button_exportResults
  708. //
  709. this.button_exportResults.Location = new System.Drawing.Point(28, 63);
  710. this.button_exportResults.Name = "button_exportResults";
  711. this.button_exportResults.Size = new System.Drawing.Size(75, 24);
  712. this.button_exportResults.TabIndex = 1;
  713. this.button_exportResults.Text = "导出结果";
  714. this.button_exportResults.UseVisualStyleBackColor = true;
  715. this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
  716. //
  717. // button_generateReport
  718. //
  719. this.button_generateReport.Location = new System.Drawing.Point(29, 24);
  720. this.button_generateReport.Name = "button_generateReport";
  721. this.button_generateReport.Size = new System.Drawing.Size(75, 23);
  722. this.button_generateReport.TabIndex = 0;
  723. this.button_generateReport.Text = "生成报告";
  724. this.button_generateReport.UseVisualStyleBackColor = true;
  725. this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
  726. //
  727. // groupBox6groupBox_analysisResult2
  728. //
  729. this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  730. | System.Windows.Forms.AnchorStyles.Right)));
  731. this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult2);
  732. this.groupBox6groupBox_analysisResult2.Controls.Add(this.listView_analysisResult);
  733. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(233, 597);
  734. this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
  735. this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(792, 188);
  736. this.groupBox6groupBox_analysisResult2.TabIndex = 46;
  737. this.groupBox6groupBox_analysisResult2.TabStop = false;
  738. //
  739. // listView_analysisResult2
  740. //
  741. this.listView_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  742. | System.Windows.Forms.AnchorStyles.Right)));
  743. this.listView_analysisResult2.FullRowSelect = true;
  744. this.listView_analysisResult2.GridLines = true;
  745. this.listView_analysisResult2.HideSelection = false;
  746. this.listView_analysisResult2.Location = new System.Drawing.Point(6, 114);
  747. this.listView_analysisResult2.MultiSelect = false;
  748. this.listView_analysisResult2.Name = "listView_analysisResult2";
  749. this.listView_analysisResult2.Size = new System.Drawing.Size(780, 63);
  750. this.listView_analysisResult2.TabIndex = 2;
  751. this.listView_analysisResult2.UseCompatibleStateImageBehavior = false;
  752. //
  753. // listView_analysisResult
  754. //
  755. this.listView_analysisResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  756. | System.Windows.Forms.AnchorStyles.Right)));
  757. this.listView_analysisResult.FullRowSelect = true;
  758. this.listView_analysisResult.GridLines = true;
  759. this.listView_analysisResult.HideSelection = false;
  760. this.listView_analysisResult.Location = new System.Drawing.Point(6, 20);
  761. this.listView_analysisResult.MultiSelect = false;
  762. this.listView_analysisResult.Name = "listView_analysisResult";
  763. this.listView_analysisResult.Size = new System.Drawing.Size(780, 88);
  764. this.listView_analysisResult.TabIndex = 2;
  765. this.listView_analysisResult.UseCompatibleStateImageBehavior = false;
  766. //
  767. // groupBox_analysisResult1
  768. //
  769. this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  770. this.groupBox_analysisResult1.Controls.Add(this.listBox_analysisResult);
  771. this.groupBox_analysisResult1.Controls.Add(this.button_remove);
  772. this.groupBox_analysisResult1.Controls.Add(this.button_all);
  773. this.groupBox_analysisResult1.Location = new System.Drawing.Point(3, 597);
  774. this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
  775. this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 188);
  776. this.groupBox_analysisResult1.TabIndex = 45;
  777. this.groupBox_analysisResult1.TabStop = false;
  778. //
  779. // listBox_analysisResult
  780. //
  781. this.listBox_analysisResult.CheckOnClick = true;
  782. this.listBox_analysisResult.FormattingEnabled = true;
  783. this.listBox_analysisResult.HorizontalScrollbar = true;
  784. this.listBox_analysisResult.Location = new System.Drawing.Point(6, 53);
  785. this.listBox_analysisResult.Name = "listBox_analysisResult";
  786. this.listBox_analysisResult.Size = new System.Drawing.Size(212, 132);
  787. this.listBox_analysisResult.TabIndex = 0;
  788. this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
  789. //
  790. // button_remove
  791. //
  792. this.button_remove.Location = new System.Drawing.Point(143, 24);
  793. this.button_remove.Name = "button_remove";
  794. this.button_remove.Size = new System.Drawing.Size(75, 23);
  795. this.button_remove.TabIndex = 8;
  796. this.button_remove.Text = "删除";
  797. this.button_remove.UseVisualStyleBackColor = true;
  798. this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
  799. //
  800. // button_all
  801. //
  802. this.button_all.Location = new System.Drawing.Point(6, 24);
  803. this.button_all.Name = "button_all";
  804. this.button_all.Size = new System.Drawing.Size(75, 23);
  805. this.button_all.TabIndex = 1;
  806. this.button_all.Text = "全部显示";
  807. this.button_all.UseVisualStyleBackColor = true;
  808. this.button_all.Click += new System.EventHandler(this.button_all_Click);
  809. //
  810. // groupBox_review
  811. //
  812. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  813. | System.Windows.Forms.AnchorStyles.Left)
  814. | System.Windows.Forms.AnchorStyles.Right)));
  815. this.groupBox_review.Location = new System.Drawing.Point(551, 73);
  816. this.groupBox_review.Name = "groupBox_review";
  817. this.groupBox_review.Size = new System.Drawing.Size(622, 525);
  818. this.groupBox_review.TabIndex = 48;
  819. this.groupBox_review.TabStop = false;
  820. //
  821. // MethodKDialog
  822. //
  823. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  824. this.ClientSize = new System.Drawing.Size(1177, 788);
  825. this.Controls.Add(this.groupBox_review);
  826. this.Controls.Add(this.groupBox_report);
  827. this.Controls.Add(this.groupBox6groupBox_analysisResult2);
  828. this.Controls.Add(this.groupBox_analysisResult1);
  829. this.Controls.Add(this.groupBox4);
  830. this.Controls.Add(this.groupBox3);
  831. this.Controls.Add(this.groupBox2);
  832. this.Controls.Add(this.groupBox1);
  833. this.Controls.Add(this.groupBox_img);
  834. this.Controls.Add(this.groupBox_operating);
  835. this.Name = "MethodKDialog";
  836. this.Controls.SetChildIndex(this.groupBox_operating, 0);
  837. this.Controls.SetChildIndex(this.groupBox_img, 0);
  838. this.Controls.SetChildIndex(this.groupBox1, 0);
  839. this.Controls.SetChildIndex(this.groupBox2, 0);
  840. this.Controls.SetChildIndex(this.groupBox3, 0);
  841. this.Controls.SetChildIndex(this.groupBox4, 0);
  842. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  843. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  844. this.Controls.SetChildIndex(this.groupBox_report, 0);
  845. this.Controls.SetChildIndex(this.groupBox_review, 0);
  846. this.groupBox_operating.ResumeLayout(false);
  847. this.groupBox_operating.PerformLayout();
  848. this.groupBox_img.ResumeLayout(false);
  849. this.groupBox1.ResumeLayout(false);
  850. this.groupBox1.PerformLayout();
  851. this.groupBox2.ResumeLayout(false);
  852. this.groupBox2.PerformLayout();
  853. this.groupBox3.ResumeLayout(false);
  854. this.groupBox3.PerformLayout();
  855. this.groupBox4.ResumeLayout(false);
  856. this.groupBox_report.ResumeLayout(false);
  857. this.groupBox_report.PerformLayout();
  858. this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
  859. this.groupBox_analysisResult1.ResumeLayout(false);
  860. this.ResumeLayout(false);
  861. }
  862. private void InitializeComponent2()
  863. {
  864. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  865. //
  866. // bc
  867. //
  868. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  869. this.bc.BinaryChecked = false;
  870. this.bc.BinaryStyle = 1;
  871. this.bc.Location = new System.Drawing.Point(178, 120);
  872. this.bc.Name = "bc";
  873. this.bc.OriginChecked = false;
  874. this.bc.scope1End = 0D;
  875. this.bc.scope1Start = 0D;
  876. this.bc.scope2End = 0D;
  877. this.bc.scope2Start = 0D;
  878. this.bc.scope3End = 0D;
  879. this.bc.scope3Start = 0D;
  880. this.bc.Size = new System.Drawing.Size(360, 292);
  881. this.bc.TabIndex = 35;
  882. this.Controls.Add(this.bc);
  883. this.Controls.SetChildIndex(this.bc, 0);
  884. }
  885. private void Initialize()
  886. {
  887. radioButton1.Enabled = false;
  888. radioButton2.Enabled = false;
  889. checkBox1.Enabled = false;
  890. checkBox2.Enabled = false;
  891. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  892. this.comboBox_rollingDirection.SelectedIndex = 0;
  893. this.comboBox_rollingDirection.SelectedIndexChanged += new System.EventHandler(this.comboBox_rollingDirection_SelectedIndexChanged);
  894. for (int i = 10; i >= 1; i--)
  895. {
  896. this.domainUpDown_resultPrecision.Items.Add(i.ToString());
  897. }
  898. this.domainUpDown_resultPrecision.SelectedIndex = 8;
  899. this.documentItems = new Dictionary<int, DocumentItem>();
  900. //初始化图片列表
  901. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  902. {
  903. this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  904. this.lstView_img.Items.Add("", i);
  905. this.lstView_img.Items[i].ImageIndex = i;
  906. this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  907. this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  908. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  909. {
  910. this.imgIndex = i;
  911. }
  912. }
  913. //
  914. //初始化图像控件
  915. //
  916. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  917. this.documentWorkspace.Cursor = Cursors.Default;
  918. this.documentWorkspace.Dock = DockStyle.Fill;
  919. this.documentWorkspace.HookMouseEvents();
  920. this.documentWorkspace.AuxiliaryLineEnabled = false;
  921. this.documentWorkspace.Visible = true;
  922. //this.documentWorkspace.panel.Click += new EventHandler(this.documentWorkspace_panel_Click);
  923. this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.documentWorkspace_panel_MouseDown);
  924. this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.documentWorkspace_panel_MouseMove);
  925. this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.documentWorkspace_panel_MouseUp);
  926. PdnBaseForm.RegisterFormHotKey(Keys.Delete, (key) => { this.documentWorkspace.MouseEvent_Del(null, null); return true; });
  927. this.groupBox_review.Controls.Add(this.documentWorkspace);
  928. //
  929. //初始化操作按钮
  930. //
  931. this.commonControlButtons = new CommonControlButtons();
  932. this.commonControlButtons.Dock = DockStyle.Top;
  933. this.commonControlButtons.Height = 30;
  934. this.commonControlButtons.HideZoomToWindowAndActualSize();
  935. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  936. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  937. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  938. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  939. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  940. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  941. groupBox_review.Controls.Add(this.commonControlButtons);
  942. this.binaryExtractionModel.ColorInterval = 2;
  943. // 初始化报告列表
  944. this.listView_analysisResult.View = View.Details;
  945. this.listView_analysisResult2.View = View.Details;
  946. this.listBox_analysisResult.DisplayMember = "Display";
  947. this.listBox_analysisResult.ValueMember = "Value";
  948. #region [处理自动阈值]
  949. this.bc.button7.Click -= new System.EventHandler(this.bc.button7_Click);
  950. this.bc.button7.Click += new System.EventHandler(this.AutomaticThreshold);
  951. //this.bc.button4.Text = "筛选假象";
  952. #endregion
  953. }
  954. /// <summary>
  955. /// 自动阈值
  956. /// </summary>
  957. private void AutomaticThreshold(object sender, EventArgs e)
  958. {
  959. //先计算阈值
  960. //Mat mat = imageMat.Clone();//待测试
  961. Mat gray = imageMat.CvtColor(ColorConversionCodes.BGR2GRAY);
  962. double otsu = Cv2.Threshold(gray, gray, 0, 255, ThresholdTypes.Triangle/*.Otsu*/);
  963. if (otsu <= 10 || otsu >= 245)
  964. {
  965. otsu = Cv2.Threshold(imageMat.CvtColor(ColorConversionCodes.BGR2GRAY), gray, 0, 255, ThresholdTypes.Otsu);//.Triangle
  966. }
  967. this.bc.numberScopeControl3.minValue = 0;
  968. this.bc.numberScopeControl3.maxValue = otsu;
  969. if (otsu <= 139)
  970. {
  971. this.bc.numberScopeControl2.minValue = 255;
  972. this.bc.numberScopeControl2.maxValue = 255;
  973. }
  974. else
  975. {
  976. this.bc.numberScopeControl3.maxValue = 139;
  977. this.bc.numberScopeControl2.minValue = 140;
  978. this.bc.numberScopeControl2.maxValue = otsu;
  979. }
  980. if (this.checkBox3.Checked || this.checkBox4.Checked)
  981. {
  982. bClassBinaryImplFinishAction(null, null);
  983. }
  984. }
  985. private void showImg(object sender, EventArgs e)
  986. {
  987. lstView_img.Focus();
  988. if (this.imgIndex != -1)
  989. {
  990. //滚动到指定的行位置
  991. this.lstView_img.EnsureVisible(this.imgIndex);
  992. this.lstView_img.Items[imgIndex].Focused = true;
  993. this.lstView_img.Items[imgIndex].Selected = true;
  994. }
  995. //this.methodOfAssessment = getMethodOfAssessment();
  996. //MethodOfAssessment.activeMethod = this.methodOfAssessment;
  997. //SetAnalyzeModelFromXml(this.methodOfAssessment.resourcesName);
  998. //SubclassInitialize();
  999. //initColorSetting();
  1000. //initDisplaySetting();
  1001. ////如果是脚本执行,将参数带入
  1002. //if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  1003. //{
  1004. // this.initScriptValues = true;//ScriptAutomatic
  1005. // //Boolean initScriptValues = true;
  1006. // ////在这里反射出对应功能的参数类
  1007. // string className = InvariantData.path_Action + ".Action" + menuId;
  1008. // ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1009. // foreach (Args arg in param.Lists)
  1010. // {
  1011. // Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  1012. // if (param1.value != null)
  1013. // arg.Value = param1.value;
  1014. // getValue(arg.key, arg.Value);
  1015. // }
  1016. // appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1017. //}
  1018. //else
  1019. //{//读取上次关闭窗口时保存的参数
  1020. // getLastData();
  1021. //}
  1022. this.firstShow = false;
  1023. binaryClass.RefreshHistogramControl1Values();
  1024. //// 初始化显示设置区域
  1025. //foreach (var item in this.groupBox_displaySetting.Controls)
  1026. //{
  1027. // if (item is Button)
  1028. // {
  1029. // ((Button)item).Click += this.label_displaySetting;
  1030. // }
  1031. //}
  1032. //if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1033. // this.startScriptAutomaticAction();
  1034. }
  1035. #endregion
  1036. #region [二值化相关方法]
  1037. /// <summary>
  1038. /// 添加参数改变的监听
  1039. /// </summary>
  1040. /// <param name="sender"></param>
  1041. /// <param name="e"></param>
  1042. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1043. {
  1044. this.binaryClass.loadParams();
  1045. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  1046. //if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1047. // this.startScriptAutomaticAction();
  1048. }
  1049. /// <summary>
  1050. /// 参数改变时,重新处理图像
  1051. /// </summary>
  1052. /// <param name="sender"></param>
  1053. /// <param name="e"></param>
  1054. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1055. {
  1056. //if (!bcOriginChecked())
  1057. //{
  1058. // if (bcBinaryChecked())
  1059. // {
  1060. // this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelectRecognitionArea;
  1061. // this.documentWorkspace.Cursor = Cursors.Default;
  1062. // }
  1063. // else
  1064. // {
  1065. // this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1066. // }
  1067. //}
  1068. //else
  1069. //{
  1070. // this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1071. //}
  1072. if (!checkBox3.Checked && !checkBox4.Checked)
  1073. {
  1074. return;
  1075. }
  1076. if (!bcOriginChecked())
  1077. {
  1078. binaryClass.BinaryImplFinishAction -= new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1079. if (checkBox3.Checked)
  1080. {
  1081. List<double> valueList = new List<double>() { this.bc.numberScopeControl3.minValue, this.bc.numberScopeControl3.maxValue };
  1082. this.binaryClass.applyButtonImplMethodInclusion(null, -1, null, 0, this.panel_color1.BackColor.ToArgb(), valueList);
  1083. this.documentWorkspace.PhaseModels[0].choise = true;
  1084. }
  1085. else
  1086. {
  1087. this.documentWorkspace.PhaseModels[0].choise = false;
  1088. }
  1089. if (checkBox4.Checked)
  1090. {
  1091. List<double> valueList = new List<double>() { this.bc.numberScopeControl2.minValue, this.bc.numberScopeControl2.maxValue };
  1092. this.binaryClass.applyButtonImplMethodInclusion(null, -1, null, 1, this.panel_color2.BackColor.ToArgb(), valueList);
  1093. this.documentWorkspace.PhaseModels[1].choise = true;
  1094. }
  1095. else
  1096. {
  1097. this.documentWorkspace.PhaseModels[1].choise = false;
  1098. }
  1099. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1100. }
  1101. else
  1102. {
  1103. this.documentWorkspace.PhaseModels[0].choise = false;
  1104. this.documentWorkspace.PhaseModels[1].choise = false;
  1105. }
  1106. this.documentWorkspace.Refresh();
  1107. }
  1108. private bool bcBinaryChecked()
  1109. {
  1110. return bc != null && bc.BinaryChecked;
  1111. }
  1112. private bool bcOriginChecked()
  1113. {
  1114. return bc != null && bc.OriginChecked;
  1115. }
  1116. /// <summary>
  1117. /// 显示原图/原图+二值图
  1118. /// </summary>
  1119. /// <param name="sender"></param>
  1120. /// <param name="e"></param>
  1121. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1122. {
  1123. if (!bcOriginChecked())
  1124. {
  1125. //if (bcBinaryChecked())
  1126. //{
  1127. // this.documentWorkspace.PhaseModels[0].choise = true;
  1128. // this.documentWorkspace.PhaseModels[1].choise = true;
  1129. // this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelectRecognitionArea;
  1130. // this.documentWorkspace.Cursor = Cursors.Default;
  1131. //}
  1132. this.bClassBinaryImplFinishAction(null, null);
  1133. }
  1134. else
  1135. {
  1136. this.documentWorkspace.PhaseModels[0].choise = false;
  1137. this.documentWorkspace.PhaseModels[1].choise = false;
  1138. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1139. }
  1140. this.documentWorkspace.Refresh();
  1141. }
  1142. #endregion [二值化相关方法]
  1143. #region [面板相关事件]
  1144. private void documentWorkspace_panel_MouseDown(object sender, MouseEventArgs e)
  1145. {
  1146. if (this.selectedTypesOfInclusions == null && !this.clearSelect)
  1147. {
  1148. return;
  1149. }
  1150. if (e.Button == MouseButtons.Left)
  1151. {
  1152. this.selectedTypesOfInclusionsPoint = e.Location;
  1153. }
  1154. }
  1155. private void documentWorkspace_panel_MouseMove(object sender, MouseEventArgs e)
  1156. {
  1157. Pen pen = null;
  1158. if (this.selectedTypesOfInclusionsPoint == null)
  1159. {
  1160. return;
  1161. }
  1162. if (this.selectedTypesOfInclusions != null)
  1163. {
  1164. pen = new Pen(Color.FromArgb(this.selectedTypesOfInclusions.showColor), 1);
  1165. }
  1166. else if (this.clearSelect)
  1167. {
  1168. pen = new Pen(Color.Black, 1);
  1169. pen.DashStyle = DashStyle.Dash;
  1170. }
  1171. this.documentWorkspace.Refresh();
  1172. float x = Math.Min(this.selectedTypesOfInclusionsPoint.Value.X, e.Location.X);
  1173. float y = Math.Min(this.selectedTypesOfInclusionsPoint.Value.Y, e.Location.Y);
  1174. float width = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.X - e.Location.X);
  1175. float height = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.Y - e.Location.Y);
  1176. this.documentWorkspace.panel.CreateGraphics().DrawRectangles(pen, new RectangleF[] { new RectangleF(x, y, width, height) });
  1177. }
  1178. private void documentWorkspace_panel_MouseUp(object sender, MouseEventArgs e)
  1179. {
  1180. if (this.selectedTypesOfInclusions == null && !this.clearSelect)
  1181. {
  1182. return;
  1183. }
  1184. if (e.Button == MouseButtons.Left)
  1185. {
  1186. if (this.selectedTypesOfInclusionsPoint == null)
  1187. {
  1188. return;
  1189. }
  1190. var startPoint = this.documentWorkspace.GetScalePoint(this.selectedTypesOfInclusionsPoint.Value);
  1191. var stopPoint = this.documentWorkspace.GetScalePoint(e.Location);
  1192. float x = Math.Min(startPoint.X, stopPoint.X);
  1193. float y = Math.Min(startPoint.Y, stopPoint.Y);
  1194. float width = Math.Abs(startPoint.X - stopPoint.X);
  1195. float height = Math.Abs(startPoint.Y - stopPoint.Y);
  1196. this.selectedTypesOfInclusionsRectangle = new RectangleF(x, y, width, height);
  1197. if (this.selectedTypesOfInclusions != null)
  1198. {
  1199. startStatistics();
  1200. }
  1201. else
  1202. {
  1203. if (this.tempAnalysisResult != null)
  1204. {
  1205. for (int i = this.tempAnalysisResult.inclusions.Count - 1; i >= 0; i--)
  1206. {
  1207. if (this.selectedTypesOfInclusionsRectangle.Value.Contains(this.tempAnalysisResult.inclusions[i].rectProfile)
  1208. || this.selectedTypesOfInclusionsRectangle.Value.IntersectsWith(this.tempAnalysisResult.inclusions[i].rectProfile))
  1209. {
  1210. this.tempAnalysisResult.inclusions.RemoveAt(i);
  1211. }
  1212. }
  1213. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, this.tempAnalysisResult.inclusions, is_showRectangle, is_showOval, is_full);
  1214. }
  1215. }
  1216. this.clearSelect = false;
  1217. this.selectedTypesOfInclusionsPoint = null;
  1218. this.selectedTypesOfInclusionsRectangle = null;
  1219. radioButton1.Enabled = true;
  1220. radioButton2.Enabled = true;
  1221. checkBox1.Enabled = true;
  1222. checkBox2.Enabled = true;
  1223. }
  1224. }
  1225. /// <summary>
  1226. /// 面板绘制
  1227. /// </summary>
  1228. /// <param name="sender"></param>
  1229. /// <param name="e"></param>
  1230. private void Panel_Paint(object sender, PaintEventArgs e)
  1231. {
  1232. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1233. int wid = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Width : this.documentWorkspace.CompositionSurface.Width;
  1234. int hei = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Height : this.documentWorkspace.CompositionSurface.Height;
  1235. int width = (int)(wid * this.documentWorkspace.ScaleFactor.Ratio);
  1236. int height = (int)(hei * this.documentWorkspace.ScaleFactor.Ratio);
  1237. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  1238. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  1239. e.Graphics.TranslateTransform(x, y);
  1240. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1241. if (this.documentWorkspace.GraphicsList.Count > 0)
  1242. {
  1243. Font font = new Font(System.Drawing.SystemFonts.DefaultFont.FontFamily, 40, System.Drawing.SystemFonts.DefaultFont.Style);
  1244. double pxPerUnit = this.imgPxPerUnit;
  1245. int allWidth = (int)(this.imageMat.Width * pxPerUnit);
  1246. int allHeight = (int)(this.imageMat.Height * pxPerUnit);
  1247. if (this.tempAnalysisResult == null)
  1248. {
  1249. this.paintRectangle = this.documentWorkspace.GraphicsList[0].Rectangle;
  1250. }
  1251. int realWidth = (int)(this.paintRectangle.Width * pxPerUnit);
  1252. int realHeight = (int)(this.paintRectangle.Height * pxPerUnit);
  1253. e.Graphics.DrawString($"{realWidth}/{allWidth}", font, new SolidBrush(Color.Blue), this.paintRectangle.Right, this.paintRectangle.Bottom / 2);
  1254. e.Graphics.DrawString($"{realHeight}/{allHeight}", font, new SolidBrush(Color.Blue), this.paintRectangle.Right / 2, this.paintRectangle.Bottom + 10);
  1255. }
  1256. if (this.tempAnalysisResult != null && this.tempAnalysisResult.segmentationView == 2)
  1257. {
  1258. foreach (var s in this.tempAnalysisResult.MedthodKRectangles)
  1259. {
  1260. e.Graphics.DrawRectangle(new Pen(Color.Black, 0.1f), new Rectangle((int)s.X, (int)s.Y, (int)s.Width, (int)s.Height));
  1261. }
  1262. }
  1263. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1264. e.Graphics.TranslateTransform(-x, -y);
  1265. }
  1266. private void zoomInButton_Click(object sender, EventArgs e)
  1267. {
  1268. this.documentWorkspace.ZoomIn();
  1269. }
  1270. private void zoomOutButton_Click(object sender, EventArgs e)
  1271. {
  1272. this.documentWorkspace.ZoomOut();
  1273. }
  1274. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1275. {
  1276. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1277. }
  1278. private void actualSizeButton_Click(object sender, EventArgs e)
  1279. {
  1280. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1281. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1282. }
  1283. private void pointerButton_Click(object sender, EventArgs e)
  1284. {
  1285. this.documentWorkspace.Cursor = Cursors.Default;
  1286. this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelectRecognitionArea;
  1287. }
  1288. private void mobileModeButton_Click(object sender, EventArgs e)
  1289. {
  1290. this.documentWorkspace.ActiveTool = DrawToolType.MoveMode;
  1291. }
  1292. #endregion
  1293. #region [图片选择]
  1294. /// <summary>
  1295. ///
  1296. /// </summary>
  1297. /// <param name="sender"></param>
  1298. /// <param name="e"></param>
  1299. private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
  1300. {
  1301. if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
  1302. {
  1303. this.imgPxPerUnit = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1304. //if (this.methodOfAssessment != null)
  1305. //{
  1306. // this.methodOfAssessment = getMethodOfAssessment();
  1307. // MethodOfAssessment.activeMethod = this.methodOfAssessment;
  1308. // SetAnalyzeModelFromXml(this.methodOfAssessment.resourcesName);
  1309. //}
  1310. this.methodOfAssessment = getMethodOfAssessment();
  1311. MethodOfAssessment.activeMethod = this.methodOfAssessment;
  1312. SetAnalyzeModelFromXml(this.methodOfAssessment.resourcesName);
  1313. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  1314. this.tempAnalysisResult = null;
  1315. //二值化
  1316. binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), this.imageList_img.Images.Keys[this.lstView_img.FocusedItem.Index]);
  1317. this.bc.button6_Click(null, null);
  1318. var gList = new GraphicsList();
  1319. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.Count; i++)
  1320. {
  1321. var obj = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList[i].Clone();
  1322. gList.Add(obj);
  1323. }
  1324. this.documentWorkspace.GraphicsList = gList;
  1325. this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelectRecognitionArea;
  1326. this.documentWorkspace.GraphicsList.DeleteAllView();
  1327. var line = new ViewRectangle(0, 0, this.imageMat.Width, this.imageMat.Height);
  1328. line.ISurfaceBox = documentWorkspace;
  1329. line.combineMode = (CombineMode)Enum.Parse(typeof(CombineMode), "Union");
  1330. line.Selected = true;
  1331. this.documentWorkspace.AddGraphicsFromForm(line);
  1332. if (!this.bcBinaryChecked())
  1333. {
  1334. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1335. }
  1336. //if (userAll)
  1337. //{
  1338. // this.startStatistics();
  1339. //}
  1340. this.documentWorkspace.Refresh();
  1341. }
  1342. else
  1343. {
  1344. this.documentWorkspace.Visible = false;
  1345. }
  1346. }
  1347. #endregion
  1348. #region [设置 样式 操作]
  1349. /// <summary>
  1350. /// S选择
  1351. /// </summary>
  1352. /// <param name="sender"></param>
  1353. /// <param name="e"></param>
  1354. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  1355. {
  1356. if (!bcOriginChecked())
  1357. {
  1358. if (checkBox3.Checked)
  1359. {
  1360. binaryClass.BinaryImplFinishAction -= new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1361. List<double> valueList = new List<double>() { this.bc.numberScopeControl3.minValue, this.bc.numberScopeControl3.maxValue };
  1362. this.binaryClass.applyButtonImplMethodInclusion(null, -1, null, 0,this.panel_color1.BackColor.ToArgb(), valueList);
  1363. this.documentWorkspace.PhaseModels[0].choise = true;
  1364. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1365. }
  1366. else {
  1367. this.documentWorkspace.PhaseModels[0].choise = false;
  1368. }
  1369. }
  1370. else
  1371. {
  1372. this.documentWorkspace.PhaseModels[0].choise = false;
  1373. }
  1374. this.documentWorkspace.Refresh();
  1375. }
  1376. /// <summary>
  1377. /// O选择
  1378. /// </summary>
  1379. /// <param name="sender"></param>
  1380. /// <param name="e"></param>
  1381. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  1382. {
  1383. if (!bcOriginChecked())
  1384. {
  1385. if (checkBox4.Checked)
  1386. {
  1387. binaryClass.BinaryImplFinishAction -= new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1388. List<double> valueList = new List<double>() { this.bc.numberScopeControl2.minValue, this.bc.numberScopeControl2.maxValue };
  1389. this.binaryClass.applyButtonImplMethodInclusion(null, -1, null, 1, this.panel_color2.BackColor.ToArgb(), valueList);
  1390. this.documentWorkspace.PhaseModels[1].choise = true;
  1391. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1392. }
  1393. else
  1394. {
  1395. this.documentWorkspace.PhaseModels[1].choise = false;
  1396. }
  1397. }
  1398. else
  1399. {
  1400. this.documentWorkspace.PhaseModels[1].choise = false;
  1401. }
  1402. this.documentWorkspace.Refresh();
  1403. }
  1404. /// <summary>
  1405. /// 改变S颜色
  1406. /// </summary>
  1407. /// <param name="sender"></param>
  1408. /// <param name="e"></param>
  1409. private void panel_color1_Click(object sender, EventArgs e)
  1410. {
  1411. this.oneColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel_color1.BackColor);
  1412. this.oneColorsForm.setSaveBtn_Click(new System.EventHandler(this.oneColorsChanged));
  1413. this.oneColorsForm.ShowDialog();
  1414. }
  1415. private void oneColorsChanged(object sender, EventArgs e)
  1416. {
  1417. Color color = this.oneColorsForm.UserPrimaryColor.ToColor();
  1418. //更改背景色,触发事件
  1419. this.panel_color1.BackColor = color;
  1420. this.oneColorsForm.Close();
  1421. }
  1422. /// <summary>
  1423. /// 改变O颜色
  1424. /// </summary>
  1425. /// <param name="sender"></param>
  1426. /// <param name="e"></param>
  1427. private void panel_color2_Click(object sender, EventArgs e)
  1428. {
  1429. this.twoColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel_color2.BackColor);
  1430. this.twoColorsForm.setSaveBtn_Click(new System.EventHandler(this.twoColorsChanged));
  1431. this.twoColorsForm.ShowDialog();
  1432. }
  1433. private void twoColorsChanged(object sender, EventArgs e)
  1434. {
  1435. Color color = this.twoColorsForm.UserPrimaryColor.ToColor();
  1436. //更改背景色,触发事件
  1437. this.panel_color2.BackColor = color;
  1438. this.twoColorsForm.Close();
  1439. }
  1440. /// <summary>
  1441. ///
  1442. /// </summary>
  1443. /// <param name="sender"></param>
  1444. /// <param name="e"></param>
  1445. private void comboBox_rollingDirection_SelectedIndexChanged(object sender, EventArgs e)
  1446. {
  1447. this.methodOfAssessment.inclusionsStandard.globalSettings.rollingDirection = (InclusionsGlobalSettings.RollingDirection)this.comboBox_rollingDirection.SelectedIndex;
  1448. }
  1449. /// <summary>
  1450. /// 更多操作
  1451. /// </summary>
  1452. /// <param name="sender"></param>
  1453. /// <param name="e"></param>
  1454. private void button2_Click(object sender, EventArgs e)
  1455. {
  1456. MethodSettingDialog form = new MethodSettingDialog(inclusionSetting);
  1457. form.StartPosition = FormStartPosition.CenterParent;
  1458. form.TransferEvent += frm_TransEvent;
  1459. form.ShowDialog();
  1460. }
  1461. /// <summary>
  1462. /// 弹窗委托
  1463. /// </summary>
  1464. private void frm_TransEvent(InclusionSetting inclusionSetting)
  1465. {
  1466. this.inclusionSetting = inclusionSetting;
  1467. }
  1468. /// <summary>
  1469. /// 设置
  1470. /// </summary>
  1471. /// <param name="sender"></param>
  1472. /// <param name="e"></param>
  1473. private void button_setting_Click(object sender, EventArgs e)
  1474. {
  1475. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1476. if (recombinationRateSetDialog.hasModule)
  1477. {
  1478. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1479. recombinationRateSetDialog.ShowDialog();
  1480. }
  1481. else
  1482. {
  1483. recombinationRateSetDialog = null;
  1484. }
  1485. }
  1486. /// <summary>
  1487. /// 边框or实心
  1488. /// </summary>
  1489. /// <param name="sender"></param>
  1490. /// <param name="e"></param>
  1491. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  1492. {
  1493. if (this.firstShow)
  1494. {
  1495. return;
  1496. }
  1497. if (this.tempAnalysisResult == null)
  1498. {
  1499. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttostartstatistics.text"));
  1500. return;
  1501. }
  1502. if (radioButton1.Checked)
  1503. {
  1504. this.is_full = 2;
  1505. }
  1506. else
  1507. {
  1508. this.is_full = 1;
  1509. }
  1510. if (this.tempAnalysisResult.segmentationView != 2)
  1511. {
  1512. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, this.tempAnalysisResult.inclusions, is_showRectangle, is_showOval, is_full);
  1513. }
  1514. else
  1515. {
  1516. this.documentWorkspace.Refresh();
  1517. }
  1518. }
  1519. /// <summary>
  1520. /// 显示矩形框
  1521. /// </summary>
  1522. /// <param name="sender"></param>
  1523. /// <param name="e"></param>
  1524. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1525. {
  1526. if (this.firstShow)
  1527. {
  1528. return;
  1529. }
  1530. if (this.tempAnalysisResult == null)
  1531. {
  1532. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttostartstatistics.text"));
  1533. return;
  1534. }
  1535. is_showRectangle = !is_showRectangle;
  1536. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, this.tempAnalysisResult.inclusions, is_showRectangle, is_showOval, is_full);
  1537. this.documentWorkspace.Refresh();
  1538. }
  1539. /// <summary>
  1540. /// 显示椭圆框
  1541. /// </summary>
  1542. /// <param name="sender"></param>
  1543. /// <param name="e"></param>
  1544. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  1545. {
  1546. if (this.firstShow)
  1547. {
  1548. return;
  1549. }
  1550. if (this.tempAnalysisResult == null)
  1551. {
  1552. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttostartstatistics.text"));
  1553. return;
  1554. }
  1555. is_showOval = !is_showOval;
  1556. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, this.tempAnalysisResult.inclusions, is_showRectangle, is_showOval, is_full);
  1557. }
  1558. /// <summary>
  1559. /// 编辑夹杂物
  1560. /// </summary>
  1561. /// <param name="sender"></param>
  1562. /// <param name="e"></param>
  1563. private void button6_Click(object sender, EventArgs e)
  1564. {
  1565. if (this.tempAnalysisResult == null)
  1566. {
  1567. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttostartstatistics.text"));
  1568. return;
  1569. }
  1570. new MethodKInclusionEditDialog(this.appWorkspace,this.tempAnalysisResult.inclusions , this.imageMat,this).ShowDialog();
  1571. }
  1572. /// <summary>
  1573. /// 删除夹杂物
  1574. /// </summary>
  1575. /// <param name="sender"></param>
  1576. /// <param name="e"></param>
  1577. private void button5_Click(object sender, EventArgs e)
  1578. {
  1579. this.clearSelect = true;
  1580. }
  1581. /// <summary>
  1582. /// 夹杂物编辑回调
  1583. /// </summary>
  1584. public void inclusionEditDialogCloseCallback(List<Inclusion> inclusions)
  1585. {
  1586. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, inclusions, is_showRectangle, is_showOval, is_full);
  1587. }
  1588. #endregion
  1589. #region [开始统计 清除统计 保存结果]
  1590. /// <summary>
  1591. /// 开始统计
  1592. /// </summary>
  1593. /// <param name="sender"></param>
  1594. /// <param name="e"></param>
  1595. private void btn_statistics_Click(object sender, EventArgs e)
  1596. {
  1597. radioButton1.Enabled = true;
  1598. radioButton2.Enabled = true;
  1599. checkBox1.Enabled = true;
  1600. checkBox2.Enabled = true;
  1601. this.startStatistics();
  1602. }
  1603. /// <summary>
  1604. /// 清除统计
  1605. /// </summary>
  1606. /// <param name="sender"></param>
  1607. /// <param name="e"></param>
  1608. private void btn_clean_result_Click(object sender, EventArgs e)
  1609. {
  1610. this.tempAnalysisResult = null;
  1611. ToolInclusionSelect.CleanInclusionAll(this.documentWorkspace);
  1612. radioButton1.Enabled = false;
  1613. radioButton2.Enabled = false;
  1614. checkBox1.Enabled = false;
  1615. checkBox2.Enabled = false;
  1616. //userAll = false;
  1617. }
  1618. /// <summary>
  1619. /// 保存结果
  1620. /// </summary>
  1621. /// <param name="sender"></param>
  1622. /// <param name="e"></param>
  1623. private void btn_saveresult_Click(object sender, EventArgs e)
  1624. {
  1625. if (this.tempAnalysisResult == null)
  1626. {
  1627. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttostartstatistics.text"));
  1628. return;
  1629. }
  1630. if (analysisResults.ContainsKey(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]))
  1631. {
  1632. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  1633. if (dr != DialogResult.OK)
  1634. {
  1635. return;
  1636. }
  1637. analysisResults[this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index]] = this.tempAnalysisResult;
  1638. }
  1639. else
  1640. {
  1641. analysisResults.Add(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index], this.tempAnalysisResult);
  1642. }
  1643. buildListBox_analysisResult();
  1644. }
  1645. private void buildListBox_analysisResult()
  1646. {
  1647. this.listBox_analysisResult.Items.Clear();
  1648. foreach (var item in analysisResults.Keys)
  1649. {
  1650. this.listBox_analysisResult.Items.Add(new LocalListViewItem(item, item.GetFriendlyName()));
  1651. }
  1652. buildListView_analysisResult();
  1653. }
  1654. private List<ListViewItem> buildAnalysisResults(DocumentWorkspace workspace, AnalysisResult analysisResult)
  1655. {
  1656. List<ListViewItem> listViews = new List<ListViewItem>();
  1657. foreach (var fieldOfView in analysisResult.resultBody.Keys)
  1658. {
  1659. ListViewItem lvi = new ListViewItem();
  1660. lvi.Text = workspace.GetFriendlyName();
  1661. lvi.SubItems.Add(fieldOfView.name);
  1662. foreach (var item in analysisResult.resultBody[fieldOfView])
  1663. {
  1664. try
  1665. {
  1666. int num = 2;
  1667. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1668. {
  1669. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1670. }
  1671. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(item), num).ToString());
  1672. }
  1673. catch (Exception ex)
  1674. {
  1675. lvi.SubItems.Add(item);
  1676. }
  1677. }
  1678. listViews.Add(lvi);
  1679. }
  1680. return listViews;
  1681. }
  1682. private void buildListView_analysisResult()
  1683. {
  1684. List<AnalysisResult> conclusions = new List<AnalysisResult>();
  1685. this.listView_analysisResult.Columns.Clear();
  1686. this.listView_analysisResult.Items.Clear();
  1687. this.listView_analysisResult2.Columns.Clear();
  1688. this.listView_analysisResult2.Items.Clear();
  1689. if (analysisResults.Count == 0)
  1690. {
  1691. return;
  1692. }
  1693. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  1694. {
  1695. return;
  1696. }
  1697. this.listView_analysisResult.BeginUpdate();
  1698. // 构建头
  1699. foreach (var item in analysisResults.First().Value.getResultHead())
  1700. {
  1701. ColumnHeader header = new ColumnHeader();
  1702. header.Text = item;
  1703. header.Width = 150;
  1704. this.listView_analysisResult.Columns.Add(header);
  1705. }
  1706. foreach (var item in this.listBox_analysisResult.CheckedItems)
  1707. {
  1708. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  1709. this.listView_analysisResult.Items.AddRange(buildAnalysisResults(workspace, analysisResults[workspace]).ToArray());
  1710. conclusions.Add(analysisResults[workspace]);
  1711. }
  1712. this.listView_analysisResult.EndUpdate();
  1713. if (this.listView_analysisResult.Items.Count > 0)
  1714. {
  1715. this.listView_analysisResult.Items[0].Selected = true;
  1716. }
  1717. this.listView_analysisResult2.Columns.Clear();
  1718. this.listView_analysisResult2.Items.Clear();
  1719. ListViewItem lvi = new ListViewItem();
  1720. List<string> strings = this.methodOfAssessment.buildResultConclusion(conclusions);
  1721. // 构建头
  1722. foreach (var item in this.methodOfAssessment.getResultConclusionHead())
  1723. {
  1724. ColumnHeader header = new ColumnHeader();
  1725. header.Text = item;
  1726. header.Width = 150;
  1727. this.listView_analysisResult2.Columns.Add(header);
  1728. }
  1729. try
  1730. {
  1731. int num = 2;
  1732. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1733. {
  1734. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1735. }
  1736. lvi.Text = Math.Round(Convert.ToDecimal(strings[0]), num).ToString();
  1737. }
  1738. catch (Exception ex)
  1739. {
  1740. lvi.Text = strings[0];
  1741. }
  1742. for (int i = 1; i < strings.Count; i++)
  1743. {
  1744. try
  1745. {
  1746. int num = 2;
  1747. if (this.domainUpDown_resultPrecision.SelectedIndex != -1)
  1748. {
  1749. num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]);
  1750. }
  1751. lvi.SubItems.Add(Math.Round(Convert.ToDecimal(strings[i]), num).ToString());
  1752. }
  1753. catch (Exception ex)
  1754. {
  1755. lvi.SubItems.Add(strings[i]);
  1756. }
  1757. }
  1758. this.listView_analysisResult2.Items.Add(lvi);
  1759. this.listView_analysisResult2.EndUpdate();
  1760. }
  1761. #endregion
  1762. #region [夹杂物分析]
  1763. private MethodOfAssessment getMethodOfAssessment()
  1764. {
  1765. return new MethodK(this.imgPxPerUnit);
  1766. }
  1767. /// <summary>
  1768. /// 分析开始
  1769. /// </summary>
  1770. private void startStatistics()
  1771. {
  1772. if (this.lstView_img.FocusedItem == null || !this.lstView_img.FocusedItem.Selected)
  1773. {
  1774. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1775. return;
  1776. }
  1777. if (this.documentWorkspace.phaseModels[0].mat == null)
  1778. {
  1779. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformabinaryoperationfirst.text"));
  1780. return;
  1781. }
  1782. ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  1783. int itemCount = 100;
  1784. ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  1785. System.Threading.ThreadStart copyThreadProc =
  1786. delegate ()
  1787. {
  1788. try
  1789. {
  1790. if (dict.ContainsKey(this.lstView_img.FocusedItem.Text))
  1791. {
  1792. dict[this.lstView_img.FocusedItem.Text] = this.documentWorkspace.phaseModels;
  1793. }
  1794. else
  1795. {
  1796. dict.Add(this.lstView_img.FocusedItem.Text, this.documentWorkspace.phaseModels);
  1797. }
  1798. Mat mat;
  1799. bool twoMat = false;
  1800. if (checkBox3.Checked && checkBox4.Checked)
  1801. {
  1802. var mat1 = this.documentWorkspace.phaseModels[0].mat.Clone();
  1803. var mat2 = this.documentWorkspace.phaseModels[1].mat.Clone();
  1804. mat = mat1.CvtColor(ColorConversionCodes.BGR2GRAY)* 255 + mat2.CvtColor(ColorConversionCodes.BGR2GRAY) * 255;
  1805. for (int i = 0; i < mat.Height; i++)
  1806. {
  1807. for (int j = 0; j < mat.Width; j++)
  1808. {
  1809. if (mat.At<byte>(i, j) > 0)
  1810. {
  1811. mat.Set<byte>(i, j, 0);
  1812. }
  1813. else {
  1814. mat.Set<byte>(i, j, 255);
  1815. }
  1816. }
  1817. }
  1818. twoMat = true;
  1819. }
  1820. else if (checkBox3.Checked)
  1821. {
  1822. mat = this.documentWorkspace.phaseModels[0].mat.Clone();
  1823. }
  1824. else if (checkBox4.Checked)
  1825. {
  1826. mat = this.documentWorkspace.phaseModels[1].mat.Clone();
  1827. }
  1828. else {
  1829. mat = this.documentWorkspace.phaseModels[0].mat.Clone();
  1830. }
  1831. List<RectangleF> rectangles = new List<RectangleF>();
  1832. //if (this.selectedTypesOfInclusionsRectangle != null)
  1833. //{
  1834. // // 添加框选范围
  1835. // rectangles.Add(this.selectedTypesOfInclusionsRectangle.Value);
  1836. // // 删除框选范围内夹杂物
  1837. // if (this.tempAnalysisResult != null)
  1838. // {
  1839. // for (int i = this.tempAnalysisResult.inclusions.Count - 1; i >= 0; i--)
  1840. // {
  1841. // if (this.selectedTypesOfInclusionsRectangle.Value.Contains(this.tempAnalysisResult.inclusions[i].rectProfile)
  1842. // || this.selectedTypesOfInclusionsRectangle.Value.IntersectsWith(this.tempAnalysisResult.inclusions[i].rectProfile))
  1843. // {
  1844. // this.tempAnalysisResult.inclusions.RemoveAt(i);
  1845. // }
  1846. // }
  1847. // }
  1848. //}
  1849. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  1850. {
  1851. if (this.documentWorkspace.GraphicsList[i].drawToolType == DrawToolType.InclusionDrawRecognitionArea)
  1852. {
  1853. DedicatedAnalysisDrawObject drawObject = (DrawRecognitionAreaDrawObject)this.documentWorkspace.GraphicsList[i];
  1854. rectangles.Add(drawObject.Rectangle);
  1855. }
  1856. }
  1857. // 二值图非黑色点涂白
  1858. for (int i = 0; i < mat.Height; i++)
  1859. {
  1860. for (int j = 0; j < mat.Width; j++)
  1861. {
  1862. if (!twoMat)
  1863. {
  1864. if (mat.At<int>(i, j) == 0)
  1865. {
  1866. mat.Set<Vec3b>(i, j, new Vec3b(255, 255, 255));
  1867. }
  1868. }
  1869. if (rectangles.Count > 0)
  1870. {
  1871. bool contains = false;
  1872. // 二值图过滤未选中区域
  1873. foreach (var item in rectangles)
  1874. {
  1875. if (item.Contains(j, i))
  1876. {
  1877. contains = true;
  1878. }
  1879. }
  1880. if (!contains)
  1881. {
  1882. mat.Set<Vec3b>(i, j, new Vec3b(255, 255, 255));
  1883. }
  1884. }
  1885. }
  1886. }
  1887. // 找出正方形视场
  1888. List<RectangleF> rectangleF = new List<RectangleF>();
  1889. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  1890. {
  1891. if (this.documentWorkspace.GraphicsList[i].drawToolType == DrawToolType.ViewSquare || this.documentWorkspace.GraphicsList[i].drawToolType == DrawToolType.ViewRectangle || this.documentWorkspace.GraphicsList[i].drawToolType == DrawToolType.ViewRectangleEx)
  1892. {
  1893. rectangleF.Add(this.documentWorkspace.GraphicsList[i].Rectangle);
  1894. }
  1895. }
  1896. int k = inclusionSetting.kNum;
  1897. var rollingDirection = (InclusionsGlobalSettings.RollingDirection)this.comboBox_rollingDirection.SelectedIndex;
  1898. var report = this.methodOfAssessment.generateReport(this.imageMat.Clone(), mat, rectangleF, 1, this.viewNum, k, this.is_full, rollingDirection);
  1899. if (this.selectedTypesOfInclusionsRectangle == null)
  1900. {
  1901. this.tempAnalysisResult = report;
  1902. }
  1903. else
  1904. {
  1905. foreach (var item in report.inclusions)
  1906. {
  1907. item.type = this.selectedTypesOfInclusions;
  1908. }
  1909. if (this.tempAnalysisResult == null)
  1910. {
  1911. this.tempAnalysisResult = report;
  1912. }
  1913. else
  1914. {
  1915. this.tempAnalysisResult.inclusions.AddRange(report.inclusions);
  1916. }
  1917. this.tempAnalysisResult.buildResultBody();
  1918. }
  1919. //if (userAll)
  1920. //{
  1921. // if (hasResultIndexList.IndexOf(this.lstView_img.FocusedItem.Index) == -1)
  1922. // {
  1923. // resultList.Add(this.tempAnalysisResult);
  1924. // hasResultIndexList.Add(this.lstView_img.FocusedItem.Index);
  1925. // }
  1926. // else
  1927. // {
  1928. // resultList[this.lstView_img.FocusedItem.Index] = this.tempAnalysisResult;
  1929. // }
  1930. //}
  1931. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, this.tempAnalysisResult.inclusions, is_showRectangle, is_showOval, is_full);
  1932. }
  1933. catch (Exception ex)
  1934. {
  1935. }
  1936. finally
  1937. {
  1938. progressEvents.EndOperation(OperationResult.Finished);
  1939. }
  1940. };
  1941. procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  1942. }
  1943. #endregion
  1944. #region [生成报告 导出报告 项目工程]
  1945. /// <summary>
  1946. /// 生成报告
  1947. /// </summary>
  1948. /// <param name="sender"></param>
  1949. /// <param name="e"></param>
  1950. private void button_generateReport_Click(object sender, EventArgs e)
  1951. {
  1952. if (this.listView_analysisResult.Items.Count == 0)
  1953. {
  1954. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1955. return;
  1956. }
  1957. if (this.checkBox_generateReport_opensetting.Checked)
  1958. {
  1959. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, this.methodOfAssessment.resourcesName);
  1960. if (recombinationRateSetDialog.hasModule)
  1961. {
  1962. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1963. recombinationRateSetDialog.ShowDialog();
  1964. }
  1965. else
  1966. {
  1967. recombinationRateSetDialog = null;
  1968. }
  1969. }
  1970. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1971. {
  1972. //获取word书签与excel单元格的关系,以字典方式存储
  1973. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1974. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1975. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1976. {
  1977. foreach (mic_module_infos info in mic_module_infos)
  1978. {
  1979. tagInfos.Add(info.tag_name, info.cell_position);
  1980. }
  1981. }
  1982. List<List<List<string>>> sheets = new List<List<List<string>>>();
  1983. sheets.Add(new List<List<string>>());
  1984. List<List<string>> contentList = new List<List<string>>();
  1985. List<string> contentHead = new List<string>();
  1986. contentList.Add(contentHead);
  1987. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  1988. {
  1989. contentHead.Add(c.Text);
  1990. }
  1991. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  1992. {
  1993. List<string> contentBody = new List<string>();
  1994. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  1995. {
  1996. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  1997. }
  1998. contentList.Add(contentBody);
  1999. }
  2000. contentList.Add(new List<string>());
  2001. contentHead = new List<string>();
  2002. contentList.Add(contentHead);
  2003. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  2004. {
  2005. contentHead.Add(c.Text);
  2006. }
  2007. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  2008. {
  2009. List<string> contentBody = new List<string>();
  2010. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  2011. {
  2012. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  2013. }
  2014. contentList.Add(contentBody);
  2015. }
  2016. sheets.Add(contentList);
  2017. List<List<string>> inclusionList = new List<List<string>>();
  2018. List<string> inclusionHead = new List<string>();
  2019. inclusionList.Add(inclusionHead);
  2020. inclusionHead.Add("pixelLength");
  2021. inclusionHead.Add("pixelWidth");
  2022. inclusionHead.Add("physicalLength");
  2023. inclusionHead.Add("physicalWidth");
  2024. inclusionHead.Add("lwRatio");
  2025. inclusionHead.Add("arrangement");
  2026. inclusionHead.Add("shape");
  2027. inclusionHead.Add("shapeFactor");
  2028. inclusionHead.Add("area");
  2029. inclusionHead.Add("diameter");
  2030. inclusionHead.Add("type");
  2031. inclusionHead.Add("color");
  2032. inclusionHead.Add("chemicalCharacteristics");
  2033. inclusionHead.Add("X-Position");
  2034. inclusionHead.Add("Y-Position");
  2035. //K法独有
  2036. inclusionHead.Add("fieldNumber");
  2037. inclusionHead.Add("fieldLeftLimit");
  2038. inclusionHead.Add("fieldRightLimit");
  2039. inclusionHead.Add("fieldTopLimit");
  2040. inclusionHead.Add("fieldBottomLimit");
  2041. inclusionHead.Add("rating");
  2042. //if (this.isK == 1)
  2043. //{
  2044. //}
  2045. foreach (var analysisResult in this.analysisResults.Values)
  2046. {
  2047. foreach (var inclusion in analysisResult.inclusions)
  2048. {
  2049. List<string> inclusionBody = new List<string>();
  2050. inclusionList.Add(inclusionBody);
  2051. inclusionBody.Add(inclusion.pixelLength + "");
  2052. inclusionBody.Add(inclusion.pixelWidth + "");
  2053. inclusionBody.Add(inclusion.physicalLength + "");
  2054. inclusionBody.Add(inclusion.physicalWidth + "");
  2055. inclusionBody.Add(inclusion.lwRatio + "");
  2056. inclusionBody.Add(inclusion.arrangement + "");
  2057. inclusionBody.Add(inclusion.shape + "");
  2058. inclusionBody.Add(inclusion.shapeFactor + "");
  2059. inclusionBody.Add(inclusion.area + "");
  2060. inclusionBody.Add(inclusion.diameter + "");
  2061. inclusionBody.Add(inclusion.type.type + "");
  2062. inclusionBody.Add(inclusion.color == null ? "" : inclusion.color.colorName + "");
  2063. inclusionBody.Add(inclusion.chemicalCharacteristics + "");
  2064. inclusionBody.Add(inclusion.rectProfile.X + "");
  2065. inclusionBody.Add(inclusion.rectProfile.Y + "");
  2066. //K法独有
  2067. inclusionBody.Add(inclusion.viewNum + "");
  2068. inclusionBody.Add(inclusion.viewLeft + "");
  2069. inclusionBody.Add(inclusion.viewRight + "");
  2070. inclusionBody.Add(inclusion.viewTop + "");
  2071. inclusionBody.Add(inclusion.viewBottom + "");
  2072. inclusionBody.Add(inclusion.rating + "");
  2073. //if (this.isK == 1)
  2074. //{
  2075. //}
  2076. }
  2077. }
  2078. sheets.Add(inclusionList);
  2079. List<Bitmap> bitList = new List<Bitmap>();
  2080. foreach (var item in this.listBox_analysisResult.CheckedItems)
  2081. {
  2082. DocumentWorkspace workspace = ((LocalListViewItem)item).Value;
  2083. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);
  2084. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  2085. originalBit.Tag = pantographRatio;
  2086. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2087. newBit.Tag = pantographRatio;
  2088. Graphics graphics = Graphics.FromImage(newBit);
  2089. foreach (var phase in dict[((LocalListViewItem)item).Display])
  2090. {
  2091. if (phase.mat == null)
  2092. {
  2093. continue;
  2094. }
  2095. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  2096. graphics.DrawImage(processedBit, new PointF(0, 0));
  2097. }
  2098. foreach (var inclusion in analysisResults[workspace].inclusions)
  2099. {
  2100. new InclusionDrawObject(workspace, inclusion, this.is_full).Draw(graphics);
  2101. }
  2102. bitList.Add(originalBit);
  2103. bitList.Add(newBit);
  2104. }
  2105. try
  2106. {
  2107. //OfficeFileHandleHelper.CreateAnalysisReportInclusion(this.analyzeSettingModel, sheets, bitList, tagInfos);
  2108. this.appWorkspace.CreateAnalysisReportInclusion(this.analyzeSettingModel, sheets, bitList, tagInfos);
  2109. }
  2110. catch (Exception ex)
  2111. {
  2112. MessageBox.Show(ex.Message);
  2113. }
  2114. }
  2115. else
  2116. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2117. }
  2118. /// <summary>
  2119. /// 导出结果
  2120. /// </summary>
  2121. /// <param name="sender"></param>
  2122. /// <param name="e"></param>
  2123. private void button_exportResults_Click(object sender, EventArgs e)
  2124. {
  2125. if (this.listView_analysisResult.Items.Count == 0)
  2126. {
  2127. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  2128. return;
  2129. }
  2130. SaveFileDialog exe = new SaveFileDialog();
  2131. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  2132. exe.FilterIndex = 0;
  2133. exe.RestoreDirectory = true;
  2134. //exe.CreatePrompt = true;
  2135. exe.Title = "Export Excel File";
  2136. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  2137. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + this.methodOfAssessment.resourcesName;
  2138. DialogResult dr = exe.ShowDialog();
  2139. if (dr != DialogResult.OK)
  2140. {
  2141. return;
  2142. }
  2143. List<DataTable> list = new List<DataTable>();
  2144. DataTable dtb = new DataTable();
  2145. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  2146. {
  2147. dtb.Columns.Add(c.Text);
  2148. }
  2149. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  2150. {
  2151. DataRow dataRow = dtb.NewRow();
  2152. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  2153. {
  2154. dataRow[c] = this.listView_analysisResult.Items[r].SubItems[c].Text;
  2155. }
  2156. dtb.Rows.Add(dataRow);
  2157. }
  2158. DataTable dtb1 = new DataTable();
  2159. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  2160. {
  2161. dtb1.Columns.Add(c.Text);
  2162. }
  2163. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  2164. {
  2165. DataRow dataRow = dtb1.NewRow();
  2166. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  2167. {
  2168. dataRow[c] = this.listView_analysisResult2.Items[r].SubItems[c].Text;
  2169. }
  2170. dtb1.Rows.Add(dataRow);
  2171. }
  2172. DataTable dtb2 = new DataTable();
  2173. dtb2.Columns.Add("pixelLength");
  2174. dtb2.Columns.Add("pixelWidth");
  2175. dtb2.Columns.Add("physicalLength");
  2176. dtb2.Columns.Add("physicalWidth");
  2177. dtb2.Columns.Add("lwRatio");
  2178. dtb2.Columns.Add("arrangement");
  2179. dtb2.Columns.Add("shape");
  2180. dtb2.Columns.Add("shapeFactor");
  2181. dtb2.Columns.Add("area");
  2182. dtb2.Columns.Add("diameter");
  2183. dtb2.Columns.Add("type");
  2184. dtb2.Columns.Add("color");
  2185. dtb2.Columns.Add("chemicalCharacteristics");
  2186. dtb2.Columns.Add("X-Position");
  2187. dtb2.Columns.Add("Y-Position");
  2188. //k法独有
  2189. dtb2.Columns.Add("rating");
  2190. //if (this.isK == 1)
  2191. //{
  2192. //}
  2193. foreach (var analysisResult in this.analysisResults.Values)
  2194. {
  2195. foreach (var inclusion in analysisResult.inclusions)
  2196. {
  2197. DataRow dataRow = dtb2.NewRow();
  2198. dataRow[0] = (inclusion.pixelLength + "");
  2199. dataRow[1] = (inclusion.pixelWidth + "");
  2200. dataRow[2] = (inclusion.physicalLength + "");
  2201. dataRow[3] = (inclusion.physicalWidth + "");
  2202. dataRow[4] = (inclusion.lwRatio + "");
  2203. dataRow[5] = (inclusion.arrangement + "");
  2204. dataRow[6] = (inclusion.shape + "");
  2205. dataRow[7] = (inclusion.shapeFactor + "");
  2206. dataRow[8] = (inclusion.area + "");
  2207. dataRow[9] = (inclusion.diameter + "");
  2208. dataRow[10] = (inclusion.type.type + "");
  2209. dataRow[11] = (inclusion.color == null ? "" : inclusion.color.colorName + "");
  2210. dataRow[12] = (inclusion.chemicalCharacteristics + "");
  2211. dataRow[13] = (inclusion.rectProfile.X + "");
  2212. dataRow[14] = (inclusion.rectProfile.Y + "");
  2213. //k法独有
  2214. dataRow[15] = (inclusion.rating + "");
  2215. dataRow[8] = (inclusion.areaK + "");
  2216. //if (this.isK == 1)
  2217. //{
  2218. //}
  2219. dtb2.Rows.Add(dataRow);
  2220. }
  2221. }
  2222. dtb.TableName = "Sheet1";
  2223. dtb1.TableName = "Sheet2";
  2224. dtb2.TableName = "Sheet3";
  2225. list.Add(dtb);
  2226. list.Add(dtb1);
  2227. list.Add(dtb2);
  2228. try
  2229. {
  2230. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, true, true);
  2231. }
  2232. catch (Exception ex)
  2233. {
  2234. MessageBox.Show(ex.Message);
  2235. }
  2236. }
  2237. /// <summary>
  2238. /// 项目工程
  2239. /// </summary>
  2240. /// <param name="sender"></param>
  2241. /// <param name="e"></param>
  2242. private void button1_Click(object sender, EventArgs e)
  2243. {
  2244. if (this.listView_analysisResult.Items.Count == 0)
  2245. {
  2246. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  2247. return;
  2248. }
  2249. if (this.analyzeSettingModel == null)
  2250. {
  2251. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  2252. return;
  2253. }
  2254. //获取项目工程内的文件夹路径
  2255. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.Inclusion.Text", this.analyzeSettingModel.savePath);
  2256. if (item != null)
  2257. {
  2258. //向文件夹内保存图片和报告
  2259. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2260. {
  2261. //获取word书签与excel单元格的关系,以字典方式存储
  2262. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2263. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2264. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2265. {
  2266. foreach (mic_module_infos info in mic_module_infos)
  2267. {
  2268. tagInfos.Add(info.tag_name, info.cell_position);
  2269. }
  2270. }
  2271. List<List<string>> contentList = new List<List<string>>();
  2272. List<string> contentHead = new List<string>();
  2273. contentList.Add(contentHead);
  2274. foreach (ColumnHeader c in this.listView_analysisResult2.Columns)
  2275. {
  2276. contentHead.Add(c.Text);
  2277. }
  2278. for (int r = 0; r < this.listView_analysisResult2.Items.Count; r++)
  2279. {
  2280. List<string> contentBody = new List<string>();
  2281. for (int c = 0; c < this.listView_analysisResult2.Items[r].SubItems.Count; c++)
  2282. {
  2283. contentBody.Add(this.listView_analysisResult2.Items[r].SubItems[c].Text);
  2284. }
  2285. contentList.Add(contentBody);
  2286. }
  2287. contentList.Add(new List<string>());
  2288. contentHead = new List<string>();
  2289. contentList.Add(contentHead);
  2290. foreach (ColumnHeader c in this.listView_analysisResult.Columns)
  2291. {
  2292. contentHead.Add(c.Text);
  2293. }
  2294. for (int r = 0; r < this.listView_analysisResult.Items.Count; r++)
  2295. {
  2296. List<string> contentBody = new List<string>();
  2297. for (int c = 0; c < this.listView_analysisResult.Items[r].SubItems.Count; c++)
  2298. {
  2299. contentBody.Add(this.listView_analysisResult.Items[r].SubItems[c].Text);
  2300. }
  2301. contentList.Add(contentBody);
  2302. }
  2303. List<Bitmap> bitList = new List<Bitmap>();
  2304. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2305. foreach (var itemIt in this.listBox_analysisResult.CheckedItems)
  2306. {
  2307. List<List<string>> inclusionList = new List<List<string>>();
  2308. List<string> inclusionHead = new List<string>();
  2309. inclusionList.Add(inclusionHead);
  2310. inclusionHead.Add("pixelLength");
  2311. inclusionHead.Add("pixelWidth");
  2312. inclusionHead.Add("physicalLength");
  2313. inclusionHead.Add("physicalWidth");
  2314. inclusionHead.Add("lwRatio");
  2315. inclusionHead.Add("arrangement");
  2316. inclusionHead.Add("shape");
  2317. inclusionHead.Add("shapeFactor");
  2318. inclusionHead.Add("area");
  2319. inclusionHead.Add("diameter");
  2320. inclusionHead.Add("type");
  2321. inclusionHead.Add("color");
  2322. inclusionHead.Add("chemicalCharacteristics");
  2323. inclusionHead.Add("X-Position");
  2324. inclusionHead.Add("Y-Position");
  2325. //k法独有
  2326. inclusionHead.Add("fieldNumber");
  2327. inclusionHead.Add("fieldLeftLimit");
  2328. inclusionHead.Add("fieldRightLimit");
  2329. inclusionHead.Add("fieldTopLimit");
  2330. inclusionHead.Add("fieldBottomLimit");
  2331. inclusionHead.Add("rating");
  2332. //if (this.isK == 1)
  2333. //{
  2334. //}
  2335. DocumentWorkspace workspace = ((LocalListViewItem)itemIt).Value;
  2336. double pantographRatio = workspace.GetRulerMultiple(MeasurementUnit.Micron);
  2337. Bitmap originalBit = workspace.CompositionSurface.CreateAliasedBitmap();
  2338. originalBit.Tag = pantographRatio;
  2339. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2340. newBit.Tag = pantographRatio;
  2341. Graphics graphics = Graphics.FromImage(newBit);
  2342. foreach (var phase in dict[((LocalListViewItem)itemIt).Display])
  2343. {
  2344. if (phase.mat == null)
  2345. {
  2346. continue;
  2347. }
  2348. Bitmap processedBit = BitmapConverter.ToBitmap(phase.mat);
  2349. graphics.DrawImage(processedBit, new PointF(0, 0));
  2350. }
  2351. foreach (var inclusion in analysisResults[workspace].inclusions)
  2352. {
  2353. List<string> inclusionBody = new List<string>();
  2354. inclusionBody.Add(inclusion.pixelLength + "");
  2355. inclusionBody.Add(inclusion.pixelWidth + "");
  2356. inclusionBody.Add(inclusion.physicalLength + "");
  2357. inclusionBody.Add(inclusion.physicalWidth + "");
  2358. inclusionBody.Add(inclusion.lwRatio + "");
  2359. inclusionBody.Add(inclusion.arrangement + "");
  2360. inclusionBody.Add(inclusion.shape + "");
  2361. inclusionBody.Add(inclusion.shapeFactor + "");
  2362. //k法独有
  2363. inclusionBody.Add(inclusion.areaK + "");
  2364. //if (this.isK == 1)
  2365. //{
  2366. //}
  2367. //else
  2368. //{
  2369. // inclusionBody.Add(inclusion.area + "");
  2370. //}
  2371. inclusionBody.Add(inclusion.diameter + "");
  2372. inclusionBody.Add(inclusion.type.type + "");
  2373. inclusionBody.Add(inclusion.color == null ? "" : inclusion.color.colorName + "");
  2374. inclusionBody.Add(inclusion.chemicalCharacteristics + "");
  2375. inclusionBody.Add(inclusion.rectProfile.X + "");
  2376. inclusionBody.Add(inclusion.rectProfile.Y + "");
  2377. //k法独有
  2378. inclusionBody.Add(inclusion.viewNum + "");
  2379. inclusionBody.Add(inclusion.viewLeft + "");
  2380. inclusionBody.Add(inclusion.viewRight + "");
  2381. inclusionBody.Add(inclusion.viewTop + "");
  2382. inclusionBody.Add(inclusion.viewBottom + "");
  2383. inclusionBody.Add(inclusion.rating + "");
  2384. //if (this.isK == 1)
  2385. //{
  2386. //}
  2387. inclusionList.Add(inclusionBody);
  2388. new InclusionDrawObject(workspace, inclusion, this.is_full).Draw(graphics);
  2389. }
  2390. ExportProjectModel exportProjectModel = new ExportProjectModel();
  2391. exportProjectModel.dataList = inclusionList;
  2392. exportProjectModel.picName = ((LocalListViewItem)itemIt).Display;
  2393. exportProjectModel.tagName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.Inclusion.Text");
  2394. exportModel.Add(exportProjectModel);
  2395. bitList.Add(originalBit);
  2396. bitList.Add(newBit);
  2397. }
  2398. try
  2399. {
  2400. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, contentList, exportModel, bitList, tagInfos, item.path, item.code);
  2401. }
  2402. catch (Exception ex)
  2403. {
  2404. MessageBox.Show(ex.Message);
  2405. }
  2406. }
  2407. else
  2408. {
  2409. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2410. return;
  2411. }
  2412. //保存项目信息到数据库
  2413. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2414. }
  2415. }
  2416. #endregion
  2417. #region [应用全部 保存全部]
  2418. /// <summary>
  2419. /// 应用全部
  2420. /// </summary>
  2421. /// <param name="sender"></param>
  2422. /// <param name="e"></param>
  2423. private void button4_Click(object sender, EventArgs e)
  2424. {
  2425. }
  2426. /// <summary>
  2427. /// 保存全部
  2428. /// </summary>
  2429. /// <param name="sender"></param>
  2430. /// <param name="e"></param>
  2431. private void button3_Click(object sender, EventArgs e)
  2432. {
  2433. }
  2434. #endregion
  2435. #region [全部显示 删除 勾选结果]
  2436. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  2437. {
  2438. buildListView_analysisResult();
  2439. }
  2440. private void button_all_Click(object sender, EventArgs e)
  2441. {
  2442. for (int i = 0; i < this.listBox_analysisResult.Items.Count; i++)
  2443. {
  2444. this.listBox_analysisResult.SetItemChecked(i, true);
  2445. }
  2446. buildListView_analysisResult();
  2447. }
  2448. private void button_remove_Click(object sender, EventArgs e)
  2449. {
  2450. if (this.listBox_analysisResult.Items.Count == 0)
  2451. {
  2452. MessageBox.Show(PdnResources.GetString("Menu.Noresultsatmeasuring.text"));
  2453. return;
  2454. }
  2455. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeleteth.text") + "?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
  2456. {
  2457. if (this.listBox_analysisResult.CheckedItems.Count == 0)
  2458. {
  2459. return;
  2460. }
  2461. foreach (var item in this.listBox_analysisResult.CheckedItems)
  2462. {
  2463. this.analysisResults.Remove(((LocalListViewItem)item).Value);
  2464. }
  2465. buildListBox_analysisResult();
  2466. }
  2467. }
  2468. #endregion
  2469. }
  2470. }