BearingSteelStripRatingDialog .cs 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using OpenCvSharp.Extensions;
  4. using PaintDotNet.Base;
  5. using PaintDotNet.Base.CommTool;
  6. using PaintDotNet.Base.Functionodel;
  7. using PaintDotNet.CustomControl;
  8. using PaintDotNet.Data.Param;
  9. using PaintDotNet.DbOpreate.DbBll;
  10. using PaintDotNet.DbOpreate.DbModel;
  11. using PaintDotNet.DedicatedAnalysis.DuctileIron.Common;
  12. using PaintDotNet.Instrument;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.ComponentModel;
  16. using System.Data;
  17. using System.Drawing;
  18. using System.Drawing.Drawing2D;
  19. using System.Linq;
  20. using System.Runtime.InteropServices;
  21. using System.Windows.Forms;
  22. namespace PaintDotNet.DedicatedAnalysis.BearingSteelStripRating.GB18254
  23. {
  24. /// <summary>
  25. /// 轴承钢碳化物带状
  26. /// </summary>
  27. internal class BearingSteelStripRatingDialog : PdnBaseForm
  28. {
  29. #region 基础控件
  30. private Button button1;
  31. private CheckBox checkBox1;
  32. private Button button2;
  33. private GroupBox groupBox2;
  34. private ListView listView1;
  35. private GroupBox groupBox3;
  36. private GroupBox groupBox5;
  37. private Panel panel2;
  38. private GroupBox groupBox8;
  39. private DataGridView dataGridView1;
  40. private GroupBox groupBox9;
  41. private Button button6;
  42. private Button button7;
  43. private ListView listView2;
  44. private DataGridView dataGridView2;
  45. private Button button9;
  46. private Button button8;
  47. private NumericUpDown numericUpDown1;
  48. private Label label8;
  49. private Label label9;
  50. private Label label10;
  51. private ImageList imageList1;
  52. private IContainer components;
  53. private GroupBox groupBox1;
  54. private CheckBox checkBox3;
  55. private Panel panel4;
  56. private Panel panel3;
  57. private CheckBox checkBox4;
  58. private Label label1;
  59. private NumericUpDown numericUpDown2;
  60. private Button button4;
  61. private Button button5;
  62. private Button button3;
  63. #endregion
  64. /// <summary>
  65. /// 主控件
  66. /// </summary>
  67. private AppWorkspace appWorkspace;
  68. /// <summary>
  69. /// 图像面板
  70. /// </summary>
  71. private DocumentWorkspaceWindow documentWorkspace;
  72. /// <summary>
  73. /// 公共按钮
  74. /// </summary>
  75. private CommonControlButtons commonControlButtons;
  76. /// <summary>
  77. /// 选中图片的mat
  78. /// </summary>
  79. private Mat imageMat;
  80. /// <summary>
  81. /// 选中图片的结果图
  82. /// </summary>
  83. private Mat resultMat;
  84. /// <summary>
  85. /// 计算结果的表格集合
  86. /// </summary>
  87. private List<DataTable> resultTableList = new List<DataTable>();
  88. /// <summary>
  89. /// 保存用于生成报告的图片
  90. /// </summary>
  91. private List<Bitmap> bitList;
  92. /// <summary>
  93. /// 储存点击保存结果后的所有原图与分析图
  94. /// </summary>
  95. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  96. /// <summary>
  97. /// 是否显示全部
  98. /// </summary>
  99. private bool showAll = false;
  100. /// <summary>
  101. /// 当前图片是否有视场
  102. /// </summary>
  103. //private bool isHadView = false;
  104. /// <summary>
  105. /// 原图mat-包括视场
  106. /// </summary>
  107. private Mat mat;
  108. /// <summary>
  109. /// 单位标尺
  110. /// </summary>
  111. private double unitLength = 1;
  112. /// <summary>
  113. /// 是否仅修改相的颜色
  114. /// </summary>
  115. private bool changeColor = false;
  116. /// <summary>
  117. /// 是否未对图片做其他操作
  118. /// </summary>
  119. private bool isFirstSwitch = false;
  120. /// <summary>
  121. /// 中间数据
  122. /// </summary>
  123. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  124. /// <summary>
  125. /// 面积
  126. /// </summary>
  127. //private List<string> tempArea;
  128. private BinaryControl bc;
  129. //二值化集成1
  130. BinaryClass binaryClass;
  131. private int menuId;
  132. private string menuName;
  133. private int defaultIndex = -1;
  134. /// <summary>
  135. /// 保存窗口参数
  136. /// </summary>
  137. /// <summary>
  138. /// 各个图片对应数据
  139. /// </summary>
  140. private Dictionary<string, GrainSizeAnalysisModel> eachData = new Dictionary<string, GrainSizeAnalysisModel>();
  141. private const string ParamKey_Report = "report";//报告设置
  142. private const string ParamKey_Screen = "screen";//筛选
  143. private const string ParamKey_ScreenMin = "screenMin";//面积最小值
  144. private const string ParamKey_ScreenMax = "screenMax";//面积最大值
  145. private const string ParamKey_MaxColour = "maxColour";//最大色
  146. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  147. private decimal areaMin = 5;//宽
  148. private decimal areaMax = 5;//长
  149. private double rate = 0.3;//有效颗粒筛选占比
  150. private int binaryValue = -1;//二值方法选择
  151. private bool isExportResults = false;
  152. private bool isExportReports = false;
  153. private bool isExportProjects = false;
  154. private Button button10;
  155. private Button button11;
  156. private GroupBox groupBox4;
  157. private CheckBox checkBox2;
  158. private Button button13;
  159. private Button button12;
  160. /// <summary>
  161. /// 是否脚本运行
  162. /// </summary>
  163. private Boolean initScriptValues = false;
  164. #region 0811新增变量
  165. //绘制状态:0,无操作;1,新增;2,删除;3,区域删除
  166. int DrawType = 0;
  167. //添加颗粒轮廓临时一个
  168. List<PointF> addPoints = new List<PointF>();
  169. //所有添加的颗粒轮廓
  170. List<List<PointF>> addPointsList = new List<List<PointF>>();
  171. //所有删除的颗粒轮廓
  172. List<List<PointF>> delPointsList = new List<List<PointF>>();
  173. //区域删除起始点与结束点
  174. PointF star = new PointF();
  175. PointF end = new PointF();
  176. //所有删除的区域起始点
  177. List<List<PointF>> delRegionList = new List<List<PointF>>();
  178. //所有删除的区域的颗粒轮廓
  179. List<List<List<PointF>>> delRegionPointsList = new List<List<List<PointF>>>();
  180. //操作记录
  181. List<int> HisOperate = new List<int>();
  182. //寻找连通分量
  183. Mat labelMat = new Mat();
  184. Mat stats = new Mat();
  185. Mat centroids = new Mat();
  186. int nonenum = 0;
  187. //连通域集合
  188. OpenCvSharp.Point[][] AllFields;
  189. //连通域集合
  190. List<IEnumerable<OpenCvSharp.Point>> AllFieldsTemp = new List<IEnumerable<OpenCvSharp.Point>>();
  191. private CheckBox checkBox5;
  192. private Button btnDelRegion;
  193. private GroupBox groupBox6;
  194. private Label label2;
  195. private NumericUpDown numericUpDown3;
  196. private CheckBox checkBox6;
  197. private CheckBox checkBox7;
  198. //当前二值化图
  199. Mat currentMat = new Mat();
  200. #endregion
  201. public BearingSteelStripRatingDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  202. {
  203. this.appWorkspace = appWorkspace;
  204. NullKey();
  205. InitializeComponent();
  206. InitializeLanguageText();
  207. InitializeCustomControl();
  208. this.menuId = menuItem.MenuId;
  209. this.menuName = menuItem.Text;
  210. this.binaryClass = new BinaryClass(menuId);
  211. InitGridHeader();
  212. InitOtherTools();
  213. InitPicList();
  214. InitCommonButtonEvent();
  215. SetAnalyzeModelFromXml("Template.Manager.item3.BearingSteelGBT18254");
  216. }
  217. private void ShowImgEvent(object sender, EventArgs e)
  218. {
  219. listView1.Focus();
  220. if (this.defaultIndex != -1)
  221. {
  222. //如果是脚本执行,将参数带入
  223. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  224. {
  225. this.initScriptValues = true;//ScriptAutomatic
  226. //Boolean initScriptValues = true;
  227. ////在这里反射出对应功能的参数类
  228. string className = InvariantData.path_Action + ".Action" + menuId;
  229. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  230. foreach (Args arg in param.Lists)
  231. {
  232. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  233. if (param1.value != null)
  234. arg.Value = param1.value;
  235. getValue(arg.key, arg.Value);
  236. }
  237. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  238. }
  239. else
  240. {//读取上次关闭窗口时保存的参数
  241. GetXmlParameter();
  242. GetListParamModel();
  243. }
  244. this.listView1.Items[defaultIndex].Focused = true;
  245. this.listView1.Items[defaultIndex].Selected = true;
  246. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  247. this.startScriptAutomaticAction();
  248. }
  249. }
  250. private void InitializeCustomControl()
  251. {
  252. //
  253. // bc
  254. //
  255. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  256. this.bc.BinaryBackColor = System.Drawing.Color.Black;
  257. this.bc.BinaryChecked = false;
  258. this.bc.BinaryStyle = 1;
  259. this.bc.Location = new System.Drawing.Point(150, 59);
  260. this.bc.Name = "bc";
  261. this.bc.OriginChecked = false;
  262. this.bc.scope1End = 0D;
  263. this.bc.scope1Start = 0D;
  264. this.bc.scope2End = 0D;
  265. this.bc.scope2Start = 0D;
  266. this.bc.scope3End = 0D;
  267. this.bc.scope3Start = 0D;
  268. this.bc.Size = new System.Drawing.Size(360, 292);
  269. this.bc.TabIndex = 19;
  270. this.bc.button4.Visible = false;
  271. //相颜色设定隐藏
  272. this.bc.button4.Visible = false;
  273. //this.bc.radioButton1.Enabled = false;
  274. //this.bc.label2.Visible = false;
  275. //this.Controls.Add(this.bc);
  276. //this.Controls.SetChildIndex(this.bc, 0);
  277. }
  278. private void InitializeLanguageText()
  279. {
  280. this.groupBox1.Text = "操作";
  281. this.checkBox1.Text = "生成报告时打开设置";
  282. this.button1.Text = "设置";
  283. this.groupBox2.Text = "图像索引";
  284. this.groupBox3.Text = "预览";
  285. this.groupBox5.Text = "颗粒筛选";
  286. this.checkBox3.Text = "有效颗粒筛选";
  287. this.checkBox4.Text = "无筛选";
  288. this.groupBox8.Text = "结果展示";
  289. this.groupBox9.Text = "分析结果";
  290. this.button3.Text = "导出项目";
  291. this.label8.Text = "小数:";
  292. this.button9.Text = "导出结果";
  293. this.button8.Text = "生成报告";
  294. this.button7.Text = "删除";
  295. this.button6.Text = "全部显示";
  296. this.Text = "高碳铬轴承钢带状GB/T 18254-2002";
  297. this.button4.Text = "保存全部";
  298. this.button5.Text = "应用全部";
  299. }
  300. private void InitializeComponent()
  301. {
  302. this.components = new System.ComponentModel.Container();
  303. this.groupBox1 = new System.Windows.Forms.GroupBox();
  304. this.checkBox5 = new System.Windows.Forms.CheckBox();
  305. this.button4 = new System.Windows.Forms.Button();
  306. this.button2 = new System.Windows.Forms.Button();
  307. this.button5 = new System.Windows.Forms.Button();
  308. this.checkBox1 = new System.Windows.Forms.CheckBox();
  309. this.button1 = new System.Windows.Forms.Button();
  310. this.button11 = new System.Windows.Forms.Button();
  311. this.button10 = new System.Windows.Forms.Button();
  312. this.groupBox2 = new System.Windows.Forms.GroupBox();
  313. this.listView1 = new System.Windows.Forms.ListView();
  314. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  315. this.groupBox3 = new System.Windows.Forms.GroupBox();
  316. this.groupBox5 = new System.Windows.Forms.GroupBox();
  317. this.label1 = new System.Windows.Forms.Label();
  318. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  319. this.checkBox4 = new System.Windows.Forms.CheckBox();
  320. this.checkBox3 = new System.Windows.Forms.CheckBox();
  321. this.panel4 = new System.Windows.Forms.Panel();
  322. this.panel3 = new System.Windows.Forms.Panel();
  323. this.panel2 = new System.Windows.Forms.Panel();
  324. this.groupBox8 = new System.Windows.Forms.GroupBox();
  325. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  326. this.groupBox9 = new System.Windows.Forms.GroupBox();
  327. this.button3 = new System.Windows.Forms.Button();
  328. this.label10 = new System.Windows.Forms.Label();
  329. this.label9 = new System.Windows.Forms.Label();
  330. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  331. this.label8 = new System.Windows.Forms.Label();
  332. this.button9 = new System.Windows.Forms.Button();
  333. this.button8 = new System.Windows.Forms.Button();
  334. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  335. this.listView2 = new System.Windows.Forms.ListView();
  336. this.button7 = new System.Windows.Forms.Button();
  337. this.button6 = new System.Windows.Forms.Button();
  338. this.groupBox4 = new System.Windows.Forms.GroupBox();
  339. this.btnDelRegion = new System.Windows.Forms.Button();
  340. this.button13 = new System.Windows.Forms.Button();
  341. this.button12 = new System.Windows.Forms.Button();
  342. this.checkBox2 = new System.Windows.Forms.CheckBox();
  343. this.groupBox6 = new System.Windows.Forms.GroupBox();
  344. this.label2 = new System.Windows.Forms.Label();
  345. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  346. this.checkBox6 = new System.Windows.Forms.CheckBox();
  347. this.checkBox7 = new System.Windows.Forms.CheckBox();
  348. this.groupBox1.SuspendLayout();
  349. this.groupBox2.SuspendLayout();
  350. this.groupBox5.SuspendLayout();
  351. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  352. this.groupBox8.SuspendLayout();
  353. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  354. this.groupBox9.SuspendLayout();
  355. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  356. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  357. this.groupBox4.SuspendLayout();
  358. this.groupBox6.SuspendLayout();
  359. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  360. this.SuspendLayout();
  361. //
  362. // groupBox1
  363. //
  364. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  365. | System.Windows.Forms.AnchorStyles.Right)));
  366. this.groupBox1.Controls.Add(this.checkBox5);
  367. this.groupBox1.Controls.Add(this.button4);
  368. this.groupBox1.Controls.Add(this.button2);
  369. this.groupBox1.Controls.Add(this.button5);
  370. this.groupBox1.Controls.Add(this.checkBox1);
  371. this.groupBox1.Controls.Add(this.button1);
  372. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  373. this.groupBox1.Name = "groupBox1";
  374. this.groupBox1.Size = new System.Drawing.Size(1107, 50);
  375. this.groupBox1.TabIndex = 1;
  376. this.groupBox1.TabStop = false;
  377. //
  378. // checkBox5
  379. //
  380. this.checkBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  381. | System.Windows.Forms.AnchorStyles.Right)));
  382. this.checkBox5.Location = new System.Drawing.Point(753, 23);
  383. this.checkBox5.Name = "checkBox5";
  384. this.checkBox5.Size = new System.Drawing.Size(72, 16);
  385. this.checkBox5.TabIndex = 20;
  386. this.checkBox5.Text = "显示原图";
  387. this.checkBox5.UseVisualStyleBackColor = true;
  388. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  389. //
  390. // button4
  391. //
  392. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  393. this.button4.Location = new System.Drawing.Point(1019, 14);
  394. this.button4.Name = "button4";
  395. this.button4.Size = new System.Drawing.Size(84, 30);
  396. this.button4.TabIndex = 19;
  397. this.button4.Text = "保存全部";
  398. this.button4.UseVisualStyleBackColor = true;
  399. this.button4.Click += new System.EventHandler(this.button4_Click);
  400. //
  401. // button2
  402. //
  403. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  404. | System.Windows.Forms.AnchorStyles.Right)));
  405. this.button2.Location = new System.Drawing.Point(929, 14);
  406. this.button2.Name = "button2";
  407. this.button2.Size = new System.Drawing.Size(84, 30);
  408. this.button2.TabIndex = 2;
  409. this.button2.Text = "保存结果";
  410. this.button2.UseVisualStyleBackColor = true;
  411. this.button2.Click += new System.EventHandler(this.button2_Click);
  412. //
  413. // button5
  414. //
  415. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  416. this.button5.Location = new System.Drawing.Point(839, 14);
  417. this.button5.Name = "button5";
  418. this.button5.Size = new System.Drawing.Size(84, 30);
  419. this.button5.TabIndex = 18;
  420. this.button5.Text = "应用全部";
  421. this.button5.UseVisualStyleBackColor = true;
  422. this.button5.Click += new System.EventHandler(this.button5_Click);
  423. //
  424. // checkBox1
  425. //
  426. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  427. | System.Windows.Forms.AnchorStyles.Left)));
  428. this.checkBox1.AutoSize = true;
  429. this.checkBox1.Checked = true;
  430. this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
  431. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  432. this.checkBox1.Name = "checkBox1";
  433. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  434. this.checkBox1.TabIndex = 1;
  435. this.checkBox1.UseVisualStyleBackColor = true;
  436. //
  437. // button1
  438. //
  439. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  440. | System.Windows.Forms.AnchorStyles.Left)));
  441. this.button1.Location = new System.Drawing.Point(15, 14);
  442. this.button1.Name = "button1";
  443. this.button1.Size = new System.Drawing.Size(84, 30);
  444. this.button1.TabIndex = 0;
  445. this.button1.UseVisualStyleBackColor = true;
  446. this.button1.Click += new System.EventHandler(this.button1_Click);
  447. //
  448. // button11
  449. //
  450. this.button11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  451. this.button11.Location = new System.Drawing.Point(145, 32);
  452. this.button11.Name = "button11";
  453. this.button11.Size = new System.Drawing.Size(84, 30);
  454. this.button11.TabIndex = 21;
  455. this.button11.Text = "删除";
  456. this.button11.UseVisualStyleBackColor = true;
  457. this.button11.Click += new System.EventHandler(this.DelClick);
  458. //
  459. // button10
  460. //
  461. this.button10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  462. this.button10.Location = new System.Drawing.Point(41, 32);
  463. this.button10.Name = "button10";
  464. this.button10.Size = new System.Drawing.Size(84, 30);
  465. this.button10.TabIndex = 20;
  466. this.button10.Text = "添加";
  467. this.button10.UseVisualStyleBackColor = true;
  468. this.button10.Click += new System.EventHandler(this.AddClick);
  469. //
  470. // groupBox2
  471. //
  472. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  473. | System.Windows.Forms.AnchorStyles.Left)));
  474. this.groupBox2.Controls.Add(this.listView1);
  475. this.groupBox2.Location = new System.Drawing.Point(14, 60);
  476. this.groupBox2.Name = "groupBox2";
  477. this.groupBox2.Size = new System.Drawing.Size(135, 607);
  478. this.groupBox2.TabIndex = 2;
  479. this.groupBox2.TabStop = false;
  480. //
  481. // listView1
  482. //
  483. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  484. | System.Windows.Forms.AnchorStyles.Left)
  485. | System.Windows.Forms.AnchorStyles.Right)));
  486. this.listView1.HideSelection = false;
  487. this.listView1.LargeImageList = this.imageList1;
  488. this.listView1.Location = new System.Drawing.Point(5, 17);
  489. this.listView1.MultiSelect = false;
  490. this.listView1.Name = "listView1";
  491. this.listView1.Size = new System.Drawing.Size(124, 584);
  492. this.listView1.TabIndex = 0;
  493. this.listView1.UseCompatibleStateImageBehavior = false;
  494. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  495. this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
  496. //
  497. // imageList1
  498. //
  499. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  500. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  501. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  502. //
  503. // groupBox3
  504. //
  505. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  506. | System.Windows.Forms.AnchorStyles.Left)
  507. | System.Windows.Forms.AnchorStyles.Right)));
  508. this.groupBox3.Location = new System.Drawing.Point(515, 60);
  509. this.groupBox3.Name = "groupBox3";
  510. this.groupBox3.Size = new System.Drawing.Size(606, 605);
  511. this.groupBox3.TabIndex = 3;
  512. this.groupBox3.TabStop = false;
  513. //
  514. // groupBox5
  515. //
  516. this.groupBox5.Controls.Add(this.label1);
  517. this.groupBox5.Controls.Add(this.numericUpDown2);
  518. this.groupBox5.Controls.Add(this.checkBox4);
  519. this.groupBox5.Controls.Add(this.checkBox3);
  520. this.groupBox5.Location = new System.Drawing.Point(155, 59);
  521. this.groupBox5.Name = "groupBox5";
  522. this.groupBox5.Size = new System.Drawing.Size(353, 94);
  523. this.groupBox5.TabIndex = 5;
  524. this.groupBox5.TabStop = false;
  525. //
  526. // label1
  527. //
  528. this.label1.AutoSize = true;
  529. this.label1.Location = new System.Drawing.Point(167, 27);
  530. this.label1.Name = "label1";
  531. this.label1.Size = new System.Drawing.Size(65, 12);
  532. this.label1.TabIndex = 3;
  533. this.label1.Text = "有效占比:";
  534. //
  535. // numericUpDown2
  536. //
  537. this.numericUpDown2.DecimalPlaces = 1;
  538. this.numericUpDown2.Increment = new decimal(new int[] {
  539. 1,
  540. 0,
  541. 0,
  542. 65536});
  543. this.numericUpDown2.Location = new System.Drawing.Point(238, 23);
  544. this.numericUpDown2.Maximum = new decimal(new int[] {
  545. 1,
  546. 0,
  547. 0,
  548. 0});
  549. this.numericUpDown2.Name = "numericUpDown2";
  550. this.numericUpDown2.Size = new System.Drawing.Size(52, 21);
  551. this.numericUpDown2.TabIndex = 2;
  552. this.numericUpDown2.Value = new decimal(new int[] {
  553. 3,
  554. 0,
  555. 0,
  556. 65536});
  557. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  558. //
  559. // checkBox4
  560. //
  561. this.checkBox4.AutoSize = true;
  562. this.checkBox4.Location = new System.Drawing.Point(41, 61);
  563. this.checkBox4.Name = "checkBox4";
  564. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  565. this.checkBox4.TabIndex = 1;
  566. this.checkBox4.UseVisualStyleBackColor = true;
  567. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  568. //
  569. // checkBox3
  570. //
  571. this.checkBox3.AutoSize = true;
  572. this.checkBox3.Checked = true;
  573. this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked;
  574. this.checkBox3.Location = new System.Drawing.Point(41, 25);
  575. this.checkBox3.Name = "checkBox3";
  576. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  577. this.checkBox3.TabIndex = 0;
  578. this.checkBox3.UseVisualStyleBackColor = true;
  579. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  580. //
  581. // panel4
  582. //
  583. this.panel4.Location = new System.Drawing.Point(0, 0);
  584. this.panel4.Name = "panel4";
  585. this.panel4.Size = new System.Drawing.Size(200, 100);
  586. this.panel4.TabIndex = 0;
  587. //
  588. // panel3
  589. //
  590. this.panel3.Location = new System.Drawing.Point(0, 0);
  591. this.panel3.Name = "panel3";
  592. this.panel3.Size = new System.Drawing.Size(200, 100);
  593. this.panel3.TabIndex = 0;
  594. //
  595. // panel2
  596. //
  597. this.panel2.Location = new System.Drawing.Point(0, 0);
  598. this.panel2.Name = "panel2";
  599. this.panel2.Size = new System.Drawing.Size(200, 100);
  600. this.panel2.TabIndex = 0;
  601. //
  602. // groupBox8
  603. //
  604. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  605. | System.Windows.Forms.AnchorStyles.Left)));
  606. this.groupBox8.Controls.Add(this.dataGridView1);
  607. this.groupBox8.Location = new System.Drawing.Point(155, 408);
  608. this.groupBox8.Name = "groupBox8";
  609. this.groupBox8.Size = new System.Drawing.Size(353, 258);
  610. this.groupBox8.TabIndex = 8;
  611. this.groupBox8.TabStop = false;
  612. //
  613. // dataGridView1
  614. //
  615. this.dataGridView1.AllowUserToAddRows = false;
  616. this.dataGridView1.AllowUserToDeleteRows = false;
  617. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  618. | System.Windows.Forms.AnchorStyles.Left)
  619. | System.Windows.Forms.AnchorStyles.Right)));
  620. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  621. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  622. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  623. this.dataGridView1.Location = new System.Drawing.Point(7, 20);
  624. this.dataGridView1.MultiSelect = false;
  625. this.dataGridView1.Name = "dataGridView1";
  626. this.dataGridView1.RowHeadersVisible = false;
  627. this.dataGridView1.RowTemplate.Height = 23;
  628. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  629. this.dataGridView1.Size = new System.Drawing.Size(340, 232);
  630. this.dataGridView1.TabIndex = 0;
  631. //
  632. // groupBox9
  633. //
  634. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  635. | System.Windows.Forms.AnchorStyles.Right)));
  636. this.groupBox9.Controls.Add(this.button3);
  637. this.groupBox9.Controls.Add(this.label10);
  638. this.groupBox9.Controls.Add(this.label9);
  639. this.groupBox9.Controls.Add(this.numericUpDown1);
  640. this.groupBox9.Controls.Add(this.label8);
  641. this.groupBox9.Controls.Add(this.button9);
  642. this.groupBox9.Controls.Add(this.button8);
  643. this.groupBox9.Controls.Add(this.dataGridView2);
  644. this.groupBox9.Controls.Add(this.listView2);
  645. this.groupBox9.Controls.Add(this.button7);
  646. this.groupBox9.Controls.Add(this.button6);
  647. this.groupBox9.Location = new System.Drawing.Point(14, 672);
  648. this.groupBox9.Name = "groupBox9";
  649. this.groupBox9.Size = new System.Drawing.Size(1107, 204);
  650. this.groupBox9.TabIndex = 9;
  651. this.groupBox9.TabStop = false;
  652. //
  653. // button3
  654. //
  655. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  656. this.button3.Enabled = false;
  657. this.button3.Location = new System.Drawing.Point(967, 102);
  658. this.button3.Name = "button3";
  659. this.button3.Size = new System.Drawing.Size(128, 26);
  660. this.button3.TabIndex = 10;
  661. this.button3.UseVisualStyleBackColor = true;
  662. this.button3.Visible = false;
  663. this.button3.Click += new System.EventHandler(this.button3_Click);
  664. //
  665. // label10
  666. //
  667. this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  668. this.label10.AutoSize = true;
  669. this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
  670. this.label10.Location = new System.Drawing.Point(953, 9);
  671. this.label10.Name = "label10";
  672. this.label10.Size = new System.Drawing.Size(11, 192);
  673. this.label10.TabIndex = 9;
  674. this.label10.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  675. //
  676. // label9
  677. //
  678. this.label9.AutoSize = true;
  679. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  680. this.label9.Location = new System.Drawing.Point(210, 9);
  681. this.label9.Name = "label9";
  682. this.label9.Size = new System.Drawing.Size(11, 192);
  683. this.label9.TabIndex = 8;
  684. this.label9.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  685. //
  686. // numericUpDown1
  687. //
  688. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  689. this.numericUpDown1.Location = new System.Drawing.Point(1019, 162);
  690. this.numericUpDown1.Maximum = new decimal(new int[] {
  691. 10,
  692. 0,
  693. 0,
  694. 0});
  695. this.numericUpDown1.Name = "numericUpDown1";
  696. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  697. this.numericUpDown1.TabIndex = 7;
  698. this.numericUpDown1.Value = new decimal(new int[] {
  699. 2,
  700. 0,
  701. 0,
  702. 0});
  703. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  704. //
  705. // label8
  706. //
  707. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  708. this.label8.AutoSize = true;
  709. this.label8.Location = new System.Drawing.Point(983, 167);
  710. this.label8.Name = "label8";
  711. this.label8.Size = new System.Drawing.Size(0, 12);
  712. this.label8.TabIndex = 6;
  713. //
  714. // button9
  715. //
  716. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  717. this.button9.Location = new System.Drawing.Point(967, 68);
  718. this.button9.Name = "button9";
  719. this.button9.Size = new System.Drawing.Size(128, 26);
  720. this.button9.TabIndex = 5;
  721. this.button9.UseVisualStyleBackColor = true;
  722. this.button9.Click += new System.EventHandler(this.button9_Click);
  723. //
  724. // button8
  725. //
  726. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  727. this.button8.Location = new System.Drawing.Point(967, 34);
  728. this.button8.Name = "button8";
  729. this.button8.Size = new System.Drawing.Size(128, 26);
  730. this.button8.TabIndex = 4;
  731. this.button8.UseVisualStyleBackColor = true;
  732. this.button8.Click += new System.EventHandler(this.button8_Click);
  733. //
  734. // dataGridView2
  735. //
  736. this.dataGridView2.AllowUserToAddRows = false;
  737. this.dataGridView2.AllowUserToDeleteRows = false;
  738. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  739. | System.Windows.Forms.AnchorStyles.Left)
  740. | System.Windows.Forms.AnchorStyles.Right)));
  741. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  742. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  743. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  744. this.dataGridView2.Location = new System.Drawing.Point(228, 13);
  745. this.dataGridView2.MultiSelect = false;
  746. this.dataGridView2.Name = "dataGridView2";
  747. this.dataGridView2.RowHeadersVisible = false;
  748. this.dataGridView2.RowTemplate.Height = 23;
  749. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  750. this.dataGridView2.Size = new System.Drawing.Size(719, 183);
  751. this.dataGridView2.TabIndex = 3;
  752. //
  753. // listView2
  754. //
  755. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  756. | System.Windows.Forms.AnchorStyles.Left)));
  757. this.listView2.HideSelection = false;
  758. this.listView2.Location = new System.Drawing.Point(16, 56);
  759. this.listView2.Name = "listView2";
  760. this.listView2.Size = new System.Drawing.Size(181, 140);
  761. this.listView2.TabIndex = 2;
  762. this.listView2.UseCompatibleStateImageBehavior = false;
  763. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  764. //
  765. // button7
  766. //
  767. this.button7.Location = new System.Drawing.Point(145, 20);
  768. this.button7.Name = "button7";
  769. this.button7.Size = new System.Drawing.Size(52, 26);
  770. this.button7.TabIndex = 1;
  771. this.button7.UseVisualStyleBackColor = true;
  772. this.button7.Click += new System.EventHandler(this.button7_Click);
  773. //
  774. // button6
  775. //
  776. this.button6.Location = new System.Drawing.Point(16, 20);
  777. this.button6.Name = "button6";
  778. this.button6.Size = new System.Drawing.Size(93, 26);
  779. this.button6.TabIndex = 0;
  780. this.button6.UseVisualStyleBackColor = true;
  781. this.button6.Click += new System.EventHandler(this.button6_Click);
  782. //
  783. // groupBox4
  784. //
  785. this.groupBox4.Controls.Add(this.btnDelRegion);
  786. this.groupBox4.Controls.Add(this.button13);
  787. this.groupBox4.Controls.Add(this.button12);
  788. this.groupBox4.Controls.Add(this.checkBox2);
  789. this.groupBox4.Controls.Add(this.button10);
  790. this.groupBox4.Controls.Add(this.button11);
  791. this.groupBox4.Location = new System.Drawing.Point(155, 159);
  792. this.groupBox4.Name = "groupBox4";
  793. this.groupBox4.Size = new System.Drawing.Size(353, 143);
  794. this.groupBox4.TabIndex = 10;
  795. this.groupBox4.TabStop = false;
  796. this.groupBox4.Text = "颗粒编辑";
  797. //
  798. // btnDelRegion
  799. //
  800. this.btnDelRegion.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  801. this.btnDelRegion.Location = new System.Drawing.Point(249, 32);
  802. this.btnDelRegion.Name = "btnDelRegion";
  803. this.btnDelRegion.Size = new System.Drawing.Size(84, 30);
  804. this.btnDelRegion.TabIndex = 25;
  805. this.btnDelRegion.Text = "区域删除";
  806. this.btnDelRegion.UseVisualStyleBackColor = true;
  807. this.btnDelRegion.Click += new System.EventHandler(this.DelRegionClick);
  808. //
  809. // button13
  810. //
  811. this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  812. this.button13.Location = new System.Drawing.Point(145, 85);
  813. this.button13.Name = "button13";
  814. this.button13.Size = new System.Drawing.Size(84, 30);
  815. this.button13.TabIndex = 24;
  816. this.button13.Text = "应用";
  817. this.button13.UseVisualStyleBackColor = true;
  818. this.button13.Click += new System.EventHandler(this.ApplyClick);
  819. //
  820. // button12
  821. //
  822. this.button12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  823. this.button12.Location = new System.Drawing.Point(41, 85);
  824. this.button12.Name = "button12";
  825. this.button12.Size = new System.Drawing.Size(84, 30);
  826. this.button12.TabIndex = 23;
  827. this.button12.Text = "撤销";
  828. this.button12.UseVisualStyleBackColor = true;
  829. this.button12.Click += new System.EventHandler(this.RedoClick);
  830. //
  831. // checkBox2
  832. //
  833. this.checkBox2.AutoSize = true;
  834. this.checkBox2.Checked = true;
  835. this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
  836. this.checkBox2.Location = new System.Drawing.Point(249, 93);
  837. this.checkBox2.Name = "checkBox2";
  838. this.checkBox2.Size = new System.Drawing.Size(48, 16);
  839. this.checkBox2.TabIndex = 22;
  840. this.checkBox2.Text = "连续";
  841. this.checkBox2.UseVisualStyleBackColor = true;
  842. //
  843. // groupBox6
  844. //
  845. this.groupBox6.Controls.Add(this.label2);
  846. this.groupBox6.Controls.Add(this.numericUpDown3);
  847. this.groupBox6.Controls.Add(this.checkBox6);
  848. this.groupBox6.Controls.Add(this.checkBox7);
  849. this.groupBox6.Location = new System.Drawing.Point(155, 308);
  850. this.groupBox6.Name = "groupBox6";
  851. this.groupBox6.Size = new System.Drawing.Size(353, 94);
  852. this.groupBox6.TabIndex = 11;
  853. this.groupBox6.TabStop = false;
  854. this.groupBox6.Text = "阈值调整";
  855. //
  856. // label2
  857. //
  858. this.label2.AutoSize = true;
  859. this.label2.Location = new System.Drawing.Point(188, 61);
  860. this.label2.Name = "label2";
  861. this.label2.Size = new System.Drawing.Size(41, 12);
  862. this.label2.TabIndex = 3;
  863. this.label2.Text = "阈值:";
  864. //
  865. // numericUpDown3
  866. //
  867. this.numericUpDown3.Location = new System.Drawing.Point(238, 56);
  868. this.numericUpDown3.Maximum = new decimal(new int[] {
  869. 255,
  870. 0,
  871. 0,
  872. 0});
  873. this.numericUpDown3.Name = "numericUpDown3";
  874. this.numericUpDown3.Size = new System.Drawing.Size(52, 21);
  875. this.numericUpDown3.TabIndex = 2;
  876. this.numericUpDown3.Value = new decimal(new int[] {
  877. 60,
  878. 0,
  879. 0,
  880. 0});
  881. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  882. //
  883. // checkBox6
  884. //
  885. this.checkBox6.AutoSize = true;
  886. this.checkBox6.Location = new System.Drawing.Point(41, 61);
  887. this.checkBox6.Name = "checkBox6";
  888. this.checkBox6.Size = new System.Drawing.Size(72, 16);
  889. this.checkBox6.TabIndex = 1;
  890. this.checkBox6.Text = "固定阈值";
  891. this.checkBox6.UseVisualStyleBackColor = true;
  892. this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
  893. //
  894. // checkBox7
  895. //
  896. this.checkBox7.AutoSize = true;
  897. this.checkBox7.Checked = true;
  898. this.checkBox7.CheckState = System.Windows.Forms.CheckState.Checked;
  899. this.checkBox7.Location = new System.Drawing.Point(41, 25);
  900. this.checkBox7.Name = "checkBox7";
  901. this.checkBox7.Size = new System.Drawing.Size(60, 16);
  902. this.checkBox7.TabIndex = 0;
  903. this.checkBox7.Text = "大津法";
  904. this.checkBox7.UseVisualStyleBackColor = true;
  905. this.checkBox7.CheckedChanged += new System.EventHandler(this.checkBox7_CheckedChanged);
  906. //
  907. // BearingSteelStripRatingDialog
  908. //
  909. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  910. this.ClientSize = new System.Drawing.Size(1133, 881);
  911. this.Controls.Add(this.groupBox6);
  912. this.Controls.Add(this.groupBox4);
  913. this.Controls.Add(this.groupBox9);
  914. this.Controls.Add(this.groupBox8);
  915. this.Controls.Add(this.groupBox5);
  916. this.Controls.Add(this.groupBox3);
  917. this.Controls.Add(this.groupBox2);
  918. this.Controls.Add(this.groupBox1);
  919. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  920. this.Location = new System.Drawing.Point(0, 0);
  921. this.Name = "BearingSteelStripRatingDialog";
  922. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Dialog_FormClosing);
  923. this.Load += new System.EventHandler(this.MicrostructureBandDialog_Load);
  924. this.Controls.SetChildIndex(this.groupBox1, 0);
  925. this.Controls.SetChildIndex(this.groupBox2, 0);
  926. this.Controls.SetChildIndex(this.groupBox3, 0);
  927. this.Controls.SetChildIndex(this.groupBox5, 0);
  928. this.Controls.SetChildIndex(this.groupBox8, 0);
  929. this.Controls.SetChildIndex(this.groupBox9, 0);
  930. this.Controls.SetChildIndex(this.groupBox4, 0);
  931. this.Controls.SetChildIndex(this.groupBox6, 0);
  932. this.groupBox1.ResumeLayout(false);
  933. this.groupBox1.PerformLayout();
  934. this.groupBox2.ResumeLayout(false);
  935. this.groupBox5.ResumeLayout(false);
  936. this.groupBox5.PerformLayout();
  937. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  938. this.groupBox8.ResumeLayout(false);
  939. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  940. this.groupBox9.ResumeLayout(false);
  941. this.groupBox9.PerformLayout();
  942. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  943. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  944. this.groupBox4.ResumeLayout(false);
  945. this.groupBox4.PerformLayout();
  946. this.groupBox6.ResumeLayout(false);
  947. this.groupBox6.PerformLayout();
  948. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  949. this.ResumeLayout(false);
  950. }
  951. private void BearingSteelStripRatingDialog_Load(object sender, EventArgs e)
  952. {
  953. this.binaryClass.loadParams();
  954. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  955. this.startScriptAutomaticAction();
  956. }
  957. /// <summary>
  958. /// 初始化其他控件
  959. /// </summary>
  960. private void InitOtherTools()
  961. {
  962. //
  963. //初始化图像控件
  964. //
  965. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  966. this.documentWorkspace.Dock = DockStyle.Fill;
  967. this.documentWorkspace.HookMouseEvents();
  968. this.documentWorkspace.AuxiliaryLineEnabled = false;
  969. this.documentWorkspace.Visible = false;
  970. #region 0811新增
  971. this.documentWorkspace.panel.Paint += Panel_Paint;
  972. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  973. this.documentWorkspace.panel.MouseUp += OnMouseUp;
  974. this.documentWorkspace.panel.MouseMove += onMouseMove;
  975. #endregion
  976. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.NullTool;
  977. this.groupBox3.Controls.Add(documentWorkspace);
  978. //
  979. //初始化操作按钮
  980. //
  981. this.commonControlButtons = new CommonControlButtons();
  982. this.commonControlButtons.Dock = DockStyle.Top;
  983. this.commonControlButtons.Height = 30;
  984. this.commonControlButtons.HideZoomToWindowAndActualSize();
  985. this.commonControlButtons.Visible = false;
  986. this.groupBox3.Controls.Add(commonControlButtons);
  987. //
  988. //颜色pane2给定初始值
  989. //
  990. this.panel2.BackColor = Color.Red;
  991. //
  992. //获取系统标尺-微米
  993. //
  994. this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  995. //二值化集成2
  996. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  997. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Particlescreening.text") }
  998. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  999. //binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1000. }
  1001. /// <summary>
  1002. /// 初始化图片列表数据
  1003. /// </summary>
  1004. public void InitPicList()
  1005. {
  1006. //初始化图片列表
  1007. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1008. {
  1009. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1010. this.listView1.Items.Add("", i);
  1011. this.listView1.Items[i].ImageIndex = i;
  1012. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1013. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1014. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1015. {
  1016. defaultIndex = i;
  1017. }
  1018. }
  1019. this.Shown += ShowImgEvent;
  1020. }
  1021. /// <summary>
  1022. /// 初始化表头
  1023. /// </summary>
  1024. private void InitGridHeader()
  1025. {
  1026. //
  1027. //结果展示表
  1028. //
  1029. this.dataGridView1.ColumnHeadersHeight = 30;
  1030. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1031. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1032. h1.Width = 60;
  1033. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1034. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1035. h2.Width = 60;
  1036. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1037. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1038. h3.Width = 60;
  1039. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1040. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1041. h4.Width = 60;
  1042. DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();
  1043. h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1044. h5.Width = 60;
  1045. DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();
  1046. h6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1047. h6.Width = 36;
  1048. this.dataGridView1.Columns.Add(h1);
  1049. this.dataGridView1.Columns.Add(h2);
  1050. this.dataGridView1.Columns.Add(h3);
  1051. this.dataGridView1.Columns.Add(h4);
  1052. this.dataGridView1.Columns.Add(h5);
  1053. this.dataGridView1.Columns.Add(h6);
  1054. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1055. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, "平均直径"));
  1056. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, "最大直径"));
  1057. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, "平均面积"));
  1058. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, "最大面积"));
  1059. helper.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, "平均距离"));
  1060. helper.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, "级别"));
  1061. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1062. this.dataGridView1.Columns[0].ReadOnly = true;
  1063. //this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1064. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1065. this.dataGridView1.Columns[1].ReadOnly = true;
  1066. //this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1067. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1068. this.dataGridView1.Columns[2].ReadOnly = true;
  1069. //this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1070. this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1071. this.dataGridView1.Columns[3].ReadOnly = true;
  1072. //this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1073. this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1074. this.dataGridView1.Columns[4].ReadOnly = true;
  1075. //this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1076. this.dataGridView1.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  1077. this.dataGridView1.Columns[5].ReadOnly = false;
  1078. //this.dataGridView1.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1079. this.dataGridView1.AllowUserToResizeRows = false;
  1080. this.dataGridView1.AllowUserToResizeColumns = false;
  1081. //
  1082. //分析结果表
  1083. //
  1084. this.dataGridView2.ColumnHeadersHeight = 30;
  1085. DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();
  1086. //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1087. h7.Width = 70;
  1088. DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();
  1089. h8.Width = 90;
  1090. DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();
  1091. //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1092. h9.Width = 90;
  1093. DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn();
  1094. //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1095. h10.Width = 90;
  1096. DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
  1097. //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1098. h11.Width = 90;
  1099. DataGridViewTextBoxColumn h12 = new DataGridViewTextBoxColumn();
  1100. //h12.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1101. h12.Width = 190;
  1102. DataGridViewTextBoxColumn h13 = new DataGridViewTextBoxColumn();
  1103. //h13.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1104. h13.Width = 70;
  1105. this.dataGridView2.Columns.Add(h7);
  1106. this.dataGridView2.Columns.Add(h8);
  1107. this.dataGridView2.Columns.Add(h9);
  1108. this.dataGridView2.Columns.Add(h10);
  1109. this.dataGridView2.Columns.Add(h11);
  1110. this.dataGridView2.Columns.Add(h12);
  1111. this.dataGridView2.Columns.Add(h13);
  1112. DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  1113. helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, "图片"));
  1114. helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, "平均直径/um"));
  1115. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, "最大直径/um"));
  1116. helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, "平均面积/um²"));
  1117. helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, "最大面积/um²"));
  1118. helper2.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, "颗粒间平均距离/um"));
  1119. helper2.Headers.Add(new DataGridViewHelper.TopHeader(6, 1, "级别"));
  1120. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1121. this.dataGridView2.Columns[0].ReadOnly = true;
  1122. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1123. this.dataGridView2.Columns[1].ReadOnly = true;
  1124. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1125. this.dataGridView2.Columns[2].ReadOnly = true;
  1126. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1127. this.dataGridView2.Columns[3].ReadOnly = true;
  1128. this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1129. this.dataGridView2.Columns[4].ReadOnly = true;
  1130. this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  1131. this.dataGridView2.Columns[5].ReadOnly = true;
  1132. this.dataGridView2.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  1133. this.dataGridView2.Columns[6].ReadOnly = false;
  1134. this.dataGridView2.AllowUserToResizeRows = false;
  1135. this.dataGridView2.AllowUserToResizeColumns = false;
  1136. //
  1137. //左下表
  1138. //
  1139. this.listView2.View = View.Details;
  1140. ColumnHeader header0 = new ColumnHeader();
  1141. header0.Text = "图片列表";
  1142. header0.Width = 175;
  1143. this.listView2.Columns.Add(header0);
  1144. }
  1145. /// <summary>
  1146. /// 初始化画布按键功能
  1147. /// </summary>
  1148. private void InitCommonButtonEvent()
  1149. {
  1150. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1151. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1152. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1153. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1154. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1155. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1156. }
  1157. //二值化集成3
  1158. #region 二值化相关方法
  1159. private void Dialog_FormClosing(object sender, FormClosingEventArgs e)
  1160. {
  1161. #region [开启脚本录制]
  1162. if (appWorkspace.startScriptRecording)
  1163. {
  1164. getScriptRecording();
  1165. }
  1166. #endregion
  1167. binaryClass.saveParams();
  1168. this.saveDialogParamValues();
  1169. //xml保存路径
  1170. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  1171. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1172. foreach (var analysisItem in this.eachData[GetImgKey()].ListParam)
  1173. {
  1174. bool foundItem = false;
  1175. foreach (var item in analysisModelXml.ListParam)
  1176. {
  1177. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  1178. {
  1179. item.param_value = analysisItem.param_value;
  1180. foundItem = true;
  1181. break;
  1182. }
  1183. }
  1184. if (!foundItem)
  1185. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  1186. }
  1187. //按路径和名称保存xml文件
  1188. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  1189. //保存xml
  1190. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  1191. }
  1192. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  1193. {
  1194. binaryClass.RefreshHistogramControl1Values();
  1195. }
  1196. /// <summary>
  1197. /// 添加参数改变的监听
  1198. /// </summary>
  1199. /// <param name="sender"></param>
  1200. /// <param name="e"></param>
  1201. private void MicrostructureBandDialog_Load(object sender, EventArgs e)
  1202. {
  1203. this.binaryClass.loadParams();
  1204. }
  1205. private bool bcBinaryChecked()
  1206. {
  1207. return bc != null && bc.BinaryChecked;
  1208. }
  1209. private bool bcOriginChecked()
  1210. {
  1211. return bc != null && bc.OriginChecked;
  1212. }
  1213. /// <summary>
  1214. /// 参数改变时,重新处理图像
  1215. /// </summary>
  1216. /// <param name="sender"></param>
  1217. /// <param name="e"></param>
  1218. //AppCommon appCommonDisplay = new AppCommon();
  1219. //private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1220. //{
  1221. // if (this.documentWorkspace.CompositionSurface == null)
  1222. // return;
  1223. // sum++;
  1224. // if (bcBinaryChecked())
  1225. // {
  1226. // if (bcOriginChecked())
  1227. // {
  1228. // this.documentWorkspace.PhaseModels[1].choise = false;
  1229. // }
  1230. // else
  1231. // {
  1232. // this.documentWorkspace.PhaseModels[1].choise = false;
  1233. // }
  1234. // //ResetAreaAndContent();
  1235. // ReloadDebrisSelection();
  1236. // changeColor = false;
  1237. // this.documentWorkspace.PhaseModels[0].choise = false;
  1238. // }
  1239. // else
  1240. // {
  1241. // this.documentWorkspace.PhaseModels[0].choise = false;
  1242. // this.documentWorkspace.PhaseModels[1].choise = false;
  1243. // appCommon.DisplayData(this.dataGridView1, false);
  1244. // }
  1245. // //this.documentWorkspace.Refresh();
  1246. //}
  1247. /// <summary>
  1248. /// 显示原图/原图+二值图
  1249. /// </summary>
  1250. /// <param name="sender"></param>
  1251. /// <param name="e"></param>
  1252. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1253. {
  1254. if (!bcOriginChecked())
  1255. {
  1256. if (bcBinaryChecked())
  1257. {
  1258. //this.documentWorkspace.PhaseModels[0].choise = false;
  1259. this.documentWorkspace.PhaseModels[1].choise = true;
  1260. appCommon.DisplayData(this.dataGridView1, true);
  1261. }
  1262. }
  1263. else
  1264. {
  1265. this.documentWorkspace.PhaseModels[0].choise = false;
  1266. this.documentWorkspace.PhaseModels[1].choise = false;
  1267. appCommon.DisplayData(this.dataGridView1, false);
  1268. }
  1269. this.documentWorkspace.Refresh();
  1270. }
  1271. #endregion
  1272. private void zoomInButton_Click(object sender, EventArgs e)
  1273. {
  1274. this.documentWorkspace.ZoomIn();
  1275. }
  1276. private void zoomOutButton_Click(object sender, EventArgs e)
  1277. {
  1278. this.documentWorkspace.ZoomOut();
  1279. }
  1280. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1281. {
  1282. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1283. }
  1284. private void actualSizeButton_Click(object sender, EventArgs e)
  1285. {
  1286. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1287. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1288. }
  1289. private void pointerButton_Click(object sender, EventArgs e)
  1290. {
  1291. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1292. }
  1293. private void mobileModeButton_Click(object sender, EventArgs e)
  1294. {
  1295. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1296. }
  1297. /// <summary>
  1298. /// 设置按钮
  1299. /// </summary>
  1300. /// <param name="sender"></param>
  1301. /// <param name="e"></param>
  1302. private void button1_Click(object sender, EventArgs e)
  1303. {
  1304. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.BearingSteelGBT18254");
  1305. if (metallographicMethodSetDialog.hasModule)
  1306. {
  1307. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1308. metallographicMethodSetDialog.ShowDialog();
  1309. }
  1310. else
  1311. {
  1312. metallographicMethodSetDialog = null;
  1313. }
  1314. }
  1315. DialogResult dr;
  1316. /// <summary>
  1317. /// 保存结果按钮
  1318. /// </summary>
  1319. /// <param name="sender"></param>
  1320. /// <param name="e"></param>
  1321. private void button2_Click(object sender, EventArgs e)
  1322. {
  1323. if (this.listView1.SelectedItems.Count > 0)
  1324. {
  1325. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1326. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1327. bool replace = false;
  1328. int rowIndex = 0;
  1329. if (this.dataGridView1.Rows.Count > 0)
  1330. {
  1331. if (this.listView2.Items.Count > 0)
  1332. {
  1333. foreach (ListViewItem item in this.listView2.Items)
  1334. {
  1335. if (!blSaveAll && item.Name.Equals(tag))
  1336. {
  1337. dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1338. break;
  1339. }
  1340. }
  1341. foreach (ListViewItem item in this.listView2.Items)
  1342. {
  1343. if (item.Name.Equals(tag))
  1344. {
  1345. if (dr == DialogResult.OK || blSaveAll)
  1346. {
  1347. replace = true;
  1348. }
  1349. else
  1350. {
  1351. return;
  1352. }
  1353. break;
  1354. }
  1355. }
  1356. }
  1357. //有重名需要替换
  1358. if (replace)
  1359. {
  1360. for (int i = 0; i < this.resultTableList.Count; i++)
  1361. {
  1362. if (this.resultTableList[i].TableName.Equals(tag))
  1363. {
  1364. rowIndex = i;
  1365. this.resultTableList.Remove(this.resultTableList[i]);
  1366. resultTableList.Insert(rowIndex, dtResult);
  1367. }
  1368. }
  1369. }
  1370. //新增
  1371. else
  1372. {
  1373. ListViewItem listViewItem = new ListViewItem();
  1374. listViewItem.Name = tag;
  1375. listViewItem.SubItems[0].Text = imgName;
  1376. this.listView2.Items.Add(listViewItem);
  1377. this.listView2.SelectedItems.Clear();
  1378. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1379. resultTableList.Insert(rowIndex, dtResult);
  1380. }
  1381. RefreshDataGridView2();
  1382. //保存处理后的图片
  1383. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1384. List<Bitmap> tempBit = new List<Bitmap>();
  1385. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1386. originalBit.Tag = pantographRatio;
  1387. tempBit.Add(originalBit);
  1388. Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  1389. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1390. Graphics graphics = Graphics.FromImage(newBit);
  1391. graphics.DrawImage(processedBit, new PointF(0, 0));
  1392. newBit.Tag = pantographRatio;
  1393. tempBit.Add(newBit);
  1394. if (bitDic.ContainsKey(tag))
  1395. bitDic[tag] = tempBit;
  1396. else
  1397. bitDic.Add(tag, tempBit);
  1398. //拼接中间数据
  1399. List<List<string>> dataList = new List<List<string>>();
  1400. List<string> columnName = new List<string>();
  1401. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  1402. columnName.Add(PdnResources.GetString("Menu.area.text"));
  1403. columnName.Add(PdnResources.GetString("Menu.Maximumcaliperdiameter.text"));
  1404. dataList.Add(columnName);
  1405. bool isExist = false;//是否已存在进行替换
  1406. int modelIndex = -1;//要替换的下标
  1407. for (int j = 0; j < tempDataModel.Count; j++)
  1408. {
  1409. if (tempDataModel[j].tagName.Equals(tag))
  1410. {
  1411. isExist = true;
  1412. modelIndex = j;
  1413. break;
  1414. }
  1415. }
  1416. if (isExist && modelIndex > -1)
  1417. tempDataModel[modelIndex].dataList = dataList;
  1418. else
  1419. {
  1420. ExportProjectModel newModel = new ExportProjectModel();
  1421. newModel.tagName = tag;
  1422. newModel.picName = imgName;
  1423. newModel.dataList = dataList;
  1424. tempDataModel.Add(newModel);
  1425. }
  1426. }
  1427. else
  1428. {
  1429. MessageBox.Show(PdnResources.GetString("Menu.Nocarbidtosave.text"));
  1430. }
  1431. }
  1432. else
  1433. {
  1434. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1435. }
  1436. }
  1437. /// <summary>
  1438. /// 刷新分析结果表
  1439. /// </summary>
  1440. private void RefreshDataGridView2()
  1441. {
  1442. dataGridView2.Rows.Clear();
  1443. if (resultTableList.Count > 0)
  1444. {
  1445. if (this.showAll)
  1446. {
  1447. //dataGridView2.Rows.Clear();
  1448. int i = 0;
  1449. for (int k = 0; k < resultTableList.Count; k++)
  1450. {
  1451. dataGridView2.Rows.Add(resultTableList[k].Rows.Count);//增加同等数量的行数
  1452. foreach (DataRow row in resultTableList[k].Rows)//逐个读取单元格的内容;
  1453. {
  1454. DataGridViewRow r1 = dataGridView2.Rows[i];
  1455. r1.Cells[0].Value = row.RowState.ToString();
  1456. for (int j = 0; j < resultTableList[k].Columns.Count; j++)
  1457. {
  1458. r1.Cells[j].Value = row[j].ToString();
  1459. //r1.Cells[j].Value = row[j];
  1460. }
  1461. i++;
  1462. }
  1463. }
  1464. }
  1465. else
  1466. {
  1467. //dataGridView2.Rows.Clear();
  1468. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1469. {
  1470. int h = 0;
  1471. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1472. {
  1473. string tableName = this.listView2.SelectedItems[i].Name;
  1474. foreach (DataTable dt in resultTableList)
  1475. {
  1476. if (dt.TableName.Equals(tableName))
  1477. {
  1478. dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1479. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1480. {
  1481. DataGridViewRow r1 = dataGridView2.Rows[h];
  1482. r1.Cells[0].Value = row.RowState.ToString();
  1483. for (int j = 0; j < dt.Columns.Count; j++)
  1484. {
  1485. r1.Cells[j].Value = row[j].ToString();
  1486. }
  1487. h++;
  1488. }
  1489. }
  1490. }
  1491. }
  1492. }
  1493. }
  1494. //this.dataGridView3.Rows.Add(PdnResources.GetString("Menu.comprehensive.text"), PdnResources.GetString("Menu.Comprehensivaverage.text"), series, Math.Round(double.Parse(string.IsNullOrEmpty(avglstSize.ToString()) ? "0" : avglstSize.ToString()), Convert.ToInt32(this.numericUpDown1.Value)), avgLevel);
  1495. }
  1496. }
  1497. /// <summary>
  1498. /// 全部显示按钮
  1499. /// </summary>
  1500. /// <param name="sender"></param>
  1501. /// <param name="e"></param>
  1502. private void button6_Click(object sender, EventArgs e)
  1503. {
  1504. if (this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1505. {
  1506. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1507. this.showAll = true;
  1508. RefreshDataGridView2();
  1509. }
  1510. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1511. {
  1512. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1513. this.showAll = false;
  1514. RefreshDataGridView2();
  1515. }
  1516. }
  1517. /// <summary>
  1518. /// 删除结果图片按钮
  1519. /// </summary>
  1520. /// <param name="sender"></param>
  1521. /// <param name="e"></param>
  1522. private void button7_Click(object sender, EventArgs e)
  1523. {
  1524. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1525. {
  1526. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1527. if (dr == DialogResult.OK)
  1528. {
  1529. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1530. {
  1531. string tableName = this.listView2.SelectedItems[i].Name;
  1532. foreach (DataTable dt in resultTableList)
  1533. {
  1534. if (dt.TableName.Equals(tableName))
  1535. {
  1536. resultTableList.Remove(dt);
  1537. break;
  1538. }
  1539. }
  1540. if (bitDic.ContainsKey(tableName))
  1541. bitDic.Remove(tableName);
  1542. foreach (ExportProjectModel model in this.tempDataModel)
  1543. {
  1544. if (model.tagName.Equals(tableName))
  1545. {
  1546. this.tempDataModel.Remove(model);
  1547. break;
  1548. }
  1549. }
  1550. }
  1551. foreach (ListViewItem item in this.listView2.Items)
  1552. {
  1553. if (item.Selected)
  1554. this.listView2.Items.Remove(item);
  1555. }
  1556. RefreshDataGridView2();
  1557. }
  1558. }
  1559. }
  1560. /// <summary>
  1561. /// 生成报告按钮
  1562. /// </summary>
  1563. /// <param name="sender"></param>
  1564. /// <param name="e"></param>
  1565. private void button8_Click(object sender, EventArgs e)
  1566. {
  1567. if (dataGridView2.Rows.Count == 0)
  1568. {
  1569. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  1570. return;
  1571. }
  1572. if (this.checkBox1.Checked)
  1573. this.button1.PerformClick();
  1574. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.savePath))
  1575. //if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1576. {
  1577. //获取word书签与excel单元格的关系,以字典方式存储
  1578. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1579. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1580. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1581. {
  1582. foreach (mic_module_infos info in mic_module_infos)
  1583. {
  1584. tagInfos.Add(info.tag_name, info.cell_position);
  1585. }
  1586. }
  1587. //分析结果
  1588. List<List<string>> analysisContent = new List<List<string>>();
  1589. List<string> contentHead = new List<string>();
  1590. contentHead.Add("图片");
  1591. contentHead.Add("平均直径/um");
  1592. contentHead.Add("最大直径/um");
  1593. contentHead.Add("平均面积/um²");
  1594. contentHead.Add("最大面积/um²");
  1595. contentHead.Add("颗粒间平均距离/um");
  1596. contentHead.Add("级别");
  1597. analysisContent.Add(contentHead);
  1598. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1599. {
  1600. List<string> content = new List<string>();
  1601. content.Add(item.Cells[0].Value.ToString());
  1602. content.Add(item.Cells[1].Value.ToString());
  1603. content.Add(item.Cells[2].Value.ToString());
  1604. content.Add(item.Cells[3].Value.ToString());
  1605. content.Add(item.Cells[4].Value.ToString());
  1606. content.Add(item.Cells[5].Value.ToString());
  1607. content.Add(item.Cells[6].Value.ToString());
  1608. analysisContent.Add(content);
  1609. }
  1610. analysisContent.Add(new List<string>() { "\r" });
  1611. //图片
  1612. bitList = new List<Bitmap>();
  1613. if (this.showAll)
  1614. {
  1615. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1616. {
  1617. bitList.Add(kv.Value[0]);
  1618. bitList.Add(kv.Value[1]);
  1619. }
  1620. }
  1621. else
  1622. {
  1623. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1624. {
  1625. foreach (ListViewItem item in this.listView2.SelectedItems)
  1626. {
  1627. if (bitDic.ContainsKey(item.Name))
  1628. {
  1629. bitList.Add(bitDic[item.Name][0]);
  1630. bitList.Add(bitDic[item.Name][1]);
  1631. }
  1632. }
  1633. }
  1634. }
  1635. this.appWorkspace.CreateAnalysisReportBearingSteal(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1636. }
  1637. else
  1638. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1639. }
  1640. /// <summary>
  1641. /// 导出结果按钮
  1642. /// </summary>
  1643. /// <param name="sender"></param>
  1644. /// <param name="e"></param>
  1645. private void button9_Click(object sender, EventArgs e)
  1646. {
  1647. if (this.dataGridView2.Rows.Count > 0)
  1648. {
  1649. SaveFileDialog exe = new SaveFileDialog();
  1650. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1651. exe.FilterIndex = 0;
  1652. exe.RestoreDirectory = true;
  1653. //exe.CreatePrompt = true;
  1654. exe.Title = "Export Excel File";
  1655. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1656. exe.FileName = "高碳铬轴承钢带状500倍" + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1657. DialogResult dr = exe.ShowDialog();
  1658. if (dr != DialogResult.OK)
  1659. return;
  1660. DataTable dtb = new DataTable();
  1661. dtb.Columns.Add("图片");
  1662. dtb.Columns.Add("平均直径/um");
  1663. dtb.Columns.Add("最大直径/um");
  1664. dtb.Columns.Add("平均面积/um²");
  1665. dtb.Columns.Add("最大面积/um²");
  1666. dtb.Columns.Add("颗粒间平均距离/um");
  1667. dtb.Columns.Add("级别");
  1668. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  1669. {
  1670. DataRow dataRow = dtb.NewRow();
  1671. dataRow["图片"] = this.dataGridView2.Rows[i].Cells[0].Value;
  1672. dataRow["平均直径/um"] = this.dataGridView2.Rows[i].Cells[1].Value;
  1673. dataRow["最大直径/um"] = this.dataGridView2.Rows[i].Cells[2].Value;
  1674. dataRow["平均面积/um²"] = this.dataGridView2.Rows[i].Cells[3].Value;
  1675. dataRow["最大面积/um²"] = this.dataGridView2.Rows[i].Cells[4].Value;
  1676. dataRow["颗粒间平均距离/um"] = this.dataGridView2.Rows[i].Cells[5].Value;
  1677. dataRow["级别"] = this.dataGridView2.Rows[i].Cells[6].Value;
  1678. dtb.Rows.Add(dataRow);
  1679. }
  1680. DataTable dtb1 = new DataTable();
  1681. dtb1.Columns.Add("图片");
  1682. dtb1.Columns.Add("平均直径/um");
  1683. dtb1.Columns.Add("最大直径/um");
  1684. dtb1.Columns.Add("平均面积/um²");
  1685. dtb1.Columns.Add("最大面积/um²");
  1686. dtb1.Columns.Add("颗粒间平均距离/um");
  1687. dtb1.Columns.Add("级别");
  1688. List<DataTable> list = new List<DataTable>();
  1689. list.Add(dtb);
  1690. list.Add(dtb1);
  1691. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1692. }
  1693. else
  1694. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  1695. }
  1696. /// <summary>
  1697. /// 图像索引切换选中事件
  1698. /// </summary>
  1699. /// <param name="sender"></param>
  1700. /// <param name="e"></param>
  1701. //int sum;//判断是否二值过
  1702. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1703. {
  1704. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1705. {
  1706. //获取标尺-微米
  1707. unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1708. GetListParamModel();
  1709. //sum = 0;
  1710. this.dataGridView1.Rows.Clear();
  1711. if (this.documentWorkspace.PhaseModels.Count > 1)
  1712. this.documentWorkspace.PhaseModels.Remove(this.documentWorkspace.PhaseModels[1]);
  1713. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
  1714. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  1715. //二值化集成5
  1716. binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.imageMat.Clone(), this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]);
  1717. //Document document = Document.FromImageMat(imageMat/* //待测试.Clone()*/);
  1718. //this.documentWorkspace.Document = document;
  1719. this.documentWorkspace.Visible = true;
  1720. this.commonControlButtons.Visible = true;
  1721. changeColor = false;
  1722. isFirstSwitch = false;
  1723. #region 0811修改
  1724. GetPoints(imageMat);
  1725. #endregion
  1726. ReloadDebrisSelection();
  1727. }
  1728. }
  1729. /// <summary>
  1730. /// 分析结果列表选择切换
  1731. /// </summary>
  1732. /// <param name="sender"></param>
  1733. /// <param name="e"></param>
  1734. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  1735. {
  1736. if (this.showAll)
  1737. return;
  1738. RefreshDataGridView2();
  1739. }
  1740. /// <summary>
  1741. /// 小数数字框值改变
  1742. /// </summary>
  1743. /// <param name="sender"></param>
  1744. /// <param name="e"></param>
  1745. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1746. {
  1747. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  1748. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  1749. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  1750. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  1751. RefreshDataGridView1();
  1752. RefreshDataGridView2();
  1753. }
  1754. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  1755. {
  1756. if (this.checkBox4.Checked == true)
  1757. {
  1758. this.checkBox3.Checked = false;
  1759. this.label1.Visible = false;
  1760. this.numericUpDown2.Visible = false;
  1761. rate = 0.0;
  1762. }
  1763. if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
  1764. return;
  1765. ReloadDebrisSelection();
  1766. this.documentWorkspace.Refresh();
  1767. }
  1768. /// <summary>
  1769. /// 是否筛选
  1770. /// </summary>
  1771. /// <param name="sender"></param>
  1772. /// <param name="e"></param>
  1773. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  1774. {
  1775. if (this.checkBox3.Checked == true)
  1776. {
  1777. this.checkBox4.Checked = false;
  1778. this.label1.Visible = true;
  1779. this.numericUpDown2.Visible = true;
  1780. rate = (double)numericUpDown2.Value;
  1781. }
  1782. if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
  1783. return;
  1784. ReloadDebrisSelection();
  1785. this.documentWorkspace.Refresh();
  1786. }
  1787. /// <summary>
  1788. /// 二值处理
  1789. /// </summary>
  1790. /// <param name="colorOneStart"></param>
  1791. /// <param name="colorOneEnd"></param>
  1792. /// <param name="phaseColor"></param>
  1793. /// <returns></returns>
  1794. private unsafe Mat Binarization(int colorOneStart, int colorOneEnd, Color phaseColor)
  1795. {
  1796. Mat srcGray;
  1797. if (mat.Type() == MatType.CV_8UC1)
  1798. srcGray = mat;
  1799. else
  1800. srcGray = mat.CvtColor(ColorConversionCodes.BGR2GRAY);
  1801. Mat src = new Mat(mat.Rows, mat.Cols, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  1802. int index0 = 0;
  1803. byte* ptr0 = (byte*)mat.Data;
  1804. int index1 = 0;
  1805. byte* ptr1 = (byte*)srcGray.Data;
  1806. int index2 = 0;
  1807. byte* ptr2 = (byte*)src.Data;
  1808. for (int o = 0; o < srcGray.Height; o++)
  1809. {
  1810. for (int p = 0; p < srcGray.Width; p++)
  1811. {
  1812. index0 = (int)((mat.Step() * o) + (p * 4));
  1813. index1 = (int)((srcGray.Step() * o) + (p * 1));
  1814. index2 = (int)((src.Step() * o) + (p * 4));
  1815. if (ptr1[index1] >= colorOneStart && ptr1[index1] <= colorOneEnd)
  1816. {
  1817. ptr2[index2] = phaseColor.B;
  1818. ptr2[index2 + 1] = phaseColor.G;
  1819. ptr2[index2 + 2] = phaseColor.R;
  1820. ptr2[index2 + 3] = 255;
  1821. }
  1822. }
  1823. }
  1824. return src;
  1825. }
  1826. /// <summary>
  1827. /// 刷新二值效果
  1828. /// </summary>
  1829. //private void ReLoadBinarization()
  1830. //{
  1831. // if (this.documentWorkspace.CompositionSurface == null)
  1832. // return;
  1833. // if (bcBinaryChecked())
  1834. // {
  1835. // ReloadDebrisSelection();
  1836. // }
  1837. // else
  1838. // {
  1839. // this.documentWorkspace.PhaseModels[0].mat = null;
  1840. // //phaseModel.choise = false;
  1841. // isFirstSwitch = false;
  1842. // this.dataGridView1.Rows.Clear();
  1843. // }
  1844. // this.documentWorkspace.Refresh();
  1845. //}
  1846. DataTable dtDataGridView1 = null;
  1847. DataTable dtResult = null;
  1848. AppCommon appCommon = new AppCommon();
  1849. /// <summary>
  1850. /// 刷新颗粒筛选效果
  1851. /// </summary>
  1852. private void ReloadDebrisSelection()
  1853. {
  1854. if (this.documentWorkspace != null || this.documentWorkspace.PhaseModels[0].mat != null)
  1855. {
  1856. this.dataGridView1.Rows.Clear();
  1857. dtDataGridView1 = new DataTable();
  1858. Mat temp = new Mat();//中间变量
  1859. Mat resultImg = imageMat.Clone();//DLL处理后得结果
  1860. //DLL部分处理
  1861. BearingSteelProcessor CP = new BearingSteelProcessor();
  1862. #region 0811修改
  1863. if (AllFields.Length < 1)
  1864. {
  1865. return;
  1866. }
  1867. CP.clear();
  1868. foreach (var cnt in AllFields)
  1869. {
  1870. CP.addParticle(cnt);
  1871. }
  1872. #endregion
  1873. CP.draw(rate,unitLength);
  1874. double distance = (double)Math.Round(CP.getAllDistance() * 100) / 100;
  1875. double avgarea = (double)Math.Round(CP.getAvgArea() * 100) / 100;
  1876. double maxarea = (double)Math.Round(CP.getMaxArea() * 100) / 100;
  1877. double avgdim = (double)Math.Round(CP.getAvgDim() * 100) / 100;
  1878. double maxdim = (double)Math.Round(CP.getMaxDim() * 100) / 100;
  1879. double level = (double)Math.Round(CP.getLevel() * 100) / 100;
  1880. this.dataGridView1.Rows.Add(avgdim, maxdim, avgarea, maxarea, distance, level);
  1881. List<IEnumerable<OpenCvSharp.Point>> particles = new List<IEnumerable<OpenCvSharp.Point>>();
  1882. IEnumerable<OpenCvSharp.Point> Contour;
  1883. for (int i = 0; i < CP.getParticleCount(); i++)
  1884. {
  1885. Contour = CP.getParticleContour(i);
  1886. particles.Add(Contour);
  1887. }
  1888. AllFieldsTemp.Clear();
  1889. AllFieldsTemp.AddRange(particles);
  1890. Cv2.DrawContours(resultImg, particles, -1, new Scalar(0, 0, 255, 255), -1);
  1891. //防止结果图为RGB,进行转换,转换成RGBA
  1892. Mat resultImg_a = new Mat();
  1893. Cv2.CvtColor(resultImg, resultImg_a, ColorConversionCodes.BGR2BGRA);
  1894. this.documentWorkspace.PhaseModels[0].mat = resultImg;
  1895. this.documentWorkspace.PhaseModels[0].choise = true;
  1896. resultMat = resultImg_a;
  1897. this.documentWorkspace.Refresh();
  1898. //数据结果保存
  1899. dtDataGridView1 = appCommon.ResultDataSaving(dataGridView1);
  1900. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1901. string tag = this.imageList1.Images.Keys[this.listView1.FocusedItem.Index];
  1902. //分析数据保存
  1903. dtResult = appCommon.AnalysisDataSaving(dataGridView1, imgName, tag);
  1904. if (dtDataGridView1.Rows.Count > 0)
  1905. {
  1906. RefreshDataGridView1();
  1907. }
  1908. if (bcOriginChecked())
  1909. {
  1910. appCommon.DisplayData(this.dataGridView1, false);
  1911. }
  1912. }
  1913. }
  1914. /// <summary>
  1915. /// 有效颗粒筛选-默认是碳化物面积占外接圆得30%
  1916. /// </summary>
  1917. /// <param name="sender"></param>
  1918. /// <param name="e"></param>
  1919. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  1920. {
  1921. rate = (double)this.numericUpDown2.Value;
  1922. if (this.checkBox3.Checked )
  1923. ReloadDebrisSelection();
  1924. }
  1925. /// <summary>
  1926. /// 导出项目到项目工程
  1927. /// </summary>
  1928. /// <param name="sender"></param>
  1929. /// <param name="e"></param>
  1930. private void button3_Click(object sender, EventArgs e)
  1931. {
  1932. try
  1933. {
  1934. if (dataGridView2.Rows.Count == 0)
  1935. {
  1936. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  1937. return;
  1938. }
  1939. if (this.analyzeSettingModel == null)
  1940. {
  1941. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1942. return;
  1943. }
  1944. //获取项目工程内的文件夹路径
  1945. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.HighSpeedSteelCarbonBlock.Text", this.analyzeSettingModel.savePath);
  1946. if (item != null)
  1947. {
  1948. //向文件夹内保存图片和报告
  1949. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1950. {
  1951. //获取word书签与excel单元格的关系,以字典方式存储
  1952. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1953. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1954. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1955. {
  1956. foreach (mic_module_infos info in mic_module_infos)
  1957. {
  1958. tagInfos.Add(info.tag_name, info.cell_position);
  1959. }
  1960. }
  1961. //分析结果
  1962. List<List<string>> analysisContent = new List<List<string>>();
  1963. List<string> contentHead = new List<string>();
  1964. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  1965. contentHead.Add(PdnResources.GetString("Menu.view.text"));
  1966. contentHead.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
  1967. contentHead.Add(PdnResources.GetString("Menu.sizeed.text"));
  1968. contentHead.Add(PdnResources.GetString("Menu.levdel.Text"));
  1969. analysisContent.Add(contentHead);
  1970. foreach (DataGridViewRow rowItem in this.dataGridView2.Rows)
  1971. {
  1972. List<string> content = new List<string>();
  1973. content.Add(rowItem.Cells[0].Value.ToString());
  1974. content.Add(rowItem.Cells[1].Value.ToString());
  1975. content.Add(rowItem.Cells[2].Value.ToString());
  1976. content.Add(rowItem.Cells[3].Value.ToString());
  1977. content.Add(rowItem.Cells[4].Value.ToString());
  1978. analysisContent.Add(content);
  1979. }
  1980. analysisContent.Add(new List<string>() { "\r" });
  1981. //图片
  1982. bitList = new List<Bitmap>();
  1983. if (this.showAll)
  1984. {
  1985. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1986. {
  1987. bitList.Add(kv.Value[0]);
  1988. bitList.Add(kv.Value[1]);
  1989. }
  1990. }
  1991. else
  1992. {
  1993. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1994. {
  1995. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  1996. {
  1997. if (bitDic.ContainsKey(rowItem.Name))
  1998. {
  1999. bitList.Add(bitDic[rowItem.Name][0]);
  2000. bitList.Add(bitDic[rowItem.Name][1]);
  2001. }
  2002. }
  2003. }
  2004. }
  2005. //中间数据
  2006. if (!this.showAll)
  2007. {
  2008. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2009. {
  2010. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2011. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2012. {
  2013. foreach (ExportProjectModel model in this.tempDataModel)
  2014. {
  2015. if (model.tagName.Equals(rowItem.Name))
  2016. {
  2017. ExportProjectModel tempModel = new ExportProjectModel();
  2018. tempModel.tagName = model.tagName;
  2019. tempModel.picName = model.picName;
  2020. tempModel.dataList = model.dataList;
  2021. exportModel.Add(tempModel);
  2022. break;
  2023. }
  2024. }
  2025. }
  2026. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
  2027. }
  2028. }
  2029. else
  2030. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
  2031. }
  2032. else
  2033. {
  2034. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2035. return;
  2036. }
  2037. //保存项目信息到数据库
  2038. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2039. }
  2040. }
  2041. catch (Exception)
  2042. {
  2043. }
  2044. }
  2045. #region 参数保存及提取
  2046. /// <summary>
  2047. /// 保存参数的key,value和type
  2048. /// </summary>
  2049. /// <param name="param_key"></param>
  2050. /// <param name="param_value"></param>
  2051. /// <param name="param_type"></param>
  2052. private void saveParamValue(string param_key, string param_value, int param_type)
  2053. {
  2054. bool foundItem = false;
  2055. if (!this.eachData.ContainsKey(GetImgKey()))
  2056. {
  2057. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  2058. analysisItem.menuId = this.menuId;
  2059. analysisItem.param_key = param_key;
  2060. analysisItem.param_type = param_type;
  2061. analysisItem.param_value = param_value;
  2062. analysisItem.setValue();
  2063. analysisItem.ListParam = new List<GrainSizeAnalysisModel>();
  2064. analysisItem.ListParam.Add(analysisItem);
  2065. this.eachData.Add(GetImgKey(), analysisItem);
  2066. }
  2067. foreach (var item in this.eachData[GetImgKey()].ListParam)
  2068. {
  2069. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  2070. {
  2071. item.param_value = param_value;
  2072. item.setValue();
  2073. foundItem = true;
  2074. break;
  2075. }
  2076. }
  2077. if (!foundItem)
  2078. {
  2079. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  2080. analysisItem.menuId = this.menuId;
  2081. analysisItem.param_key = param_key;
  2082. analysisItem.param_type = param_type;
  2083. analysisItem.param_value = param_value;
  2084. analysisItem.setValue();
  2085. this.eachData[GetImgKey()].ListParam.Add(analysisItem);
  2086. }
  2087. }
  2088. /// <summary>
  2089. /// 保存界面中的参数到model
  2090. /// </summary>
  2091. private void saveDialogParamValues()
  2092. {
  2093. saveParamValue(ParamKey_Report, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置
  2094. saveParamValue(ParamKey_Screen, checkBox3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//筛选
  2095. //saveParamValue(ParamKey_ScreenMin, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最小值
  2096. //saveParamValue(ParamKey_ScreenMax, numericUpDown5 != null ? numericUpDown5.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最大值
  2097. saveParamValue(ParamKey_MaxColour, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//最大色
  2098. saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
  2099. }
  2100. /// <summary>
  2101. /// 获取保存的参数
  2102. /// </summary>
  2103. private void GetListParamModel()
  2104. {
  2105. if (this.eachData.ContainsKey(GetImgKey()) && this.eachData[GetImgKey()] != null)
  2106. {
  2107. for (int i = 0; i < this.eachData[GetImgKey()].ListParam.Count; i++)
  2108. {
  2109. switch (this.eachData[GetImgKey()].ListParam[i].param_key)
  2110. {
  2111. case ParamKey_Report:
  2112. checkBox1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2113. break;
  2114. case ParamKey_Screen:
  2115. checkBox3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2116. break;
  2117. case ParamKey_ScreenMin:
  2118. areaMin = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2119. break;
  2120. case ParamKey_ScreenMax:
  2121. areaMax = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2122. break;
  2123. case ParamKey_MaxColour:
  2124. panel2.BackColor = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value);
  2125. break;
  2126. case ParamKey_DecimalPlace:
  2127. numericUpDown1.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2128. break;
  2129. }
  2130. }
  2131. }
  2132. }
  2133. /// <summary>
  2134. /// 获取XML保存的参数
  2135. /// </summary>
  2136. private void GetXmlParameter()
  2137. {
  2138. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  2139. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  2140. for (int i = 0; i < listView1.Items.Count; i++)
  2141. {
  2142. if (this.eachData.ContainsKey(listView1.Items[i].Index.ToString()))
  2143. {
  2144. this.eachData[listView1.Items[i].Index.ToString()] = analysisModelXml.cloneListParamModel(this.menuId);
  2145. }
  2146. else
  2147. {
  2148. this.eachData.Add(listView1.Items[i].Index.ToString(), analysisModelXml.cloneListParamModel(this.menuId));
  2149. }
  2150. }
  2151. foreach (var item in this.eachData[GetImgKey()].ListParam)
  2152. item.setValue();
  2153. }
  2154. /// <summary>
  2155. /// 保存参数,防止没有图片
  2156. /// </summary>
  2157. private void NullKey()
  2158. {
  2159. GrainSizeAnalysisModel grainsizeanalysismodel = new GrainSizeAnalysisModel();
  2160. grainsizeanalysismodel.ListParam = new List<GrainSizeAnalysisModel>();
  2161. this.eachData.Add("null", grainsizeanalysismodel);
  2162. }
  2163. private string GetImgKey()
  2164. {
  2165. string key = this.listView1.FocusedItem != null ? this.listView1.FocusedItem.Index.ToString() : "null";
  2166. return key;
  2167. }
  2168. #endregion
  2169. //按钮-应用全部
  2170. private void button5_Click(object sender, EventArgs e)
  2171. {
  2172. if (this.listView1.FocusedItem == null)
  2173. {
  2174. return;
  2175. }
  2176. binaryClass.saveParams();
  2177. binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[int.Parse(GetImgKey())]);
  2178. saveDialogParamValues();
  2179. GrainSizeAnalysisModel data = new GrainSizeAnalysisModel();
  2180. if (eachData.ContainsKey(GetImgKey()))
  2181. {
  2182. data = eachData[GetImgKey()];
  2183. }
  2184. for (int i = 0; i < listView1.Items.Count; i++)
  2185. {
  2186. eachData[i.ToString()] = data.cloneListParamModel(this.menuId);
  2187. this.listView1.EnsureVisible(i);
  2188. this.listView1.Items[i].Focused = true;
  2189. this.listView1.Items[i].Selected = true;
  2190. }
  2191. }
  2192. private bool blSaveAll = false;
  2193. //按钮-保存全部
  2194. private void button4_Click(object sender, EventArgs e)
  2195. {
  2196. if (this.listView1.FocusedItem == null)
  2197. {
  2198. return;
  2199. }
  2200. if (eachData.Count - 1 != listView1.Items.Count)
  2201. {
  2202. MessageBox.Show("请先点击应用全部!");
  2203. return;
  2204. }
  2205. saveDialogParamValues();
  2206. int current = int.Parse(GetImgKey());
  2207. for (int i = 0; i < listView1.Items.Count; i++)
  2208. {
  2209. this.listView1.EnsureVisible(i);
  2210. this.listView1.Items[i].Focused = true;
  2211. this.listView1.Items[i].Selected = true;
  2212. this.button2.PerformClick();
  2213. blSaveAll = true;
  2214. }
  2215. this.listView1.EnsureVisible(current);
  2216. this.listView1.Items[current].Focused = true;
  2217. this.listView1.Items[current].Selected = true;
  2218. blSaveAll = false;
  2219. }
  2220. private void listView1_MouseDown(object sender, MouseEventArgs e)
  2221. {
  2222. if (this.listView1.FocusedItem != null)
  2223. saveDialogParamValues();
  2224. }
  2225. #region [脚本相关]
  2226. private void getValue(string key, object value)
  2227. {
  2228. switch (key)
  2229. {
  2230. //是否筛选
  2231. case "parameter1":
  2232. checkBox3.Checked = Convert.ToBoolean(value);
  2233. break;
  2234. case "parameter5":
  2235. int val1 = (int)value;
  2236. break;
  2237. case "parameter6":
  2238. int val2 = (int)value;
  2239. panel2.BackColor = Color.FromArgb(val2);
  2240. break;
  2241. case "OpenWhileExportReport":
  2242. checkBox1.Checked = Convert.ToBoolean(value);
  2243. break;
  2244. case "CalculatorDecimalDigits":
  2245. numericUpDown1.Value = Convert.ToDecimal(value);
  2246. break;
  2247. case "ExportResults":
  2248. isExportResults = Convert.ToBoolean(value);
  2249. break;
  2250. case "ExportReports":
  2251. isExportReports = Convert.ToBoolean(value);
  2252. break;
  2253. case "ExportProjects":
  2254. isExportProjects = Convert.ToBoolean(value);
  2255. break;
  2256. }
  2257. }
  2258. private void startScriptAutomaticAction()
  2259. {
  2260. this.button5.PerformClick();
  2261. this.button4.PerformClick();
  2262. this.button6.Text = "全部显示";
  2263. this.showAll = true;
  2264. RefreshDataGridView2();
  2265. if (isExportResults)//导出结果
  2266. this.button8.PerformClick();
  2267. if (isExportReports)//生成报告
  2268. this.button9.PerformClick();
  2269. if (isExportProjects)//导出项目
  2270. this.button3.PerformClick();
  2271. this.appWorkspace.ScriptAutomatic = false;
  2272. this.Close();
  2273. }
  2274. #endregion
  2275. #region [脚本录制]
  2276. private void getScriptRecording()
  2277. {
  2278. string className = InvariantData.path_Action + ".Action" + menuId;
  2279. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  2280. List<Args> args = param.Lists;
  2281. foreach (var item in args)
  2282. {
  2283. item.value = setScriptRecording(item.key);
  2284. }
  2285. //找出二值相关参数 进行赋值
  2286. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  2287. foreach (var item in isNullList)
  2288. {
  2289. item.value = binaryClass.setScriptRecording(item.key);
  2290. }
  2291. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  2292. }
  2293. private object setScriptRecording(string key)
  2294. {
  2295. object value = null;
  2296. switch (key)
  2297. {
  2298. case "parameter1":
  2299. value = checkBox3.Checked;
  2300. break;
  2301. //case "parameter2":
  2302. // value = trackBar2.Value;
  2303. // break;
  2304. //case "parameter3":
  2305. // value = trackBar4.Value;
  2306. // break;
  2307. case "parameter6":
  2308. value = panel2.BackColor.ToArgb();
  2309. break;
  2310. case "OpenWhileExportReport":
  2311. value = checkBox1.Checked;
  2312. break;
  2313. case "CalculatorDecimalDigits":
  2314. value = numericUpDown1.Value;
  2315. break;
  2316. case "ExportResults":
  2317. value = isExportResults;
  2318. break;
  2319. case "ExportReports":
  2320. value = isExportReports;
  2321. break;
  2322. case "ExportProjects":
  2323. value = isExportProjects;
  2324. break;
  2325. }
  2326. return value;
  2327. }
  2328. #endregion
  2329. /// <summary>
  2330. /// 刷新数据展示表
  2331. /// </summary>
  2332. private void RefreshDataGridView1()
  2333. {
  2334. this.dataGridView1.Rows.Clear();
  2335. if (dtDataGridView1 != null && dtDataGridView1.Rows.Count > 0)
  2336. {
  2337. dataGridView1.Rows.Add(dtDataGridView1.Rows.Count);//增加同等数量的行数
  2338. int i = 0;
  2339. foreach (DataRow row in dtDataGridView1.Rows)//逐个读取单元格的内容;
  2340. {
  2341. DataGridViewRow r1 = dataGridView1.Rows[i];
  2342. r1.Cells[0].Value = row.RowState.ToString();
  2343. for (int j = 0; j < dtDataGridView1.Columns.Count; j++)
  2344. {
  2345. r1.Cells[j].Value = row[j].ToString();
  2346. }
  2347. i++;
  2348. }
  2349. }
  2350. }
  2351. #region 颗粒编辑0811新增,1021新增区域删除
  2352. #region 图像绘制与刷新
  2353. /// <summary>
  2354. /// 预览刷新
  2355. /// </summary>
  2356. /// <param name="sender"></param>
  2357. /// <param name="e"></param>
  2358. private void Panel_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  2359. {
  2360. //
  2361. // 以下是计算绘制图片的位置和大小并绘制图片
  2362. //
  2363. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2364. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  2365. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  2366. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  2367. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  2368. //
  2369. // 以下是绘制网格、标注、测量、视场等开始
  2370. //
  2371. e.Graphics.TranslateTransform(x, y);
  2372. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2373. Draw(e.Graphics);
  2374. //e.Graphics.DrawLines(new Pen(this.panel1.BackColor, Convert.ToInt32(this.txt_LeftLineWeight.Text)), list.ToArray());
  2375. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2376. e.Graphics.TranslateTransform(-x, -y);
  2377. }
  2378. /// <summary>
  2379. /// 绘制
  2380. /// </summary>
  2381. private void Draw(Graphics graphics)
  2382. {
  2383. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  2384. Pen addPen = new Pen(Color.FromArgb(0, 0, 255), 2);//添加颗粒画笔
  2385. Pen delPen = new Pen(Color.FromArgb(0, 255, 0), 2);//删除颗粒画笔
  2386. //画已经添加颗粒
  2387. if (addPointsList.Count > 0)
  2388. {
  2389. for (int i = 0; i < addPointsList.Count; i++)
  2390. {
  2391. graphics.DrawLines(addPen, addPointsList[i].ToArray());
  2392. }
  2393. }
  2394. if (delPointsList.Count > 0)
  2395. {
  2396. for (int i = 0; i < delPointsList.Count; i++)
  2397. {
  2398. graphics.DrawLines(delPen, delPointsList[i].ToArray());
  2399. }
  2400. }
  2401. if (star != null && end != null && star != end)
  2402. {
  2403. Rectangle rectangle = CreatRectangle(star, end);
  2404. graphics.DrawRectangle(delPen, rectangle);
  2405. }
  2406. if (delRegionPointsList.Count > 0)
  2407. {
  2408. foreach (var item in delRegionPointsList)
  2409. {
  2410. if (item.Count > 0)
  2411. {
  2412. for (int i = 0; i < item.Count; i++)
  2413. {
  2414. if (item[i].Count > 2)
  2415. graphics.DrawLines(delPen, item[i].ToArray());
  2416. }
  2417. }
  2418. }
  2419. }
  2420. //画正在添加颗粒
  2421. if (addPoints.Count > 0)
  2422. {
  2423. graphics.DrawLines(addPen, addPoints.ToArray());
  2424. }
  2425. addPen.Dispose();
  2426. delPen.Dispose();
  2427. }
  2428. //获取矩形
  2429. private Rectangle CreatRectangle(PointF p1, PointF p2)
  2430. {
  2431. Rectangle rectangleF = new Rectangle();
  2432. if (p1.X > p2.X)
  2433. rectangleF.X = (int)p2.X;
  2434. else
  2435. rectangleF.X = (int)p1.X;
  2436. if (p1.Y > p2.Y)
  2437. rectangleF.Y = (int)p2.Y;
  2438. else
  2439. rectangleF.Y = (int)p1.Y;
  2440. rectangleF.Width = (int)Math.Abs(p2.X - p1.X);
  2441. rectangleF.Height = (int)Math.Abs(p2.Y - p1.Y);
  2442. return new Rectangle(rectangleF.X, rectangleF.Y, rectangleF.Width, rectangleF.Height);
  2443. }
  2444. #endregion
  2445. #region 鼠标事件
  2446. /// <summary>
  2447. /// 移动
  2448. /// </summary>
  2449. /// <param name="sender"></param>
  2450. /// <param name="e"></param>
  2451. private void onMouseMove(object sender, MouseEventArgs e)
  2452. {
  2453. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  2454. if (e.Button == MouseButtons.Left)
  2455. {
  2456. switch (DrawType)
  2457. {
  2458. case 1:
  2459. addPoints.Add(movePoint);
  2460. break;
  2461. case 2:
  2462. break;
  2463. case 3:
  2464. end = movePoint;
  2465. break;
  2466. }
  2467. }
  2468. this.documentWorkspace.Refresh();
  2469. }
  2470. /// <summary>
  2471. /// 鼠标抬起
  2472. /// </summary>
  2473. /// <param name="sender"></param>
  2474. /// <param name="e"></param>
  2475. private void OnMouseUp(object sender, MouseEventArgs e)
  2476. {
  2477. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  2478. if (e.Button == MouseButtons.Left)
  2479. {
  2480. switch (DrawType)
  2481. {
  2482. case 1:
  2483. if (addPoints.Count > 3)
  2484. {
  2485. List<PointF> points = new List<PointF>();
  2486. points.AddRange(addPoints);
  2487. addPointsList.Add(points);
  2488. HisOperate.Add(1);
  2489. }
  2490. addPoints.Clear();
  2491. if (!checkBox2.Checked)
  2492. DrawType = 0;
  2493. break;
  2494. case 3:
  2495. if (star != end)
  2496. {
  2497. DelRegionPoints();
  2498. HisOperate.Add(3);
  2499. star = new PointF();
  2500. end = new PointF();
  2501. }
  2502. if (!checkBox2.Checked)
  2503. DrawType = 0;
  2504. break;
  2505. }
  2506. }
  2507. this.documentWorkspace.Refresh();
  2508. }
  2509. /// <summary>
  2510. /// 鼠标按下
  2511. /// </summary>
  2512. /// <param name="drawArea"></param>
  2513. /// <param name="e"></param>
  2514. private void OnMouseDown(object sender, MouseEventArgs e)
  2515. {
  2516. //禁止画黑色矩形
  2517. this.documentWorkspace.DrawRectangleFlag = false;
  2518. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  2519. if (e.Button == MouseButtons.Left)
  2520. {
  2521. switch (DrawType)
  2522. {
  2523. case 1:
  2524. addPoints.Add(downPoint);
  2525. break;
  2526. case 2:
  2527. DelPoints(downPoint);
  2528. if (!checkBox2.Checked)
  2529. DrawType = 0;
  2530. break;
  2531. case 3:
  2532. star = end = downPoint;
  2533. break;
  2534. }
  2535. }
  2536. }
  2537. #endregion
  2538. #region 按钮事件
  2539. /// <summary>
  2540. /// 添加按钮
  2541. /// </summary>
  2542. private void AddClick(object sender, EventArgs e)
  2543. {
  2544. DrawType = 1;
  2545. }
  2546. /// <summary>
  2547. /// 删除按钮
  2548. /// </summary>
  2549. private void DelClick(object sender, EventArgs e)
  2550. {
  2551. DrawType = 2;
  2552. }
  2553. /// <summary>
  2554. /// 撤销按钮
  2555. /// </summary>
  2556. private void RedoClick(object sender, EventArgs e)
  2557. {
  2558. if (HisOperate.Count > 0)
  2559. {
  2560. int op = HisOperate.Last();
  2561. switch (op)
  2562. {
  2563. case 1:
  2564. addPointsList.RemoveAt(addPointsList.Count - 1);
  2565. break;
  2566. case 2:
  2567. delPointsList.RemoveAt(delPointsList.Count - 1);
  2568. break;
  2569. case 3:
  2570. delRegionPointsList.RemoveAt(delRegionPointsList.Count - 1);
  2571. break;
  2572. }
  2573. HisOperate.RemoveAt(HisOperate.Count - 1);
  2574. this.documentWorkspace.Refresh();
  2575. }
  2576. }
  2577. /// <summary>
  2578. /// 应用按钮
  2579. /// </summary>
  2580. private void ApplyClick(object sender, EventArgs e)
  2581. {
  2582. if (addPointsList.Count > 0)
  2583. {
  2584. List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
  2585. foreach (var item in addPointsList)
  2586. {
  2587. List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
  2588. item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
  2589. points.Add(plistAdd);
  2590. }
  2591. currentMat.DrawContours(points, -1, new Scalar(255), -1);
  2592. addPointsList.Clear();
  2593. }
  2594. if (delPointsList.Count > 0)
  2595. {
  2596. List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
  2597. foreach (var item in delPointsList)
  2598. {
  2599. List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
  2600. item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
  2601. points.Add(plistAdd);
  2602. }
  2603. currentMat.DrawContours(points, -1, new Scalar(0), -1);
  2604. delPointsList.Clear();
  2605. }
  2606. if (delRegionPointsList.Count > 0)
  2607. {
  2608. List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
  2609. for (int i = 0; i < delRegionPointsList.Count; i++)
  2610. {
  2611. foreach (var item in delRegionPointsList[i])
  2612. {
  2613. List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
  2614. item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
  2615. points.Add(plistAdd);
  2616. }
  2617. }
  2618. currentMat.DrawContours(points, -1, new Scalar(0), -1);
  2619. delRegionPointsList.Clear();
  2620. }
  2621. HisOperate.Clear();
  2622. DrawType = 0;
  2623. GetPoints(currentMat);
  2624. ReloadDebrisSelection();
  2625. }
  2626. /// <summary>
  2627. /// 区域删除按钮
  2628. /// </summary>
  2629. private void DelRegionClick(object sender, EventArgs e)
  2630. {
  2631. DrawType = 3;
  2632. }
  2633. #endregion
  2634. #region 图形处理
  2635. /// <summary>
  2636. /// 获取图像所有轮廓
  2637. /// </summary>
  2638. /// <param name="source"></param>
  2639. private unsafe void GetPoints(Mat source)
  2640. {
  2641. Mat srcGray;
  2642. if (source.Type() == MatType.CV_8UC1)
  2643. {
  2644. srcGray = source;
  2645. }
  2646. else
  2647. {
  2648. srcGray = source.CvtColor(ColorConversionCodes.BGR2GRAY);
  2649. //修改-20221114
  2650. if (binaryValue == -1)
  2651. {
  2652. Cv2.Threshold(srcGray, srcGray, 0, 255, ThresholdTypes.Otsu);
  2653. }
  2654. else
  2655. {
  2656. Cv2.Threshold(srcGray, srcGray, binaryValue, 255, ThresholdTypes.Binary);
  2657. }
  2658. }
  2659. currentMat = srcGray.Clone();
  2660. OpenCvSharp.Point[][] contours = new OpenCvSharp.Point[][] { };
  2661. HierarchyIndex[] hierarchyIndex = new HierarchyIndex[] { };
  2662. //轮廓
  2663. Cv2.FindContours(srcGray, out contours, out hierarchyIndex, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2664. AllFields = contours;
  2665. }
  2666. private void DelPoints(PointF pointF)
  2667. {
  2668. OpenCvSharp.Point2f p1 = new OpenCvSharp.Point2f(pointF.X, pointF.Y);
  2669. bool del = false;
  2670. for (int i = 0; i < AllFields.Count(); i++)
  2671. {
  2672. double d = Cv2.PointPolygonTest(AllFields[i], p1, false);
  2673. if (d >= 0)
  2674. {
  2675. List<PointF> pointFs = new List<PointF>();
  2676. AllFields[i].ToList().ForEach(p => pointFs.Add(new PointF(p.X, p.Y)));
  2677. delPointsList.Add(pointFs);
  2678. del = true;
  2679. break;
  2680. }
  2681. }
  2682. if (del)
  2683. {
  2684. HisOperate.Add(2);
  2685. this.documentWorkspace.Refresh();
  2686. }
  2687. }
  2688. private void DelRegionPoints()
  2689. {
  2690. List<List<PointF>> delList = new List<List<PointF>>();
  2691. for (int i = 0; i < AllFieldsTemp.Count(); i++)
  2692. {
  2693. for (int j = 0; j < AllFieldsTemp[i].Count(); j++)
  2694. {
  2695. OpenCvSharp.Point point = AllFieldsTemp[i].ElementAt(j);
  2696. if (point.X >= star.X && point.X <= end.X && point.Y >= star.Y && point.Y <= end.Y)
  2697. {
  2698. List<PointF> pointFs = new List<PointF>();
  2699. AllFieldsTemp[i].ToList().ForEach(p => pointFs.Add(new PointF(p.X, p.Y)));
  2700. delList.Add(pointFs);
  2701. break;
  2702. }
  2703. }
  2704. }
  2705. delRegionPointsList.Add(delList);
  2706. this.documentWorkspace.Refresh();
  2707. }
  2708. #endregion
  2709. #endregion
  2710. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  2711. {
  2712. if (checkBox5.Checked == true)
  2713. {
  2714. this.documentWorkspace.PhaseModels[0].mat = imageMat;
  2715. this.documentWorkspace.PhaseModels[0].choise = true;
  2716. this.documentWorkspace.Refresh();
  2717. }
  2718. else
  2719. {
  2720. this.documentWorkspace.PhaseModels[0].mat = resultMat;
  2721. this.documentWorkspace.PhaseModels[0].choise = true;
  2722. this.documentWorkspace.Refresh();
  2723. }
  2724. }
  2725. /// <summary>
  2726. /// 20221114-添加二值阈值
  2727. /// </summary>
  2728. /// <param name="sender"></param>
  2729. /// <param name="e"></param>
  2730. private void checkBox7_CheckedChanged(object sender, EventArgs e)
  2731. {
  2732. if (this.checkBox7.Checked == true)
  2733. {
  2734. this.checkBox7.Checked = true;
  2735. this.checkBox6.Checked = false;
  2736. this.label2.Visible = false;
  2737. this.numericUpDown3.Visible = false;
  2738. binaryValue = -1;
  2739. }
  2740. if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
  2741. return;
  2742. GetPoints(imageMat);
  2743. ReloadDebrisSelection();
  2744. this.documentWorkspace.Refresh();
  2745. }
  2746. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  2747. {
  2748. if (this.checkBox6.Checked == true)
  2749. {
  2750. this.checkBox6.Checked = true;
  2751. this.label2.Visible = true;
  2752. this.numericUpDown3.Visible = true;
  2753. binaryValue = (int)numericUpDown3.Value;
  2754. this.checkBox7.Checked = false;
  2755. }
  2756. if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
  2757. return;
  2758. GetPoints(imageMat);
  2759. ReloadDebrisSelection();
  2760. this.documentWorkspace.Refresh();
  2761. }
  2762. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  2763. {
  2764. binaryValue = (int)numericUpDown3.Value;
  2765. if (this.checkBox6.Checked )
  2766. {
  2767. GetPoints(imageMat);
  2768. ReloadDebrisSelection();
  2769. }
  2770. }
  2771. }
  2772. public class BearingSteelProcessor
  2773. {
  2774. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2775. private static extern IntPtr createBearingSteelProcessor();
  2776. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2777. private static extern void run(IntPtr pClassObject, IntPtr img, double rate, bool isFillHole,double unitlength);
  2778. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2779. private static extern void draw(IntPtr pClassObject, double rate,double unitlength);
  2780. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2781. private static extern int getParticleCount(IntPtr pClassObject);
  2782. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2783. private static extern int getParticleId(IntPtr pClassObject, int idx);
  2784. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2785. private static extern double getParticleArea(IntPtr pClassObject, int idx);
  2786. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2787. private static extern double getParticleFeretmax(IntPtr pClassObject, int idx);
  2788. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2789. private static extern double getParticleFeretmin(IntPtr pClassObject, int idx);
  2790. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2791. private static extern void getParticleContour(IntPtr pClassObject, IntPtr Contour, int idx);
  2792. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2793. private static extern void addParticle(IntPtr pClassObject, IntPtr Contour);
  2794. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2795. private static extern double getAllDistance(IntPtr pClassObject);
  2796. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2797. private static extern double getAvgArea(IntPtr pClassObject);
  2798. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2799. private static extern double getMaxArea(IntPtr pClassObject);
  2800. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2801. private static extern double getAvgDim(IntPtr pClassObject);
  2802. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2803. private static extern double getMaxDim(IntPtr pClassObject);
  2804. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2805. private static extern double getLevel(IntPtr pClassObject);
  2806. [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
  2807. private static extern void clear(IntPtr pClassObject);
  2808. private IntPtr p_Object;
  2809. public BearingSteelProcessor()
  2810. {
  2811. this.p_Object = createBearingSteelProcessor();
  2812. }
  2813. /// <summary>
  2814. /// 颗粒检测
  2815. /// </summary>
  2816. public void run(Mat img, double rate, bool isFillHole,double unitlength)
  2817. {
  2818. run(this.p_Object, img.CvPtr, rate, isFillHole, unitlength);
  2819. }
  2820. public void draw(double rate, double unitlength)
  2821. {
  2822. draw(this.p_Object, rate, unitlength);
  2823. }
  2824. public int getParticleCount()
  2825. {
  2826. return getParticleCount(this.p_Object);
  2827. }
  2828. public int getParticleId(int idx)
  2829. {
  2830. return getParticleId(this.p_Object, idx);
  2831. }
  2832. public double getParticleArea(int idx)
  2833. {
  2834. return getParticleArea(this.p_Object, idx);
  2835. }
  2836. public double getParticleFeretmax(int idx)
  2837. {
  2838. return getParticleFeretmax(this.p_Object, idx);
  2839. }
  2840. public double getParticleFeretmin(int idx)
  2841. {
  2842. return getParticleFeretmin(this.p_Object, idx);
  2843. }
  2844. public double getAllDistance()
  2845. {
  2846. return getAllDistance(this.p_Object);
  2847. }
  2848. public double getAvgArea()
  2849. {
  2850. return getAvgArea(this.p_Object);
  2851. }
  2852. public double getMaxArea()
  2853. {
  2854. return getMaxArea(this.p_Object);
  2855. }
  2856. public double getAvgDim()
  2857. {
  2858. return getAvgDim(this.p_Object);
  2859. }
  2860. public double getMaxDim()
  2861. {
  2862. return getMaxDim(this.p_Object);
  2863. }
  2864. public double getLevel()
  2865. {
  2866. return getLevel(this.p_Object);
  2867. }
  2868. public void clear()
  2869. {
  2870. clear(this.p_Object);
  2871. }
  2872. public IEnumerable<OpenCvSharp.Point> getParticleContour(int idx)
  2873. {
  2874. var Contour = new VectorOfPoint();
  2875. getParticleContour(this.p_Object, Contour.CvPtr, idx);
  2876. return Contour.ToArray().AsEnumerable();
  2877. }
  2878. public IEnumerable<IEnumerable<OpenCvSharp.Point>> getParticles()
  2879. {
  2880. IEnumerable<IEnumerable<OpenCvSharp.Point>> particles = new List<IEnumerable<OpenCvSharp.Point>>();
  2881. for (int i = 0; i < getParticleCount(); i++)
  2882. {
  2883. IEnumerable<OpenCvSharp.Point> Contour;
  2884. Contour = getParticleContour(i);
  2885. particles.Append(Contour);
  2886. }
  2887. return particles;
  2888. }
  2889. public void addParticle(IEnumerable<OpenCvSharp.Point> cnts)
  2890. {
  2891. var contour = new VectorOfPoint(cnts);
  2892. addParticle(this.p_Object, contour.CvPtr);
  2893. }
  2894. public void addParticle(OpenCvSharp.Point[] cnts)
  2895. {
  2896. var contour = new VectorOfPoint(cnts);
  2897. addParticle(this.p_Object, contour.CvPtr);
  2898. }
  2899. }
  2900. }