DebrisSelectionDialog.cs 208 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148
  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.label7 = new System.Windows.Forms.Label();
  135. this.panel3 = new System.Windows.Forms.Panel();
  136. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  137. this.panel2 = new System.Windows.Forms.Panel();
  138. this.label6 = new System.Windows.Forms.Label();
  139. this.label5 = new System.Windows.Forms.Label();
  140. this.label3 = new System.Windows.Forms.Label();
  141. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  142. this.checkBox4 = new System.Windows.Forms.CheckBox();
  143. this.label2 = new System.Windows.Forms.Label();
  144. this.comboBox1 = new System.Windows.Forms.ComboBox();
  145. this.checkBox3 = new System.Windows.Forms.CheckBox();
  146. this.checkBox2 = new System.Windows.Forms.CheckBox();
  147. this.groupBox8 = new System.Windows.Forms.GroupBox();
  148. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  149. this.groupBox9 = new System.Windows.Forms.GroupBox();
  150. this.button3 = new System.Windows.Forms.Button();
  151. this.label9 = new System.Windows.Forms.Label();
  152. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  153. this.label8 = new System.Windows.Forms.Label();
  154. this.button9 = new System.Windows.Forms.Button();
  155. this.button8 = new System.Windows.Forms.Button();
  156. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  157. this.listView2 = new System.Windows.Forms.ListView();
  158. this.button7 = new System.Windows.Forms.Button();
  159. this.button6 = new System.Windows.Forms.Button();
  160. this.comboBox2 = new System.Windows.Forms.ComboBox();
  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. // label7
  402. //
  403. this.label7.AutoSize = true;
  404. this.label7.Location = new System.Drawing.Point(240, 49);
  405. this.label7.Name = "label7";
  406. this.label7.Size = new System.Drawing.Size(0, 12);
  407. this.label7.TabIndex = 22;
  408. //
  409. // panel3
  410. //
  411. this.panel3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  412. this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  413. this.panel3.Location = new System.Drawing.Point(293, 45);
  414. this.panel3.Name = "panel3";
  415. this.panel3.Size = new System.Drawing.Size(44, 18);
  416. this.panel3.TabIndex = 21;
  417. this.panel3.BackColorChanged += new System.EventHandler(this.panel3_BackColorChanged);
  418. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  419. //
  420. // numericUpDown3
  421. //
  422. this.numericUpDown3.Location = new System.Drawing.Point(293, 77);
  423. this.numericUpDown3.Maximum = new decimal(new int[] {
  424. 99999,
  425. 0,
  426. 0,
  427. 0});
  428. this.numericUpDown3.Minimum = new decimal(new int[] {
  429. 1,
  430. 0,
  431. 0,
  432. 0});
  433. this.numericUpDown3.Name = "numericUpDown3";
  434. this.numericUpDown3.Size = new System.Drawing.Size(44, 21);
  435. this.numericUpDown3.TabIndex = 20;
  436. this.numericUpDown3.Value = new decimal(new int[] {
  437. 15,
  438. 0,
  439. 0,
  440. 0});
  441. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  442. //
  443. // panel2
  444. //
  445. this.panel2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  446. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  447. this.panel2.Location = new System.Drawing.Point(293, 108);
  448. this.panel2.Name = "panel2";
  449. this.panel2.Size = new System.Drawing.Size(44, 18);
  450. this.panel2.TabIndex = 19;
  451. this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
  452. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  453. //
  454. // label6
  455. //
  456. this.label6.AutoSize = true;
  457. this.label6.Location = new System.Drawing.Point(234, 111);
  458. this.label6.Name = "label6";
  459. this.label6.Size = new System.Drawing.Size(0, 12);
  460. this.label6.TabIndex = 18;
  461. //
  462. // label5
  463. //
  464. this.label5.AutoSize = true;
  465. this.label5.Location = new System.Drawing.Point(240, 81);
  466. this.label5.Name = "label5";
  467. this.label5.Size = new System.Drawing.Size(0, 12);
  468. this.label5.TabIndex = 16;
  469. //
  470. // label3
  471. //
  472. this.label3.AutoSize = true;
  473. this.label3.Location = new System.Drawing.Point(162, 111);
  474. this.label3.Name = "label3";
  475. this.label3.Size = new System.Drawing.Size(0, 12);
  476. this.label3.TabIndex = 15;
  477. //
  478. // numericUpDown2
  479. //
  480. this.numericUpDown2.Location = new System.Drawing.Point(94, 105);
  481. this.numericUpDown2.Maximum = new decimal(new int[] {
  482. 99999,
  483. 0,
  484. 0,
  485. 0});
  486. this.numericUpDown2.Minimum = new decimal(new int[] {
  487. 1,
  488. 0,
  489. 0,
  490. 0});
  491. this.numericUpDown2.Name = "numericUpDown2";
  492. this.numericUpDown2.Size = new System.Drawing.Size(55, 21);
  493. this.numericUpDown2.TabIndex = 14;
  494. this.numericUpDown2.Value = new decimal(new int[] {
  495. 10,
  496. 0,
  497. 0,
  498. 0});
  499. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  500. //
  501. // checkBox4
  502. //
  503. this.checkBox4.AutoSize = true;
  504. this.checkBox4.Location = new System.Drawing.Point(20, 110);
  505. this.checkBox4.Name = "checkBox4";
  506. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  507. this.checkBox4.TabIndex = 13;
  508. this.checkBox4.UseVisualStyleBackColor = true;
  509. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  510. //
  511. // label2
  512. //
  513. this.label2.AutoSize = true;
  514. this.label2.Location = new System.Drawing.Point(37, 81);
  515. this.label2.Name = "label2";
  516. this.label2.Size = new System.Drawing.Size(0, 12);
  517. this.label2.TabIndex = 11;
  518. //
  519. // comboBox1
  520. //
  521. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  522. this.comboBox1.FormattingEnabled = true;
  523. this.comboBox1.Location = new System.Drawing.Point(94, 47);
  524. this.comboBox1.Name = "comboBox1";
  525. this.comboBox1.Size = new System.Drawing.Size(106, 20);
  526. this.comboBox1.TabIndex = 10;
  527. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  528. //
  529. // checkBox3
  530. //
  531. this.checkBox3.AutoSize = true;
  532. this.checkBox3.Location = new System.Drawing.Point(20, 49);
  533. this.checkBox3.Name = "checkBox3";
  534. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  535. this.checkBox3.TabIndex = 9;
  536. this.checkBox3.UseVisualStyleBackColor = true;
  537. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  538. //
  539. // checkBox2
  540. //
  541. this.checkBox2.AutoSize = true;
  542. this.checkBox2.Location = new System.Drawing.Point(20, 20);
  543. this.checkBox2.Name = "checkBox2";
  544. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  545. this.checkBox2.TabIndex = 8;
  546. this.checkBox2.UseVisualStyleBackColor = true;
  547. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  548. //
  549. // groupBox8
  550. //
  551. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  552. | System.Windows.Forms.AnchorStyles.Left)));
  553. this.groupBox8.Controls.Add(this.dataGridView1);
  554. this.groupBox8.Location = new System.Drawing.Point(155, 377);
  555. this.groupBox8.Name = "groupBox8";
  556. this.groupBox8.Size = new System.Drawing.Size(353, 179);
  557. this.groupBox8.TabIndex = 8;
  558. this.groupBox8.TabStop = false;
  559. this.groupBox8.Text = "统计结果预览";
  560. //
  561. // dataGridView1
  562. //
  563. this.dataGridView1.AllowUserToAddRows = false;
  564. this.dataGridView1.AllowUserToDeleteRows = false;
  565. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  566. | System.Windows.Forms.AnchorStyles.Left)
  567. | System.Windows.Forms.AnchorStyles.Right)));
  568. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  569. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  570. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  571. this.dataGridView1.Location = new System.Drawing.Point(7, 21);
  572. this.dataGridView1.MultiSelect = false;
  573. this.dataGridView1.Name = "dataGridView1";
  574. this.dataGridView1.ReadOnly = true;
  575. this.dataGridView1.RowHeadersVisible = false;
  576. this.dataGridView1.RowTemplate.Height = 23;
  577. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  578. this.dataGridView1.Size = new System.Drawing.Size(340, 152);
  579. this.dataGridView1.TabIndex = 0;
  580. this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
  581. //
  582. // groupBox9
  583. //
  584. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  585. | System.Windows.Forms.AnchorStyles.Right)));
  586. this.groupBox9.Controls.Add(this.button3);
  587. this.groupBox9.Controls.Add(this.label9);
  588. this.groupBox9.Controls.Add(this.numericUpDown1);
  589. this.groupBox9.Controls.Add(this.label8);
  590. this.groupBox9.Controls.Add(this.button9);
  591. this.groupBox9.Controls.Add(this.button8);
  592. this.groupBox9.Controls.Add(this.dataGridView2);
  593. this.groupBox9.Controls.Add(this.listView2);
  594. this.groupBox9.Controls.Add(this.button7);
  595. this.groupBox9.Controls.Add(this.button6);
  596. this.groupBox9.Location = new System.Drawing.Point(14, 562);
  597. this.groupBox9.Name = "groupBox9";
  598. this.groupBox9.Size = new System.Drawing.Size(1081, 204);
  599. this.groupBox9.TabIndex = 9;
  600. this.groupBox9.TabStop = false;
  601. this.groupBox9.Text = "分析结果";
  602. //
  603. // button3
  604. //
  605. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  606. this.button3.Location = new System.Drawing.Point(941, 102);
  607. this.button3.Name = "button3";
  608. this.button3.Size = new System.Drawing.Size(128, 26);
  609. this.button3.TabIndex = 10;
  610. this.button3.Text = "导出项目";
  611. this.button3.UseVisualStyleBackColor = true;
  612. this.button3.Click += new System.EventHandler(this.button3_Click);
  613. //
  614. // label9
  615. //
  616. this.label9.AutoSize = true;
  617. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  618. this.label9.Location = new System.Drawing.Point(210, 9);
  619. this.label9.Name = "label9";
  620. this.label9.Size = new System.Drawing.Size(11, 192);
  621. this.label9.TabIndex = 8;
  622. 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|";
  623. //
  624. // numericUpDown1
  625. //
  626. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  627. this.numericUpDown1.Location = new System.Drawing.Point(993, 162);
  628. this.numericUpDown1.Maximum = new decimal(new int[] {
  629. 10,
  630. 0,
  631. 0,
  632. 0});
  633. this.numericUpDown1.Name = "numericUpDown1";
  634. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  635. this.numericUpDown1.TabIndex = 7;
  636. this.numericUpDown1.Value = new decimal(new int[] {
  637. 2,
  638. 0,
  639. 0,
  640. 0});
  641. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  642. //
  643. // label8
  644. //
  645. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  646. this.label8.AutoSize = true;
  647. this.label8.Location = new System.Drawing.Point(957, 167);
  648. this.label8.Name = "label8";
  649. this.label8.Size = new System.Drawing.Size(41, 12);
  650. this.label8.TabIndex = 6;
  651. this.label8.Text = "小数:";
  652. //
  653. // button9
  654. //
  655. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  656. this.button9.Location = new System.Drawing.Point(941, 68);
  657. this.button9.Name = "button9";
  658. this.button9.Size = new System.Drawing.Size(128, 26);
  659. this.button9.TabIndex = 5;
  660. this.button9.Text = "导出结果";
  661. this.button9.UseVisualStyleBackColor = true;
  662. this.button9.Click += new System.EventHandler(this.button9_Click);
  663. //
  664. // button8
  665. //
  666. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  667. this.button8.Location = new System.Drawing.Point(941, 34);
  668. this.button8.Name = "button8";
  669. this.button8.Size = new System.Drawing.Size(128, 26);
  670. this.button8.TabIndex = 4;
  671. this.button8.Text = "生成报告";
  672. this.button8.UseVisualStyleBackColor = true;
  673. this.button8.Click += new System.EventHandler(this.button8_Click);
  674. //
  675. // dataGridView2
  676. //
  677. this.dataGridView2.AllowUserToAddRows = false;
  678. this.dataGridView2.AllowUserToDeleteRows = false;
  679. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  680. | System.Windows.Forms.AnchorStyles.Left)
  681. | System.Windows.Forms.AnchorStyles.Right)));
  682. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  683. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  684. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
  685. this.dataGridView2.Location = new System.Drawing.Point(228, 20);
  686. this.dataGridView2.MultiSelect = false;
  687. this.dataGridView2.Name = "dataGridView2";
  688. this.dataGridView2.ReadOnly = true;
  689. this.dataGridView2.RowHeadersVisible = false;
  690. this.dataGridView2.RowTemplate.Height = 23;
  691. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  692. this.dataGridView2.Size = new System.Drawing.Size(693, 176);
  693. this.dataGridView2.TabIndex = 3;
  694. //
  695. // listView2
  696. //
  697. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  698. | System.Windows.Forms.AnchorStyles.Left)));
  699. this.listView2.HideSelection = false;
  700. this.listView2.Location = new System.Drawing.Point(16, 56);
  701. this.listView2.Name = "listView2";
  702. this.listView2.Size = new System.Drawing.Size(181, 140);
  703. this.listView2.TabIndex = 2;
  704. this.listView2.UseCompatibleStateImageBehavior = false;
  705. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  706. //
  707. // button7
  708. //
  709. this.button7.Location = new System.Drawing.Point(112, 20);
  710. this.button7.Name = "button7";
  711. this.button7.Size = new System.Drawing.Size(85, 26);
  712. this.button7.TabIndex = 1;
  713. this.button7.Text = "删除";
  714. this.button7.UseVisualStyleBackColor = true;
  715. this.button7.Click += new System.EventHandler(this.button7_Click);
  716. //
  717. // button6
  718. //
  719. this.button6.Location = new System.Drawing.Point(16, 20);
  720. this.button6.Name = "button6";
  721. this.button6.Size = new System.Drawing.Size(85, 26);
  722. this.button6.TabIndex = 0;
  723. this.button6.Text = "全部显示";
  724. this.button6.UseVisualStyleBackColor = true;
  725. this.button6.Click += new System.EventHandler(this.button6_Click);
  726. //
  727. // comboBox2
  728. //
  729. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  730. this.comboBox2.FormattingEnabled = true;
  731. this.comboBox2.Location = new System.Drawing.Point(94, 76);
  732. this.comboBox2.Name = "comboBox2";
  733. this.comboBox2.Size = new System.Drawing.Size(79, 20);
  734. this.comboBox2.TabIndex = 23;
  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. /// 选中图片的bitmap
  803. /// </summary>
  804. private Bitmap bitmap;
  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. arg.Value = param1.value;
  1035. getValue(arg.key, arg.Value);
  1036. if (arg.choiseList != null && arg.choiseList.Count > 0)
  1037. {
  1038. try
  1039. {
  1040. int index = Convert.ToInt32(arg.value);
  1041. var thisArg = arg.choiseList[index];
  1042. foreach (var item in thisArg.lists)
  1043. {
  1044. Args thisParam = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(item.Key));
  1045. if (thisParam != null)
  1046. {
  1047. item.Value = thisParam.value;
  1048. getValue(item.key, item.Value);
  1049. }
  1050. }
  1051. }
  1052. catch (Exception)
  1053. {
  1054. continue;
  1055. }
  1056. }
  1057. }
  1058. }
  1059. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1060. }
  1061. else
  1062. {//读取上次关闭窗口时保存的参数
  1063. getLastData();
  1064. }
  1065. this.firstShow = false;
  1066. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1067. this.startScriptAutomaticAction();
  1068. }
  1069. }
  1070. /// <summary>
  1071. /// 获取上次操作参数
  1072. /// </summary>
  1073. private void getLastData()
  1074. {
  1075. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1076. if (!System.IO.File.Exists(filePath))
  1077. {
  1078. generalAnalysisModel = new GeneralAnalysisModel();
  1079. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1080. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1081. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1082. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1083. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1084. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1085. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1086. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1087. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1088. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1089. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1090. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1091. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1092. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1093. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1094. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1095. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1096. }
  1097. else
  1098. {
  1099. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1100. if (generalAnalysisModel.DebrisSelectionModels == null)
  1101. {
  1102. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1103. }
  1104. if (generalAnalysisModel.DebrisSelectionModels.hasUsed)
  1105. {
  1106. if (generalAnalysisModel.DebrisSelectionModels.parameter1 != -1 && generalAnalysisModel.DebrisSelectionModels.parameter1 <= comboBox1.Items.Count - 1) {
  1107. comboBox3.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter1;
  1108. }
  1109. //foreach (var item in generalAnalysisModel.DebrisSelectionModels.parameter2)
  1110. //{
  1111. // dataGridView3.Rows.Add(item.name, item.analyzingConditions, item.conditionsNum, item.associationCondition);
  1112. //}
  1113. checkBox2.Checked = generalAnalysisModel.DebrisSelectionModels.parameter3;
  1114. panel1.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter4);
  1115. checkBox3.Checked = generalAnalysisModel.DebrisSelectionModels.parameter5;
  1116. if (generalAnalysisModel.DebrisSelectionModels.parameter6 != -1 && generalAnalysisModel.DebrisSelectionModels.parameter6 <= comboBox1.Items.Count - 1) {
  1117. comboBox1.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter6;
  1118. }
  1119. panel3.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter7);
  1120. if (generalAnalysisModel.DebrisSelectionModels.parameter8 != -1)
  1121. {
  1122. comboBox2.SelectedIndex = generalAnalysisModel.DebrisSelectionModels.parameter8;
  1123. }
  1124. numericUpDown3.Value = generalAnalysisModel.DebrisSelectionModels.parameter9;
  1125. checkBox4.Checked = generalAnalysisModel.DebrisSelectionModels.parameter10;
  1126. numericUpDown2.Value = generalAnalysisModel.DebrisSelectionModels.parameter11;
  1127. panel2.BackColor = Color.FromArgb(generalAnalysisModel.DebrisSelectionModels.parameter12);
  1128. numericUpDown1.Value = generalAnalysisModel.DebrisSelectionModels.parameter13;
  1129. checkBox1.Checked = generalAnalysisModel.DebrisSelectionModels.parameter14;
  1130. for (int i = 0; i < listView1.Items.Count; i++)
  1131. {
  1132. if (everyImgData.ContainsKey(listView1.Items[i].Name))
  1133. {
  1134. everyImgData[listView1.Items[i].Name] = generalAnalysisModel.DebrisSelectionModels;
  1135. }
  1136. else
  1137. {
  1138. everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.DebrisSelectionModels);
  1139. }
  1140. }
  1141. }
  1142. }
  1143. }
  1144. /// <summary>
  1145. /// 保存上次操作参数
  1146. /// </summary>
  1147. private void saveLastData(object sender, EventArgs e)
  1148. {
  1149. #region [开启脚本录制]
  1150. if (appWorkspace.startScriptRecording)
  1151. {
  1152. getScriptRecording();
  1153. }
  1154. #endregion
  1155. if (generalAnalysisModel.DebrisSelectionModels == null)
  1156. {
  1157. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1158. }
  1159. generalAnalysisModel.DebrisSelectionModels.hasUsed = true;
  1160. //generalAnalysisModel.DebrisSelectionModels.parameter2.Clear();
  1161. //for (int i = 0;i < dataGridView3.Rows.Count;i++)
  1162. //{
  1163. // var dataList = new GeneralAnalysisModel.DebrisSelectionModel.DataList();
  1164. // dataList.name = dataGridView3.Rows[i].Cells[0].Value.ToString();
  1165. // dataList.analyzingConditions = dataGridView3.Rows[i].Cells[1].Value.ToString();
  1166. // dataList.conditionsNum = dataGridView3.Rows[i].Cells[2].Value.ToString();
  1167. // dataList.associationCondition = dataGridView3.Rows[i].Cells[3].Value.ToString();
  1168. // generalAnalysisModel.DebrisSelectionModels.parameter2.Add(dataList);
  1169. //}
  1170. generalAnalysisModel.DebrisSelectionModels.parameter3 = checkBox2.Checked;
  1171. generalAnalysisModel.DebrisSelectionModels.parameter4 = panel1.BackColor.ToArgb();
  1172. generalAnalysisModel.DebrisSelectionModels.parameter5 = checkBox3.Checked;
  1173. generalAnalysisModel.DebrisSelectionModels.parameter1 = comboBox3.SelectedIndex;
  1174. generalAnalysisModel.DebrisSelectionModels.parameter6 = comboBox1.SelectedIndex;
  1175. generalAnalysisModel.DebrisSelectionModels.parameter8 = comboBox2.SelectedIndex;
  1176. generalAnalysisModel.DebrisSelectionModels.parameter7 = panel3.BackColor.ToArgb();
  1177. generalAnalysisModel.DebrisSelectionModels.parameter9 = (int)numericUpDown3.Value;
  1178. generalAnalysisModel.DebrisSelectionModels.parameter10 = checkBox4.Checked;
  1179. generalAnalysisModel.DebrisSelectionModels.parameter11 = (int)numericUpDown2.Value;
  1180. generalAnalysisModel.DebrisSelectionModels.parameter12 = panel2.BackColor.ToArgb();
  1181. generalAnalysisModel.DebrisSelectionModels.parameter13 = (int)numericUpDown1.Value;
  1182. generalAnalysisModel.DebrisSelectionModels.parameter14 = checkBox1.Checked;
  1183. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1184. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1185. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1186. }
  1187. /// <summary>
  1188. /// 初始化表头
  1189. /// </summary>
  1190. private void InitGridHeader()
  1191. {
  1192. //
  1193. //选择统计数据表
  1194. //
  1195. this.dataGridView3.ColumnHeadersHeight = 35;
  1196. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1197. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1198. h1.Width = 84;
  1199. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1200. h2.Width = 84;
  1201. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1202. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1203. h3.Width = 84;
  1204. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1205. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1206. h4.Width = 84;
  1207. this.dataGridView3.Columns.Add(h1);
  1208. this.dataGridView3.Columns.Add(h2);
  1209. this.dataGridView3.Columns.Add(h3);
  1210. this.dataGridView3.Columns.Add(h4);
  1211. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView3);
  1212. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.projectname.text")));
  1213. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.judgementconditions.text")));
  1214. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Conditionvalue.text")));
  1215. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.associatedcondition.text")));
  1216. this.dataGridView3.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1217. this.dataGridView3.Columns[0].ReadOnly = true;
  1218. this.dataGridView3.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1219. this.dataGridView3.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1220. this.dataGridView3.Columns[1].ReadOnly = true;
  1221. this.dataGridView3.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1222. this.dataGridView3.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1223. this.dataGridView3.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1224. this.dataGridView3.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1225. this.dataGridView3.Columns[3].ReadOnly = true;
  1226. this.dataGridView3.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1227. this.dataGridView3.AllowUserToResizeRows = false;
  1228. this.dataGridView3.AllowUserToResizeColumns = false;
  1229. //
  1230. //统计结果预览表
  1231. //
  1232. this.dataGridView1.ColumnHeadersHeight = 30;
  1233. this.dataGridView1.AllowUserToResizeRows = false;
  1234. this.dataGridView1.AllowUserToResizeColumns = false;
  1235. //
  1236. //分析结果表
  1237. //
  1238. this.dataGridView2.ColumnHeadersHeight = 30;
  1239. this.dataGridView2.AllowUserToResizeRows = false;
  1240. this.dataGridView2.AllowUserToResizeColumns = false;
  1241. //
  1242. //左下表
  1243. //
  1244. this.listView2.View = View.Details;
  1245. ColumnHeader header0 = new ColumnHeader();
  1246. header0.Text = PdnResources.GetString("Menu.Imagelist.Text");
  1247. header0.Width = 175;
  1248. this.listView2.Columns.Add(header0);
  1249. }
  1250. /// <summary>
  1251. /// 重新加载xml中已经配置好的条件
  1252. /// </summary>
  1253. public void ReloadDebrisSelectionFromXml()
  1254. {
  1255. if (System.IO.File.Exists(filePath))
  1256. {
  1257. this.debrisSelectionModel = XmlSerializeHelper.DESerializer<DebrisSelectionModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1258. this.listView1_SelectedIndexChanged(null, null);
  1259. }
  1260. }
  1261. /// <summary>
  1262. /// 刷新统计选择的下拉框
  1263. /// </summary>
  1264. public void RefreshDebrisComboBox()
  1265. {
  1266. this.comboBox3.DataSource = null;
  1267. if (this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  1268. {
  1269. int selectedIndex = -1;
  1270. if (this.comboBox3.SelectedIndex > -1)//获取上次选中的下标
  1271. selectedIndex = this.comboBox3.SelectedIndex;
  1272. string[] dataSourceArr = new string[this.debrisSelectionModel.debrisSelectionList.Count];
  1273. for(int i = 0; i < this.debrisSelectionModel.debrisSelectionList.Count; i++)
  1274. {
  1275. dataSourceArr[i] = this.debrisSelectionModel.debrisSelectionList[i].itemName;
  1276. }
  1277. this.comboBox3.DataSource = dataSourceArr;
  1278. if (selectedIndex != -1)
  1279. this.comboBox3.SelectedIndex = selectedIndex;
  1280. else
  1281. this.comboBox3.SelectedIndex = 0;
  1282. this.RefreshDebirsDataGrid();
  1283. this.listView1_SelectedIndexChanged(null, null);
  1284. }
  1285. }
  1286. /// <summary>
  1287. /// 刷新统计数据表
  1288. /// </summary>
  1289. private void RefreshDebirsDataGrid()
  1290. {
  1291. this.dataGridView3.Rows.Clear();
  1292. this.dataGridView1.Rows.Clear();
  1293. this.dataGridView1.Columns.Clear();
  1294. if (this.comboBox3.SelectedIndex > -1 && this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  1295. {
  1296. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1297. if (model != null && model.conditionList.Count > 0)
  1298. {
  1299. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1300. RefreshResultViewDataGrid(null, 1, 0, helper, PdnResources.GetString("Menu.Particlenumber.Text"));
  1301. listDictionary.Clear();
  1302. for (int i = 0; i < model.conditionList.Count; i++)
  1303. {
  1304. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1305. object paraName = new object();
  1306. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1307. if (!listDictionary.ContainsKey(parameter))
  1308. {
  1309. listDictionary.Add(parameter, paraName.ToString());
  1310. }
  1311. else
  1312. {
  1313. continue;
  1314. }
  1315. DataGridViewRow row = new DataGridViewRow();
  1316. row.Height = 25;
  1317. row.Cells.Add(CreateTextBoxCell(paraName.ToString(), model.conditionList[i].conditionName));
  1318. row.Cells.Add(CreateTextBoxCell(InvariantData.judgeCondition[model.conditionList[i].judgeCondition], model.conditionList[i].judgeCondition));
  1319. row.Cells.Add(CreateTextBoxCell(model.conditionList[i].conditionNum.ToString(), ""));
  1320. row.Cells.Add(CreateTextBoxCell(InvariantData.joinCondition[model.conditionList[i].joinCondition], model.conditionList[i].joinCondition));
  1321. this.dataGridView3.Rows.Add(row);
  1322. RefreshResultViewDataGrid(model.conditionList[i], model.conditionList.Count, i+1, helper, paraName.ToString());
  1323. }
  1324. RefreshParameterList();
  1325. this.dataGridView3.ClearSelection();
  1326. this.dataGridView1.ClearSelection();
  1327. }
  1328. }
  1329. //this.AutoSizeColumn(this.dataGridView1, 20);
  1330. }
  1331. /// <summary>
  1332. /// 刷新结果预览表
  1333. /// </summary>
  1334. /// <param name="model"></param>
  1335. /// <param name="count"></param>
  1336. /// <param name="nowNum"></param>
  1337. /// <param name="helper"></param>
  1338. /// <param name="itemName"></param>
  1339. private void RefreshResultViewDataGrid(DebrisSelectionModel.Condition model, int count, int nowNum, DataGridViewHelper helper, string itemName)
  1340. {
  1341. if(count > 0)
  1342. {
  1343. int columnWidth = 0;
  1344. switch (count)
  1345. {
  1346. case 1:
  1347. columnWidth = 336;
  1348. break;
  1349. case 2:
  1350. columnWidth = 168;
  1351. break;
  1352. case 3:
  1353. columnWidth = 112;
  1354. break;
  1355. default:
  1356. columnWidth = 84;
  1357. break;
  1358. }
  1359. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1360. //if (nowNum != 0)
  1361. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1362. tbColumn.SortMode = DataGridViewColumnSortMode.Automatic;
  1363. if (nowNum==0)
  1364. {
  1365. tbColumn.Width = 70;
  1366. }
  1367. else
  1368. {
  1369. tbColumn.Width = columnWidth;
  1370. }
  1371. tbColumn.ValueType = typeof(double);
  1372. this.dataGridView1.Columns.Add(tbColumn);
  1373. helper.Headers.Add(new DataGridViewHelper.TopHeader(nowNum, 1, itemName));
  1374. }
  1375. }
  1376. /// <summary>
  1377. /// 刷新显示参数列表
  1378. /// </summary>
  1379. /// <param name="strArr"></param>
  1380. private void RefreshParameterList()
  1381. {
  1382. BindingSource bs = new BindingSource();
  1383. bs.DataSource = listDictionary;
  1384. this.comboBox1.DataSource = null;
  1385. this.comboBox1.DataSource = bs;
  1386. this.comboBox1.DisplayMember = "value";
  1387. this.comboBox1.ValueMember = "key";
  1388. }
  1389. /// <summary>
  1390. /// 初始化画布按键功能
  1391. /// </summary>
  1392. private void InitCommonButtonEvent()
  1393. {
  1394. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1395. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1396. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1397. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1398. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1399. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1400. }
  1401. private void zoomInButton_Click(object sender, EventArgs e)
  1402. {
  1403. if (this.bitmap!=null)
  1404. this.documentWorkspace.ZoomIn();
  1405. }
  1406. private void zoomOutButton_Click(object sender, EventArgs e)
  1407. {
  1408. if (this.bitmap != null)
  1409. this.documentWorkspace.ZoomOut();
  1410. }
  1411. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1412. {
  1413. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1414. }
  1415. private void actualSizeButton_Click(object sender, EventArgs e)
  1416. {
  1417. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1418. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1419. }
  1420. private void pointerButton_Click(object sender, EventArgs e)
  1421. {
  1422. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1423. }
  1424. private void mobileModeButton_Click(object sender, EventArgs e)
  1425. {
  1426. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1427. }
  1428. /// <summary>
  1429. /// 调色板回调函数
  1430. /// </summary>
  1431. /// <param name="sender"></param>
  1432. /// <param name="ce"></param>
  1433. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1434. {
  1435. }
  1436. /// <summary>
  1437. /// 添加内容单元格
  1438. /// </summary>
  1439. /// <param name="text"></param>
  1440. /// <param name="tag"></param>
  1441. /// <returns></returns>
  1442. private DataGridViewTextBoxCell CreateTextBoxCell(object text, object tag)
  1443. {
  1444. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1445. textboxcell.Value = text;
  1446. textboxcell.Tag = tag;
  1447. return textboxcell;
  1448. }
  1449. /// <summary>
  1450. /// 设置按钮
  1451. /// </summary>
  1452. /// <param name="sender"></param>
  1453. /// <param name="e"></param>
  1454. private void button1_Click(object sender, EventArgs e)
  1455. {
  1456. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.ParticleStatistics");
  1457. if (metallographicMethodSetDialog.hasModule)
  1458. {
  1459. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1460. metallographicMethodSetDialog.ShowDialog();
  1461. }
  1462. else
  1463. {
  1464. metallographicMethodSetDialog = null;
  1465. }
  1466. }
  1467. /// <summary>
  1468. /// 保存结果按钮
  1469. /// </summary>
  1470. /// <param name="sender"></param>
  1471. /// <param name="e"></param>
  1472. private void button2_Click(object sender, EventArgs e)
  1473. {
  1474. if (this.listView1.SelectedItems.Count > 0)
  1475. {
  1476. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1477. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1478. bool replace = false;
  1479. int rowIndex = 0;
  1480. if (this.dataGridView1.Rows.Count > 0)
  1481. {
  1482. if (this.listView2.Items.Count > 0)
  1483. {
  1484. foreach (ListViewItem item in this.listView2.Items)
  1485. {
  1486. if (item.Name.Equals(tag))
  1487. {
  1488. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1489. if(dr == DialogResult.OK)
  1490. {
  1491. replace = true;
  1492. }
  1493. else
  1494. {
  1495. return;
  1496. }
  1497. break;
  1498. }
  1499. }
  1500. }
  1501. //有重名需要替换
  1502. if (replace)
  1503. {
  1504. for(int ik = 0; ik < this.resultTableList.Count; ik++)
  1505. {
  1506. if (this.resultTableList[ik].TableName.Equals(tag))
  1507. {
  1508. rowIndex = ik;
  1509. this.resultTableList.Remove(this.resultTableList[ik]);
  1510. DataTable dt = new DataTable(tag);
  1511. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1512. if (model != null && model.conditionList.Count > 0)
  1513. {
  1514. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text"), typeof(string)));
  1515. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Particlenumber.Text"), typeof(string)));
  1516. //DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1517. listDictionary.Clear();
  1518. for (int i = 0; i < model.conditionList.Count; i++)
  1519. {
  1520. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1521. object paraName = new object();
  1522. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1523. if (!listDictionary.ContainsKey(parameter))
  1524. {
  1525. listDictionary.Add(parameter, paraName.ToString());
  1526. }
  1527. else
  1528. {
  1529. continue;
  1530. }
  1531. dt.Columns.Add(new DataColumn(paraName.ToString(), typeof(string)));
  1532. }
  1533. }
  1534. for (int f = 0; f < this.dataGridView1.Rows.Count; f++)
  1535. {
  1536. if(this.dataGridView1.Rows[f].Visible)
  1537. {
  1538. DataRow dataRow = dt.NewRow();
  1539. dataRow[PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text")] = imgName;
  1540. for (int j = 1; j < dt.Columns.Count; j++)
  1541. {
  1542. dataRow[dt.Columns[j].ColumnName] = ((DataGridViewTextBoxCell)this.dataGridView1.Rows[f].Cells[j - 1]).Tag.ToString();
  1543. }
  1544. dt.Rows.Add(dataRow);
  1545. }
  1546. }
  1547. resultTableList.Insert(rowIndex, dt);
  1548. }
  1549. }
  1550. }
  1551. //新增
  1552. else
  1553. {
  1554. ListViewItem listViewItem = new ListViewItem();
  1555. listViewItem.Name = tag;
  1556. listViewItem.SubItems[0].Text = imgName;
  1557. this.listView2.Items.Add(listViewItem);
  1558. this.listView2.SelectedItems.Clear();
  1559. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1560. DataTable dt = new DataTable(tag);
  1561. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.comboBox3.SelectedValue.ToString()));
  1562. if (model != null && model.conditionList.Count > 0)
  1563. {
  1564. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text"), typeof(string)));
  1565. dt.Columns.Add(new DataColumn(PdnResources.GetString("Menu.Particlenumber.Text"), typeof(string)));
  1566. //DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1567. listDictionary.Clear();
  1568. for (int i = 0; i < model.conditionList.Count; i++)
  1569. {
  1570. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  1571. object paraName = new object();
  1572. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  1573. if (!listDictionary.ContainsKey(parameter))
  1574. {
  1575. listDictionary.Add(parameter, paraName.ToString());
  1576. }
  1577. else
  1578. {
  1579. continue;
  1580. }
  1581. dt.Columns.Add(new DataColumn(paraName.ToString(), typeof(string)));
  1582. }
  1583. }
  1584. for (int f = 0; f < this.dataGridView1.Rows.Count; f++)
  1585. {
  1586. if (this.dataGridView1.Rows[f].Visible)
  1587. {
  1588. DataRow dataRow = dt.NewRow();
  1589. dataRow[PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text")] = imgName;
  1590. for (int j = 1; j < dt.Columns.Count; j++)
  1591. {
  1592. dataRow[dt.Columns[j].ColumnName] = ((DataGridViewTextBoxCell)this.dataGridView1.Rows[f].Cells[j - 1]).Tag.ToString();
  1593. }
  1594. dt.Rows.Add(dataRow);
  1595. }
  1596. }
  1597. resultTableList.Add(dt);
  1598. }
  1599. RefreshDataGridView2();
  1600. //保存处理后的图片
  1601. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1602. List<Bitmap> tempBit = new List<Bitmap>();
  1603. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1604. originalBit.Tag = pantographRatio;
  1605. tempBit.Add(originalBit);
  1606. Bitmap processedBit = BitmapConverter.ToBitmap(phaseModel.mat);
  1607. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1608. Graphics graphics = Graphics.FromImage(newBit);
  1609. graphics.DrawImage(processedBit, new PointF(0, 0));
  1610. newBit.Tag = pantographRatio;
  1611. tempBit.Add(newBit);
  1612. if (bitDic.ContainsKey(tag))
  1613. bitDic[tag] = tempBit;
  1614. else
  1615. bitDic.Add(tag, tempBit);
  1616. }
  1617. else
  1618. {
  1619. MessageBox.Show(PdnResources.GetString("Menu.Noinformationtosave.text"));
  1620. }
  1621. }
  1622. else
  1623. {
  1624. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1625. }
  1626. }
  1627. /// <summary>
  1628. /// 刷新分析结果表
  1629. /// </summary>
  1630. private void RefreshDataGridView2()
  1631. {
  1632. this.dataGridView2.Columns.Clear();
  1633. this.dataGridView2.Rows.Clear();
  1634. if (this.showAll)
  1635. {
  1636. if (this.resultTableList.Count > 0)
  1637. {
  1638. int k = 0;
  1639. int kk = 0;
  1640. foreach (DataTable dt in resultTableList)
  1641. {
  1642. if (kk == 0)
  1643. {
  1644. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1645. {
  1646. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1647. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1648. //tbColumn.Width = 250;
  1649. tbColumn.HeaderText = dt.Columns[ii].ColumnName;
  1650. tbColumn.ValueType = typeof(double);
  1651. this.dataGridView2.Columns.Add(tbColumn);
  1652. }
  1653. }
  1654. this.dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1655. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1656. {
  1657. DataGridViewRow r1 = dataGridView2.Rows[k];
  1658. //r1.Cells[0].Value = row.RowState.ToString();
  1659. for (int j = 0; j < dt.Columns.Count; j++)
  1660. {
  1661. if (j > 0)
  1662. {
  1663. r1.Cells[j].Value = Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value);
  1664. }
  1665. else
  1666. {
  1667. r1.Cells[j].Value = row[j].ToString();
  1668. }
  1669. }
  1670. k++;
  1671. }
  1672. kk++;
  1673. }
  1674. }
  1675. }
  1676. else
  1677. {
  1678. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1679. {
  1680. int k = 0;
  1681. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1682. {
  1683. string tableName = this.listView2.SelectedItems[i].Name;
  1684. foreach (DataTable dt in resultTableList)
  1685. {
  1686. if (dt.TableName.Equals(tableName))
  1687. {
  1688. if(i==0)
  1689. {
  1690. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1691. {
  1692. DataGridViewTextBoxColumn tbColumn = new DataGridViewTextBoxColumn();
  1693. tbColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1694. //tbColumn.Width = 250;
  1695. tbColumn.HeaderText = dt.Columns[ii].ColumnName;
  1696. tbColumn.ValueType = typeof(double);
  1697. this.dataGridView2.Columns.Add(tbColumn);
  1698. }
  1699. }
  1700. this.dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1701. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1702. {
  1703. DataGridViewRow r1 = dataGridView2.Rows[k];
  1704. //r1.Cells[0].Value = row.RowState.ToString();
  1705. for (int j = 0; j < dt.Columns.Count; j++)
  1706. {
  1707. if(j>0)
  1708. {
  1709. r1.Cells[j].Value = Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value);
  1710. }
  1711. else
  1712. {
  1713. r1.Cells[j].Value = row[j].ToString();
  1714. }
  1715. }
  1716. k++;
  1717. }
  1718. }
  1719. }
  1720. }
  1721. }
  1722. }
  1723. this.AutoSizeColumn(this.dataGridView2, 20);
  1724. }
  1725. /// <summary>
  1726. /// 全部显示按钮
  1727. /// </summary>
  1728. /// <param name="sender"></param>
  1729. /// <param name="e"></param>
  1730. private void button6_Click(object sender, EventArgs e)
  1731. {
  1732. if(this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1733. {
  1734. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1735. this.showAll = true;
  1736. RefreshDataGridView2();
  1737. }
  1738. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1739. {
  1740. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1741. this.showAll = false;
  1742. RefreshDataGridView2();
  1743. }
  1744. }
  1745. /// <summary>
  1746. /// 删除按钮
  1747. /// </summary>
  1748. /// <param name="sender"></param>
  1749. /// <param name="e"></param>
  1750. private void button7_Click(object sender, EventArgs e)
  1751. {
  1752. if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1753. {
  1754. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1755. if (dr == DialogResult.OK)
  1756. {
  1757. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1758. {
  1759. string tableName = this.listView2.SelectedItems[i].Name;
  1760. foreach (DataTable dt in resultTableList)
  1761. {
  1762. if (dt.TableName.Equals(tableName))
  1763. {
  1764. resultTableList.Remove(dt);
  1765. break;
  1766. }
  1767. }
  1768. if (bitDic.ContainsKey(tableName))
  1769. bitDic.Remove(tableName);
  1770. }
  1771. foreach (ListViewItem item in this.listView2.Items)
  1772. {
  1773. if (item.Selected)
  1774. this.listView2.Items.Remove(item);
  1775. }
  1776. RefreshDataGridView2();
  1777. }
  1778. }
  1779. }
  1780. private bool ExistInSelectItems(string tablename)
  1781. {
  1782. if(this.listView2.SelectedItems!=null && this.listView2.SelectedItems.Count>0)
  1783. {
  1784. for (int i=0; i< this.listView2.SelectedItems.Count; i++)
  1785. {
  1786. if (this.listView2.SelectedItems[i].Name.Equals(tablename))
  1787. {
  1788. return true;
  1789. }
  1790. }
  1791. }
  1792. return false;
  1793. }
  1794. /// <summary>
  1795. /// 生成报告按钮
  1796. /// </summary>
  1797. /// <param name="sender"></param>
  1798. /// <param name="e"></param>
  1799. private void button8_Click(object sender, EventArgs e)
  1800. {
  1801. if (this.checkBox1.Checked)
  1802. this.button1.PerformClick();
  1803. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1804. {
  1805. //获取word书签与excel单元格的关系,以字典方式存储
  1806. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1807. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1808. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1809. {
  1810. foreach (mic_module_infos info in mic_module_infos)
  1811. {
  1812. tagInfos.Add(info.tag_name, info.cell_position);
  1813. }
  1814. }
  1815. //分析结果
  1816. List<List<string>> analysisContent = new List<List<string>>();
  1817. if (this.listView2.Items != null && this.listView2.Items.Count > 0)
  1818. {
  1819. int k = 0;
  1820. int kk = 0;
  1821. foreach (DataTable dt in resultTableList)
  1822. {
  1823. if (kk == 0)
  1824. {
  1825. List<string> contentHead = new List<string>();
  1826. for (int ii = 0; ii < dt.Columns.Count; ii++)
  1827. {
  1828. contentHead.Add(dt.Columns[ii].ColumnName);
  1829. }
  1830. analysisContent.Add(contentHead);
  1831. kk++;
  1832. }
  1833. //如果不是显示全部
  1834. if (!this.showAll)
  1835. {
  1836. if (!ExistInSelectItems(dt.TableName))
  1837. continue;
  1838. }
  1839. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1840. {
  1841. List<string> content = new List<string>();
  1842. for (int j = 0; j < dt.Columns.Count; j++)
  1843. {
  1844. if (j > 0)
  1845. {
  1846. content.Add(Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value).ToString());
  1847. }
  1848. else
  1849. {
  1850. content.Add(row[j].ToString());
  1851. }
  1852. }
  1853. analysisContent.Add(content);
  1854. k++;
  1855. }
  1856. }
  1857. }
  1858. //图片
  1859. bitList = new List<Bitmap>();
  1860. if (this.showAll)
  1861. {
  1862. foreach(KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1863. {
  1864. bitList.Add(kv.Value[0]);
  1865. bitList.Add(kv.Value[1]);
  1866. }
  1867. }
  1868. else
  1869. {
  1870. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1871. {
  1872. foreach (ListViewItem item in this.listView2.SelectedItems)
  1873. {
  1874. if (bitDic.ContainsKey(item.Name))
  1875. {
  1876. bitList.Add(bitDic[item.Name][0]);
  1877. bitList.Add(bitDic[item.Name][1]);
  1878. }
  1879. }
  1880. }
  1881. }
  1882. if (config.calipersSetModel != null && config.calipersSetModel.isExport == 1)
  1883. CreateCalipersDataTable();
  1884. pNames = new Dictionary<string, string>();
  1885. string dictPath = Application.StartupPath + "\\temp";
  1886. if (!System.IO.Directory.Exists(dictPath))
  1887. System.IO.Directory.CreateDirectory(dictPath);
  1888. DeleteFolder(dictPath);
  1889. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1890. this.SaveAllImage(bitList, dictPath, 1, 1, imgName);
  1891. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos, dictPath, pNames);
  1892. }
  1893. else
  1894. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1895. }
  1896. Dictionary<string, string> pNames;
  1897. /// <summary>
  1898. /// 保存图片到本地
  1899. /// </summary>
  1900. /// <param name="bitList"></param>
  1901. private void SaveAllImage(List<Bitmap> bitList, string newPath, int originNum, int codeNum, string pName)
  1902. {
  1903. if (bitList != null && bitList.Count > 0)
  1904. {
  1905. for (int i = 0; i < bitList.Count; i++)
  1906. {
  1907. string bitPath = "";
  1908. //分别为原图和处理后的图命名
  1909. if (i % 2 == 0)
  1910. {
  1911. bitPath = newPath + "/" + "origin" + originNum + ".jpg";
  1912. pNames.Add("origin" + originNum, pName);
  1913. }
  1914. else
  1915. {
  1916. bitPath = newPath + "/" + codeNum + ".jpg";
  1917. pNames.Add(codeNum.ToString(), pName);
  1918. }
  1919. bitList[i].Save(bitPath);
  1920. }
  1921. }
  1922. }
  1923. public void DeleteFolder(string path)
  1924. {
  1925. foreach (string d in Directory.GetFileSystemEntries(path))
  1926. {
  1927. if (System.IO.File.Exists(d))
  1928. {
  1929. FileInfo fi = new FileInfo(d);
  1930. if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
  1931. fi.Attributes = FileAttributes.Normal;
  1932. System.IO.File.Delete(d);//直接删除其中的文件
  1933. }
  1934. else
  1935. {
  1936. DirectoryInfo d1 = new DirectoryInfo(d);
  1937. if (d1.GetFiles().Length != 0)
  1938. {
  1939. DeleteFolder(d1.FullName);
  1940. }
  1941. Directory.Delete(d);
  1942. }
  1943. }
  1944. }
  1945. /// <summary>
  1946. /// 导出结果按钮
  1947. /// </summary>
  1948. /// <param name="sender"></param>
  1949. /// <param name="e"></param>
  1950. private void button9_Click(object sender, EventArgs e)
  1951. {
  1952. if (this.dataGridView2.Rows.Count > 0)
  1953. {
  1954. SaveFileDialog exe = new SaveFileDialog();
  1955. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1956. exe.FilterIndex = 0;
  1957. exe.RestoreDirectory = true;
  1958. exe.Title = "Export Excel File";
  1959. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1960. exe.FileName = PdnResources.GetString("Menu.GeneralAnalysis.ParticleStatistics.Text")+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1961. DialogResult dr = exe.ShowDialog();
  1962. if (dr == DialogResult.OK)
  1963. {
  1964. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1965. {
  1966. List<DataTable> list = new List<DataTable>();
  1967. if (!this.showAll)
  1968. {
  1969. foreach (DataTable dtb in resultTableList)
  1970. {
  1971. if (!ExistInSelectItems(dtb.TableName))
  1972. {
  1973. continue;
  1974. }
  1975. for (int j = 0; j < dtb.Rows.Count; j++)
  1976. {
  1977. for (int k = 1; k < dtb.Columns.Count; k++)
  1978. {
  1979. dtb.Rows[j][k] = Math.Round(double.Parse(dtb.Rows[j][k].ToString()), (int)this.numericUpDown1.Value);
  1980. }
  1981. }
  1982. list.Add(dtb);
  1983. }
  1984. }
  1985. else
  1986. {
  1987. list = resultTableList;
  1988. }
  1989. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1990. }
  1991. else
  1992. {
  1993. MessageBox.Show(PdnResources.GetString("Menu.Selecttheresultstoexport.Text"));
  1994. return;
  1995. }
  1996. }
  1997. }
  1998. else
  1999. {
  2000. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  2001. }
  2002. }
  2003. /// <summary>
  2004. /// 图像索引切换选中事件
  2005. /// </summary>
  2006. /// <param name="sender"></param>
  2007. /// <param name="e"></param>
  2008. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  2009. {
  2010. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  2011. {
  2012. ruleValue = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2013. this.gridView1SelectIndex = 0;
  2014. if (!string.IsNullOrEmpty(this.selectedImg))
  2015. {
  2016. #region [保存参数]
  2017. var model = new GeneralAnalysisModel.DebrisSelectionModel();
  2018. model.parameter3 = checkBox2.Checked;
  2019. model.parameter4 = panel1.BackColor.ToArgb();
  2020. model.parameter5 = checkBox3.Checked;
  2021. model.parameter1 = comboBox3.SelectedIndex;
  2022. model.parameter6 = comboBox1.SelectedIndex;
  2023. model.parameter8 = comboBox2.SelectedIndex;
  2024. model.parameter7 = panel3.BackColor.ToArgb();
  2025. model.parameter9 = (int)numericUpDown3.Value;
  2026. model.parameter10 = checkBox4.Checked;
  2027. model.parameter11 = (int)numericUpDown2.Value;
  2028. model.parameter12 = panel2.BackColor.ToArgb();
  2029. model.parameter13 = (int)numericUpDown1.Value;
  2030. model.parameter14 = checkBox1.Checked;
  2031. if (everyImgData.ContainsKey(this.selectedImg))
  2032. {
  2033. everyImgData[this.selectedImg] = model;
  2034. }
  2035. else
  2036. {
  2037. everyImgData.Add(this.selectedImg, model);
  2038. }
  2039. #endregion
  2040. }
  2041. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  2042. Document document = Document.FromImage(bitmap);
  2043. this.documentWorkspace.Document = document;
  2044. this.documentWorkspace.phaseModels.Clear();
  2045. this.phaseModel = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].AnalysisPhaseModel;
  2046. this.documentWorkspace.phaseModels.Add(phaseModel);
  2047. //获得视场并绘制
  2048. List<DrawObject> drawObject = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.GetDrawClassList(DrawClass.View);
  2049. if (drawObject != null && drawObject.Count > 0)
  2050. {
  2051. isHadView = true;
  2052. foreach (DrawObject dObject in drawObject)
  2053. {
  2054. dObject.Selected = false;
  2055. this.documentWorkspace.GraphicsList.Add(dObject);
  2056. }
  2057. }
  2058. else
  2059. {
  2060. isHadView = false;
  2061. this.documentWorkspace.GraphicsList.DeleteAllView();
  2062. }
  2063. this.documentWorkspace.Visible = true;
  2064. this.commonControlButtons.Visible = true;
  2065. //获得图像对应的mat
  2066. if (isHadView)
  2067. {
  2068. this.mat = BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion());//获取视场对应的mat
  2069. }
  2070. else
  2071. {
  2072. this.mat = BitmapConverter.ToMat(this.bitmap);
  2073. }
  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. }else
  2804. {
  2805. set.AddRange(temp);
  2806. }
  2807. //去重复
  2808. set = set.Where((x, i) => set.FindIndex(n => n.index == x.index) == i).ToList();
  2809. if (flag < debrisSelection.conditionList.Count())
  2810. {
  2811. //指定下一次循环从什么数据集中过滤
  2812. if (condition.joinCondition == 0)
  2813. temps = set;
  2814. else
  2815. temps = this.list;
  2816. }
  2817. }
  2818. //对index重新赋值
  2819. for (int i = 0; i < set.Count(); i++)
  2820. {
  2821. set[i].index = i + 1;
  2822. }
  2823. }
  2824. }
  2825. }
  2826. }
  2827. /// <summary>
  2828. /// 根据筛选的条件进行绘制
  2829. /// </summary>
  2830. private void DrawConditionMat()
  2831. {
  2832. if (this.set!=null && this.set.Count>0 && this.binarizationMat!=null)
  2833. {
  2834. Mat mat1 = this.binarizationMat.Clone();
  2835. List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
  2836. foreach(ContoursAndRelatedInfo c in set)
  2837. {
  2838. points.Add(c.contours.ToList());
  2839. }
  2840. if (points.Count > 0)
  2841. {
  2842. Mat temp = mat1.CvtColor(ColorConversionCodes.BGRA2BGR);
  2843. for(int k=0; k<points.Count; k++)
  2844. {
  2845. Rect rect;
  2846. if(k== this.gridView1SelectIndex)
  2847. {
  2848. 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);
  2849. }
  2850. else
  2851. {
  2852. 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);
  2853. }
  2854. }
  2855. Cv2.Merge(temp.Split().Union(new Mat[] { mat1.Split()[3] }).ToArray(), mat1);
  2856. //Cv2.FillPoly(mat1, points, new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255)) ;
  2857. //如果显示编号,则绘制编号
  2858. //如果显示参数,则绘制参数
  2859. if (this.checkBox2.Checked || this.checkBox3.Checked)
  2860. {
  2861. using (Bitmap bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat1))
  2862. {
  2863. Graphics graphics = Graphics.FromImage(bitmap);
  2864. Font font = new Font(this.comboBox2.SelectedItem.ToString(), (int)this.numericUpDown3.Value);
  2865. Color color1 = this.panel1.BackColor;
  2866. Color color3 = this.panel3.BackColor;
  2867. foreach (ContoursAndRelatedInfo c in set)
  2868. {
  2869. if (this.checkBox2.Checked)
  2870. {
  2871. graphics.DrawString(c.index.ToString(), font, new SolidBrush(color1), new System.Drawing.Point(c.contours[0].X, c.contours[0].Y));
  2872. //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);
  2873. }
  2874. if (this.checkBox3.Checked && this.comboBox1.SelectedValue!=null)
  2875. {
  2876. switch ((DebrisSelectionParameters)((int)(this.comboBox1.SelectedValue)))
  2877. {
  2878. case DebrisSelectionParameters.area:
  2879. graphics.DrawString(Math.Round(c.Area, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2880. break;
  2881. case DebrisSelectionParameters.areaRatio:
  2882. graphics.DrawString(Math.Round(c.AreaRatio, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2883. break;
  2884. case DebrisSelectionParameters.perimeter:
  2885. graphics.DrawString(Math.Round(c.Perimeter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2886. break;
  2887. case DebrisSelectionParameters.longAxis:
  2888. graphics.DrawString(Math.Round(c.LongAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2889. break;
  2890. case DebrisSelectionParameters.shortAxis:
  2891. graphics.DrawString(Math.Round(c.ShortAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2892. break;
  2893. case DebrisSelectionParameters.centerX:
  2894. graphics.DrawString(Math.Round(c.CenterX * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2895. break;
  2896. case DebrisSelectionParameters.centerY:
  2897. graphics.DrawString(Math.Round(c.CenterY * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2898. break;
  2899. case DebrisSelectionParameters.inclinationAngle:
  2900. graphics.DrawString(Math.Round(c.InclinationAngle, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2901. break;
  2902. case DebrisSelectionParameters.objectAppearance:
  2903. graphics.DrawString(Math.Round(c.ObjectAppearance, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2904. break;
  2905. case DebrisSelectionParameters.height:
  2906. graphics.DrawString(Math.Round(c.Height * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2907. break;
  2908. case DebrisSelectionParameters.width:
  2909. graphics.DrawString(Math.Round(c.Width * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2910. break;
  2911. case DebrisSelectionParameters.aspectRatio:
  2912. graphics.DrawString(Math.Round(c.AspectRatio, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2913. break;
  2914. case DebrisSelectionParameters.redDensity:
  2915. graphics.DrawString(Math.Round(c.RedDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2916. break;
  2917. case DebrisSelectionParameters.greenDensity:
  2918. graphics.DrawString(Math.Round(c.GreenDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2919. break;
  2920. case DebrisSelectionParameters.blueDensity:
  2921. graphics.DrawString(Math.Round(c.BlueDensity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2922. break;
  2923. /*case DebrisSelectionParameters.maxDensity:
  2924. break;
  2925. case DebrisSelectionParameters.minDensity:
  2926. break;
  2927. case DebrisSelectionParameters.avgDensity:
  2928. break;
  2929. case DebrisSelectionParameters.sumDensity:
  2930. break;*/
  2931. case DebrisSelectionParameters.majorAxis:
  2932. graphics.DrawString(Math.Round(c.MajorAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2933. break;
  2934. case DebrisSelectionParameters.minorAxis:
  2935. graphics.DrawString(Math.Round(c.MinorAxis, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2936. break;
  2937. case DebrisSelectionParameters.circumcircleDiameter:
  2938. graphics.DrawString(Math.Round(c.CircumcircleDiameter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2939. break;
  2940. case DebrisSelectionParameters.nodularity:
  2941. graphics.DrawString(Math.Round(c.Nodularity, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2942. break;
  2943. case DebrisSelectionParameters.equalCircleDiameter:
  2944. graphics.DrawString(Math.Round(c.EqualCircleDiameter, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2945. break;
  2946. case DebrisSelectionParameters.maxCaliperDiameter:
  2947. graphics.DrawString(Math.Round(c.MaxCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2948. break;
  2949. case DebrisSelectionParameters.minCaliperDiameter:
  2950. graphics.DrawString(Math.Round(c.MinCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2951. break;
  2952. case DebrisSelectionParameters.avgCaliperDiameter:
  2953. graphics.DrawString(Math.Round(c.AvgCaliperDiameter * 1d, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2954. break;
  2955. case DebrisSelectionParameters.maxGray:
  2956. graphics.DrawString(Math.Round(c.MaxGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2957. break;
  2958. case DebrisSelectionParameters.minGray:
  2959. graphics.DrawString(Math.Round(c.MinGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2960. break;
  2961. case DebrisSelectionParameters.avgGray:
  2962. graphics.DrawString(Math.Round(c.AvgGray, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2963. break;
  2964. case DebrisSelectionParameters.fiberLength:
  2965. graphics.DrawString(Math.Round(c.FiberLength, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2966. break;
  2967. case DebrisSelectionParameters.fillArea:
  2968. graphics.DrawString(Math.Round(c.FillArea, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2969. break;
  2970. case DebrisSelectionParameters.waistDepth:
  2971. //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));
  2972. //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));
  2973. graphics.DrawString(Math.Round(c.WaistDepth, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2974. break;
  2975. case DebrisSelectionParameters.waistDepthShort:
  2976. graphics.DrawString(Math.Round(c.WaistDepthShort, (int)this.numericUpDown1.Value).ToString(), font, new SolidBrush(color3), new System.Drawing.Point(c.CenterX, c.CenterY));
  2977. break;
  2978. }
  2979. }
  2980. }
  2981. mat1 = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  2982. }
  2983. }
  2984. }
  2985. this.phaseModel.mat = mat1;
  2986. this.documentWorkspace.Refresh();
  2987. }
  2988. else
  2989. {
  2990. if(this.binarizationMat!=null)
  2991. {
  2992. this.phaseModel.mat = this.binarizationMat;
  2993. this.documentWorkspace.Refresh();
  2994. }
  2995. }
  2996. }
  2997. private void CreateCalipersDataTable()
  2998. {
  2999. if (this.set == null || this.set.Count == 0)
  3000. {
  3001. MessageBox.Show("数据为空!");
  3002. return;
  3003. }
  3004. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  3005. List<ContoursAndRelatedInfo> setCalipers = new List<ContoursAndRelatedInfo>(this.set);
  3006. var type = config.calipersSetModel.sort;//获取排序选项
  3007. int sortMode = config.calipersSetModel.sortMode;//获取排序方式
  3008. int exportRecord = config.calipersSetModel.exportRecord;//导出记录
  3009. //var keyss = InvariantData.debrisSelectionparameters.Where(q => q.Value.ToString() == type).Select(q => q.Key);
  3010. var firstKey = InvariantData.debrisSelectionparameters.FirstOrDefault(q => q.Value.ToString() == type).Key;
  3011. switch (firstKey)
  3012. {
  3013. case DebrisSelectionParameters.area:
  3014. if (sortMode == 1) setCalipers.Sort((x, y) => -x.area.CompareTo(y.area));
  3015. else setCalipers.Sort((x, y) => x.area.CompareTo(y.area));
  3016. break;
  3017. case DebrisSelectionParameters.areaRatio:
  3018. if (sortMode == 1) setCalipers.Sort((x, y) => -x.areaRatio.CompareTo(y.areaRatio));
  3019. else setCalipers.Sort((x, y) => x.areaRatio.CompareTo(y.areaRatio));
  3020. break;
  3021. case DebrisSelectionParameters.perimeter:
  3022. if (sortMode == 1) setCalipers.Sort((x, y) => -x.perimeter.CompareTo(y.perimeter));
  3023. else setCalipers.Sort((x, y) => x.perimeter.CompareTo(y.perimeter));
  3024. break;
  3025. case DebrisSelectionParameters.longAxis:
  3026. if (sortMode == 1) setCalipers.Sort((x, y) => -x.longAxis.CompareTo(y.longAxis));
  3027. else setCalipers.Sort((x, y) => x.longAxis.CompareTo(y.longAxis));
  3028. break;
  3029. case DebrisSelectionParameters.shortAxis:
  3030. if (sortMode == 1) setCalipers.Sort((x, y) => -x.shortAxis.CompareTo(y.shortAxis));
  3031. else setCalipers.Sort((x, y) => x.shortAxis.CompareTo(y.shortAxis));
  3032. break;
  3033. case DebrisSelectionParameters.centerX:
  3034. if (sortMode == 1) setCalipers.Sort((x, y) => -x.centerX.CompareTo(y.centerX));
  3035. else setCalipers.Sort((x, y) => x.centerX.CompareTo(y.centerX));
  3036. break;
  3037. case DebrisSelectionParameters.centerY:
  3038. if (sortMode == 1) setCalipers.Sort((x, y) => -x.centerY.CompareTo(y.centerY));
  3039. else setCalipers.Sort((x, y) => x.centerY.CompareTo(y.centerY));
  3040. break;
  3041. case DebrisSelectionParameters.inclinationAngle:
  3042. if (sortMode == 1) setCalipers.Sort((x, y) => -x.inclinationAngle.CompareTo(y.inclinationAngle));
  3043. else setCalipers.Sort((x, y) => x.inclinationAngle.CompareTo(y.inclinationAngle));
  3044. break;
  3045. case DebrisSelectionParameters.objectAppearance:
  3046. if (sortMode == 1) setCalipers.Sort((x, y) => -x.inclinationAngle.CompareTo(y.inclinationAngle));
  3047. else setCalipers.Sort((x, y) => x.inclinationAngle.CompareTo(y.inclinationAngle));
  3048. break;
  3049. case DebrisSelectionParameters.height:
  3050. if (sortMode == 1) setCalipers.Sort((x, y) => -x.height.CompareTo(y.height));
  3051. else setCalipers.Sort((x, y) => x.height.CompareTo(y.height));
  3052. break;
  3053. case DebrisSelectionParameters.width:
  3054. if (sortMode == 1) setCalipers.Sort((x, y) => -x.width.CompareTo(y.width));
  3055. else setCalipers.Sort((x, y) => x.width.CompareTo(y.width));
  3056. break;
  3057. case DebrisSelectionParameters.aspectRatio:
  3058. if (sortMode == 1) setCalipers.Sort((x, y) => -x.aspectRatio.CompareTo(y.aspectRatio));
  3059. else setCalipers.Sort((x, y) => x.aspectRatio.CompareTo(y.aspectRatio));
  3060. break;
  3061. case DebrisSelectionParameters.redDensity:
  3062. if (sortMode == 1) setCalipers.Sort((x, y) => -x.redDensity.CompareTo(y.redDensity));
  3063. else setCalipers.Sort((x, y) => x.redDensity.CompareTo(y.redDensity));
  3064. break;
  3065. case DebrisSelectionParameters.greenDensity:
  3066. if (sortMode == 1) setCalipers.Sort((x, y) => -x.greenDensity.CompareTo(y.greenDensity));
  3067. else setCalipers.Sort((x, y) => x.greenDensity.CompareTo(y.greenDensity));
  3068. break;
  3069. case DebrisSelectionParameters.blueDensity:
  3070. if (sortMode == 1) setCalipers.Sort((x, y) => -x.blueDensity.CompareTo(y.blueDensity));
  3071. else setCalipers.Sort((x, y) => x.blueDensity.CompareTo(y.blueDensity));
  3072. break;
  3073. /*case DebrisSelectionParameters.maxDensity:
  3074. break;
  3075. case DebrisSelectionParameters.minDensity:
  3076. break;
  3077. case DebrisSelectionParameters.avgDensity:
  3078. break;
  3079. case DebrisSelectionParameters.sumDensity:
  3080. break;*/
  3081. case DebrisSelectionParameters.majorAxis:
  3082. if (sortMode == 1) setCalipers.Sort((x, y) => -x.majorAxis.CompareTo(y.majorAxis));
  3083. else setCalipers.Sort((x, y) => x.majorAxis.CompareTo(y.majorAxis));
  3084. break;
  3085. case DebrisSelectionParameters.minorAxis:
  3086. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minorAxis.CompareTo(y.minorAxis));
  3087. else setCalipers.Sort((x, y) => x.minorAxis.CompareTo(y.minorAxis));
  3088. break;
  3089. case DebrisSelectionParameters.circumcircleDiameter:
  3090. if (sortMode == 1) setCalipers.Sort((x, y) => -x.circumcircleDiameter.CompareTo(y.circumcircleDiameter));
  3091. else setCalipers.Sort((x, y) => x.circumcircleDiameter.CompareTo(y.circumcircleDiameter));
  3092. break;
  3093. case DebrisSelectionParameters.nodularity:
  3094. if (sortMode == 1) setCalipers.Sort((x, y) => -x.nodularity.CompareTo(y.nodularity));
  3095. else setCalipers.Sort((x, y) => x.nodularity.CompareTo(y.nodularity));
  3096. break;
  3097. case DebrisSelectionParameters.equalCircleDiameter:
  3098. if (sortMode == 1) setCalipers.Sort((x, y) => -x.equalCircleDiameter.CompareTo(y.equalCircleDiameter));
  3099. else setCalipers.Sort((x, y) => x.equalCircleDiameter.CompareTo(y.equalCircleDiameter));
  3100. break;
  3101. case DebrisSelectionParameters.maxCaliperDiameter:
  3102. if (sortMode == 1) setCalipers.Sort((x, y) => -x.maxCaliperDiameter.CompareTo(y.maxCaliperDiameter));
  3103. else setCalipers.Sort((x, y) => x.maxCaliperDiameter.CompareTo(y.maxCaliperDiameter));
  3104. break;
  3105. case DebrisSelectionParameters.minCaliperDiameter:
  3106. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minCaliperDiameter.CompareTo(y.minCaliperDiameter));
  3107. else setCalipers.Sort((x, y) => x.minCaliperDiameter.CompareTo(y.minCaliperDiameter));
  3108. break;
  3109. case DebrisSelectionParameters.avgCaliperDiameter:
  3110. if (sortMode == 1) setCalipers.Sort((x, y) => -x.avgCaliperDiameter.CompareTo(y.avgCaliperDiameter));
  3111. else setCalipers.Sort((x, y) => x.avgCaliperDiameter.CompareTo(y.avgCaliperDiameter));
  3112. break;
  3113. case DebrisSelectionParameters.maxGray:
  3114. if (sortMode == 1) setCalipers.Sort((x, y) => -x.maxGray.CompareTo(y.maxGray));
  3115. else setCalipers.Sort((x, y) => x.maxGray.CompareTo(y.maxGray));
  3116. break;
  3117. case DebrisSelectionParameters.minGray:
  3118. if (sortMode == 1) setCalipers.Sort((x, y) => -x.minGray.CompareTo(y.minGray));
  3119. else setCalipers.Sort((x, y) => x.minGray.CompareTo(y.minGray));
  3120. break;
  3121. case DebrisSelectionParameters.avgGray:
  3122. if (sortMode == 1) setCalipers.Sort((x, y) => -x.avgGray.CompareTo(y.avgGray));
  3123. else setCalipers.Sort((x, y) => x.avgGray.CompareTo(y.avgGray));
  3124. break;
  3125. case DebrisSelectionParameters.fiberLength:
  3126. if (sortMode == 1) setCalipers.Sort((x, y) => -x.fiberLength.CompareTo(y.fiberLength));
  3127. else setCalipers.Sort((x, y) => x.fiberLength.CompareTo(y.fiberLength));
  3128. break;
  3129. case DebrisSelectionParameters.fillArea:
  3130. if (sortMode == 1) setCalipers.Sort((x, y) => -x.fillArea.CompareTo(y.fillArea));
  3131. else setCalipers.Sort((x, y) => x.fillArea.CompareTo(y.fillArea));
  3132. break;
  3133. case DebrisSelectionParameters.waistDepth:
  3134. if (sortMode == 1) setCalipers.Sort((x, y) => -x.waistDepth.CompareTo(y.waistDepth));
  3135. else setCalipers.Sort((x, y) => x.waistDepth.CompareTo(y.waistDepth));
  3136. break;
  3137. case DebrisSelectionParameters.waistDepthShort:
  3138. if (sortMode == 1) setCalipers.Sort((x, y) => -x.waistDepthShort.CompareTo(y.waistDepthShort));
  3139. else setCalipers.Sort((x, y) => x.waistDepthShort.CompareTo(y.waistDepthShort));
  3140. break;
  3141. }
  3142. var vs = InvariantData.debrisSelectionparameters.Values;
  3143. string[] lst = vs.Select(a => a.ToString()).ToArray();
  3144. DataTable calipersTable = new DataTable();
  3145. DataColumn dc = new DataColumn("图片名称");
  3146. calipersTable.Columns.Add(dc);
  3147. dc = new DataColumn("颗粒编号");
  3148. calipersTable.Columns.Add(dc);
  3149. dc = new DataColumn("最大卡规直径");
  3150. calipersTable.Columns.Add(dc);
  3151. dc = new DataColumn("最小卡规直径");
  3152. calipersTable.Columns.Add(dc);
  3153. dc = new DataColumn("平均卡规直径");
  3154. calipersTable.Columns.Add(dc);
  3155. dc = new DataColumn("最大/最小卡规直径");
  3156. calipersTable.Columns.Add(dc);
  3157. dc = new DataColumn("最小/最大卡规直径");
  3158. calipersTable.Columns.Add(dc);
  3159. for (int i = 1; i < 33; i++)
  3160. {
  3161. dc = new DataColumn("卡规" + i);
  3162. calipersTable.Columns.Add(dc);
  3163. }
  3164. int length = exportRecord == 0 ? setCalipers.Count : (exportRecord > setCalipers.Count ? setCalipers.Count : exportRecord);
  3165. for (int count = 0; count < length; count++)
  3166. {
  3167. DataRow dr = calipersTable.NewRow();
  3168. int index = 0;
  3169. for (int i = 0; i < calipersTable.Columns.Count; i++)
  3170. {
  3171. if (i == 0) dr[i] = imgName;
  3172. if (i == 1) dr[i] = setCalipers[count].index;
  3173. if (i == 2) dr[i] = setCalipers[count].MaxCaliperDiameter;
  3174. if (i == 3) dr[i] = setCalipers[count].MinCaliperDiameter;
  3175. if (i == 4) dr[i] = setCalipers[count].AvgCaliperDiameter;
  3176. if (i == 5) dr[i] = setCalipers[count].MaxCaliperDiameter / setCalipers[count].MinCaliperDiameter;
  3177. if (i == 6) dr[i] = setCalipers[count].MinCaliperDiameter / setCalipers[count].MaxCaliperDiameter;
  3178. if (i > 6)
  3179. {
  3180. for (int j = index; j < 32; j++)
  3181. {
  3182. dr[i] = setCalipers[count].Vs[j] * ruleValue;
  3183. index = j+1;
  3184. break;
  3185. }
  3186. }
  3187. }
  3188. calipersTable.Rows.Add(dr);
  3189. //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);
  3190. }
  3191. OfficeFileHandleHelper.calipersTable = calipersTable;
  3192. //OfficeFileHandleHelper.ExportCalipersSet(calipersTable, "");
  3193. }
  3194. /// <summary>
  3195. /// 将筛选的结果添加到datagridview中
  3196. /// </summary>
  3197. private void CreateDataGridViewData()
  3198. {
  3199. if (this.set != null && this.set.Count > 0)
  3200. {
  3201. this.set.Sort((l, r) => l.index.CompareTo(r.index));
  3202. this.dataGridView1.Rows.Clear();
  3203. foreach (ContoursAndRelatedInfo c in set)
  3204. {
  3205. DataGridViewRow row = new DataGridViewRow();
  3206. row.Height = 25;
  3207. row.Cells.Add(CreateTextBoxCell(c.index, c.index));
  3208. foreach (var item in listDictionary)
  3209. {
  3210. switch (item.Key)
  3211. {
  3212. case DebrisSelectionParameters.area:
  3213. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Area, (int)this.numericUpDown1.Value), c.Area));
  3214. break;
  3215. case DebrisSelectionParameters.areaRatio:
  3216. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AreaRatio, (int)this.numericUpDown1.Value), c.AreaRatio));
  3217. break;
  3218. case DebrisSelectionParameters.perimeter:
  3219. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Perimeter, (int)this.numericUpDown1.Value), c.Perimeter));
  3220. break;
  3221. case DebrisSelectionParameters.longAxis:
  3222. row.Cells.Add(CreateTextBoxCell(Math.Round(c.LongAxis, (int)this.numericUpDown1.Value), c.LongAxis));
  3223. break;
  3224. case DebrisSelectionParameters.shortAxis:
  3225. row.Cells.Add(CreateTextBoxCell(Math.Round(c.ShortAxis, (int)this.numericUpDown1.Value), c.ShortAxis));
  3226. break;
  3227. case DebrisSelectionParameters.centerX:
  3228. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CenterX * 1d, (int)this.numericUpDown1.Value), c.CenterX));
  3229. break;
  3230. case DebrisSelectionParameters.centerY:
  3231. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CenterY * 1d, (int)this.numericUpDown1.Value), c.CenterY));
  3232. break;
  3233. case DebrisSelectionParameters.inclinationAngle:
  3234. row.Cells.Add(CreateTextBoxCell(Math.Round(c.InclinationAngle, (int)this.numericUpDown1.Value), c.InclinationAngle));
  3235. break;
  3236. case DebrisSelectionParameters.objectAppearance:
  3237. row.Cells.Add(CreateTextBoxCell(Math.Round(c.ObjectAppearance, (int)this.numericUpDown1.Value), c.ObjectAppearance));
  3238. break;
  3239. case DebrisSelectionParameters.height:
  3240. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Height * 1d, (int)this.numericUpDown1.Value), c.Height));
  3241. break;
  3242. case DebrisSelectionParameters.width:
  3243. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Width * 1d, (int)this.numericUpDown1.Value), c.Width));
  3244. break;
  3245. case DebrisSelectionParameters.aspectRatio:
  3246. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AspectRatio, (int)this.numericUpDown1.Value), c.AspectRatio));
  3247. break;
  3248. case DebrisSelectionParameters.redDensity:
  3249. row.Cells.Add(CreateTextBoxCell(Math.Round(c.RedDensity, (int)this.numericUpDown1.Value), c.RedDensity));
  3250. break;
  3251. case DebrisSelectionParameters.greenDensity:
  3252. row.Cells.Add(CreateTextBoxCell(Math.Round(c.GreenDensity, (int)this.numericUpDown1.Value), c.GreenDensity));
  3253. break;
  3254. case DebrisSelectionParameters.blueDensity:
  3255. row.Cells.Add(CreateTextBoxCell(Math.Round(c.BlueDensity, (int)this.numericUpDown1.Value), c.BlueDensity));
  3256. break;
  3257. /*case DebrisSelectionParameters.maxDensity:
  3258. break;
  3259. case DebrisSelectionParameters.minDensity:
  3260. break;
  3261. case DebrisSelectionParameters.avgDensity:
  3262. break;
  3263. case DebrisSelectionParameters.sumDensity:
  3264. break;*/
  3265. case DebrisSelectionParameters.majorAxis:
  3266. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MajorAxis, (int)this.numericUpDown1.Value), c.MajorAxis));
  3267. break;
  3268. case DebrisSelectionParameters.minorAxis:
  3269. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinorAxis, (int)this.numericUpDown1.Value), c.MinorAxis));
  3270. break;
  3271. case DebrisSelectionParameters.circumcircleDiameter:
  3272. row.Cells.Add(CreateTextBoxCell(Math.Round(c.CircumcircleDiameter, (int)this.numericUpDown1.Value), c.CircumcircleDiameter));
  3273. break;
  3274. case DebrisSelectionParameters.nodularity:
  3275. row.Cells.Add(CreateTextBoxCell(Math.Round(c.Nodularity, (int)this.numericUpDown1.Value), c.Nodularity));
  3276. break;
  3277. case DebrisSelectionParameters.equalCircleDiameter:
  3278. row.Cells.Add(CreateTextBoxCell(Math.Round(c.EqualCircleDiameter, (int)this.numericUpDown1.Value), c.EqualCircleDiameter));
  3279. break;
  3280. case DebrisSelectionParameters.maxCaliperDiameter:
  3281. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MaxCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.MaxCaliperDiameter));
  3282. break;
  3283. case DebrisSelectionParameters.minCaliperDiameter:
  3284. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.MinCaliperDiameter));
  3285. break;
  3286. case DebrisSelectionParameters.avgCaliperDiameter:
  3287. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AvgCaliperDiameter * 1d, (int)this.numericUpDown1.Value), c.AvgCaliperDiameter));
  3288. break;
  3289. case DebrisSelectionParameters.maxGray:
  3290. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MaxGray, (int)this.numericUpDown1.Value), c.MaxGray));
  3291. break;
  3292. case DebrisSelectionParameters.minGray:
  3293. row.Cells.Add(CreateTextBoxCell(Math.Round(c.MinGray, (int)this.numericUpDown1.Value), c.MinGray));
  3294. break;
  3295. case DebrisSelectionParameters.avgGray:
  3296. row.Cells.Add(CreateTextBoxCell(Math.Round(c.AvgGray, (int)this.numericUpDown1.Value), c.AvgGray));
  3297. break;
  3298. case DebrisSelectionParameters.fiberLength:
  3299. row.Cells.Add(CreateTextBoxCell(Math.Round(c.FiberLength, (int)this.numericUpDown1.Value), c.FiberLength));
  3300. break;
  3301. case DebrisSelectionParameters.fillArea:
  3302. row.Cells.Add(CreateTextBoxCell(Math.Round(c.FillArea, (int)this.numericUpDown1.Value), c.FillArea));
  3303. break;
  3304. case DebrisSelectionParameters.waistDepth:
  3305. row.Cells.Add(CreateTextBoxCell(Math.Round(c.WaistDepth, (int)this.numericUpDown1.Value), c.WaistDepth));
  3306. break;
  3307. case DebrisSelectionParameters.waistDepthShort:
  3308. row.Cells.Add(CreateTextBoxCell(Math.Round(c.WaistDepthShort, (int)this.numericUpDown1.Value), c.WaistDepthShort));
  3309. break;
  3310. }
  3311. }
  3312. if(this.dataGridView1.Columns.Count>0)
  3313. {
  3314. this.dataGridView1.Rows.Add(row);
  3315. }
  3316. }
  3317. }
  3318. else
  3319. {
  3320. this.dataGridView1.Rows.Clear();
  3321. }
  3322. }
  3323. /// <summary>
  3324. /// 分析结果列表选择切换
  3325. /// </summary>
  3326. /// <param name="sender"></param>
  3327. /// <param name="e"></param>
  3328. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  3329. {
  3330. if (this.showAll)
  3331. return;
  3332. RefreshDataGridView2();
  3333. }
  3334. /// <summary>
  3335. /// 刷新数据展示表
  3336. /// </summary>
  3337. private void RefreshDataGridView1()
  3338. {
  3339. this.dataGridView1.Rows.Clear();
  3340. }
  3341. /// <summary>
  3342. /// 二值化颜色panel被点击
  3343. /// </summary>
  3344. /// <param name="sender"></param>
  3345. /// <param name="e"></param>
  3346. private void panel1_Click(object sender, EventArgs e)
  3347. {
  3348. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  3349. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  3350. this.colorsForm1.ShowDialog();
  3351. }
  3352. private void colorsForm1Changed(object sender, EventArgs e)
  3353. {
  3354. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  3355. this.colorsForm1.Close();
  3356. this.documentWorkspace.Refresh();
  3357. }
  3358. /// <summary>
  3359. /// 小数数字框值改变
  3360. /// </summary>
  3361. /// <param name="sender"></param>
  3362. /// <param name="e"></param>
  3363. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  3364. {
  3365. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  3366. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  3367. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  3368. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  3369. this.RefreshDataGridView1();
  3370. this.listView1_SelectedIndexChanged(null, null);
  3371. this.RefreshDataGridView2();
  3372. this.DrawConditionMat();
  3373. }
  3374. /// <summary>
  3375. /// 导出项目到项目工程
  3376. /// </summary>
  3377. /// <param name="sender"></param>
  3378. /// <param name="e"></param>
  3379. private void button3_Click(object sender, EventArgs e)
  3380. {
  3381. try
  3382. {
  3383. if (this.analyzeSettingModel == null)
  3384. {
  3385. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3386. return;
  3387. }
  3388. //获取项目工程内的文件夹路径
  3389. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.ParticleStatistics.Text", this.analyzeSettingModel.savePath);
  3390. if (item != null)
  3391. {
  3392. //向文件夹内保存图片和报告
  3393. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3394. {
  3395. //获取word书签与excel单元格的关系,以字典方式存储
  3396. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3397. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3398. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3399. {
  3400. foreach (mic_module_infos info in mic_module_infos)
  3401. {
  3402. tagInfos.Add(info.tag_name, info.cell_position);
  3403. }
  3404. }
  3405. //分析结果
  3406. List<List<string>> analysisContent = new List<List<string>>();
  3407. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3408. {
  3409. int k = 0;
  3410. int kk = 0;
  3411. foreach (DataTable dt in resultTableList)
  3412. {
  3413. if (kk == 0)
  3414. {
  3415. List<string> contentHead = new List<string>();
  3416. for (int ii = 0; ii < dt.Columns.Count; ii++)
  3417. {
  3418. contentHead.Add(dt.Columns[ii].ColumnName);
  3419. }
  3420. analysisContent.Add(contentHead);
  3421. kk++;
  3422. }
  3423. //如果不是显示全部
  3424. if (!this.showAll)
  3425. {
  3426. if (!ExistInSelectItems(dt.TableName))
  3427. continue;
  3428. }
  3429. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  3430. {
  3431. List<string> content = new List<string>();
  3432. for (int j = 0; j < dt.Columns.Count; j++)
  3433. {
  3434. if(j>0)
  3435. {
  3436. content.Add(Math.Round(double.Parse(row[j].ToString()), (int)this.numericUpDown1.Value).ToString());
  3437. }
  3438. else
  3439. {
  3440. content.Add(row[j].ToString());
  3441. }
  3442. }
  3443. analysisContent.Add(content);
  3444. k++;
  3445. }
  3446. }
  3447. }
  3448. //图片
  3449. bitList = new List<Bitmap>();
  3450. if (this.showAll)
  3451. {
  3452. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  3453. {
  3454. bitList.Add(kv.Value[0]);
  3455. bitList.Add(kv.Value[1]);
  3456. }
  3457. }
  3458. else
  3459. {
  3460. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3461. {
  3462. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  3463. {
  3464. if (bitDic.ContainsKey(rowItem.Name))
  3465. {
  3466. bitList.Add(bitDic[rowItem.Name][0]);
  3467. bitList.Add(bitDic[rowItem.Name][1]);
  3468. }
  3469. }
  3470. }
  3471. }
  3472. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, null, bitList, tagInfos, item.path, item.code);
  3473. }
  3474. else
  3475. {
  3476. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  3477. return;
  3478. }
  3479. //保存项目信息到数据库
  3480. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  3481. }
  3482. }
  3483. catch(Exception)
  3484. {
  3485. }
  3486. }
  3487. /// <summary>
  3488. /// 设置统计数据按钮
  3489. /// </summary>
  3490. /// <param name="sender"></param>
  3491. /// <param name="e"></param>
  3492. private void button4_Click(object sender, EventArgs e)
  3493. {
  3494. using (DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog = new DebrisSelectionValidConditionDialog(this))
  3495. {
  3496. debrisSelectionValidConditionDialog.StartPosition = FormStartPosition.CenterScreen;
  3497. debrisSelectionValidConditionDialog.ShowDialog();
  3498. }
  3499. }
  3500. /// <summary>
  3501. /// 统计选择下拉框切换
  3502. /// </summary>
  3503. /// <param name="sender"></param>
  3504. /// <param name="e"></param>
  3505. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  3506. {
  3507. this.RefreshDebirsDataGrid();
  3508. this.listView1_SelectedIndexChanged(null, null);
  3509. }
  3510. private void panel2_Click(object sender, EventArgs e)
  3511. {
  3512. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  3513. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed));
  3514. this.colorsForm2.ShowDialog();
  3515. }
  3516. private void colorsForm2Changed(object sender, EventArgs e)
  3517. {
  3518. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  3519. this.colorsForm2.Close();
  3520. this.documentWorkspace.Refresh();
  3521. }
  3522. private void panel3_Click(object sender, EventArgs e)
  3523. {
  3524. this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  3525. this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.colorsForm3Changed));
  3526. this.colorsForm3.ShowDialog();
  3527. }
  3528. private void colorsForm3Changed(object sender, EventArgs e)
  3529. {
  3530. this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor();
  3531. this.colorsForm3.Close();
  3532. this.documentWorkspace.Refresh();
  3533. }
  3534. /// <summary>
  3535. /// 修改参数
  3536. /// </summary>
  3537. /// <param name="sender"></param>
  3538. /// <param name="e"></param>
  3539. private void dataGridView3_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  3540. {
  3541. if (this.dataGridView3.IsCurrentCellDirty)
  3542. {
  3543. this.dataGridView3.CommitEdit(DataGridViewDataErrorContexts.Commit);
  3544. //循环处理this.debrisSelectionModel
  3545. for (int i = 0; i < this.dataGridView3.Rows.Count; i++)
  3546. {
  3547. double v;
  3548. if (((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value != null && double.TryParse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString(), out v))
  3549. {
  3550. this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum = v;// double.Parse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString());
  3551. }
  3552. else
  3553. {
  3554. ((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value = this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum;
  3555. }
  3556. }
  3557. //重新进行过滤
  3558. this.FilterParticlesByCondition();
  3559. //绘制图片
  3560. this.DrawConditionMat();
  3561. //处理数据
  3562. this.CreateDataGridViewData();
  3563. }
  3564. }
  3565. /// <summary>
  3566. /// 显示编号事件
  3567. /// </summary>
  3568. /// <param name="sender"></param>
  3569. /// <param name="e"></param>
  3570. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  3571. {
  3572. DrawConditionMat();
  3573. }
  3574. /// <summary>
  3575. /// 显示参数事件
  3576. /// </summary>
  3577. /// <param name="sender"></param>
  3578. /// <param name="e"></param>
  3579. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  3580. {
  3581. DrawConditionMat();
  3582. }
  3583. /// <summary>
  3584. /// 显示前10事件的checkbox事件
  3585. /// </summary>
  3586. /// <param name="sender"></param>
  3587. /// <param name="e"></param>
  3588. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  3589. {
  3590. if(this.checkBox4.Checked)
  3591. {
  3592. for (int i = this.dataGridView1.Rows.Count-1; i > (this.numericUpDown2.Value-1); i--)
  3593. {
  3594. this.dataGridView1.Rows[i].Visible = false;
  3595. //this.dataGridView1.Rows.RemoveAt(i);
  3596. }
  3597. }
  3598. else
  3599. {
  3600. this.listView1_SelectedIndexChanged(null, null);
  3601. }
  3602. }
  3603. /// <summary>
  3604. /// 显示前10的数字改变事件
  3605. /// </summary>
  3606. /// <param name="sender"></param>
  3607. /// <param name="e"></param>
  3608. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  3609. {
  3610. if (this.checkBox4.Checked)
  3611. {
  3612. for (int i = this.dataGridView1.Rows.Count - 1; i > 0; i--)
  3613. {
  3614. if(i > this.numericUpDown2.Value - 1)
  3615. {
  3616. this.dataGridView1.Rows[i].Visible = false;
  3617. }
  3618. else
  3619. {
  3620. this.dataGridView1.Rows[i].Visible = true;
  3621. }
  3622. //this.dataGridView1.Rows.RemoveAt(i);
  3623. }
  3624. }
  3625. }
  3626. /// <summary>
  3627. /// 字体改变事件
  3628. /// </summary>
  3629. /// <param name="sender"></param>
  3630. /// <param name="e"></param>
  3631. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  3632. {
  3633. if (this.binarizationMat != null)
  3634. DrawConditionMat();
  3635. }
  3636. /// <summary>
  3637. /// 字号改变事件
  3638. /// </summary>
  3639. /// <param name="sender"></param>
  3640. /// <param name="e"></param>
  3641. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  3642. {
  3643. if (this.binarizationMat != null)
  3644. DrawConditionMat();
  3645. }
  3646. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  3647. {
  3648. if(this.binarizationMat!=null)
  3649. DrawConditionMat();
  3650. }
  3651. private void panel1_BackColorChanged(object sender, EventArgs e)
  3652. {
  3653. if (this.binarizationMat != null)
  3654. DrawConditionMat();
  3655. }
  3656. private void panel2_BackColorChanged(object sender, EventArgs e)
  3657. {
  3658. if (this.binarizationMat != null)
  3659. DrawConditionMat();
  3660. }
  3661. private void panel3_BackColorChanged(object sender, EventArgs e)
  3662. {
  3663. if (this.binarizationMat != null)
  3664. DrawConditionMat();
  3665. }
  3666. private void button5_Click(object sender, EventArgs e)
  3667. {
  3668. if (int.Parse(this.button5.Tag.ToString()) == 1)
  3669. {
  3670. //判断是否存在数据
  3671. if(this.listView2.Items.Count>0)
  3672. {
  3673. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Restartingwillclearthecurrentdata.Text")+"!", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3674. if (dr == DialogResult.OK)
  3675. {
  3676. this.listView2.Items.Clear();
  3677. this.dataGridView2.Columns.Clear();
  3678. this.dataGridView2.Rows.Clear();
  3679. this.resultTableList.Clear();
  3680. this.button2.Enabled = true;
  3681. this.button5.Tag = 2;
  3682. this.button5.Text = PdnResources.GetString("Menu.stop.text");
  3683. this.comboBox3.Enabled = false;
  3684. this.button4.Enabled = false;
  3685. }
  3686. }
  3687. else
  3688. {
  3689. this.button2.Enabled = true;
  3690. this.button5.Tag = 2;
  3691. this.button5.Text = PdnResources.GetString("Menu.stop.text");
  3692. this.comboBox3.Enabled = false;
  3693. this.button4.Enabled = false;
  3694. }
  3695. }
  3696. else if (int.Parse(this.button5.Tag.ToString()) == 2)
  3697. {
  3698. this.button2.Enabled = false;
  3699. this.button5.Tag = 1;
  3700. this.button5.Text = PdnResources.GetString("Menu.Started.text");
  3701. this.comboBox3.Enabled = true;
  3702. this.button4.Enabled = true;
  3703. }
  3704. }
  3705. private void listView1_MouseUp(object sender, MouseEventArgs e)
  3706. {
  3707. if (e.Button == MouseButtons.Left)
  3708. {
  3709. if (listView1.SelectedItems.Count == 0)//点击空白区
  3710. {
  3711. if (this.listView1.FocusedItem != null)
  3712. {
  3713. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  3714. if (item == null)
  3715. {
  3716. this.listView1.FocusedItem.Selected = true;
  3717. }
  3718. }
  3719. }
  3720. }
  3721. }
  3722. /// <summary>
  3723. /// 准备用来处理单个颗粒的选中事件
  3724. /// </summary>
  3725. /// <param name="sender"></param>
  3726. /// <param name="e"></param>
  3727. private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  3728. {
  3729. //当点击表头部的列时,e.RowIndex==-1
  3730. if (e.RowIndex > -1)
  3731. {
  3732. /*ContoursAndRelatedInfo contoursAndRelatedInfo = this.set[e.RowIndex];
  3733. Mat temp = new Mat();
  3734. Mat[] arr1 = this.binarizationMat.Split(); ;// this.phaseModel.mat.Split();
  3735. Mat[] arr2 = new Mat[3];
  3736. arr2[0] = arr1[0];
  3737. arr2[1] = arr1[1];
  3738. arr2[2] = arr1[2];
  3739. Cv2.Merge(arr2, temp);
  3740. 111111111111
  3741. Rect rect;
  3742. 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);
  3743. 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);
  3744. Mat[] arr3 = temp.Split();
  3745. Mat[] arr4 = new Mat[4];
  3746. arr4[0] = arr3[0];
  3747. arr4[1] = arr3[1];
  3748. arr4[2] = arr3[2];
  3749. arr4[3] = arr1[3];
  3750. Cv2.Merge(arr4, temp);
  3751. this.phaseModel.mat = temp;
  3752. this.documentWorkspace.Refresh();*/
  3753. this.gridView1SelectIndex = e.RowIndex;
  3754. this.DrawConditionMat();
  3755. }
  3756. }
  3757. #region [脚本相关]
  3758. private void getValue(string key, Object value)
  3759. {
  3760. switch (key)
  3761. {
  3762. case "parameter1":
  3763. checkBox2.Checked = Convert.ToBoolean(value);
  3764. break;
  3765. case "parameter2":
  3766. panel1.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3767. break;
  3768. case "parameter3":
  3769. checkBox3.Checked = Convert.ToBoolean(value);
  3770. break;
  3771. case "parameter4":
  3772. comboBox1.SelectedIndex = Convert.ToInt32(value);
  3773. break;
  3774. case "parameter5":
  3775. panel3.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3776. break;
  3777. case "parameter6":
  3778. comboBox2.SelectedIndex = Convert.ToInt32(value);
  3779. break;
  3780. case "parameter7":
  3781. numericUpDown3.Value = Convert.ToDecimal(value);
  3782. break;
  3783. case "parameter8":
  3784. numericUpDown2.Value = Convert.ToDecimal(value);
  3785. break;
  3786. case "parameter9":
  3787. panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3788. break;
  3789. case "parameter10":
  3790. checkBox4.Checked = Convert.ToBoolean(value);
  3791. break;
  3792. case "parameter11":
  3793. comboBox3.SelectedIndex = Convert.ToInt32(value);
  3794. break;
  3795. case "OpenWhileExportReport":
  3796. checkBox1.Checked = Convert.ToBoolean(value);
  3797. break;
  3798. case "CalculatorDecimalDigits":
  3799. numericUpDown1.Value = Convert.ToDecimal(value);
  3800. break;
  3801. case "ExportResults":
  3802. isExportResults = Convert.ToBoolean(value);
  3803. break;
  3804. case "ExportReports":
  3805. isExportReports = Convert.ToBoolean(value);
  3806. break;
  3807. case "ExportProjects":
  3808. isExportProjects = Convert.ToBoolean(value);
  3809. break;
  3810. }
  3811. }
  3812. /// <summary>
  3813. /// 执行脚本自动化的步骤
  3814. /// </summary>
  3815. private void startScriptAutomaticAction()
  3816. {
  3817. if (isExportResults)//导出结果
  3818. this.button9.PerformClick();
  3819. if (isExportReports)//生成报告
  3820. this.button8.PerformClick();
  3821. if (isExportProjects)//导出项目
  3822. this.button3.PerformClick();
  3823. this.appWorkspace.ScriptAutomatic = false;
  3824. this.Close();
  3825. }
  3826. #endregion
  3827. #region [脚本录制]
  3828. private void getScriptRecording()
  3829. {
  3830. string className = InvariantData.path_Action + ".Action" + menuId;
  3831. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3832. List<Args> args = param.Lists;
  3833. foreach (var item in args)
  3834. {
  3835. item.value = setScriptRecording(item.key);
  3836. }
  3837. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3838. }
  3839. private object setScriptRecording(string key)
  3840. {
  3841. object value = null;
  3842. switch (key)
  3843. {
  3844. case "parameter1":
  3845. value = checkBox2.Checked;
  3846. break;
  3847. case "parameter2":
  3848. value = panel1.BackColor.ToArgb();
  3849. break;
  3850. case "parameter3":
  3851. value = checkBox3.Checked;
  3852. break;
  3853. case "parameter4":
  3854. value = comboBox1.SelectedIndex;
  3855. break;
  3856. case "parameter5":
  3857. value = panel3.BackColor.ToArgb();
  3858. break;
  3859. case "parameter6":
  3860. value = comboBox2.SelectedIndex;
  3861. break;
  3862. case "parameter7":
  3863. value = numericUpDown3.Value;
  3864. break;
  3865. case "parameter8":
  3866. value = numericUpDown2.Value;
  3867. break;
  3868. case "parameter9":
  3869. value = panel2.BackColor.ToArgb();
  3870. break;
  3871. case "parameter10":
  3872. value = checkBox4.Checked;
  3873. break;
  3874. case "parameter11":
  3875. value = comboBox3.SelectedIndex;
  3876. break;
  3877. case "OpenWhileExportReport":
  3878. value = checkBox1.Checked;
  3879. break;
  3880. case "CalculatorDecimalDigits":
  3881. value = numericUpDown1.Value;
  3882. break;
  3883. case "ExportResults":
  3884. value = isExportResults;
  3885. break;
  3886. case "ExportReports":
  3887. value = isExportReports;
  3888. break;
  3889. case "ExportProjects":
  3890. value = isExportProjects;
  3891. break;
  3892. }
  3893. return value;
  3894. }
  3895. #endregion
  3896. private void btn_SetUp_Click(object sender, EventArgs e)
  3897. {
  3898. DebrisCalipersSetDialog debrisCalipersSetDialog = new DebrisCalipersSetDialog();
  3899. debrisCalipersSetDialog.ShowDialog();
  3900. }
  3901. }
  3902. }