DebrisSelectionDialog.cs 208 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149
  1. using Metis.GeneralAnalysis;
  2. using Metis.ParameterSet;
  3. using OpenCvSharp;
  4. using OpenCvSharp.Extensions;
  5. using PaintDotNet.Annotation;
  6. using PaintDotNet.Annotation.Enum;
  7. using PaintDotNet.Base;
  8. using PaintDotNet.Base.CommTool;
  9. using PaintDotNet.Base.Enum;
  10. using PaintDotNet.Base.Functionodel;
  11. using PaintDotNet.Base.SettingModel;
  12. using PaintDotNet.CustomControl;
  13. using PaintDotNet.Data.Param;
  14. using PaintDotNet.DbOpreate.DbBll;
  15. using PaintDotNet.DbOpreate.DbModel;
  16. using PaintDotNet.Instrument;
  17. using System;
  18. using System.Collections;
  19. using System.Collections.Generic;
  20. using System.ComponentModel;
  21. using System.Data;
  22. using System.Drawing;
  23. using System.IO;
  24. using System.Linq;
  25. using System.Windows.Forms;
  26. using static PaintDotNet.Base.Functionodel.DebrisSelectionModel;
  27. namespace PaintDotNet.GeneralAnalysis
  28. {
  29. /// <summary>
  30. /// 颗粒统计
  31. /// </summary>
  32. internal class DebrisSelectionDialog : PdnBaseForm
  33. {
  34. #region 基础控件
  35. private Button button1;
  36. private CheckBox checkBox1;
  37. private Button button2;
  38. private GroupBox groupBox2;
  39. private ListView listView1;
  40. private GroupBox groupBox3;
  41. private GroupBox groupBox4;
  42. private GroupBox groupBox6;
  43. private GroupBox groupBox8;
  44. private DataGridView dataGridView1;
  45. private GroupBox groupBox9;
  46. private Button button6;
  47. private Button button7;
  48. private ListView listView2;
  49. private DataGridView dataGridView2;
  50. private Button button9;
  51. private Button button8;
  52. private NumericUpDown numericUpDown1;
  53. private Label label8;
  54. private Label label9;
  55. private ImageList imageList1;
  56. private IContainer components;
  57. private GroupBox groupBox1;
  58. private Label label1;
  59. private Button button3;
  60. private Panel panel1;
  61. private ComboBox comboBox1;
  62. private CheckBox checkBox3;
  63. private CheckBox checkBox2;
  64. private CheckBox checkBox4;
  65. private Label label2;
  66. private NumericUpDown numericUpDown2;
  67. private Label label3;
  68. private Button button4;
  69. private ComboBox comboBox3;
  70. private Label label4;
  71. private DataGridView dataGridView3;
  72. private Label label5;
  73. private Label label6;
  74. private NumericUpDown numericUpDown3;
  75. private Button button5;
  76. private Label label7;
  77. private Panel panel3;
  78. private Button btn_SetUp;
  79. private ComboBox comboBox2;
  80. private Panel panel2;
  81. private void InitializeLanguageText()
  82. {
  83. this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  84. this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  85. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  86. this.Text = PdnResources.GetString("Menu.GeneralAnalysis.ParticleStatistics.Text");
  87. this.checkBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Displaynumber.text");
  88. this.groupBox8.Text = PdnResources.GetString("Menu.Statisticalresultspreview.text");
  89. this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");
  90. this.button3.Text = PdnResources.GetString("Menu.Exportproject.text");
  91. this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  92. this.button9.Text = PdnResources.GetString("Menu.Exportresults.text");
  93. this.label4.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Statisticalselection.text") + ":";
  94. this.label1.Text = PdnResources.GetString("Menu.color.text") + ":";
  95. this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
  96. this.groupBox6.Text = PdnResources.GetString("Menu.displaysetting.text");
  97. this.label6.Text = PdnResources.GetString("Menu.Chooseacolor.Text") + ":";
  98. this.label5.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  99. this.label3.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Articledata.text");
  100. this.checkBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Beforeshowing.text");
  101. this.label2.Text = PdnResources.GetString("Menu.Font.text") + ":";
  102. this.checkBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Displayparams.text");
  103. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  104. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  105. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  106. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  107. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  108. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  109. this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Selectstatistics.text");
  110. this.button5.Text = PdnResources.GetString("Menu.Started.text");
  111. this.button4.Text = PdnResources.GetString("Menu.Setting.Text");
  112. }
  113. private void InitializeComponent()
  114. {
  115. this.components = new System.ComponentModel.Container();
  116. this.groupBox1 = new System.Windows.Forms.GroupBox();
  117. this.btn_SetUp = new System.Windows.Forms.Button();
  118. this.button2 = new System.Windows.Forms.Button();
  119. this.checkBox1 = new System.Windows.Forms.CheckBox();
  120. this.button1 = new System.Windows.Forms.Button();
  121. this.groupBox2 = new System.Windows.Forms.GroupBox();
  122. this.listView1 = new System.Windows.Forms.ListView();
  123. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  124. this.groupBox3 = new System.Windows.Forms.GroupBox();
  125. this.groupBox4 = new System.Windows.Forms.GroupBox();
  126. this.button5 = new System.Windows.Forms.Button();
  127. this.dataGridView3 = new System.Windows.Forms.DataGridView();
  128. this.button4 = new System.Windows.Forms.Button();
  129. this.comboBox3 = new System.Windows.Forms.ComboBox();
  130. this.label4 = new System.Windows.Forms.Label();
  131. this.label1 = new System.Windows.Forms.Label();
  132. this.panel1 = new System.Windows.Forms.Panel();
  133. this.groupBox6 = new System.Windows.Forms.GroupBox();
  134. this.comboBox2 = new System.Windows.Forms.ComboBox();
  135. this.label7 = new System.Windows.Forms.Label();
  136. this.panel3 = new System.Windows.Forms.Panel();
  137. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  138. this.panel2 = new System.Windows.Forms.Panel();
  139. this.label6 = new System.Windows.Forms.Label();
  140. this.label5 = new System.Windows.Forms.Label();
  141. this.label3 = new System.Windows.Forms.Label();
  142. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  143. this.checkBox4 = new System.Windows.Forms.CheckBox();
  144. this.label2 = new System.Windows.Forms.Label();
  145. this.comboBox1 = new System.Windows.Forms.ComboBox();
  146. this.checkBox3 = new System.Windows.Forms.CheckBox();
  147. this.checkBox2 = new System.Windows.Forms.CheckBox();
  148. this.groupBox8 = new System.Windows.Forms.GroupBox();
  149. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  150. this.groupBox9 = new System.Windows.Forms.GroupBox();
  151. this.button3 = new System.Windows.Forms.Button();
  152. this.label9 = new System.Windows.Forms.Label();
  153. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  154. this.label8 = new System.Windows.Forms.Label();
  155. this.button9 = new System.Windows.Forms.Button();
  156. this.button8 = new System.Windows.Forms.Button();
  157. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  158. this.listView2 = new System.Windows.Forms.ListView();
  159. this.button7 = new System.Windows.Forms.Button();
  160. this.button6 = new System.Windows.Forms.Button();
  161. this.groupBox1.SuspendLayout();
  162. this.groupBox2.SuspendLayout();
  163. this.groupBox4.SuspendLayout();
  164. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit();
  165. this.groupBox6.SuspendLayout();
  166. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  167. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  168. this.groupBox8.SuspendLayout();
  169. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  170. this.groupBox9.SuspendLayout();
  171. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  172. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  173. this.SuspendLayout();
  174. //
  175. // groupBox1
  176. //
  177. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  178. | System.Windows.Forms.AnchorStyles.Right)));
  179. this.groupBox1.Controls.Add(this.btn_SetUp);
  180. this.groupBox1.Controls.Add(this.button2);
  181. this.groupBox1.Controls.Add(this.checkBox1);
  182. this.groupBox1.Controls.Add(this.button1);
  183. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  184. this.groupBox1.Name = "groupBox1";
  185. this.groupBox1.Size = new System.Drawing.Size(1081, 50);
  186. this.groupBox1.TabIndex = 1;
  187. this.groupBox1.TabStop = false;
  188. this.groupBox1.Text = "操作";
  189. //
  190. // btn_SetUp
  191. //
  192. this.btn_SetUp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  193. | System.Windows.Forms.AnchorStyles.Right)));
  194. this.btn_SetUp.Location = new System.Drawing.Point(895, 14);
  195. this.btn_SetUp.Name = "btn_SetUp";
  196. this.btn_SetUp.Size = new System.Drawing.Size(84, 30);
  197. this.btn_SetUp.TabIndex = 3;
  198. this.btn_SetUp.Text = "卡规设置";
  199. this.btn_SetUp.UseVisualStyleBackColor = true;
  200. this.btn_SetUp.Click += new System.EventHandler(this.btn_SetUp_Click);
  201. //
  202. // button2
  203. //
  204. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  205. | System.Windows.Forms.AnchorStyles.Right)));
  206. this.button2.Enabled = false;
  207. this.button2.Location = new System.Drawing.Point(985, 14);
  208. this.button2.Name = "button2";
  209. this.button2.Size = new System.Drawing.Size(84, 30);
  210. this.button2.TabIndex = 2;
  211. this.button2.Text = "保存结果";
  212. this.button2.UseVisualStyleBackColor = true;
  213. this.button2.Click += new System.EventHandler(this.button2_Click);
  214. //
  215. // checkBox1
  216. //
  217. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  218. | System.Windows.Forms.AnchorStyles.Left)));
  219. this.checkBox1.AutoSize = true;
  220. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  221. this.checkBox1.Name = "checkBox1";
  222. this.checkBox1.Size = new System.Drawing.Size(132, 16);
  223. this.checkBox1.TabIndex = 1;
  224. this.checkBox1.Text = "生成报告时打开设置";
  225. this.checkBox1.UseVisualStyleBackColor = true;
  226. //
  227. // button1
  228. //
  229. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  230. | System.Windows.Forms.AnchorStyles.Left)));
  231. this.button1.Location = new System.Drawing.Point(15, 14);
  232. this.button1.Name = "button1";
  233. this.button1.Size = new System.Drawing.Size(84, 30);
  234. this.button1.TabIndex = 0;
  235. this.button1.Text = "设置";
  236. this.button1.UseVisualStyleBackColor = true;
  237. this.button1.Click += new System.EventHandler(this.button1_Click);
  238. //
  239. // groupBox2
  240. //
  241. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  242. | System.Windows.Forms.AnchorStyles.Left)));
  243. this.groupBox2.Controls.Add(this.listView1);
  244. this.groupBox2.Location = new System.Drawing.Point(14, 60);
  245. this.groupBox2.Name = "groupBox2";
  246. this.groupBox2.Size = new System.Drawing.Size(135, 497);
  247. this.groupBox2.TabIndex = 2;
  248. this.groupBox2.TabStop = false;
  249. this.groupBox2.Text = "图像索引";
  250. //
  251. // listView1
  252. //
  253. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  254. | System.Windows.Forms.AnchorStyles.Left)
  255. | System.Windows.Forms.AnchorStyles.Right)));
  256. this.listView1.HideSelection = false;
  257. this.listView1.LargeImageList = this.imageList1;
  258. this.listView1.Location = new System.Drawing.Point(5, 17);
  259. this.listView1.MultiSelect = false;
  260. this.listView1.Name = "listView1";
  261. this.listView1.Size = new System.Drawing.Size(124, 474);
  262. this.listView1.TabIndex = 0;
  263. this.listView1.UseCompatibleStateImageBehavior = false;
  264. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  265. this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
  266. //
  267. // imageList1
  268. //
  269. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  270. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  271. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  272. //
  273. // groupBox3
  274. //
  275. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  276. | System.Windows.Forms.AnchorStyles.Left)
  277. | System.Windows.Forms.AnchorStyles.Right)));
  278. this.groupBox3.Location = new System.Drawing.Point(515, 60);
  279. this.groupBox3.Name = "groupBox3";
  280. this.groupBox3.Size = new System.Drawing.Size(580, 496);
  281. this.groupBox3.TabIndex = 3;
  282. this.groupBox3.TabStop = false;
  283. this.groupBox3.Text = "预览";
  284. //
  285. // groupBox4
  286. //
  287. this.groupBox4.Controls.Add(this.button5);
  288. this.groupBox4.Controls.Add(this.dataGridView3);
  289. this.groupBox4.Controls.Add(this.button4);
  290. this.groupBox4.Controls.Add(this.comboBox3);
  291. this.groupBox4.Controls.Add(this.label4);
  292. this.groupBox4.Location = new System.Drawing.Point(156, 60);
  293. this.groupBox4.Name = "groupBox4";
  294. this.groupBox4.Size = new System.Drawing.Size(353, 179);
  295. this.groupBox4.TabIndex = 4;
  296. this.groupBox4.TabStop = false;
  297. this.groupBox4.Text = "选择统计数据";
  298. //
  299. // button5
  300. //
  301. this.button5.Enabled = false;
  302. this.button5.Location = new System.Drawing.Point(291, 15);
  303. this.button5.Name = "button5";
  304. this.button5.Size = new System.Drawing.Size(55, 23);
  305. this.button5.TabIndex = 4;
  306. this.button5.Tag = "1";
  307. this.button5.UseVisualStyleBackColor = true;
  308. this.button5.Click += new System.EventHandler(this.button5_Click);
  309. //
  310. // dataGridView3
  311. //
  312. this.dataGridView3.AllowUserToAddRows = false;
  313. this.dataGridView3.AllowUserToDeleteRows = false;
  314. this.dataGridView3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  315. | System.Windows.Forms.AnchorStyles.Right)));
  316. this.dataGridView3.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  317. this.dataGridView3.BackgroundColor = System.Drawing.Color.White;
  318. this.dataGridView3.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  319. this.dataGridView3.Location = new System.Drawing.Point(6, 42);
  320. this.dataGridView3.MultiSelect = false;
  321. this.dataGridView3.Name = "dataGridView3";
  322. this.dataGridView3.RowHeadersVisible = false;
  323. this.dataGridView3.RowTemplate.Height = 23;
  324. this.dataGridView3.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  325. this.dataGridView3.Size = new System.Drawing.Size(340, 131);
  326. this.dataGridView3.TabIndex = 3;
  327. this.dataGridView3.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridView3_CurrentCellDirtyStateChanged);
  328. //
  329. // button4
  330. //
  331. this.button4.Enabled = false;
  332. this.button4.Location = new System.Drawing.Point(230, 15);
  333. this.button4.Name = "button4";
  334. this.button4.Size = new System.Drawing.Size(55, 23);
  335. this.button4.TabIndex = 2;
  336. this.button4.UseVisualStyleBackColor = true;
  337. this.button4.Click += new System.EventHandler(this.button4_Click);
  338. //
  339. // comboBox3
  340. //
  341. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  342. this.comboBox3.FormattingEnabled = true;
  343. this.comboBox3.Location = new System.Drawing.Point(79, 16);
  344. this.comboBox3.Name = "comboBox3";
  345. this.comboBox3.Size = new System.Drawing.Size(141, 20);
  346. this.comboBox3.TabIndex = 1;
  347. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  348. //
  349. // label4
  350. //
  351. this.label4.AutoSize = true;
  352. this.label4.Location = new System.Drawing.Point(18, 20);
  353. this.label4.Name = "label4";
  354. this.label4.Size = new System.Drawing.Size(0, 12);
  355. this.label4.TabIndex = 0;
  356. //
  357. // label1
  358. //
  359. this.label1.AutoSize = true;
  360. this.label1.Location = new System.Drawing.Point(240, 20);
  361. this.label1.Name = "label1";
  362. this.label1.Size = new System.Drawing.Size(0, 12);
  363. this.label1.TabIndex = 7;
  364. //
  365. // panel1
  366. //
  367. this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  368. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  369. this.panel1.Location = new System.Drawing.Point(293, 16);
  370. this.panel1.Name = "panel1";
  371. this.panel1.Size = new System.Drawing.Size(44, 18);
  372. this.panel1.TabIndex = 5;
  373. this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged);
  374. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  375. //
  376. // groupBox6
  377. //
  378. this.groupBox6.Controls.Add(this.comboBox2);
  379. this.groupBox6.Controls.Add(this.label7);
  380. this.groupBox6.Controls.Add(this.panel3);
  381. this.groupBox6.Controls.Add(this.numericUpDown3);
  382. this.groupBox6.Controls.Add(this.panel2);
  383. this.groupBox6.Controls.Add(this.label6);
  384. this.groupBox6.Controls.Add(this.label5);
  385. this.groupBox6.Controls.Add(this.label3);
  386. this.groupBox6.Controls.Add(this.numericUpDown2);
  387. this.groupBox6.Controls.Add(this.checkBox4);
  388. this.groupBox6.Controls.Add(this.label2);
  389. this.groupBox6.Controls.Add(this.comboBox1);
  390. this.groupBox6.Controls.Add(this.checkBox3);
  391. this.groupBox6.Controls.Add(this.checkBox2);
  392. this.groupBox6.Controls.Add(this.label1);
  393. this.groupBox6.Controls.Add(this.panel1);
  394. this.groupBox6.Location = new System.Drawing.Point(154, 241);
  395. this.groupBox6.Name = "groupBox6";
  396. this.groupBox6.Size = new System.Drawing.Size(354, 132);
  397. this.groupBox6.TabIndex = 6;
  398. this.groupBox6.TabStop = false;
  399. this.groupBox6.Text = "显示设置";
  400. //
  401. // comboBox2
  402. //
  403. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  404. this.comboBox2.FormattingEnabled = true;
  405. this.comboBox2.Location = new System.Drawing.Point(94, 76);
  406. this.comboBox2.Name = "comboBox2";
  407. this.comboBox2.Size = new System.Drawing.Size(79, 20);
  408. this.comboBox2.TabIndex = 23;
  409. //
  410. // label7
  411. //
  412. this.label7.AutoSize = true;
  413. this.label7.Location = new System.Drawing.Point(240, 49);
  414. this.label7.Name = "label7";
  415. this.label7.Size = new System.Drawing.Size(0, 12);
  416. this.label7.TabIndex = 22;
  417. //
  418. // panel3
  419. //
  420. this.panel3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  421. this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  422. this.panel3.Location = new System.Drawing.Point(293, 45);
  423. this.panel3.Name = "panel3";
  424. this.panel3.Size = new System.Drawing.Size(44, 18);
  425. this.panel3.TabIndex = 21;
  426. this.panel3.BackColorChanged += new System.EventHandler(this.panel3_BackColorChanged);
  427. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  428. //
  429. // numericUpDown3
  430. //
  431. this.numericUpDown3.Location = new System.Drawing.Point(293, 77);
  432. this.numericUpDown3.Maximum = new decimal(new int[] {
  433. 49000,
  434. 0,
  435. 0,
  436. 0});
  437. this.numericUpDown3.Minimum = new decimal(new int[] {
  438. 1,
  439. 0,
  440. 0,
  441. 0});
  442. this.numericUpDown3.Name = "numericUpDown3";
  443. this.numericUpDown3.Size = new System.Drawing.Size(44, 21);
  444. this.numericUpDown3.TabIndex = 20;
  445. this.numericUpDown3.Value = new decimal(new int[] {
  446. 15,
  447. 0,
  448. 0,
  449. 0});
  450. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  451. //
  452. // panel2
  453. //
  454. this.panel2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  455. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  456. this.panel2.Location = new System.Drawing.Point(293, 108);
  457. this.panel2.Name = "panel2";
  458. this.panel2.Size = new System.Drawing.Size(44, 18);
  459. this.panel2.TabIndex = 19;
  460. this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
  461. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  462. //
  463. // label6
  464. //
  465. this.label6.AutoSize = true;
  466. this.label6.Location = new System.Drawing.Point(234, 111);
  467. this.label6.Name = "label6";
  468. this.label6.Size = new System.Drawing.Size(0, 12);
  469. this.label6.TabIndex = 18;
  470. //
  471. // label5
  472. //
  473. this.label5.AutoSize = true;
  474. this.label5.Location = new System.Drawing.Point(240, 81);
  475. this.label5.Name = "label5";
  476. this.label5.Size = new System.Drawing.Size(0, 12);
  477. this.label5.TabIndex = 16;
  478. //
  479. // label3
  480. //
  481. this.label3.AutoSize = true;
  482. this.label3.Location = new System.Drawing.Point(162, 111);
  483. this.label3.Name = "label3";
  484. this.label3.Size = new System.Drawing.Size(0, 12);
  485. this.label3.TabIndex = 15;
  486. //
  487. // numericUpDown2
  488. //
  489. this.numericUpDown2.Location = new System.Drawing.Point(94, 105);
  490. this.numericUpDown2.Maximum = new decimal(new int[] {
  491. 99999,
  492. 0,
  493. 0,
  494. 0});
  495. this.numericUpDown2.Minimum = new decimal(new int[] {
  496. 1,
  497. 0,
  498. 0,
  499. 0});
  500. this.numericUpDown2.Name = "numericUpDown2";
  501. this.numericUpDown2.Size = new System.Drawing.Size(55, 21);
  502. this.numericUpDown2.TabIndex = 14;
  503. this.numericUpDown2.Value = new decimal(new int[] {
  504. 10,
  505. 0,
  506. 0,
  507. 0});
  508. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  509. //
  510. // checkBox4
  511. //
  512. this.checkBox4.AutoSize = true;
  513. this.checkBox4.Location = new System.Drawing.Point(20, 110);
  514. this.checkBox4.Name = "checkBox4";
  515. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  516. this.checkBox4.TabIndex = 13;
  517. this.checkBox4.UseVisualStyleBackColor = true;
  518. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  519. //
  520. // label2
  521. //
  522. this.label2.AutoSize = true;
  523. this.label2.Location = new System.Drawing.Point(37, 81);
  524. this.label2.Name = "label2";
  525. this.label2.Size = new System.Drawing.Size(0, 12);
  526. this.label2.TabIndex = 11;
  527. //
  528. // comboBox1
  529. //
  530. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  531. this.comboBox1.FormattingEnabled = true;
  532. this.comboBox1.Location = new System.Drawing.Point(94, 47);
  533. this.comboBox1.Name = "comboBox1";
  534. this.comboBox1.Size = new System.Drawing.Size(106, 20);
  535. this.comboBox1.TabIndex = 10;
  536. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  537. //
  538. // checkBox3
  539. //
  540. this.checkBox3.AutoSize = true;
  541. this.checkBox3.Location = new System.Drawing.Point(20, 49);
  542. this.checkBox3.Name = "checkBox3";
  543. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  544. this.checkBox3.TabIndex = 9;
  545. this.checkBox3.UseVisualStyleBackColor = true;
  546. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  547. //
  548. // checkBox2
  549. //
  550. this.checkBox2.AutoSize = true;
  551. this.checkBox2.Location = new System.Drawing.Point(20, 20);
  552. this.checkBox2.Name = "checkBox2";
  553. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  554. this.checkBox2.TabIndex = 8;
  555. this.checkBox2.UseVisualStyleBackColor = true;
  556. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  557. //
  558. // groupBox8
  559. //
  560. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  561. | System.Windows.Forms.AnchorStyles.Left)));
  562. this.groupBox8.Controls.Add(this.dataGridView1);
  563. this.groupBox8.Location = new System.Drawing.Point(155, 377);
  564. this.groupBox8.Name = "groupBox8";
  565. this.groupBox8.Size = new System.Drawing.Size(353, 179);
  566. this.groupBox8.TabIndex = 8;
  567. this.groupBox8.TabStop = false;
  568. this.groupBox8.Text = "统计结果预览";
  569. //
  570. // dataGridView1
  571. //
  572. this.dataGridView1.AllowUserToAddRows = false;
  573. this.dataGridView1.AllowUserToDeleteRows = false;
  574. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  575. | System.Windows.Forms.AnchorStyles.Left)
  576. | System.Windows.Forms.AnchorStyles.Right)));
  577. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  578. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  579. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  580. this.dataGridView1.Location = new System.Drawing.Point(7, 21);
  581. this.dataGridView1.MultiSelect = false;
  582. this.dataGridView1.Name = "dataGridView1";
  583. this.dataGridView1.ReadOnly = true;
  584. this.dataGridView1.RowHeadersVisible = false;
  585. this.dataGridView1.RowTemplate.Height = 23;
  586. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  587. this.dataGridView1.Size = new System.Drawing.Size(340, 152);
  588. this.dataGridView1.TabIndex = 0;
  589. this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
  590. //
  591. // groupBox9
  592. //
  593. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  594. | System.Windows.Forms.AnchorStyles.Right)));
  595. this.groupBox9.Controls.Add(this.button3);
  596. this.groupBox9.Controls.Add(this.label9);
  597. this.groupBox9.Controls.Add(this.numericUpDown1);
  598. this.groupBox9.Controls.Add(this.label8);
  599. this.groupBox9.Controls.Add(this.button9);
  600. this.groupBox9.Controls.Add(this.button8);
  601. this.groupBox9.Controls.Add(this.dataGridView2);
  602. this.groupBox9.Controls.Add(this.listView2);
  603. this.groupBox9.Controls.Add(this.button7);
  604. this.groupBox9.Controls.Add(this.button6);
  605. this.groupBox9.Location = new System.Drawing.Point(14, 562);
  606. this.groupBox9.Name = "groupBox9";
  607. this.groupBox9.Size = new System.Drawing.Size(1081, 204);
  608. this.groupBox9.TabIndex = 9;
  609. this.groupBox9.TabStop = false;
  610. this.groupBox9.Text = "分析结果";
  611. //
  612. // button3
  613. //
  614. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  615. this.button3.Location = new System.Drawing.Point(941, 102);
  616. this.button3.Name = "button3";
  617. this.button3.Size = new System.Drawing.Size(128, 26);
  618. this.button3.TabIndex = 10;
  619. this.button3.Text = "导出项目";
  620. this.button3.UseVisualStyleBackColor = true;
  621. this.button3.Click += new System.EventHandler(this.button3_Click);
  622. //
  623. // label9
  624. //
  625. this.label9.AutoSize = true;
  626. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  627. this.label9.Location = new System.Drawing.Point(210, 9);
  628. this.label9.Name = "label9";
  629. this.label9.Size = new System.Drawing.Size(11, 192);
  630. this.label9.TabIndex = 8;
  631. 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|";
  632. //
  633. // numericUpDown1
  634. //
  635. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  636. this.numericUpDown1.Location = new System.Drawing.Point(993, 162);
  637. this.numericUpDown1.Maximum = new decimal(new int[] {
  638. 10,
  639. 0,
  640. 0,
  641. 0});
  642. this.numericUpDown1.Name = "numericUpDown1";
  643. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  644. this.numericUpDown1.TabIndex = 7;
  645. this.numericUpDown1.Value = new decimal(new int[] {
  646. 2,
  647. 0,
  648. 0,
  649. 0});
  650. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  651. //
  652. // label8
  653. //
  654. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  655. this.label8.AutoSize = true;
  656. this.label8.Location = new System.Drawing.Point(957, 167);
  657. this.label8.Name = "label8";
  658. this.label8.Size = new System.Drawing.Size(41, 12);
  659. this.label8.TabIndex = 6;
  660. this.label8.Text = "小数:";
  661. //
  662. // button9
  663. //
  664. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  665. this.button9.Location = new System.Drawing.Point(941, 68);
  666. this.button9.Name = "button9";
  667. this.button9.Size = new System.Drawing.Size(128, 26);
  668. this.button9.TabIndex = 5;
  669. this.button9.Text = "导出结果";
  670. this.button9.UseVisualStyleBackColor = true;
  671. this.button9.Click += new System.EventHandler(this.button9_Click);
  672. //
  673. // button8
  674. //
  675. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  676. this.button8.Location = new System.Drawing.Point(941, 34);
  677. this.button8.Name = "button8";
  678. this.button8.Size = new System.Drawing.Size(128, 26);
  679. this.button8.TabIndex = 4;
  680. this.button8.Text = "生成报告";
  681. this.button8.UseVisualStyleBackColor = true;
  682. this.button8.Click += new System.EventHandler(this.button8_Click);
  683. //
  684. // dataGridView2
  685. //
  686. this.dataGridView2.AllowUserToAddRows = false;
  687. this.dataGridView2.AllowUserToDeleteRows = false;
  688. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  689. | System.Windows.Forms.AnchorStyles.Left)
  690. | System.Windows.Forms.AnchorStyles.Right)));
  691. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  692. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  693. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
  694. this.dataGridView2.Location = new System.Drawing.Point(228, 20);
  695. this.dataGridView2.MultiSelect = false;
  696. this.dataGridView2.Name = "dataGridView2";
  697. this.dataGridView2.ReadOnly = true;
  698. this.dataGridView2.RowHeadersVisible = false;
  699. this.dataGridView2.RowTemplate.Height = 23;
  700. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  701. this.dataGridView2.Size = new System.Drawing.Size(693, 176);
  702. this.dataGridView2.TabIndex = 3;
  703. //
  704. // listView2
  705. //
  706. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  707. | System.Windows.Forms.AnchorStyles.Left)));
  708. this.listView2.HideSelection = false;
  709. this.listView2.Location = new System.Drawing.Point(16, 56);
  710. this.listView2.Name = "listView2";
  711. this.listView2.Size = new System.Drawing.Size(181, 140);
  712. this.listView2.TabIndex = 2;
  713. this.listView2.UseCompatibleStateImageBehavior = false;
  714. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  715. //
  716. // button7
  717. //
  718. this.button7.Location = new System.Drawing.Point(112, 20);
  719. this.button7.Name = "button7";
  720. this.button7.Size = new System.Drawing.Size(85, 26);
  721. this.button7.TabIndex = 1;
  722. this.button7.Text = "删除";
  723. this.button7.UseVisualStyleBackColor = true;
  724. this.button7.Click += new System.EventHandler(this.button7_Click);
  725. //
  726. // button6
  727. //
  728. this.button6.Location = new System.Drawing.Point(16, 20);
  729. this.button6.Name = "button6";
  730. this.button6.Size = new System.Drawing.Size(85, 26);
  731. this.button6.TabIndex = 0;
  732. this.button6.Text = "全部显示";
  733. this.button6.UseVisualStyleBackColor = true;
  734. this.button6.Click += new System.EventHandler(this.button6_Click);
  735. //
  736. // DebrisSelectionDialog
  737. //
  738. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  739. this.ClientSize = new System.Drawing.Size(1107, 771);
  740. this.Controls.Add(this.groupBox9);
  741. this.Controls.Add(this.groupBox8);
  742. this.Controls.Add(this.groupBox6);
  743. this.Controls.Add(this.groupBox4);
  744. this.Controls.Add(this.groupBox3);
  745. this.Controls.Add(this.groupBox2);
  746. this.Controls.Add(this.groupBox1);
  747. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  748. this.Name = "DebrisSelectionDialog";
  749. this.Text = "颗粒统计";
  750. this.Controls.SetChildIndex(this.groupBox1, 0);
  751. this.Controls.SetChildIndex(this.groupBox2, 0);
  752. this.Controls.SetChildIndex(this.groupBox3, 0);
  753. this.Controls.SetChildIndex(this.groupBox4, 0);
  754. this.Controls.SetChildIndex(this.groupBox6, 0);
  755. this.Controls.SetChildIndex(this.groupBox8, 0);
  756. this.Controls.SetChildIndex(this.groupBox9, 0);
  757. this.groupBox1.ResumeLayout(false);
  758. this.groupBox1.PerformLayout();
  759. this.groupBox2.ResumeLayout(false);
  760. this.groupBox4.ResumeLayout(false);
  761. this.groupBox4.PerformLayout();
  762. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit();
  763. this.groupBox6.ResumeLayout(false);
  764. this.groupBox6.PerformLayout();
  765. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  766. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  767. this.groupBox8.ResumeLayout(false);
  768. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  769. this.groupBox9.ResumeLayout(false);
  770. this.groupBox9.PerformLayout();
  771. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  772. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  773. this.ResumeLayout(false);
  774. }
  775. #endregion
  776. private ConfigModel config = Startup.instance.configModel;
  777. /// <summary>
  778. /// 调色板
  779. /// </summary>
  780. PaintDotNet.ColorsForm colorsForm1;
  781. /// <summary>
  782. /// 调色板
  783. /// </summary>
  784. PaintDotNet.ColorsForm colorsForm2;
  785. /// <summary>
  786. /// 调色板
  787. /// </summary>
  788. PaintDotNet.ColorsForm colorsForm3;
  789. /// <summary>
  790. /// 主控件
  791. /// </summary>
  792. private AppWorkspace appWorkspace;
  793. /// <summary>
  794. /// 图像面板
  795. /// </summary>
  796. private DocumentWorkspaceWindow documentWorkspace;
  797. /// <summary>
  798. /// 公共按钮
  799. /// </summary>
  800. private CommonControlButtons commonControlButtons;
  801. /// <summary>
  802. /// 选中图片的mat
  803. /// </summary>
  804. private Mat imageMat;
  805. /// <summary>
  806. /// 计算结果的表格集合
  807. /// </summary>
  808. private List<DataTable> resultTableList = new List<DataTable>();
  809. /// <summary>
  810. /// 保存用于生成报告的图片
  811. /// </summary>
  812. private List<Bitmap> bitList;
  813. /// <summary>
  814. /// 储存点击保存结果后的所有原图与分析图
  815. /// </summary>
  816. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  817. /// <summary>
  818. /// 是否显示全部
  819. /// </summary>
  820. private bool showAll = false;
  821. /// <summary>
  822. /// 当前图片是否有视场
  823. /// </summary>
  824. private bool isHadView = false;
  825. /// <summary>
  826. /// 原图mat-包括视场
  827. /// </summary>
  828. private Mat mat;
  829. /// <summary>
  830. /// 原图的灰度图
  831. /// </summary>
  832. private Mat matGray;
  833. /// <summary>
  834. /// 二值处理后的mat,但是是多通道的
  835. /// </summary>
  836. private Mat binarizationMat;
  837. /// <summary>
  838. /// 原始图片的分割
  839. /// </summary>
  840. private Mat[] mats;
  841. /// <summary>
  842. /// mask
  843. /// </summary>
  844. private Mat hole;
  845. /// <summary>
  846. /// 二值图的灰度图,单通道
  847. /// </summary>
  848. private Mat binarizationMatGray;
  849. /// <summary>
  850. /// 相的集合
  851. /// </summary>
  852. private PhaseModel phaseModel;
  853. /// <summary>
  854. /// 单位标尺
  855. /// </summary>
  856. private double ruleValue = 1;
  857. /// <summary>
  858. /// 颗粒统计的条件
  859. /// </summary>
  860. public DebrisSelectionModel debrisSelectionModel;
  861. /// <summary>
  862. /// 颗粒统计的条件的xml
  863. /// </summary>
  864. public readonly string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\" + "DebrisSelectionModel.xml";
  865. /// <summary>
  866. /// 轮廓数组
  867. /// </summary>
  868. public OpenCvSharp.Point[][] contours;
  869. /// <summary>
  870. /// 轮廓关系
  871. /// </summary>
  872. public HierarchyIndex[] hierarchy;
  873. /// <summary>
  874. /// 轮廓对应的类,以及数据等
  875. /// </summary>
  876. public List<ContoursAndRelatedInfo> list = new List<ContoursAndRelatedInfo>();
  877. /// <summary>
  878. /// 筛选后的结果集合
  879. /// </summary>
  880. public List<ContoursAndRelatedInfo> set;
  881. /// <summary>
  882. /// 筛选的下拉
  883. /// </summary>
  884. public Dictionary<DebrisSelectionParameters, string> listDictionary = new Dictionary<DebrisSelectionParameters, string>();
  885. /// <summary>
  886. /// gridView1选中的行
  887. /// </summary>
  888. public int gridView1SelectIndex = 0;
  889. /// <summary>
  890. /// 主控件选中图片索引
  891. /// </summary>
  892. private int defaultIndex = -1;
  893. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  894. private bool firstShow = true;
  895. private Dictionary<string, GeneralAnalysisModel.DebrisSelectionModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.DebrisSelectionModel>();
  896. private string selectedImg = string.Empty;
  897. private bool isExportResults = false;
  898. private bool isExportReports = false;
  899. private bool isExportProjects = false;
  900. private int menuId;
  901. private string menuName;
  902. /// <summary>
  903. /// 是否脚本运行
  904. /// </summary>
  905. private Boolean initScriptValues = false;
  906. public DebrisSelectionDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  907. {
  908. this.appWorkspace = appWorkspace;
  909. this.menuId = menuItem.MenuId;
  910. this.menuName = menuItem.Text;
  911. InitializeComponent();
  912. InitializeLanguageText();
  913. InitGridHeader();
  914. InitPicList();
  915. InitOtherTools();
  916. InitCommonButtonEvent();
  917. RefreshDebrisComboBox();
  918. SetAnalyzeModelFromXml("Template.Manager.item2.ParticleStatistics");
  919. }
  920. /// <summary>
  921. /// 初始化其他控件
  922. /// </summary>
  923. private void InitOtherTools()
  924. {
  925. //
  926. //初始化图像控件
  927. //
  928. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  929. this.documentWorkspace.Dock = DockStyle.Fill;
  930. this.documentWorkspace.HookMouseEvents();
  931. this.documentWorkspace.AuxiliaryLineEnabled = false;
  932. this.documentWorkspace.Visible = false;
  933. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.NullTool;
  934. this.groupBox3.Controls.Add(documentWorkspace);
  935. //
  936. //初始化操作按钮
  937. //
  938. this.commonControlButtons = new CommonControlButtons();
  939. this.commonControlButtons.Dock = DockStyle.Top;
  940. this.commonControlButtons.Height = 30;
  941. this.commonControlButtons.HideZoomToWindowAndActualSize();
  942. this.groupBox3.Controls.Add(commonControlButtons);
  943. //
  944. //调色板
  945. //
  946. this.colorsForm1 = new ColorsForm();
  947. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  948. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  949. //
  950. //调色板
  951. //
  952. this.colorsForm2 = new ColorsForm();
  953. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  954. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  955. //
  956. //调色板
  957. //
  958. this.colorsForm3 = new ColorsForm();
  959. this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
  960. this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  961. //
  962. //颜色panel给定初始值
  963. //
  964. this.panel1.BackColor = Color.Black;
  965. //
  966. //颜色pane2给定初始值
  967. //
  968. this.panel2.BackColor = Color.Red;
  969. //
  970. //颜色pane3给定初始值
  971. //
  972. this.panel3.BackColor = Color.Green;
  973. //
  974. //绑定字体下拉
  975. //
  976. ArrayList fontsItems = new ArrayList();
  977. System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
  978. foreach (FontFamily fontFamily in fonts.Families)
  979. {
  980. fontsItems.Add(fontFamily.Name);
  981. }
  982. this.comboBox2.DataSource = fontsItems;
  983. this.comboBox2.Text = PdnResources.GetString("Menu.Songtypeface.Text");
  984. ////
  985. ////获取系统标尺-微米
  986. ////
  987. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  988. //
  989. //获取xml存储数据
  990. //
  991. //this.debrisSelectionModel = new DebrisSelectionModel();
  992. ReloadDebrisSelectionFromXml();
  993. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  994. }
  995. /// <summary>
  996. /// 初始化图片列表数据
  997. /// </summary>
  998. public void InitPicList()
  999. {
  1000. //初始化图片列表
  1001. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1002. {
  1003. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1004. this.listView1.Items.Add("", i);
  1005. this.listView1.Items[i].ImageIndex = i;
  1006. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1007. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1008. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1009. {
  1010. defaultIndex = i;
  1011. }
  1012. }
  1013. this.Shown += ShowImgEvent;
  1014. }
  1015. private void ShowImgEvent(object sender, EventArgs e)
  1016. {
  1017. listView1.Focus();
  1018. if (this.defaultIndex != -1)
  1019. {
  1020. this.listView1.Items[defaultIndex].Focused = true;
  1021. this.listView1.Items[defaultIndex].Selected = true;
  1022. //如果是脚本执行,将参数带入
  1023. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  1024. {
  1025. this.initScriptValues = true;//ScriptAutomatic
  1026. //Boolean initScriptValues = true;
  1027. ////在这里反射出对应功能的参数类
  1028. string className = InvariantData.path_Action + ".Action" + menuId;
  1029. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1030. foreach (Args arg in param.Lists)
  1031. {
  1032. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  1033. if (param1.value != null)
  1034. {
  1035. arg.Value = param1.value;
  1036. getValue(arg.key, arg.Value);
  1037. if (arg.choiseList != null && arg.choiseList.Count > 0)
  1038. {
  1039. try
  1040. {
  1041. int index = Convert.ToInt32(arg.value);
  1042. var thisArg = arg.choiseList[index];
  1043. foreach (var item in thisArg.lists)
  1044. {
  1045. Args thisParam = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(item.Key));
  1046. if (thisParam != null)
  1047. {
  1048. item.Value = thisParam.value;
  1049. getValue(item.key, item.Value);
  1050. }
  1051. }
  1052. }
  1053. catch (Exception)
  1054. {
  1055. continue;
  1056. }
  1057. }
  1058. }
  1059. }
  1060. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1061. }
  1062. else
  1063. {//读取上次关闭窗口时保存的参数
  1064. getLastData();
  1065. }
  1066. this.firstShow = false;
  1067. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1068. this.startScriptAutomaticAction();
  1069. }
  1070. }
  1071. /// <summary>
  1072. /// 获取上次操作参数
  1073. /// </summary>
  1074. private void getLastData()
  1075. {
  1076. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1077. if (!System.IO.File.Exists(filePath))
  1078. {
  1079. generalAnalysisModel = new GeneralAnalysisModel();
  1080. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1081. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1082. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1083. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1084. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1085. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1086. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1087. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1088. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1089. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1090. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1091. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1092. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1093. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1094. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1095. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1096. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1097. }
  1098. else
  1099. {
  1100. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1101. if (generalAnalysisModel.DebrisSelectionModels == null)
  1102. {
  1103. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1104. }
  1105. if (generalAnalysisModel.DebrisSelectionModels.hasUsed)
  1106. {
  1107. if (generalAnalysisModel.DebrisSelectionModels.parameter1 != -1 && generalAnalysisModel.DebrisSelectionModels.parameter1 <= comboBox1.Items.Count - 1)
  1108. {
  1109. comboBox3.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter1;
  1110. }
  1111. //foreach (var item in generalAnalysisModel.DebrisSelectionModels.parameter2)
  1112. //{
  1113. // dataGridView3.Rows.Add(item.name, item.analyzingConditions, item.conditionsNum, item.associationCondition);
  1114. //}
  1115. checkBox2.Checked = generalAnalysisModel.DebrisSelectionModels.parameter3;
  1116. panel1.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter4);
  1117. checkBox3.Checked = generalAnalysisModel.DebrisSelectionModels.parameter5;
  1118. if (generalAnalysisModel.DebrisSelectionModels.parameter6 != -1 && generalAnalysisModel.DebrisSelectionModels.parameter6 <= comboBox1.Items.Count - 1)
  1119. {
  1120. comboBox1.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter6;
  1121. }
  1122. panel3.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter7);
  1123. if (generalAnalysisModel.DebrisSelectionModels.parameter8 != -1)
  1124. {
  1125. comboBox2.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter8;
  1126. }
  1127. numericUpDown3.Value = generalAnalysisModel.DebrisSelectionModels.parameter9;
  1128. checkBox4.Checked = generalAnalysisModel.DebrisSelectionModels.parameter10;
  1129. numericUpDown2.Value = generalAnalysisModel.DebrisSelectionModels.parameter11;
  1130. panel2.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter12);
  1131. numericUpDown1.Value = generalAnalysisModel.DebrisSelectionModels.parameter13;
  1132. checkBox1.Checked = generalAnalysisModel.DebrisSelectionModels.parameter14;
  1133. for (int i = 0; i < listView1.Items.Count; i++)
  1134. {
  1135. if (everyImgData.ContainsKey(listView1.Items[i].Name))
  1136. {
  1137. everyImgData[listView1.Items[i].Name] = generalAnalysisModel.DebrisSelectionModels;
  1138. }
  1139. else
  1140. {
  1141. everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.DebrisSelectionModels);
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. /// <summary>
  1148. /// 保存上次操作参数
  1149. /// </summary>
  1150. private void saveLastData(object sender, EventArgs e)
  1151. {
  1152. #region [开启脚本录制]
  1153. if (appWorkspace.startScriptRecording)
  1154. {
  1155. getScriptRecording();
  1156. }
  1157. #endregion
  1158. if (generalAnalysisModel.DebrisSelectionModels == null)
  1159. {
  1160. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1161. }
  1162. generalAnalysisModel.DebrisSelectionModels.hasUsed = true;
  1163. //generalAnalysisModel.DebrisSelectionModels.parameter2.Clear();
  1164. //for (int i = 0;i < dataGridView3.Rows.Count;i++)
  1165. //{
  1166. // var dataList = new GeneralAnalysisModel.DebrisSelectionModel.DataList();
  1167. // dataList.name = dataGridView3.Rows[i].Cells[0].Value.ToString();
  1168. // dataList.analyzingConditions = dataGridView3.Rows[i].Cells[1].Value.ToString();
  1169. // dataList.conditionsNum = dataGridView3.Rows[i].Cells[2].Value.ToString();
  1170. // dataList.associationCondition = dataGridView3.Rows[i].Cells[3].Value.ToString();
  1171. // generalAnalysisModel.DebrisSelectionModels.parameter2.Add(dataList);
  1172. //}
  1173. generalAnalysisModel.DebrisSelectionModels.parameter3 = checkBox2.Checked;
  1174. generalAnalysisModel.DebrisSelectionModels.parameter4 = panel1.BackColor.ToArgb();
  1175. generalAnalysisModel.DebrisSelectionModels.parameter5 = checkBox3.Checked;
  1176. generalAnalysisModel.DebrisSelectionModels.parameter1 = comboBox3.SelectedIndex;
  1177. generalAnalysisModel.DebrisSelectionModels.parameter6 = comboBox1.SelectedIndex;
  1178. generalAnalysisModel.DebrisSelectionModels.parameter8 = comboBox2.SelectedIndex;
  1179. generalAnalysisModel.DebrisSelectionModels.parameter7 = panel3.BackColor.ToArgb();
  1180. generalAnalysisModel.DebrisSelectionModels.parameter9 = (int)numericUpDown3.Value;
  1181. generalAnalysisModel.DebrisSelectionModels.parameter10 = checkBox4.Checked;
  1182. generalAnalysisModel.DebrisSelectionModels.parameter11 = (int)numericUpDown2.Value;
  1183. generalAnalysisModel.DebrisSelectionModels.parameter12 = panel2.BackColor.ToArgb();
  1184. generalAnalysisModel.DebrisSelectionModels.parameter13 = (int)numericUpDown1.Value;
  1185. generalAnalysisModel.DebrisSelectionModels.parameter14 = checkBox1.Checked;
  1186. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1187. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1188. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1189. }
  1190. /// <summary>
  1191. /// 初始化表头
  1192. /// </summary>
  1193. private void InitGridHeader()
  1194. {
  1195. //
  1196. //选择统计数据表
  1197. //
  1198. this.dataGridView3.ColumnHeadersHeight = 35;
  1199. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1200. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1201. h1.Width = 84;
  1202. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1203. h2.Width = 84;
  1204. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1205. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1206. h3.Width = 84;
  1207. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1208. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1209. h4.Width = 84;
  1210. this.dataGridView3.Columns.Add(h1);
  1211. this.dataGridView3.Columns.Add(h2);
  1212. this.dataGridView3.Columns.Add(h3);
  1213. this.dataGridView3.Columns.Add(h4);
  1214. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView3);
  1215. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.projectname.text")));
  1216. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.judgementconditions.text")));
  1217. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Conditionvalue.text")));
  1218. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.associatedcondition.text")));
  1219. this.dataGridView3.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1220. this.dataGridView3.Columns[0].ReadOnly = true;
  1221. this.dataGridView3.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1222. this.dataGridView3.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1223. this.dataGridView3.Columns[1].ReadOnly = true;
  1224. this.dataGridView3.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1225. this.dataGridView3.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1226. this.dataGridView3.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1227. this.dataGridView3.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1228. this.dataGridView3.Columns[3].ReadOnly = true;
  1229. this.dataGridView3.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1230. this.dataGridView3.AllowUserToResizeRows = false;
  1231. this.dataGridView3.AllowUserToResizeColumns = false;
  1232. //
  1233. //统计结果预览表
  1234. //
  1235. this.dataGridView1.ColumnHeadersHeight = 30;
  1236. this.dataGridView1.AllowUserToResizeRows = false;
  1237. this.dataGridView1.AllowUserToResizeColumns = false;
  1238. //
  1239. //分析结果表
  1240. //
  1241. this.dataGridView2.ColumnHeadersHeight = 30;
  1242. this.dataGridView2.AllowUserToResizeRows = false;
  1243. this.dataGridView2.AllowUserToResizeColumns = false;
  1244. //
  1245. //左下表
  1246. //
  1247. this.listView2.View = View.Details;
  1248. ColumnHeader header0 = new ColumnHeader();
  1249. header0.Text = PdnResources.GetString("Menu.Imagelist.Text");
  1250. header0.Width = 175;
  1251. this.listView2.Columns.Add(header0);
  1252. }
  1253. /// <summary>
  1254. /// 重新加载xml中已经配置好的条件
  1255. /// </summary>
  1256. public void ReloadDebrisSelectionFromXml()
  1257. {
  1258. if (System.IO.File.Exists(filePath))
  1259. {
  1260. this.debrisSelectionModel = XmlSerializeHelper.DESerializer<DebrisSelectionModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1261. this.listView1_SelectedIndexChanged(null, null);
  1262. }
  1263. }
  1264. /// <summary>
  1265. /// 刷新统计选择的下拉框
  1266. /// </summary>
  1267. public void RefreshDebrisComboBox()
  1268. {
  1269. this.comboBox3.DataSource = null;
  1270. if (this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  1271. {
  1272. int selectedIndex = -1;
  1273. if (this.comboBox3.SelectedIndex > -1)//获取上次选中的下标
  1274. selectedIndex = this.comboBox3.SelectedIndex;
  1275. string[] dataSourceArr = new string[this.debrisSelectionModel.debrisSelectionList.Count];
  1276. for (int i = 0; i < this.debrisSelectionModel.debrisSelectionList.Count; i++)
  1277. {
  1278. dataSourceArr[i] = this.debrisSelectionModel.debrisSelectionList[i].itemName;
  1279. }
  1280. this.comboBox3.DataSource = dataSourceArr;
  1281. if (selectedIndex != -1)
  1282. this.comboBox3.SelectedIndex = selectedIndex;
  1283. else
  1284. this.comboBox3.SelectedIndex = 0;
  1285. this.RefreshDebirsDataGrid();
  1286. this.listView1_SelectedIndexChanged(null, null);
  1287. }
  1288. }
  1289. /// <summary>
  1290. /// 刷新统计数据表
  1291. /// </summary>
  1292. private void RefreshDebirsDataGrid()
  1293. {
  1294. this.dataGridView3.Rows.Clear();
  1295. this.dataGridView1.Rows.Clear();
  1296. this.dataGridView1.Columns.Clear();
  1297. if (this.comboBox3.SelectedIndex > -1 && this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  1298. {
  1299. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1300. if (model != null && model.conditionList.Count > 0)
  1301. {
  1302. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1303. RefreshResultViewDataGrid(null, 1, 0, helper, PdnResources.GetString("Menu.Particlenumber.Text"));
  1304. listDictionary.Clear();
  1305. for (int i = 0; i < model.conditionList.Count; i++)
  1306. {
  1307. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1308. object paraName = new object();
  1309. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1310. if (!listDictionary.ContainsKey(parameter))
  1311. {
  1312. listDictionary.Add(parameter, paraName.ToString());
  1313. }
  1314. else
  1315. {
  1316. continue;
  1317. }
  1318. DataGridViewRow row = new DataGridViewRow();
  1319. row.Height = 25;
  1320. row.Cells.Add(CreateTextBoxCell(paraName.ToString(), model.conditionList[i].conditionName));
  1321. row.Cells.Add(CreateTextBoxCell(InvariantData.judgeCondition[model.conditionList[i].judgeCondition], model.conditionList[i].judgeCondition));
  1322. row.Cells.Add(CreateTextBoxCell(model.conditionList[i].conditionNum.ToString(), ""));
  1323. row.Cells.Add(CreateTextBoxCell(InvariantData.joinCondition[model.conditionList[i].joinCondition], model.conditionList[i].joinCondition));
  1324. this.dataGridView3.Rows.Add(row);
  1325. RefreshResultViewDataGrid(model.conditionList[i], model.conditionList.Count, i + 1, helper, paraName.ToString());
  1326. }
  1327. RefreshParameterList();
  1328. this.dataGridView3.ClearSelection();
  1329. this.dataGridView1.ClearSelection();
  1330. }
  1331. }
  1332. //this.AutoSizeColumn(this.dataGridView1, 20);
  1333. }
  1334. /// <summary>
  1335. /// 刷新结果预览表
  1336. /// </summary>
  1337. /// <param name="model"></param>
  1338. /// <param name="count"></param>
  1339. /// <param name="nowNum"></param>
  1340. /// <param name="helper"></param>
  1341. /// <param name="itemName"></param>
  1342. private void RefreshResultViewDataGrid(DebrisSelectionModel.Condition model, int count, int nowNum, DataGridViewHelper helper, string itemName)
  1343. {
  1344. if (count > 0)
  1345. {
  1346. int columnWidth = 0;
  1347. switch (count)
  1348. {
  1349. case 1:
  1350. columnWidth = 336;
  1351. break;
  1352. case 2:
  1353. columnWidth = 168;
  1354. break;
  1355. case 3:
  1356. columnWidth = 112;
  1357. break;
  1358. default:
  1359. columnWidth = 84;
  1360. break;
  1361. }
  1362. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1363. //if (nowNum != 0)
  1364. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1365. tbColumn.SortMode = DataGridViewColumnSortMode.Automatic;
  1366. if (nowNum == 0)
  1367. {
  1368. tbColumn.Width = 70;
  1369. }
  1370. else
  1371. {
  1372. tbColumn.Width = columnWidth;
  1373. }
  1374. tbColumn.ValueType = typeof(double);
  1375. this.dataGridView1.Columns.Add(tbColumn);
  1376. helper.Headers.Add(new DataGridViewHelper.TopHeader(nowNum, 1, itemName));
  1377. }
  1378. }
  1379. /// <summary>
  1380. /// 刷新显示参数列表
  1381. /// </summary>
  1382. /// <param name="strArr"></param>
  1383. private void RefreshParameterList()
  1384. {
  1385. BindingSource bs = new BindingSource();
  1386. bs.DataSource = listDictionary;
  1387. this.comboBox1.DataSource = null;
  1388. this.comboBox1.DataSource = bs;
  1389. this.comboBox1.DisplayMember = "value";
  1390. this.comboBox1.ValueMember = "key";
  1391. }
  1392. /// <summary>
  1393. /// 初始化画布按键功能
  1394. /// </summary>
  1395. private void InitCommonButtonEvent()
  1396. {
  1397. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1398. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1399. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1400. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1401. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1402. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1403. }
  1404. private void zoomInButton_Click(object sender, EventArgs e)
  1405. {
  1406. if (this.imageMat != null)
  1407. this.documentWorkspace.ZoomIn();
  1408. }
  1409. private void zoomOutButton_Click(object sender, EventArgs e)
  1410. {
  1411. if (this.imageMat != null)
  1412. this.documentWorkspace.ZoomOut();
  1413. }
  1414. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1415. {
  1416. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1417. }
  1418. private void actualSizeButton_Click(object sender, EventArgs e)
  1419. {
  1420. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1421. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1422. }
  1423. private void pointerButton_Click(object sender, EventArgs e)
  1424. {
  1425. // this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1426. }
  1427. private void mobileModeButton_Click(object sender, EventArgs e)
  1428. {
  1429. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1430. }
  1431. /// <summary>
  1432. /// 调色板回调函数
  1433. /// </summary>
  1434. /// <param name="sender"></param>
  1435. /// <param name="ce"></param>
  1436. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1437. {
  1438. }
  1439. /// <summary>
  1440. /// 添加内容单元格
  1441. /// </summary>
  1442. /// <param name="text"></param>
  1443. /// <param name="tag"></param>
  1444. /// <returns></returns>
  1445. private DataGridViewTextBoxCell CreateTextBoxCell(object text, object tag)
  1446. {
  1447. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1448. textboxcell.Value = text;
  1449. textboxcell.Tag = tag;
  1450. return textboxcell;
  1451. }
  1452. /// <summary>
  1453. /// 设置按钮
  1454. /// </summary>
  1455. /// <param name="sender"></param>
  1456. /// <param name="e"></param>
  1457. private void button1_Click(object sender, EventArgs e)
  1458. {
  1459. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.ParticleStatistics");
  1460. if (metallographicMethodSetDialog.hasModule)
  1461. {
  1462. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1463. metallographicMethodSetDialog.ShowDialog();
  1464. }
  1465. else
  1466. {
  1467. metallographicMethodSetDialog = null;
  1468. }
  1469. }
  1470. /// <summary>
  1471. /// 保存结果按钮
  1472. /// </summary>
  1473. /// <param name="sender"></param>
  1474. /// <param name="e"></param>
  1475. private void button2_Click(object sender, EventArgs e)
  1476. {
  1477. if (this.listView1.SelectedItems.Count > 0)
  1478. {
  1479. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1480. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1481. bool replace = false;
  1482. int rowIndex = 0;
  1483. if (this.dataGridView1.Rows.Count > 0)
  1484. {
  1485. if (this.listView2.Items.Count > 0)
  1486. {
  1487. foreach (ListViewItem item in this.listView2.Items)
  1488. {
  1489. if (item.Name.Equals(tag))
  1490. {
  1491. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1492. if (dr == DialogResult.OK)
  1493. {
  1494. replace = true;
  1495. }
  1496. else
  1497. {
  1498. return;
  1499. }
  1500. break;
  1501. }
  1502. }
  1503. }
  1504. //有重名需要替换
  1505. if (replace)
  1506. {
  1507. for (int ik = 0; ik < this.resultTableList.Count; ik++)
  1508. {
  1509. if (this.resultTableList[ik].TableName.Equals(tag))
  1510. {
  1511. rowIndex = ik;
  1512. this.resultTableList.Remove(this.resultTableList[ik]);
  1513. DataTable dt = new DataTable(tag);
  1514. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1515. if (model != null && model.conditionList.Count > 0)
  1516. {
  1517. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text"), typeof(string)));
  1518. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Particlenumber.Text"), typeof(string)));
  1519. //DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1520. listDictionary.Clear();
  1521. for (int i = 0; i < model.conditionList.Count; i++)
  1522. {
  1523. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1524. object paraName = new object();
  1525. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1526. if (!listDictionary.ContainsKey(parameter))
  1527. {
  1528. listDictionary.Add(parameter, paraName.ToString());
  1529. }
  1530. else
  1531. {
  1532. continue;
  1533. }
  1534. dt.Columns.Add(new DataColumn(paraName.ToString(), typeof(string)));
  1535. }
  1536. }
  1537. for (int f = 0; f < this.dataGridView1.Rows.Count; f++)
  1538. {
  1539. if (this.dataGridView1.Rows[f].Visible)
  1540. {
  1541. DataRow dataRow = dt.NewRow();
  1542. dataRow[PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text")] = imgName;
  1543. for (int j = 1; j < dt.Columns.Count; j++)
  1544. {
  1545. dataRow[dt.Columns[j].ColumnName] = ((DataGridViewTextBoxCell)this.dataGridView1.Rows[f].Cells[j - 1]).Tag.ToString();
  1546. }
  1547. dt.Rows.Add(dataRow);
  1548. }
  1549. }
  1550. resultTableList.Insert(rowIndex, dt);
  1551. }
  1552. }
  1553. }
  1554. //新增
  1555. else
  1556. {
  1557. ListViewItem listViewItem = new ListViewItem();
  1558. listViewItem.Name = tag;
  1559. listViewItem.SubItems[0].Text = imgName;
  1560. this.listView2.Items.Add(listViewItem);
  1561. this.listView2.SelectedItems.Clear();
  1562. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1563. DataTable dt = new DataTable(tag);
  1564. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1565. if (model != null && model.conditionList.Count > 0)
  1566. {
  1567. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text"), typeof(string)));
  1568. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Particlenumber.Text"), typeof(string)));
  1569. //DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1570. listDictionary.Clear();
  1571. for (int i = 0; i < model.conditionList.Count; i++)
  1572. {
  1573. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1574. object paraName = new object();
  1575. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1576. if (!listDictionary.ContainsKey(parameter))
  1577. {
  1578. listDictionary.Add(parameter, paraName.ToString());
  1579. }
  1580. else
  1581. {
  1582. continue;
  1583. }
  1584. dt.Columns.Add(new DataColumn(paraName.ToString(), typeof(string)));
  1585. }
  1586. }
  1587. for (int f = 0; f < this.dataGridView1.Rows.Count; f++)
  1588. {
  1589. if (this.dataGridView1.Rows[f].Visible)
  1590. {
  1591. DataRow dataRow = dt.NewRow();
  1592. dataRow[PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text")] = imgName;
  1593. for (int j = 1; j < dt.Columns.Count; j++)
  1594. {
  1595. dataRow[dt.Columns[j].ColumnName] = ((DataGridViewTextBoxCell)this.dataGridView1.Rows[f].Cells[j - 1]).Tag.ToString();
  1596. }
  1597. dt.Rows.Add(dataRow);
  1598. }
  1599. }
  1600. resultTableList.Add(dt);
  1601. }
  1602. RefreshDataGridView2();
  1603. //保存处理后的图片
  1604. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1605. List<Bitmap> tempBit = new List<Bitmap>();
  1606. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1607. originalBit.Tag = pantographRatio;
  1608. tempBit.Add(originalBit);
  1609. Bitmap processedBit = BitmapConverter.ToBitmap(phaseModel.mat);
  1610. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1611. Graphics graphics = Graphics.FromImage(newBit);
  1612. graphics.DrawImage(processedBit, new PointF(0, 0));
  1613. newBit.Tag = pantographRatio;
  1614. tempBit.Add(newBit);
  1615. if (bitDic.ContainsKey(tag))
  1616. bitDic[tag] = tempBit;
  1617. else
  1618. bitDic.Add(tag, tempBit);
  1619. }
  1620. else
  1621. {
  1622. MessageBox.Show(PdnResources.GetString("Menu.Noinformationtosave.text"));
  1623. }
  1624. }
  1625. else
  1626. {
  1627. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1628. }
  1629. }
  1630. /// <summary>
  1631. /// 刷新分析结果表
  1632. /// </summary>
  1633. private void RefreshDataGridView2()
  1634. {
  1635. this.dataGridView2.Columns.Clear();
  1636. this.dataGridView2.Rows.Clear();
  1637. if (this.showAll)
  1638. {
  1639. if (this.resultTableList.Count > 0)
  1640. {
  1641. int k = 0;
  1642. int kk = 0;
  1643. foreach (DataTable dt in resultTableList)
  1644. {
  1645. if (kk == 0)
  1646. {
  1647. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1648. {
  1649. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1650. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1651. //tbColumn.Width = 250;
  1652. tbColumn.HeaderText = dt.Columns[ii].ColumnName;
  1653. tbColumn.ValueType = typeof(double);
  1654. this.dataGridView2.Columns.Add(tbColumn);
  1655. }
  1656. }
  1657. this.dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1658. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1659. {
  1660. DataGridViewRow r1 = dataGridView2.Rows[k];
  1661. //r1.Cells[0].Value = row.RowState.ToString();
  1662. for (int j = 0; j < dt.Columns.Count; j++)
  1663. {
  1664. if (j > 0)
  1665. {
  1666. r1.Cells[j].Value = Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value);
  1667. }
  1668. else
  1669. {
  1670. r1.Cells[j].Value = row[j].ToString();
  1671. }
  1672. }
  1673. k++;
  1674. }
  1675. kk++;
  1676. }
  1677. }
  1678. }
  1679. else
  1680. {
  1681. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1682. {
  1683. int k = 0;
  1684. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1685. {
  1686. string tableName = this.listView2.SelectedItems[i].Name;
  1687. foreach (DataTable dt in resultTableList)
  1688. {
  1689. if (dt.TableName.Equals(tableName))
  1690. {
  1691. if (i == 0)
  1692. {
  1693. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1694. {
  1695. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1696. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1697. //tbColumn.Width = 250;
  1698. tbColumn.HeaderText = dt.Columns[ii].ColumnName;
  1699. tbColumn.ValueType = typeof(double);
  1700. this.dataGridView2.Columns.Add(tbColumn);
  1701. }
  1702. }
  1703. this.dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1704. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1705. {
  1706. DataGridViewRow r1 = dataGridView2.Rows[k];
  1707. //r1.Cells[0].Value = row.RowState.ToString();
  1708. for (int j = 0; j < dt.Columns.Count; j++)
  1709. {
  1710. if (j > 0)
  1711. {
  1712. r1.Cells[j].Value = Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value);
  1713. }
  1714. else
  1715. {
  1716. r1.Cells[j].Value = row[j].ToString();
  1717. }
  1718. }
  1719. k++;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. }
  1725. }
  1726. this.AutoSizeColumn(this.dataGridView2, 20);
  1727. }
  1728. /// <summary>
  1729. /// 全部显示按钮
  1730. /// </summary>
  1731. /// <param name="sender"></param>
  1732. /// <param name="e"></param>
  1733. private void button6_Click(object sender, EventArgs e)
  1734. {
  1735. if (this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1736. {
  1737. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1738. this.showAll = true;
  1739. RefreshDataGridView2();
  1740. }
  1741. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1742. {
  1743. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1744. this.showAll = false;
  1745. RefreshDataGridView2();
  1746. }
  1747. }
  1748. /// <summary>
  1749. /// 删除按钮
  1750. /// </summary>
  1751. /// <param name="sender"></param>
  1752. /// <param name="e"></param>
  1753. private void button7_Click(object sender, EventArgs e)
  1754. {
  1755. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1756. {
  1757. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1758. if (dr == DialogResult.OK)
  1759. {
  1760. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1761. {
  1762. string tableName = this.listView2.SelectedItems[i].Name;
  1763. foreach (DataTable dt in resultTableList)
  1764. {
  1765. if (dt.TableName.Equals(tableName))
  1766. {
  1767. resultTableList.Remove(dt);
  1768. break;
  1769. }
  1770. }
  1771. if (bitDic.ContainsKey(tableName))
  1772. bitDic.Remove(tableName);
  1773. }
  1774. foreach (ListViewItem item in this.listView2.Items)
  1775. {
  1776. if (item.Selected)
  1777. this.listView2.Items.Remove(item);
  1778. }
  1779. RefreshDataGridView2();
  1780. }
  1781. }
  1782. }
  1783. private bool ExistInSelectItems(string tablename)
  1784. {
  1785. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1786. {
  1787. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1788. {
  1789. if (this.listView2.SelectedItems[i].Name.Equals(tablename))
  1790. {
  1791. return true;
  1792. }
  1793. }
  1794. }
  1795. return false;
  1796. }
  1797. /// <summary>
  1798. /// 生成报告按钮
  1799. /// </summary>
  1800. /// <param name="sender"></param>
  1801. /// <param name="e"></param>
  1802. private void button8_Click(object sender, EventArgs e)
  1803. {
  1804. if (this.checkBox1.Checked)
  1805. this.button1.PerformClick();
  1806. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1807. {
  1808. //获取word书签与excel单元格的关系,以字典方式存储
  1809. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1810. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1811. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1812. {
  1813. foreach (mic_module_infos info in mic_module_infos)
  1814. {
  1815. tagInfos.Add(info.tag_name, info.cell_position);
  1816. }
  1817. }
  1818. //分析结果
  1819. List<List<string>> analysisContent = new List<List<string>>();
  1820. if (this.listView2.Items != null && this.listView2.Items.Count > 0)
  1821. {
  1822. int k = 0;
  1823. int kk = 0;
  1824. foreach (DataTable dt in resultTableList)
  1825. {
  1826. if (kk == 0)
  1827. {
  1828. List<string> contentHead = new List<string>();
  1829. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1830. {
  1831. contentHead.Add(dt.Columns[ii].ColumnName);
  1832. }
  1833. analysisContent.Add(contentHead);
  1834. kk++;
  1835. }
  1836. //如果不是显示全部
  1837. if (!this.showAll)
  1838. {
  1839. if (!ExistInSelectItems(dt.TableName))
  1840. continue;
  1841. }
  1842. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1843. {
  1844. List<string> content = new List<string>();
  1845. for (int j = 0; j < dt.Columns.Count; j++)
  1846. {
  1847. if (j > 0)
  1848. {
  1849. content.Add(Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value).ToString());
  1850. }
  1851. else
  1852. {
  1853. content.Add(row[j].ToString());
  1854. }
  1855. }
  1856. analysisContent.Add(content);
  1857. k++;
  1858. }
  1859. }
  1860. }
  1861. //图片
  1862. bitList = new List<Bitmap>();
  1863. if (this.showAll)
  1864. {
  1865. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1866. {
  1867. bitList.Add(kv.Value[0]);
  1868. bitList.Add(kv.Value[1]);
  1869. }
  1870. }
  1871. else
  1872. {
  1873. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1874. {
  1875. foreach (ListViewItem item in this.listView2.SelectedItems)
  1876. {
  1877. if (bitDic.ContainsKey(item.Name))
  1878. {
  1879. bitList.Add(bitDic[item.Name][0]);
  1880. bitList.Add(bitDic[item.Name][1]);
  1881. }
  1882. }
  1883. }
  1884. }
  1885. if (config.calipersSetModel != null && config.calipersSetModel.isExport == 1)
  1886. CreateCalipersDataTable();
  1887. pNames = new Dictionary<string, string>();
  1888. string dictPath = Application.StartupPath + "\\temp";
  1889. if (!System.IO.Directory.Exists(dictPath))
  1890. System.IO.Directory.CreateDirectory(dictPath);
  1891. DeleteFolder(dictPath);
  1892. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1893. this.SaveAllImage(bitList, dictPath, 1, 1, imgName);
  1894. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos, dictPath, pNames);
  1895. }
  1896. else
  1897. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1898. }
  1899. Dictionary<string, string> pNames;
  1900. /// <summary>
  1901. /// 保存图片到本地
  1902. /// </summary>
  1903. /// <param name="bitList"></param>
  1904. private void SaveAllImage(List<Bitmap> bitList, string newPath, int originNum, int codeNum, string pName)
  1905. {
  1906. if (bitList != null && bitList.Count > 0)
  1907. {
  1908. for (int i = 0; i < bitList.Count; i++)
  1909. {
  1910. string bitPath = "";
  1911. //分别为原图和处理后的图命名
  1912. if (i % 2 == 0)
  1913. {
  1914. bitPath = newPath + "/" + "origin" + originNum + ".jpg";
  1915. pNames.Add("origin" + originNum, pName);
  1916. }
  1917. else
  1918. {
  1919. bitPath = newPath + "/" + codeNum + ".jpg";
  1920. pNames.Add(codeNum.ToString(), pName);
  1921. }
  1922. bitList[i].Save(bitPath);
  1923. }
  1924. }
  1925. }
  1926. public void DeleteFolder(string path)
  1927. {
  1928. foreach (string d in Directory.GetFileSystemEntries(path))
  1929. {
  1930. if (System.IO.File.Exists(d))
  1931. {
  1932. FileInfo fi = new FileInfo(d);
  1933. if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
  1934. fi.Attributes = FileAttributes.Normal;
  1935. System.IO.File.Delete(d);//直接删除其中的文件
  1936. }
  1937. else
  1938. {
  1939. DirectoryInfo d1 = new DirectoryInfo(d);
  1940. if (d1.GetFiles().Length != 0)
  1941. {
  1942. DeleteFolder(d1.FullName);
  1943. }
  1944. Directory.Delete(d);
  1945. }
  1946. }
  1947. }
  1948. /// <summary>
  1949. /// 导出结果按钮
  1950. /// </summary>
  1951. /// <param name="sender"></param>
  1952. /// <param name="e"></param>
  1953. private void button9_Click(object sender, EventArgs e)
  1954. {
  1955. if (this.dataGridView2.Rows.Count > 0)
  1956. {
  1957. SaveFileDialog exe = new SaveFileDialog();
  1958. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1959. exe.FilterIndex = 0;
  1960. exe.RestoreDirectory = true;
  1961. exe.Title = "Export Excel File";
  1962. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1963. exe.FileName = PdnResources.GetString("Menu.GeneralAnalysis.ParticleStatistics.Text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1964. DialogResult dr = exe.ShowDialog();
  1965. if (dr == DialogResult.OK)
  1966. {
  1967. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1968. {
  1969. List<DataTable> list = new List<DataTable>();
  1970. if (!this.showAll)
  1971. {
  1972. foreach (DataTable dtb in resultTableList)
  1973. {
  1974. if (!ExistInSelectItems(dtb.TableName))
  1975. {
  1976. continue;
  1977. }
  1978. for (int j = 0; j < dtb.Rows.Count; j++)
  1979. {
  1980. for (int k = 1; k < dtb.Columns.Count; k++)
  1981. {
  1982. dtb.Rows[j][k] = Math.Round(double.Parse(dtb.Rows[j][k].ToString()), (int)this.numericUpDown1.Value);
  1983. }
  1984. }
  1985. list.Add(dtb);
  1986. }
  1987. }
  1988. else
  1989. {
  1990. list = resultTableList;
  1991. }
  1992. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1993. }
  1994. else
  1995. {
  1996. MessageBox.Show(PdnResources.GetString("Menu.Selecttheresultstoexport.Text"));
  1997. return;
  1998. }
  1999. }
  2000. }
  2001. else
  2002. {
  2003. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  2004. }
  2005. }
  2006. /// <summary>
  2007. /// 图像索引切换选中事件
  2008. /// </summary>
  2009. /// <param name="sender"></param>
  2010. /// <param name="e"></param>
  2011. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  2012. {
  2013. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  2014. {
  2015. ruleValue = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2016. this.gridView1SelectIndex = 0;
  2017. if (!string.IsNullOrEmpty(this.selectedImg))
  2018. {
  2019. #region [保存参数]
  2020. var model = new GeneralAnalysisModel.DebrisSelectionModel();
  2021. model.parameter3 = checkBox2.Checked;
  2022. model.parameter4 = panel1.BackColor.ToArgb();
  2023. model.parameter5 = checkBox3.Checked;
  2024. model.parameter1 = comboBox3.SelectedIndex;
  2025. model.parameter6 = comboBox1.SelectedIndex;
  2026. model.parameter8 = comboBox2.SelectedIndex;
  2027. model.parameter7 = panel3.BackColor.ToArgb();
  2028. model.parameter9 = (int)numericUpDown3.Value;
  2029. model.parameter10 = checkBox4.Checked;
  2030. model.parameter11 = (int)numericUpDown2.Value;
  2031. model.parameter12 = panel2.BackColor.ToArgb();
  2032. model.parameter13 = (int)numericUpDown1.Value;
  2033. model.parameter14 = checkBox1.Checked;
  2034. if (everyImgData.ContainsKey(this.selectedImg))
  2035. {
  2036. everyImgData[this.selectedImg] = model;
  2037. }
  2038. else
  2039. {
  2040. everyImgData.Add(this.selectedImg, model);
  2041. }
  2042. #endregion
  2043. }
  2044. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  2045. Document document = Document.FromImageMat(imageMat.Clone());
  2046. this.documentWorkspace.Document = document;
  2047. this.documentWorkspace.phaseModels.Clear();
  2048. this.phaseModel = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].AnalysisPhaseModel;
  2049. this.documentWorkspace.phaseModels.Add(phaseModel);
  2050. //获得视场并绘制
  2051. List<DrawObject> drawObject = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.GetDrawClassList(DrawClass.View);
  2052. if (drawObject != null && drawObject.Count > 0)
  2053. {
  2054. isHadView = true;
  2055. foreach (DrawObject dObject in drawObject)
  2056. {
  2057. dObject.Selected = false;
  2058. this.documentWorkspace.GraphicsList.Add(dObject);
  2059. }
  2060. }
  2061. else
  2062. {
  2063. isHadView = false;
  2064. this.documentWorkspace.GraphicsList.DeleteAllView();
  2065. }
  2066. this.documentWorkspace.Visible = true;
  2067. this.commonControlButtons.Visible = true;
  2068. //获得图像对应的mat
  2069. if (isHadView)
  2070. this.mat = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion());//获取视场对应的mat
  2071. //}//待测试
  2072. else
  2073. this.mat = this.imageMat.Clone();
  2074. if (this.set != null)
  2075. this.set.Clear();
  2076. if (phaseModel != null && phaseModel.mat != null)
  2077. {
  2078. if (int.Parse(this.button5.Tag.ToString()) == 1)
  2079. {
  2080. this.button4.Enabled = true;
  2081. }
  2082. this.button5.Enabled = true;
  2083. this.binarizationMat = phaseModel.mat;
  2084. this.FindContourAndCalc();
  2085. this.FilterParticlesByCondition();
  2086. this.DrawConditionMat();
  2087. this.CreateDataGridViewData();
  2088. if (this.checkBox4.Checked)
  2089. {
  2090. for (int i = this.dataGridView1.Rows.Count - 1; i > (this.numericUpDown2.Value - 1); i--)
  2091. {
  2092. this.dataGridView1.Rows[i].Visible = false;
  2093. }
  2094. }
  2095. }
  2096. else
  2097. {
  2098. this.binarizationMat = null;
  2099. this.dataGridView1.Rows.Clear();
  2100. this.button4.Enabled = false;
  2101. this.button5.Enabled = false;
  2102. if (this.firstShow)
  2103. {
  2104. return;
  2105. }
  2106. MessageBox.Show(PdnResources.GetString("Menu.Theselectotbeperformed.text"));
  2107. }
  2108. #region [设置参数]
  2109. this.selectedImg = this.listView1.FocusedItem.Name;
  2110. if (everyImgData.ContainsKey(this.selectedImg))
  2111. {
  2112. var thisModel = everyImgData[this.selectedImg];
  2113. if (thisModel.parameter1 != -1 && thisModel.parameter6 <= comboBox1.Items.Count - 1)
  2114. {
  2115. comboBox3.SelectedIndex = thisModel.parameter1;
  2116. }
  2117. checkBox2.Checked = thisModel.parameter3;
  2118. panel1.BackColor = Color.FromArgb(thisModel.parameter4);
  2119. checkBox3.Checked = thisModel.parameter5;
  2120. if (thisModel.parameter6 != -1 && thisModel.parameter6 <= comboBox1.Items.Count - 1)
  2121. {
  2122. comboBox1.SelectedIndex = thisModel.parameter6;
  2123. }
  2124. panel3.BackColor = Color.FromArgb(thisModel.parameter7);
  2125. if (thisModel.parameter8 != -1)
  2126. {
  2127. comboBox2.SelectedIndex = thisModel.parameter8;
  2128. }
  2129. numericUpDown3.Value = thisModel.parameter9;
  2130. checkBox4.Checked = thisModel.parameter10;
  2131. numericUpDown2.Value = thisModel.parameter11;
  2132. panel2.BackColor = Color.FromArgb(thisModel.parameter12);
  2133. numericUpDown1.Value = thisModel.parameter13;
  2134. checkBox1.Checked = thisModel.parameter14;
  2135. }
  2136. #endregion
  2137. }
  2138. }
  2139. /// <summary>
  2140. /// 寻找轮廓并计算
  2141. /// </summary>
  2142. private void FindContourAndCalc()
  2143. {
  2144. if (this.binarizationMat != null)
  2145. {
  2146. this.list.Clear();
  2147. Cv2.FindContours(BinaryClass.BGRA2GRAY(this.binarizationMat), out contours, out hierarchy, OpenCvSharp.RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  2148. if (contours != null && contours.Length > 0)
  2149. {
  2150. //double ruleValue = 0;
  2151. //Startup.instance.rules.TryGetValue(MeasurementUnit.Micron, out ruleValue);
  2152. this.matGray = this.mat.CvtColor(ColorConversionCodes.BGR2GRAY);
  2153. this.binarizationMatGray = BinaryClass.BGRA2GRAY(this.binarizationMat)/*//### .CvtColor(ColorConversionCodes.BGR2GRAY)*/;
  2154. this.mats = this.mat.Split();
  2155. this.hole = new Mat(mat.Size(), MatType.CV_8U, Scalar.All(-1));
  2156. int k = 1;
  2157. int i = 0;
  2158. foreach (OpenCvSharp.Point[] p in contours)
  2159. {
  2160. if (hierarchy[i].Parent == -1)
  2161. {
  2162. ContoursAndRelatedInfo info = new ContoursAndRelatedInfo();
  2163. info.contours = p;
  2164. info.wholeContours = BasicCalculationHelper.GetWholeContoursTree(contours, hierarchy, i);
  2165. info.index = k;
  2166. info.rule = ruleValue;
  2167. info.hierarchyIndex = hierarchy[i];
  2168. info.mat = this.mat;
  2169. info.mats = this.mats;
  2170. info.hole = this.hole;
  2171. info.matGray = this.matGray;
  2172. info.binarizationMatGray = this.binarizationMatGray;
  2173. this.list.Add(info);
  2174. k++;
  2175. }
  2176. i++;
  2177. }
  2178. }
  2179. }
  2180. }
  2181. /// <summary>
  2182. /// 根据条件筛选颗粒
  2183. /// </summary>
  2184. private void FilterParticlesByCondition()
  2185. {
  2186. if (this.list != null && this.list.Count > 0)
  2187. {
  2188. if (this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList != null
  2189. && this.debrisSelectionModel.debrisSelectionList.Count > 0 && this.comboBox3.SelectedIndex >= 0)
  2190. {
  2191. DebrisSelectionModel.DebrisSelection debrisSelection = this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex];
  2192. if (debrisSelection.conditionList != null && debrisSelection.conditionList.Count > 0)
  2193. {
  2194. //用于筛选的集合,如果是and则用set,如果是or则用全部的集合
  2195. List<ContoursAndRelatedInfo> temps = this.list;
  2196. //进行排序
  2197. for (int i = 0; i < temps.Count(); i++)
  2198. {
  2199. temps[i].index = i + 1;
  2200. }
  2201. //用于存储过滤后的集合
  2202. set = new List<ContoursAndRelatedInfo>();
  2203. for (int flag = 0; flag < debrisSelection.conditionList.Count; flag++)
  2204. {
  2205. Condition condition = debrisSelection.conditionList[flag];
  2206. //声明linq的条件
  2207. Predicate<ContoursAndRelatedInfo> match = null;
  2208. List<ContoursAndRelatedInfo> temp;
  2209. switch ((DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), condition.conditionName))
  2210. {
  2211. case DebrisSelectionParameters.area:
  2212. switch (condition.judgeCondition)
  2213. {
  2214. case 0:
  2215. match = a => a.Area > condition.conditionNum;
  2216. break;
  2217. case 1:
  2218. match = a => a.Area < condition.conditionNum;
  2219. break;
  2220. case 2:
  2221. match = a => a.Area >= condition.conditionNum;
  2222. break;
  2223. case 3:
  2224. match = a => a.Area <= condition.conditionNum;
  2225. break;
  2226. }
  2227. break;
  2228. case DebrisSelectionParameters.areaRatio:
  2229. switch (condition.judgeCondition)
  2230. {
  2231. case 0:
  2232. match = a => a.AreaRatio > condition.conditionNum;
  2233. break;
  2234. case 1:
  2235. match = a => a.AreaRatio < condition.conditionNum;
  2236. break;
  2237. case 2:
  2238. match = a => a.AreaRatio >= condition.conditionNum;
  2239. break;
  2240. case 3:
  2241. match = a => a.AreaRatio <= condition.conditionNum;
  2242. break;
  2243. }
  2244. break;
  2245. case DebrisSelectionParameters.perimeter:
  2246. switch (condition.judgeCondition)
  2247. {
  2248. case 0:
  2249. match = a => a.Perimeter > condition.conditionNum;
  2250. break;
  2251. case 1:
  2252. match = a => a.Perimeter < condition.conditionNum;
  2253. break;
  2254. case 2:
  2255. match = a => a.Perimeter >= condition.conditionNum;
  2256. break;
  2257. case 3:
  2258. match = a => a.Perimeter <= condition.conditionNum;
  2259. break;
  2260. }
  2261. break;
  2262. case DebrisSelectionParameters.longAxis:
  2263. switch (condition.judgeCondition)
  2264. {
  2265. case 0:
  2266. match = a => a.LongAxis > condition.conditionNum;
  2267. break;
  2268. case 1:
  2269. match = a => a.LongAxis < condition.conditionNum;
  2270. break;
  2271. case 2:
  2272. match = a => a.LongAxis >= condition.conditionNum;
  2273. break;
  2274. case 3:
  2275. match = a => a.LongAxis <= condition.conditionNum;
  2276. break;
  2277. }
  2278. break;
  2279. case DebrisSelectionParameters.shortAxis:
  2280. switch (condition.judgeCondition)
  2281. {
  2282. case 0:
  2283. match = a => a.ShortAxis > condition.conditionNum;
  2284. break;
  2285. case 1:
  2286. match = a => a.ShortAxis < condition.conditionNum;
  2287. break;
  2288. case 2:
  2289. match = a => a.ShortAxis >= condition.conditionNum;
  2290. break;
  2291. case 3:
  2292. match = a => a.ShortAxis <= condition.conditionNum;
  2293. break;
  2294. }
  2295. break;
  2296. case DebrisSelectionParameters.centerX:
  2297. switch (condition.judgeCondition)
  2298. {
  2299. case 0:
  2300. match = a => a.CenterX > condition.conditionNum;
  2301. break;
  2302. case 1:
  2303. match = a => a.CenterX < condition.conditionNum;
  2304. break;
  2305. case 2:
  2306. match = a => a.CenterX >= condition.conditionNum;
  2307. break;
  2308. case 3:
  2309. match = a => a.CenterX <= condition.conditionNum;
  2310. break;
  2311. }
  2312. break;
  2313. case DebrisSelectionParameters.centerY:
  2314. switch (condition.judgeCondition)
  2315. {
  2316. case 0:
  2317. match = a => a.CenterY > condition.conditionNum;
  2318. break;
  2319. case 1:
  2320. match = a => a.CenterY < condition.conditionNum;
  2321. break;
  2322. case 2:
  2323. match = a => a.CenterY >= condition.conditionNum;
  2324. break;
  2325. case 3:
  2326. match = a => a.CenterY <= condition.conditionNum;
  2327. break;
  2328. }
  2329. break;
  2330. case DebrisSelectionParameters.inclinationAngle:
  2331. switch (condition.judgeCondition)
  2332. {
  2333. case 0:
  2334. match = a => a.InclinationAngle > condition.conditionNum;
  2335. break;
  2336. case 1:
  2337. match = a => a.InclinationAngle < condition.conditionNum;
  2338. break;
  2339. case 2:
  2340. match = a => a.InclinationAngle >= condition.conditionNum;
  2341. break;
  2342. case 3:
  2343. match = a => a.InclinationAngle <= condition.conditionNum;
  2344. break;
  2345. }
  2346. break;
  2347. case DebrisSelectionParameters.objectAppearance:
  2348. switch (condition.judgeCondition)
  2349. {
  2350. case 0:
  2351. match = a => a.ObjectAppearance > condition.conditionNum;
  2352. break;
  2353. case 1:
  2354. match = a => a.ObjectAppearance < condition.conditionNum;
  2355. break;
  2356. case 2:
  2357. match = a => a.ObjectAppearance >= condition.conditionNum;
  2358. break;
  2359. case 3:
  2360. match = a => a.ObjectAppearance <= condition.conditionNum;
  2361. break;
  2362. }
  2363. break;
  2364. case DebrisSelectionParameters.height:
  2365. switch (condition.judgeCondition)
  2366. {
  2367. case 0:
  2368. match = a => a.Height > condition.conditionNum;
  2369. break;
  2370. case 1:
  2371. match = a => a.Height < condition.conditionNum;
  2372. break;
  2373. case 2:
  2374. match = a => a.Height >= condition.conditionNum;
  2375. break;
  2376. case 3:
  2377. match = a => a.Height <= condition.conditionNum;
  2378. break;
  2379. }
  2380. break;
  2381. case DebrisSelectionParameters.width:
  2382. switch (condition.judgeCondition)
  2383. {
  2384. case 0:
  2385. match = a => a.Width > condition.conditionNum;
  2386. break;
  2387. case 1:
  2388. match = a => a.Width < condition.conditionNum;
  2389. break;
  2390. case 2:
  2391. match = a => a.Width >= condition.conditionNum;
  2392. break;
  2393. case 3:
  2394. match = a => a.Width <= condition.conditionNum;
  2395. break;
  2396. }
  2397. break;
  2398. case DebrisSelectionParameters.aspectRatio:
  2399. switch (condition.judgeCondition)
  2400. {
  2401. case 0:
  2402. match = a => a.AspectRatio > condition.conditionNum;
  2403. break;
  2404. case 1:
  2405. match = a => a.AspectRatio < condition.conditionNum;
  2406. break;
  2407. case 2:
  2408. match = a => a.AspectRatio >= condition.conditionNum;
  2409. break;
  2410. case 3:
  2411. match = a => a.AspectRatio <= condition.conditionNum;
  2412. break;
  2413. }
  2414. break;
  2415. case DebrisSelectionParameters.redDensity:
  2416. switch (condition.judgeCondition)
  2417. {
  2418. case 0:
  2419. match = a => a.RedDensity > condition.conditionNum;
  2420. break;
  2421. case 1:
  2422. match = a => a.RedDensity < condition.conditionNum;
  2423. break;
  2424. case 2:
  2425. match = a => a.RedDensity >= condition.conditionNum;
  2426. break;
  2427. case 3:
  2428. match = a => a.RedDensity <= condition.conditionNum;
  2429. break;
  2430. }
  2431. break;
  2432. case DebrisSelectionParameters.greenDensity:
  2433. switch (condition.judgeCondition)
  2434. {
  2435. case 0:
  2436. match = a => a.GreenDensity > condition.conditionNum;
  2437. break;
  2438. case 1:
  2439. match = a => a.GreenDensity < condition.conditionNum;
  2440. break;
  2441. case 2:
  2442. match = a => a.GreenDensity >= condition.conditionNum;
  2443. break;
  2444. case 3:
  2445. match = a => a.GreenDensity <= condition.conditionNum;
  2446. break;
  2447. }
  2448. break;
  2449. case DebrisSelectionParameters.blueDensity:
  2450. switch (condition.judgeCondition)
  2451. {
  2452. case 0:
  2453. match = a => a.BlueDensity > condition.conditionNum;
  2454. break;
  2455. case 1:
  2456. match = a => a.BlueDensity < condition.conditionNum;
  2457. break;
  2458. case 2:
  2459. match = a => a.BlueDensity >= condition.conditionNum;
  2460. break;
  2461. case 3:
  2462. match = a => a.BlueDensity <= condition.conditionNum;
  2463. break;
  2464. }
  2465. break;
  2466. /*case DebrisSelectionParameters.maxDensity:
  2467. switch (condition.judgeCondition)
  2468. {
  2469. case 0:
  2470. match = a => a.MaxDensity > condition.conditionNum;
  2471. break;
  2472. case 1:
  2473. match = a => a.MaxDensity < condition.conditionNum;
  2474. break;
  2475. case 2:
  2476. match = a => a.MaxDensity >= condition.conditionNum;
  2477. break;
  2478. case 3:
  2479. match = a => a.MaxDensity <= condition.conditionNum;
  2480. break;
  2481. }
  2482. break;
  2483. case DebrisSelectionParameters.minDensity:
  2484. switch (condition.judgeCondition)
  2485. {
  2486. case 0:
  2487. match = a => a.MinDensity > condition.conditionNum;
  2488. break;
  2489. case 1:
  2490. match = a => a.MinDensity < condition.conditionNum;
  2491. break;
  2492. case 2:
  2493. match = a => a.MinDensity >= condition.conditionNum;
  2494. break;
  2495. case 3:
  2496. match = a => a.MinDensity <= condition.conditionNum;
  2497. break;
  2498. }
  2499. break;
  2500. case DebrisSelectionParameters.avgDensity:
  2501. switch (condition.judgeCondition)
  2502. {
  2503. case 0:
  2504. match = a => a.AvgDensity > condition.conditionNum;
  2505. break;
  2506. case 1:
  2507. match = a => a.AvgDensity < condition.conditionNum;
  2508. break;
  2509. case 2:
  2510. match = a => a.AvgDensity >= condition.conditionNum;
  2511. break;
  2512. case 3:
  2513. match = a => a.AvgDensity <= condition.conditionNum;
  2514. break;
  2515. }
  2516. break;
  2517. case DebrisSelectionParameters.sumDensity:
  2518. switch (condition.judgeCondition)
  2519. {
  2520. case 0:
  2521. match = a => a.SumDensity > condition.conditionNum;
  2522. break;
  2523. case 1:
  2524. match = a => a.SumDensity < condition.conditionNum;
  2525. break;
  2526. case 2:
  2527. match = a => a.SumDensity >= condition.conditionNum;
  2528. break;
  2529. case 3:
  2530. match = a => a.SumDensity <= condition.conditionNum;
  2531. break;
  2532. }
  2533. break;*/
  2534. case DebrisSelectionParameters.majorAxis:
  2535. switch (condition.judgeCondition)
  2536. {
  2537. case 0:
  2538. match = a => a.MajorAxis > condition.conditionNum;
  2539. break;
  2540. case 1:
  2541. match = a => a.MajorAxis < condition.conditionNum;
  2542. break;
  2543. case 2:
  2544. match = a => a.MajorAxis >= condition.conditionNum;
  2545. break;
  2546. case 3:
  2547. match = a => a.MajorAxis <= condition.conditionNum;
  2548. break;
  2549. }
  2550. break;
  2551. case DebrisSelectionParameters.minorAxis:
  2552. switch (condition.judgeCondition)
  2553. {
  2554. case 0:
  2555. match = a => a.MinorAxis > condition.conditionNum;
  2556. break;
  2557. case 1:
  2558. match = a => a.MinorAxis < condition.conditionNum;
  2559. break;
  2560. case 2:
  2561. match = a => a.MinorAxis >= condition.conditionNum;
  2562. break;
  2563. case 3:
  2564. match = a => a.MinorAxis <= condition.conditionNum;
  2565. break;
  2566. }
  2567. break;
  2568. case DebrisSelectionParameters.circumcircleDiameter:
  2569. switch (condition.judgeCondition)
  2570. {
  2571. case 0:
  2572. match = a => a.CircumcircleDiameter > condition.conditionNum;
  2573. break;
  2574. case 1:
  2575. match = a => a.CircumcircleDiameter < condition.conditionNum;
  2576. break;
  2577. case 2:
  2578. match = a => a.CircumcircleDiameter >= condition.conditionNum;
  2579. break;
  2580. case 3:
  2581. match = a => a.CircumcircleDiameter <= condition.conditionNum;
  2582. break;
  2583. }
  2584. break;
  2585. case DebrisSelectionParameters.nodularity:
  2586. switch (condition.judgeCondition)
  2587. {
  2588. case 0:
  2589. match = a => a.Nodularity > condition.conditionNum;
  2590. break;
  2591. case 1:
  2592. match = a => a.Nodularity < condition.conditionNum;
  2593. break;
  2594. case 2:
  2595. match = a => a.Nodularity >= condition.conditionNum;
  2596. break;
  2597. case 3:
  2598. match = a => a.Nodularity <= condition.conditionNum;
  2599. break;
  2600. }
  2601. break;
  2602. case DebrisSelectionParameters.equalCircleDiameter:
  2603. switch (condition.judgeCondition)
  2604. {
  2605. case 0:
  2606. match = a => a.EqualCircleDiameter > condition.conditionNum;
  2607. break;
  2608. case 1:
  2609. match = a => a.EqualCircleDiameter < condition.conditionNum;
  2610. break;
  2611. case 2:
  2612. match = a => a.EqualCircleDiameter >= condition.conditionNum;
  2613. break;
  2614. case 3:
  2615. match = a => a.EqualCircleDiameter <= condition.conditionNum;
  2616. break;
  2617. }
  2618. break;
  2619. case DebrisSelectionParameters.maxCaliperDiameter:
  2620. switch (condition.judgeCondition)
  2621. {
  2622. case 0:
  2623. match = a => a.MaxCaliperDiameter > condition.conditionNum;
  2624. break;
  2625. case 1:
  2626. match = a => a.MaxCaliperDiameter < condition.conditionNum;
  2627. break;
  2628. case 2:
  2629. match = a => a.MaxCaliperDiameter >= condition.conditionNum;
  2630. break;
  2631. case 3:
  2632. match = a => a.MaxCaliperDiameter <= condition.conditionNum;
  2633. break;
  2634. }
  2635. break;
  2636. case DebrisSelectionParameters.minCaliperDiameter:
  2637. switch (condition.judgeCondition)
  2638. {
  2639. case 0:
  2640. match = a => a.MinCaliperDiameter > condition.conditionNum;
  2641. break;
  2642. case 1:
  2643. match = a => a.MinCaliperDiameter < condition.conditionNum;
  2644. break;
  2645. case 2:
  2646. match = a => a.MinCaliperDiameter >= condition.conditionNum;
  2647. break;
  2648. case 3:
  2649. match = a => a.MinCaliperDiameter <= condition.conditionNum;
  2650. break;
  2651. }
  2652. break;
  2653. case DebrisSelectionParameters.avgCaliperDiameter:
  2654. switch (condition.judgeCondition)
  2655. {
  2656. case 0:
  2657. match = a => a.AvgCaliperDiameter > condition.conditionNum;
  2658. break;
  2659. case 1:
  2660. match = a => a.AvgCaliperDiameter < condition.conditionNum;
  2661. break;
  2662. case 2:
  2663. match = a => a.AvgCaliperDiameter >= condition.conditionNum;
  2664. break;
  2665. case 3:
  2666. match = a => a.AvgCaliperDiameter <= condition.conditionNum;
  2667. break;
  2668. }
  2669. break;
  2670. case DebrisSelectionParameters.maxGray:
  2671. switch (condition.judgeCondition)
  2672. {
  2673. case 0:
  2674. match = a => a.MaxGray > condition.conditionNum;
  2675. break;
  2676. case 1:
  2677. match = a => a.MaxGray < condition.conditionNum;
  2678. break;
  2679. case 2:
  2680. match = a => a.MaxGray >= condition.conditionNum;
  2681. break;
  2682. case 3:
  2683. match = a => a.MaxGray <= condition.conditionNum;
  2684. break;
  2685. }
  2686. break;
  2687. case DebrisSelectionParameters.minGray:
  2688. switch (condition.judgeCondition)
  2689. {
  2690. case 0:
  2691. match = a => a.MinGray > condition.conditionNum;
  2692. break;
  2693. case 1:
  2694. match = a => a.MinGray < condition.conditionNum;
  2695. break;
  2696. case 2:
  2697. match = a => a.MinGray >= condition.conditionNum;
  2698. break;
  2699. case 3:
  2700. match = a => a.MinGray <= condition.conditionNum;
  2701. break;
  2702. }
  2703. break;
  2704. case DebrisSelectionParameters.avgGray:
  2705. switch (condition.judgeCondition)
  2706. {
  2707. case 0:
  2708. match = a => a.AvgGray > condition.conditionNum;
  2709. break;
  2710. case 1:
  2711. match = a => a.AvgGray < condition.conditionNum;
  2712. break;
  2713. case 2:
  2714. match = a => a.AvgGray >= condition.conditionNum;
  2715. break;
  2716. case 3:
  2717. match = a => a.AvgGray <= condition.conditionNum;
  2718. break;
  2719. }
  2720. break;
  2721. case DebrisSelectionParameters.fiberLength:
  2722. switch (condition.judgeCondition)
  2723. {
  2724. case 0:
  2725. match = a => a.FiberLength > condition.conditionNum;
  2726. break;
  2727. case 1:
  2728. match = a => a.FiberLength < condition.conditionNum;
  2729. break;
  2730. case 2:
  2731. match = a => a.FiberLength >= condition.conditionNum;
  2732. break;
  2733. case 3:
  2734. match = a => a.FiberLength <= condition.conditionNum;
  2735. break;
  2736. }
  2737. break;
  2738. case DebrisSelectionParameters.fillArea:
  2739. switch (condition.judgeCondition)
  2740. {
  2741. case 0:
  2742. match = a => a.FillArea > condition.conditionNum;
  2743. break;
  2744. case 1:
  2745. match = a => a.FillArea < condition.conditionNum;
  2746. break;
  2747. case 2:
  2748. match = a => a.FillArea >= condition.conditionNum;
  2749. break;
  2750. case 3:
  2751. match = a => a.FillArea <= condition.conditionNum;
  2752. break;
  2753. }
  2754. break;
  2755. case DebrisSelectionParameters.waistDepth:
  2756. switch (condition.judgeCondition)
  2757. {
  2758. case 0:
  2759. match = a => a.WaistDepth > condition.conditionNum;
  2760. break;
  2761. case 1:
  2762. match = a => a.WaistDepth < condition.conditionNum;
  2763. break;
  2764. case 2:
  2765. match = a => a.WaistDepth >= condition.conditionNum;
  2766. break;
  2767. case 3:
  2768. match = a => a.WaistDepth <= condition.conditionNum;
  2769. break;
  2770. }
  2771. break;
  2772. case DebrisSelectionParameters.waistDepthShort:
  2773. switch (condition.judgeCondition)
  2774. {
  2775. case 0:
  2776. match = a => a.WaistDepthShort > condition.conditionNum;
  2777. break;
  2778. case 1:
  2779. match = a => a.WaistDepthShort < condition.conditionNum;
  2780. break;
  2781. case 2:
  2782. match = a => a.WaistDepthShort >= condition.conditionNum;
  2783. break;
  2784. case 3:
  2785. match = a => a.WaistDepthShort <= condition.conditionNum;
  2786. break;
  2787. }
  2788. break;
  2789. }
  2790. //获取临时的筛选集合
  2791. temp = temps.FindAll(match).ToList();
  2792. if (flag - 1 >= 0)
  2793. {
  2794. //如果上一个循环是And
  2795. if (debrisSelection.conditionList[flag - 1].joinCondition == 0)
  2796. {
  2797. set = temp;
  2798. }
  2799. else
  2800. {
  2801. set.AddRange(temp);
  2802. }
  2803. }
  2804. else
  2805. {
  2806. set.AddRange(temp);
  2807. }
  2808. //去重复
  2809. set = set.Where((x, i) => set.FindIndex(n => n.index == x.index) == i).ToList();
  2810. if (flag < debrisSelection.conditionList.Count())
  2811. {
  2812. //指定下一次循环从什么数据集中过滤
  2813. if (condition.joinCondition == 0)
  2814. temps = set;
  2815. else
  2816. temps = this.list;
  2817. }
  2818. }
  2819. //对index重新赋值
  2820. for (int i = 0; i < set.Count(); i++)
  2821. {
  2822. set[i].index = i + 1;
  2823. }
  2824. }
  2825. }
  2826. }
  2827. }
  2828. /// <summary>
  2829. /// 根据筛选的条件进行绘制
  2830. /// </summary>
  2831. private void DrawConditionMat()
  2832. {
  2833. if (this.set != null && this.set.Count > 0 && this.binarizationMat != null)
  2834. {
  2835. Mat mat1 = this.binarizationMat.Clone();
  2836. List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
  2837. foreach (ContoursAndRelatedInfo c in set)
  2838. {
  2839. points.Add(c.contours.ToList());
  2840. }
  2841. if (points.Count > 0)
  2842. {
  2843. Mat temp = mat1.CvtColor(ColorConversionCodes.BGRA2BGR);
  2844. for (int k = 0; k < points.Count; k++)
  2845. {
  2846. Rect rect;
  2847. if (k == this.gridView1SelectIndex)
  2848. {
  2849. Cv2.FloodFill(temp, points[k][0], new Scalar(255 - this.panel2.BackColor.B, 255 - this.panel2.BackColor.G, 255 - this.panel2.BackColor.R, 255), out rect, null, null, FloodFillFlags.Link8);
  2850. }
  2851. else
  2852. {
  2853. Cv2.FloodFill(temp, points[k][0], new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255), out rect, null, null, FloodFillFlags.Link8);
  2854. }
  2855. }
  2856. Cv2.Merge(temp.Split().Union(new Mat[] { mat1.Split()[3] }).ToArray(), mat1);
  2857. //Cv2.FillPoly(mat1, points, new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255)) ;
  2858. //如果显示编号,则绘制编号
  2859. //如果显示参数,则绘制参数
  2860. if (this.checkBox2.Checked || this.checkBox3.Checked)
  2861. {
  2862. using (Bitmap bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat1))
  2863. {
  2864. Graphics graphics = Graphics.FromImage(bitmap);
  2865. Font font = new Font(this.comboBox2.SelectedItem.ToString(), (int)this.numericUpDown3.Value);
  2866. Color color1 = this.panel1.BackColor;
  2867. Color color3 = this.panel3.BackColor;
  2868. foreach (ContoursAndRelatedInfo c in set)
  2869. {
  2870. if (this.checkBox2.Checked)
  2871. {
  2872. graphics.DrawString(c.index.ToString(), font, new SolidBrush(color1), new System.Drawing.Point(c.contours[0].X, c.contours[0].Y));
  2873. //Cv2.PutText(mat1, c.index.ToString(), new OpenCvSharp.Point(c.contours[0].X, c.contours[0].Y), HersheyFonts.HersheyComplex, 1, new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255), 3);
  2874. }
  2875. if (this.checkBox3.Checked && this.comboBox1.SelectedValue != null)
  2876. {
  2877. switch ((DebrisSelectionParameters)((int)(this.comboBox1.SelectedValue)))
  2878. {
  2879. case DebrisSelectionParameters.area:
  2880. graphics.DrawString(Math.Round(c.Area, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2881. break;
  2882. case DebrisSelectionParameters.areaRatio:
  2883. graphics.DrawString(Math.Round(c.AreaRatio, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2884. break;
  2885. case DebrisSelectionParameters.perimeter:
  2886. graphics.DrawString(Math.Round(c.Perimeter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2887. break;
  2888. case DebrisSelectionParameters.longAxis:
  2889. graphics.DrawString(Math.Round(c.LongAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2890. break;
  2891. case DebrisSelectionParameters.shortAxis:
  2892. graphics.DrawString(Math.Round(c.ShortAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2893. break;
  2894. case DebrisSelectionParameters.centerX:
  2895. graphics.DrawString(Math.Round(c.CenterX * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2896. break;
  2897. case DebrisSelectionParameters.centerY:
  2898. graphics.DrawString(Math.Round(c.CenterY * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2899. break;
  2900. case DebrisSelectionParameters.inclinationAngle:
  2901. graphics.DrawString(Math.Round(c.InclinationAngle, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2902. break;
  2903. case DebrisSelectionParameters.objectAppearance:
  2904. graphics.DrawString(Math.Round(c.ObjectAppearance, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2905. break;
  2906. case DebrisSelectionParameters.height:
  2907. graphics.DrawString(Math.Round(c.Height * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2908. break;
  2909. case DebrisSelectionParameters.width:
  2910. graphics.DrawString(Math.Round(c.Width * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2911. break;
  2912. case DebrisSelectionParameters.aspectRatio:
  2913. graphics.DrawString(Math.Round(c.AspectRatio, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2914. break;
  2915. case DebrisSelectionParameters.redDensity:
  2916. graphics.DrawString(Math.Round(c.RedDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2917. break;
  2918. case DebrisSelectionParameters.greenDensity:
  2919. graphics.DrawString(Math.Round(c.GreenDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2920. break;
  2921. case DebrisSelectionParameters.blueDensity:
  2922. graphics.DrawString(Math.Round(c.BlueDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2923. break;
  2924. /*case DebrisSelectionParameters.maxDensity:
  2925. break;
  2926. case DebrisSelectionParameters.minDensity:
  2927. break;
  2928. case DebrisSelectionParameters.avgDensity:
  2929. break;
  2930. case DebrisSelectionParameters.sumDensity:
  2931. break;*/
  2932. case DebrisSelectionParameters.majorAxis:
  2933. graphics.DrawString(Math.Round(c.MajorAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2934. break;
  2935. case DebrisSelectionParameters.minorAxis:
  2936. graphics.DrawString(Math.Round(c.MinorAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2937. break;
  2938. case DebrisSelectionParameters.circumcircleDiameter:
  2939. graphics.DrawString(Math.Round(c.CircumcircleDiameter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2940. break;
  2941. case DebrisSelectionParameters.nodularity:
  2942. graphics.DrawString(Math.Round(c.Nodularity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2943. break;
  2944. case DebrisSelectionParameters.equalCircleDiameter:
  2945. graphics.DrawString(Math.Round(c.EqualCircleDiameter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2946. break;
  2947. case DebrisSelectionParameters.maxCaliperDiameter:
  2948. graphics.DrawString(Math.Round(c.MaxCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2949. break;
  2950. case DebrisSelectionParameters.minCaliperDiameter:
  2951. graphics.DrawString(Math.Round(c.MinCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2952. break;
  2953. case DebrisSelectionParameters.avgCaliperDiameter:
  2954. graphics.DrawString(Math.Round(c.AvgCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2955. break;
  2956. case DebrisSelectionParameters.maxGray:
  2957. graphics.DrawString(Math.Round(c.MaxGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2958. break;
  2959. case DebrisSelectionParameters.minGray:
  2960. graphics.DrawString(Math.Round(c.MinGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2961. break;
  2962. case DebrisSelectionParameters.avgGray:
  2963. graphics.DrawString(Math.Round(c.AvgGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2964. break;
  2965. case DebrisSelectionParameters.fiberLength:
  2966. graphics.DrawString(Math.Round(c.FiberLength, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2967. break;
  2968. case DebrisSelectionParameters.fillArea:
  2969. graphics.DrawString(Math.Round(c.FillArea, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2970. break;
  2971. case DebrisSelectionParameters.waistDepth:
  2972. //graphics.DrawLine(new Pen(Color.Blue), new System.Drawing.Point(c.points_max[0].X, c.points_max[0].Y), new System.Drawing.Point(c.points_max[1].X, c.points_max[1].Y));
  2973. //graphics.DrawLine(new Pen(Color.Blue), new System.Drawing.Point(c.points_min[0].X, c.points_min[0].Y), new System.Drawing.Point(c.points_min[1].X, c.points_min[1].Y));
  2974. graphics.DrawString(Math.Round(c.WaistDepth, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2975. break;
  2976. case DebrisSelectionParameters.waistDepthShort:
  2977. graphics.DrawString(Math.Round(c.WaistDepthShort, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2978. break;
  2979. }
  2980. }
  2981. }
  2982. mat1 = PaintDotNet.Camera.Tools.ToMat(bitmap);
  2983. }
  2984. }
  2985. }
  2986. this.phaseModel.mat = mat1;
  2987. this.documentWorkspace.Refresh();
  2988. }
  2989. else
  2990. {
  2991. if (this.binarizationMat != null)
  2992. {
  2993. this.phaseModel.mat = this.binarizationMat;
  2994. this.documentWorkspace.Refresh();
  2995. }
  2996. }
  2997. }
  2998. private void CreateCalipersDataTable()
  2999. {
  3000. if (this.set == null || this.set.Count == 0)
  3001. {
  3002. MessageBox.Show("数据为空!");
  3003. return;
  3004. }
  3005. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  3006. List<ContoursAndRelatedInfo> setCalipers = new List<ContoursAndRelatedInfo>(this.set);
  3007. var type = config.calipersSetModel.sort;//获取排序选项
  3008. int sortMode = config.calipersSetModel.sortMode;//获取排序方式
  3009. int exportRecord = config.calipersSetModel.exportRecord;//导出记录
  3010. //var keyss = InvariantData.debrisSelectionparameters.Where(q => q.Value.ToString() == type).Select(q => q.Key);
  3011. var firstKey = InvariantData.debrisSelectionparameters.FirstOrDefault(q => q.Value.ToString() == type).Key;
  3012. switch (firstKey)
  3013. {
  3014. case DebrisSelectionParameters.area:
  3015. if (sortMode == 1) setCalipers.Sort((x, y) => -x.area.CompareTo(y.area));
  3016. else setCalipers.Sort((x, y) => x.area.CompareTo(y.area));
  3017. break;
  3018. case DebrisSelectionParameters.areaRatio:
  3019. if (sortMode == 1) setCalipers.Sort((x, y) => -x.areaRatio.CompareTo(y.areaRatio));
  3020. else setCalipers.Sort((x, y) => x.areaRatio.CompareTo(y.areaRatio));
  3021. break;
  3022. case DebrisSelectionParameters.perimeter:
  3023. if (sortMode == 1) setCalipers.Sort((x, y) => -x.perimeter.CompareTo(y.perimeter));
  3024. else setCalipers.Sort((x, y) => x.perimeter.CompareTo(y.perimeter));
  3025. break;
  3026. case DebrisSelectionParameters.longAxis:
  3027. if (sortMode == 1) setCalipers.Sort((x, y) => -x.longAxis.CompareTo(y.longAxis));
  3028. else setCalipers.Sort((x, y) => x.longAxis.CompareTo(y.longAxis));
  3029. break;
  3030. case DebrisSelectionParameters.shortAxis:
  3031. if (sortMode == 1) setCalipers.Sort((x, y) => -x.shortAxis.CompareTo(y.shortAxis));
  3032. else setCalipers.Sort((x, y) => x.shortAxis.CompareTo(y.shortAxis));
  3033. break;
  3034. case DebrisSelectionParameters.centerX:
  3035. if (sortMode == 1) setCalipers.Sort((x, y) => -x.centerX.CompareTo(y.centerX));
  3036. else setCalipers.Sort((x, y) => x.centerX.CompareTo(y.centerX));
  3037. break;
  3038. case DebrisSelectionParameters.centerY:
  3039. if (sortMode == 1) setCalipers.Sort((x, y) => -x.centerY.CompareTo(y.centerY));
  3040. else setCalipers.Sort((x, y) => x.centerY.CompareTo(y.centerY));
  3041. break;
  3042. case DebrisSelectionParameters.inclinationAngle:
  3043. if (sortMode == 1) setCalipers.Sort((x, y) => -x.inclinationAngle.CompareTo(y.inclinationAngle));
  3044. else setCalipers.Sort((x, y) => x.inclinationAngle.CompareTo(y.inclinationAngle));
  3045. break;
  3046. case DebrisSelectionParameters.objectAppearance:
  3047. if (sortMode == 1) setCalipers.Sort((x, y) => -x.inclinationAngle.CompareTo(y.inclinationAngle));
  3048. else setCalipers.Sort((x, y) => x.inclinationAngle.CompareTo(y.inclinationAngle));
  3049. break;
  3050. case DebrisSelectionParameters.height:
  3051. if (sortMode == 1) setCalipers.Sort((x, y) => -x.height.CompareTo(y.height));
  3052. else setCalipers.Sort((x, y) => x.height.CompareTo(y.height));
  3053. break;
  3054. case DebrisSelectionParameters.width:
  3055. if (sortMode == 1) setCalipers.Sort((x, y) => -x.width.CompareTo(y.width));
  3056. else setCalipers.Sort((x, y) => x.width.CompareTo(y.width));
  3057. break;
  3058. case DebrisSelectionParameters.aspectRatio:
  3059. if (sortMode == 1) setCalipers.Sort((x, y) => -x.aspectRatio.CompareTo(y.aspectRatio));
  3060. else setCalipers.Sort((x, y) => x.aspectRatio.CompareTo(y.aspectRatio));
  3061. break;
  3062. case DebrisSelectionParameters.redDensity:
  3063. if (sortMode == 1) setCalipers.Sort((x, y) => -x.redDensity.CompareTo(y.redDensity));
  3064. else setCalipers.Sort((x, y) => x.redDensity.CompareTo(y.redDensity));
  3065. break;
  3066. case DebrisSelectionParameters.greenDensity:
  3067. if (sortMode == 1) setCalipers.Sort((x, y) => -x.greenDensity.CompareTo(y.greenDensity));
  3068. else setCalipers.Sort((x, y) => x.greenDensity.CompareTo(y.greenDensity));
  3069. break;
  3070. case DebrisSelectionParameters.blueDensity:
  3071. if (sortMode == 1) setCalipers.Sort((x, y) => -x.blueDensity.CompareTo(y.blueDensity));
  3072. else setCalipers.Sort((x, y) => x.blueDensity.CompareTo(y.blueDensity));
  3073. break;
  3074. /*case DebrisSelectionParameters.maxDensity:
  3075. break;
  3076. case DebrisSelectionParameters.minDensity:
  3077. break;
  3078. case DebrisSelectionParameters.avgDensity:
  3079. break;
  3080. case DebrisSelectionParameters.sumDensity:
  3081. break;*/
  3082. case DebrisSelectionParameters.majorAxis:
  3083. if (sortMode == 1) setCalipers.Sort((x, y) => -x.majorAxis.CompareTo(y.majorAxis));
  3084. else setCalipers.Sort((x, y) => x.majorAxis.CompareTo(y.majorAxis));
  3085. break;
  3086. case DebrisSelectionParameters.minorAxis:
  3087. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minorAxis.CompareTo(y.minorAxis));
  3088. else setCalipers.Sort((x, y) => x.minorAxis.CompareTo(y.minorAxis));
  3089. break;
  3090. case DebrisSelectionParameters.circumcircleDiameter:
  3091. if (sortMode == 1) setCalipers.Sort((x, y) => -x.circumcircleDiameter.CompareTo(y.circumcircleDiameter));
  3092. else setCalipers.Sort((x, y) => x.circumcircleDiameter.CompareTo(y.circumcircleDiameter));
  3093. break;
  3094. case DebrisSelectionParameters.nodularity:
  3095. if (sortMode == 1) setCalipers.Sort((x, y) => -x.nodularity.CompareTo(y.nodularity));
  3096. else setCalipers.Sort((x, y) => x.nodularity.CompareTo(y.nodularity));
  3097. break;
  3098. case DebrisSelectionParameters.equalCircleDiameter:
  3099. if (sortMode == 1) setCalipers.Sort((x, y) => -x.equalCircleDiameter.CompareTo(y.equalCircleDiameter));
  3100. else setCalipers.Sort((x, y) => x.equalCircleDiameter.CompareTo(y.equalCircleDiameter));
  3101. break;
  3102. case DebrisSelectionParameters.maxCaliperDiameter:
  3103. if (sortMode == 1) setCalipers.Sort((x, y) => -x.maxCaliperDiameter.CompareTo(y.maxCaliperDiameter));
  3104. else setCalipers.Sort((x, y) => x.maxCaliperDiameter.CompareTo(y.maxCaliperDiameter));
  3105. break;
  3106. case DebrisSelectionParameters.minCaliperDiameter:
  3107. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minCaliperDiameter.CompareTo(y.minCaliperDiameter));
  3108. else setCalipers.Sort((x, y) => x.minCaliperDiameter.CompareTo(y.minCaliperDiameter));
  3109. break;
  3110. case DebrisSelectionParameters.avgCaliperDiameter:
  3111. if (sortMode == 1) setCalipers.Sort((x, y) => -x.avgCaliperDiameter.CompareTo(y.avgCaliperDiameter));
  3112. else setCalipers.Sort((x, y) => x.avgCaliperDiameter.CompareTo(y.avgCaliperDiameter));
  3113. break;
  3114. case DebrisSelectionParameters.maxGray:
  3115. if (sortMode == 1) setCalipers.Sort((x, y) => -x.maxGray.CompareTo(y.maxGray));
  3116. else setCalipers.Sort((x, y) => x.maxGray.CompareTo(y.maxGray));
  3117. break;
  3118. case DebrisSelectionParameters.minGray:
  3119. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minGray.CompareTo(y.minGray));
  3120. else setCalipers.Sort((x, y) => x.minGray.CompareTo(y.minGray));
  3121. break;
  3122. case DebrisSelectionParameters.avgGray:
  3123. if (sortMode == 1) setCalipers.Sort((x, y) => -x.avgGray.CompareTo(y.avgGray));
  3124. else setCalipers.Sort((x, y) => x.avgGray.CompareTo(y.avgGray));
  3125. break;
  3126. case DebrisSelectionParameters.fiberLength:
  3127. if (sortMode == 1) setCalipers.Sort((x, y) => -x.fiberLength.CompareTo(y.fiberLength));
  3128. else setCalipers.Sort((x, y) => x.fiberLength.CompareTo(y.fiberLength));
  3129. break;
  3130. case DebrisSelectionParameters.fillArea:
  3131. if (sortMode == 1) setCalipers.Sort((x, y) => -x.fillArea.CompareTo(y.fillArea));
  3132. else setCalipers.Sort((x, y) => x.fillArea.CompareTo(y.fillArea));
  3133. break;
  3134. case DebrisSelectionParameters.waistDepth:
  3135. if (sortMode == 1) setCalipers.Sort((x, y) => -x.waistDepth.CompareTo(y.waistDepth));
  3136. else setCalipers.Sort((x, y) => x.waistDepth.CompareTo(y.waistDepth));
  3137. break;
  3138. case DebrisSelectionParameters.waistDepthShort:
  3139. if (sortMode == 1) setCalipers.Sort((x, y) => -x.waistDepthShort.CompareTo(y.waistDepthShort));
  3140. else setCalipers.Sort((x, y) => x.waistDepthShort.CompareTo(y.waistDepthShort));
  3141. break;
  3142. }
  3143. var vs = InvariantData.debrisSelectionparameters.Values;
  3144. string[] lst = vs.Select(a => a.ToString()).ToArray();
  3145. DataTable calipersTable = new DataTable();
  3146. DataColumn dc = new DataColumn("图片名称");
  3147. calipersTable.Columns.Add(dc);
  3148. dc = new DataColumn("颗粒编号");
  3149. calipersTable.Columns.Add(dc);
  3150. dc = new DataColumn("最大卡规直径");
  3151. calipersTable.Columns.Add(dc);
  3152. dc = new DataColumn("最小卡规直径");
  3153. calipersTable.Columns.Add(dc);
  3154. dc = new DataColumn("平均卡规直径");
  3155. calipersTable.Columns.Add(dc);
  3156. dc = new DataColumn("最大/最小卡规直径");
  3157. calipersTable.Columns.Add(dc);
  3158. dc = new DataColumn("最小/最大卡规直径");
  3159. calipersTable.Columns.Add(dc);
  3160. for (int i = 1; i < 33; i++)
  3161. {
  3162. dc = new DataColumn("卡规" + i);
  3163. calipersTable.Columns.Add(dc);
  3164. }
  3165. int length = exportRecord == 0 ? setCalipers.Count : (exportRecord > setCalipers.Count ? setCalipers.Count : exportRecord);
  3166. for (int count = 0; count < length; count++)
  3167. {
  3168. DataRow dr = calipersTable.NewRow();
  3169. int index = 0;
  3170. for (int i = 0; i < calipersTable.Columns.Count; i++)
  3171. {
  3172. if (i == 0) dr[i] = imgName;
  3173. if (i == 1) dr[i] = setCalipers[count].index;
  3174. if (i == 2) dr[i] = setCalipers[count].MaxCaliperDiameter;
  3175. if (i == 3) dr[i] = setCalipers[count].MinCaliperDiameter;
  3176. if (i == 4) dr[i] = setCalipers[count].AvgCaliperDiameter;
  3177. if (i == 5) dr[i] = setCalipers[count].MinCaliperDiameter == 0 ? 0 : setCalipers[count].MaxCaliperDiameter / setCalipers[count].MinCaliperDiameter;
  3178. if (i == 6) dr[i] = setCalipers[count].MaxCaliperDiameter == 0 ? 0 : setCalipers[count].MinCaliperDiameter / setCalipers[count].MaxCaliperDiameter;
  3179. if (i > 6)
  3180. {
  3181. for (int j = index; j < 32; j++)
  3182. {
  3183. dr[i] = setCalipers[count].Vs.Count > j ? setCalipers[count].Vs[j] * ruleValue : 0;
  3184. index = j + 1;
  3185. break;
  3186. }
  3187. }
  3188. }
  3189. calipersTable.Rows.Add(dr);
  3190. //calipersTable.Rows.Add(imgName, count + 1, setCalipers[count].Area, setCalipers[count].AreaRatio, setCalipers[count].Perimeter, setCalipers[count].LongAxis, setCalipers[count].ShortAxis, setCalipers[count].CenterX, setCalipers[count].CenterY, setCalipers[count].InclinationAngle, setCalipers[count].ObjectAppearance, setCalipers[count].Height, setCalipers[count].Width, setCalipers[count].AspectRatio, setCalipers[count].RedDensity, setCalipers[count].GreenDensity, setCalipers[count].BlueDensity, setCalipers[count].MajorAxis, setCalipers[count].MinorAxis, setCalipers[count].CircumcircleDiameter, setCalipers[count].Nodularity, setCalipers[count].EqualCircleDiameter, setCalipers[count].MaxCaliperDiameter, setCalipers[count].MinCaliperDiameter, setCalipers[count].AvgCaliperDiameter, setCalipers[count].MaxGray, setCalipers[count].MinGray, setCalipers[count].AvgGray, setCalipers[count].FiberLength, setCalipers[count].FillArea, setCalipers[count].WaistDepth, setCalipers[count].WaistDepthShort);
  3191. }
  3192. OfficeFileHandleHelper.calipersTable = calipersTable;
  3193. //OfficeFileHandleHelper.ExportCalipersSet(calipersTable, "");
  3194. }
  3195. /// <summary>
  3196. /// 将筛选的结果添加到datagridview中
  3197. /// </summary>
  3198. private void CreateDataGridViewData()
  3199. {
  3200. if (this.set != null && this.set.Count > 0)
  3201. {
  3202. this.set.Sort((l, r) => l.index.CompareTo(r.index));
  3203. this.dataGridView1.Rows.Clear();
  3204. foreach (ContoursAndRelatedInfo c in set)
  3205. {
  3206. DataGridViewRow row = new DataGridViewRow();
  3207. row.Height = 25;
  3208. row.Cells.Add(CreateTextBoxCell(c.index, c.index));
  3209. foreach (var item in listDictionary)
  3210. {
  3211. switch (item.Key)
  3212. {
  3213. case DebrisSelectionParameters.area:
  3214. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Area, (int)this.numericUpDown1.Value), c.Area));
  3215. break;
  3216. case DebrisSelectionParameters.areaRatio:
  3217. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AreaRatio, (int)this.numericUpDown1.Value), c.AreaRatio));
  3218. break;
  3219. case DebrisSelectionParameters.perimeter:
  3220. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Perimeter, (int)this.numericUpDown1.Value), c.Perimeter));
  3221. break;
  3222. case DebrisSelectionParameters.longAxis:
  3223. row.Cells.Add(CreateTextBoxCell(Math.Round(c.LongAxis, (int)this.numericUpDown1.Value), c.LongAxis));
  3224. break;
  3225. case DebrisSelectionParameters.shortAxis:
  3226. row.Cells.Add(CreateTextBoxCell(Math.Round(c.ShortAxis, (int)this.numericUpDown1.Value), c.ShortAxis));
  3227. break;
  3228. case DebrisSelectionParameters.centerX:
  3229. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CenterX * 1d, (int)this.numericUpDown1.Value), c.CenterX));
  3230. break;
  3231. case DebrisSelectionParameters.centerY:
  3232. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CenterY * 1d, (int)this.numericUpDown1.Value), c.CenterY));
  3233. break;
  3234. case DebrisSelectionParameters.inclinationAngle:
  3235. row.Cells.Add(CreateTextBoxCell(Math.Round(c.InclinationAngle, (int)this.numericUpDown1.Value), c.InclinationAngle));
  3236. break;
  3237. case DebrisSelectionParameters.objectAppearance:
  3238. row.Cells.Add(CreateTextBoxCell(Math.Round(c.ObjectAppearance, (int)this.numericUpDown1.Value), c.ObjectAppearance));
  3239. break;
  3240. case DebrisSelectionParameters.height:
  3241. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Height * 1d, (int)this.numericUpDown1.Value), c.Height));
  3242. break;
  3243. case DebrisSelectionParameters.width:
  3244. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Width * 1d, (int)this.numericUpDown1.Value), c.Width));
  3245. break;
  3246. case DebrisSelectionParameters.aspectRatio:
  3247. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AspectRatio, (int)this.numericUpDown1.Value), c.AspectRatio));
  3248. break;
  3249. case DebrisSelectionParameters.redDensity:
  3250. row.Cells.Add(CreateTextBoxCell(Math.Round(c.RedDensity, (int)this.numericUpDown1.Value), c.RedDensity));
  3251. break;
  3252. case DebrisSelectionParameters.greenDensity:
  3253. row.Cells.Add(CreateTextBoxCell(Math.Round(c.GreenDensity, (int)this.numericUpDown1.Value), c.GreenDensity));
  3254. break;
  3255. case DebrisSelectionParameters.blueDensity:
  3256. row.Cells.Add(CreateTextBoxCell(Math.Round(c.BlueDensity, (int)this.numericUpDown1.Value), c.BlueDensity));
  3257. break;
  3258. /*case DebrisSelectionParameters.maxDensity:
  3259. break;
  3260. case DebrisSelectionParameters.minDensity:
  3261. break;
  3262. case DebrisSelectionParameters.avgDensity:
  3263. break;
  3264. case DebrisSelectionParameters.sumDensity:
  3265. break;*/
  3266. case DebrisSelectionParameters.majorAxis:
  3267. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MajorAxis, (int)this.numericUpDown1.Value), c.MajorAxis));
  3268. break;
  3269. case DebrisSelectionParameters.minorAxis:
  3270. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinorAxis, (int)this.numericUpDown1.Value), c.MinorAxis));
  3271. break;
  3272. case DebrisSelectionParameters.circumcircleDiameter:
  3273. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CircumcircleDiameter, (int)this.numericUpDown1.Value), c.CircumcircleDiameter));
  3274. break;
  3275. case DebrisSelectionParameters.nodularity:
  3276. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Nodularity, (int)this.numericUpDown1.Value), c.Nodularity));
  3277. break;
  3278. case DebrisSelectionParameters.equalCircleDiameter:
  3279. row.Cells.Add(CreateTextBoxCell(Math.Round(c.EqualCircleDiameter, (int)this.numericUpDown1.Value), c.EqualCircleDiameter));
  3280. break;
  3281. case DebrisSelectionParameters.maxCaliperDiameter:
  3282. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MaxCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.MaxCaliperDiameter));
  3283. break;
  3284. case DebrisSelectionParameters.minCaliperDiameter:
  3285. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.MinCaliperDiameter));
  3286. break;
  3287. case DebrisSelectionParameters.avgCaliperDiameter:
  3288. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AvgCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.AvgCaliperDiameter));
  3289. break;
  3290. case DebrisSelectionParameters.maxGray:
  3291. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MaxGray, (int)this.numericUpDown1.Value), c.MaxGray));
  3292. break;
  3293. case DebrisSelectionParameters.minGray:
  3294. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinGray, (int)this.numericUpDown1.Value), c.MinGray));
  3295. break;
  3296. case DebrisSelectionParameters.avgGray:
  3297. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AvgGray, (int)this.numericUpDown1.Value), c.AvgGray));
  3298. break;
  3299. case DebrisSelectionParameters.fiberLength:
  3300. row.Cells.Add(CreateTextBoxCell(Math.Round(c.FiberLength, (int)this.numericUpDown1.Value), c.FiberLength));
  3301. break;
  3302. case DebrisSelectionParameters.fillArea:
  3303. row.Cells.Add(CreateTextBoxCell(Math.Round(c.FillArea, (int)this.numericUpDown1.Value), c.FillArea));
  3304. break;
  3305. case DebrisSelectionParameters.waistDepth:
  3306. row.Cells.Add(CreateTextBoxCell(Math.Round(c.WaistDepth, (int)this.numericUpDown1.Value), c.WaistDepth));
  3307. break;
  3308. case DebrisSelectionParameters.waistDepthShort:
  3309. row.Cells.Add(CreateTextBoxCell(Math.Round(c.WaistDepthShort, (int)this.numericUpDown1.Value), c.WaistDepthShort));
  3310. break;
  3311. }
  3312. }
  3313. if (this.dataGridView1.Columns.Count > 0)
  3314. {
  3315. this.dataGridView1.Rows.Add(row);
  3316. }
  3317. }
  3318. }
  3319. else
  3320. {
  3321. this.dataGridView1.Rows.Clear();
  3322. }
  3323. }
  3324. /// <summary>
  3325. /// 分析结果列表选择切换
  3326. /// </summary>
  3327. /// <param name="sender"></param>
  3328. /// <param name="e"></param>
  3329. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  3330. {
  3331. if (this.showAll)
  3332. return;
  3333. RefreshDataGridView2();
  3334. }
  3335. /// <summary>
  3336. /// 刷新数据展示表
  3337. /// </summary>
  3338. private void RefreshDataGridView1()
  3339. {
  3340. this.dataGridView1.Rows.Clear();
  3341. }
  3342. /// <summary>
  3343. /// 二值化颜色panel被点击
  3344. /// </summary>
  3345. /// <param name="sender"></param>
  3346. /// <param name="e"></param>
  3347. private void panel1_Click(object sender, EventArgs e)
  3348. {
  3349. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  3350. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  3351. this.colorsForm1.ShowDialog();
  3352. }
  3353. private void colorsForm1Changed(object sender, EventArgs e)
  3354. {
  3355. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  3356. this.colorsForm1.Close();
  3357. this.documentWorkspace.Refresh();
  3358. }
  3359. /// <summary>
  3360. /// 小数数字框值改变
  3361. /// </summary>
  3362. /// <param name="sender"></param>
  3363. /// <param name="e"></param>
  3364. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  3365. {
  3366. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  3367. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  3368. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  3369. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  3370. this.RefreshDataGridView1();
  3371. this.listView1_SelectedIndexChanged(null, null);
  3372. this.RefreshDataGridView2();
  3373. this.DrawConditionMat();
  3374. }
  3375. /// <summary>
  3376. /// 导出项目到项目工程
  3377. /// </summary>
  3378. /// <param name="sender"></param>
  3379. /// <param name="e"></param>
  3380. private void button3_Click(object sender, EventArgs e)
  3381. {
  3382. try
  3383. {
  3384. if (this.analyzeSettingModel == null)
  3385. {
  3386. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3387. return;
  3388. }
  3389. //获取项目工程内的文件夹路径
  3390. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.ParticleStatistics.Text", this.analyzeSettingModel.savePath);
  3391. if (item != null)
  3392. {
  3393. //向文件夹内保存图片和报告
  3394. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3395. {
  3396. //获取word书签与excel单元格的关系,以字典方式存储
  3397. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3398. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3399. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3400. {
  3401. foreach (mic_module_infos info in mic_module_infos)
  3402. {
  3403. tagInfos.Add(info.tag_name, info.cell_position);
  3404. }
  3405. }
  3406. //分析结果
  3407. List<List<string>> analysisContent = new List<List<string>>();
  3408. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3409. {
  3410. int k = 0;
  3411. int kk = 0;
  3412. foreach (DataTable dt in resultTableList)
  3413. {
  3414. if (kk == 0)
  3415. {
  3416. List<string> contentHead = new List<string>();
  3417. for (int ii = 0; ii < dt.Columns.Count; ii++)
  3418. {
  3419. contentHead.Add(dt.Columns[ii].ColumnName);
  3420. }
  3421. analysisContent.Add(contentHead);
  3422. kk++;
  3423. }
  3424. //如果不是显示全部
  3425. if (!this.showAll)
  3426. {
  3427. if (!ExistInSelectItems(dt.TableName))
  3428. continue;
  3429. }
  3430. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  3431. {
  3432. List<string> content = new List<string>();
  3433. for (int j = 0; j < dt.Columns.Count; j++)
  3434. {
  3435. if (j > 0)
  3436. {
  3437. content.Add(Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value).ToString());
  3438. }
  3439. else
  3440. {
  3441. content.Add(row[j].ToString());
  3442. }
  3443. }
  3444. analysisContent.Add(content);
  3445. k++;
  3446. }
  3447. }
  3448. }
  3449. //图片
  3450. bitList = new List<Bitmap>();
  3451. if (this.showAll)
  3452. {
  3453. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  3454. {
  3455. bitList.Add(kv.Value[0]);
  3456. bitList.Add(kv.Value[1]);
  3457. }
  3458. }
  3459. else
  3460. {
  3461. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3462. {
  3463. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  3464. {
  3465. if (bitDic.ContainsKey(rowItem.Name))
  3466. {
  3467. bitList.Add(bitDic[rowItem.Name][0]);
  3468. bitList.Add(bitDic[rowItem.Name][1]);
  3469. }
  3470. }
  3471. }
  3472. }
  3473. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, null, bitList, tagInfos, item.path, item.code);
  3474. }
  3475. else
  3476. {
  3477. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3478. return;
  3479. }
  3480. //保存项目信息到数据库
  3481. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  3482. }
  3483. }
  3484. catch (Exception)
  3485. {
  3486. }
  3487. }
  3488. /// <summary>
  3489. /// 设置统计数据按钮
  3490. /// </summary>
  3491. /// <param name="sender"></param>
  3492. /// <param name="e"></param>
  3493. private void button4_Click(object sender, EventArgs e)
  3494. {
  3495. using (DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog = new DebrisSelectionValidConditionDialog(this))
  3496. {
  3497. debrisSelectionValidConditionDialog.StartPosition = FormStartPosition.CenterScreen;
  3498. debrisSelectionValidConditionDialog.ShowDialog();
  3499. }
  3500. }
  3501. /// <summary>
  3502. /// 统计选择下拉框切换
  3503. /// </summary>
  3504. /// <param name="sender"></param>
  3505. /// <param name="e"></param>
  3506. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  3507. {
  3508. this.RefreshDebirsDataGrid();
  3509. this.listView1_SelectedIndexChanged(null, null);
  3510. }
  3511. private void panel2_Click(object sender, EventArgs e)
  3512. {
  3513. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  3514. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed));
  3515. this.colorsForm2.ShowDialog();
  3516. }
  3517. private void colorsForm2Changed(object sender, EventArgs e)
  3518. {
  3519. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  3520. this.colorsForm2.Close();
  3521. this.documentWorkspace.Refresh();
  3522. }
  3523. private void panel3_Click(object sender, EventArgs e)
  3524. {
  3525. this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  3526. this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.colorsForm3Changed));
  3527. this.colorsForm3.ShowDialog();
  3528. }
  3529. private void colorsForm3Changed(object sender, EventArgs e)
  3530. {
  3531. this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
  3532. this.colorsForm3.Close();
  3533. this.documentWorkspace.Refresh();
  3534. }
  3535. /// <summary>
  3536. /// 修改参数
  3537. /// </summary>
  3538. /// <param name="sender"></param>
  3539. /// <param name="e"></param>
  3540. private void dataGridView3_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  3541. {
  3542. if (this.dataGridView3.IsCurrentCellDirty)
  3543. {
  3544. this.dataGridView3.CommitEdit(DataGridViewDataErrorContexts.Commit);
  3545. //循环处理this.debrisSelectionModel
  3546. for (int i = 0; i < this.dataGridView3.Rows.Count; i++)
  3547. {
  3548. double v;
  3549. if (((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value != null && double.TryParse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString(), out v))
  3550. {
  3551. this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum = v;// double.Parse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString());
  3552. }
  3553. else
  3554. {
  3555. ((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value = this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum;
  3556. }
  3557. }
  3558. //重新进行过滤
  3559. this.FilterParticlesByCondition();
  3560. //绘制图片
  3561. this.DrawConditionMat();
  3562. //处理数据
  3563. this.CreateDataGridViewData();
  3564. }
  3565. }
  3566. /// <summary>
  3567. /// 显示编号事件
  3568. /// </summary>
  3569. /// <param name="sender"></param>
  3570. /// <param name="e"></param>
  3571. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  3572. {
  3573. DrawConditionMat();
  3574. }
  3575. /// <summary>
  3576. /// 显示参数事件
  3577. /// </summary>
  3578. /// <param name="sender"></param>
  3579. /// <param name="e"></param>
  3580. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  3581. {
  3582. DrawConditionMat();
  3583. }
  3584. /// <summary>
  3585. /// 显示前10事件的checkbox事件
  3586. /// </summary>
  3587. /// <param name="sender"></param>
  3588. /// <param name="e"></param>
  3589. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  3590. {
  3591. if (this.checkBox4.Checked)
  3592. {
  3593. for (int i = this.dataGridView1.Rows.Count - 1; i > (this.numericUpDown2.Value - 1); i--)
  3594. {
  3595. this.dataGridView1.Rows[i].Visible = false;
  3596. //this.dataGridView1.Rows.RemoveAt(i);
  3597. }
  3598. }
  3599. else
  3600. {
  3601. this.listView1_SelectedIndexChanged(null, null);
  3602. }
  3603. }
  3604. /// <summary>
  3605. /// 显示前10的数字改变事件
  3606. /// </summary>
  3607. /// <param name="sender"></param>
  3608. /// <param name="e"></param>
  3609. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  3610. {
  3611. if (this.checkBox4.Checked)
  3612. {
  3613. for (int i = this.dataGridView1.Rows.Count - 1; i > 0; i--)
  3614. {
  3615. if (i > this.numericUpDown2.Value - 1)
  3616. {
  3617. this.dataGridView1.Rows[i].Visible = false;
  3618. }
  3619. else
  3620. {
  3621. this.dataGridView1.Rows[i].Visible = true;
  3622. }
  3623. //this.dataGridView1.Rows.RemoveAt(i);
  3624. }
  3625. }
  3626. }
  3627. /// <summary>
  3628. /// 字体改变事件
  3629. /// </summary>
  3630. /// <param name="sender"></param>
  3631. /// <param name="e"></param>
  3632. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  3633. {
  3634. if (this.binarizationMat != null)
  3635. DrawConditionMat();
  3636. }
  3637. /// <summary>
  3638. /// 字号改变事件
  3639. /// </summary>
  3640. /// <param name="sender"></param>
  3641. /// <param name="e"></param>
  3642. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  3643. {
  3644. if (this.binarizationMat != null)
  3645. DrawConditionMat();
  3646. }
  3647. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  3648. {
  3649. if (this.binarizationMat != null)
  3650. DrawConditionMat();
  3651. }
  3652. private void panel1_BackColorChanged(object sender, EventArgs e)
  3653. {
  3654. if (this.binarizationMat != null)
  3655. DrawConditionMat();
  3656. }
  3657. private void panel2_BackColorChanged(object sender, EventArgs e)
  3658. {
  3659. if (this.binarizationMat != null)
  3660. DrawConditionMat();
  3661. }
  3662. private void panel3_BackColorChanged(object sender, EventArgs e)
  3663. {
  3664. if (this.binarizationMat != null)
  3665. DrawConditionMat();
  3666. }
  3667. private void button5_Click(object sender, EventArgs e)
  3668. {
  3669. if (int.Parse(this.button5.Tag.ToString()) == 1)
  3670. {
  3671. //判断是否存在数据
  3672. if (this.listView2.Items.Count > 0)
  3673. {
  3674. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Restartingwillclearthecurrentdata.Text") + "!", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3675. if (dr == DialogResult.OK)
  3676. {
  3677. this.listView2.Items.Clear();
  3678. this.dataGridView2.Columns.Clear();
  3679. this.dataGridView2.Rows.Clear();
  3680. this.resultTableList.Clear();
  3681. this.button2.Enabled = true;
  3682. this.button5.Tag = 2;
  3683. this.button5.Text = PdnResources.GetString("Menu.stop.text");
  3684. this.comboBox3.Enabled = false;
  3685. this.button4.Enabled = false;
  3686. }
  3687. }
  3688. else
  3689. {
  3690. this.button2.Enabled = true;
  3691. this.button5.Tag = 2;
  3692. this.button5.Text = PdnResources.GetString("Menu.stop.text");
  3693. this.comboBox3.Enabled = false;
  3694. this.button4.Enabled = false;
  3695. }
  3696. }
  3697. else if (int.Parse(this.button5.Tag.ToString()) == 2)
  3698. {
  3699. this.button2.Enabled = false;
  3700. this.button5.Tag = 1;
  3701. this.button5.Text = PdnResources.GetString("Menu.Started.text");
  3702. this.comboBox3.Enabled = true;
  3703. this.button4.Enabled = true;
  3704. }
  3705. }
  3706. private void listView1_MouseUp(object sender, MouseEventArgs e)
  3707. {
  3708. if (e.Button == MouseButtons.Left)
  3709. {
  3710. if (listView1.SelectedItems.Count == 0)//点击空白区
  3711. {
  3712. if (this.listView1.FocusedItem != null)
  3713. {
  3714. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  3715. if (item == null)
  3716. {
  3717. this.listView1.FocusedItem.Selected = true;
  3718. }
  3719. }
  3720. }
  3721. }
  3722. }
  3723. /// <summary>
  3724. /// 准备用来处理单个颗粒的选中事件
  3725. /// </summary>
  3726. /// <param name="sender"></param>
  3727. /// <param name="e"></param>
  3728. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  3729. {
  3730. //当点击表头部的列时,e.RowIndex==-1
  3731. if (e.RowIndex > -1)
  3732. {
  3733. /*ContoursAndRelatedInfo contoursAndRelatedInfo = this.set[e.RowIndex];
  3734. Mat temp = new Mat();
  3735. Mat[] arr1 = this.binarizationMat.Split(); ;// this.phaseModel.mat.Split();
  3736. Mat[] arr2 = new Mat[3];
  3737. arr2[0] = arr1[0];
  3738. arr2[1] = arr1[1];
  3739. arr2[2] = arr1[2];
  3740. Cv2.Merge(arr2, temp);
  3741. 111111111111
  3742. Rect rect;
  3743. Cv2.FloodFill(temp, this.set[gridView1SelectIndex].contours[0], new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R), out rect, null, null, FloodFillFlags.Link8);
  3744. Cv2.FloodFill(temp, contoursAndRelatedInfo.contours[0], new Scalar(255 - this.panel2.BackColor.B, 255 - this.panel2.BackColor.G, 255 - this.panel2.BackColor.R), out rect, null, null, FloodFillFlags.Link8);
  3745. Mat[] arr3 = temp.Split();
  3746. Mat[] arr4 = new Mat[4];
  3747. arr4[0] = arr3[0];
  3748. arr4[1] = arr3[1];
  3749. arr4[2] = arr3[2];
  3750. arr4[3] = arr1[3];
  3751. Cv2.Merge(arr4, temp);
  3752. this.phaseModel.mat = temp;
  3753. this.documentWorkspace.Refresh();*/
  3754. this.gridView1SelectIndex = e.RowIndex;
  3755. this.DrawConditionMat();
  3756. }
  3757. }
  3758. #region [脚本相关]
  3759. private void getValue(string key, Object value)
  3760. {
  3761. switch (key)
  3762. {
  3763. case "parameter1":
  3764. checkBox2.Checked = Convert.ToBoolean(value);
  3765. break;
  3766. case "parameter2":
  3767. panel1.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3768. break;
  3769. case "parameter3":
  3770. checkBox3.Checked = Convert.ToBoolean(value);
  3771. break;
  3772. case "parameter4":
  3773. comboBox1.SelectedIndex = Convert.ToInt32(value);
  3774. break;
  3775. case "parameter5":
  3776. panel3.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3777. break;
  3778. case "parameter6":
  3779. comboBox2.SelectedIndex = Convert.ToInt32(value);
  3780. break;
  3781. case "parameter7":
  3782. numericUpDown3.Value = Convert.ToDecimal(value);
  3783. break;
  3784. case "parameter8":
  3785. numericUpDown2.Value = Convert.ToDecimal(value);
  3786. break;
  3787. case "parameter9":
  3788. panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3789. break;
  3790. case "parameter10":
  3791. checkBox4.Checked = Convert.ToBoolean(value);
  3792. break;
  3793. case "parameter11":
  3794. comboBox3.SelectedIndex = Convert.ToInt32(value);
  3795. break;
  3796. case "OpenWhileExportReport":
  3797. checkBox1.Checked = Convert.ToBoolean(value);
  3798. break;
  3799. case "CalculatorDecimalDigits":
  3800. numericUpDown1.Value = Convert.ToDecimal(value);
  3801. break;
  3802. case "ExportResults":
  3803. isExportResults = Convert.ToBoolean(value);
  3804. break;
  3805. case "ExportReports":
  3806. isExportReports = Convert.ToBoolean(value);
  3807. break;
  3808. case "ExportProjects":
  3809. isExportProjects = Convert.ToBoolean(value);
  3810. break;
  3811. }
  3812. }
  3813. /// <summary>
  3814. /// 执行脚本自动化的步骤
  3815. /// </summary>
  3816. private void startScriptAutomaticAction()
  3817. {
  3818. if (isExportResults)//导出结果
  3819. this.button9.PerformClick();
  3820. if (isExportReports)//生成报告
  3821. this.button8.PerformClick();
  3822. if (isExportProjects)//导出项目
  3823. this.button3.PerformClick();
  3824. this.appWorkspace.ScriptAutomatic = false;
  3825. this.Close();
  3826. }
  3827. #endregion
  3828. #region [脚本录制]
  3829. private void getScriptRecording()
  3830. {
  3831. string className = InvariantData.path_Action + ".Action" + menuId;
  3832. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3833. List<Args> args = param.Lists;
  3834. foreach (var item in args)
  3835. {
  3836. item.value = setScriptRecording(item.key);
  3837. }
  3838. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3839. }
  3840. private object setScriptRecording(string key)
  3841. {
  3842. object value = null;
  3843. switch (key)
  3844. {
  3845. case "parameter1":
  3846. value = checkBox2.Checked;
  3847. break;
  3848. case "parameter2":
  3849. value = panel1.BackColor.ToArgb();
  3850. break;
  3851. case "parameter3":
  3852. value = checkBox3.Checked;
  3853. break;
  3854. case "parameter4":
  3855. value = comboBox1.SelectedIndex;
  3856. break;
  3857. case "parameter5":
  3858. value = panel3.BackColor.ToArgb();
  3859. break;
  3860. case "parameter6":
  3861. value = comboBox2.SelectedIndex;
  3862. break;
  3863. case "parameter7":
  3864. value = numericUpDown3.Value;
  3865. break;
  3866. case "parameter8":
  3867. value = numericUpDown2.Value;
  3868. break;
  3869. case "parameter9":
  3870. value = panel2.BackColor.ToArgb();
  3871. break;
  3872. case "parameter10":
  3873. value = checkBox4.Checked;
  3874. break;
  3875. case "parameter11":
  3876. value = comboBox3.SelectedIndex;
  3877. break;
  3878. case "OpenWhileExportReport":
  3879. value = checkBox1.Checked;
  3880. break;
  3881. case "CalculatorDecimalDigits":
  3882. value = numericUpDown1.Value;
  3883. break;
  3884. case "ExportResults":
  3885. value = isExportResults;
  3886. break;
  3887. case "ExportReports":
  3888. value = isExportReports;
  3889. break;
  3890. case "ExportProjects":
  3891. value = isExportProjects;
  3892. break;
  3893. }
  3894. return value;
  3895. }
  3896. #endregion
  3897. private void btn_SetUp_Click(object sender, EventArgs e)
  3898. {
  3899. DebrisCalipersSetDialog debrisCalipersSetDialog = new DebrisCalipersSetDialog();
  3900. debrisCalipersSetDialog.ShowDialog();
  3901. }
  3902. }
  3903. }