PhaseExtractDialog.cs 178 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using PaintDotNet.Adjust.BaseImage;
  4. using PaintDotNet.Annotation.Enum;
  5. using PaintDotNet.Base;
  6. using PaintDotNet.Base.CommTool;
  7. using PaintDotNet.Base.Enum;
  8. using PaintDotNet.Base.Functionodel;
  9. using PaintDotNet.CustomControl;
  10. using PaintDotNet.Data.Param;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Drawing;
  14. using System.Threading;
  15. using System.Windows.Forms;
  16. namespace PaintDotNet.Binarization
  17. {
  18. /// <summary>
  19. /// 物相提取
  20. /// </summary>
  21. internal class PhaseExtractDialog : PdnBaseForm
  22. {
  23. #region 控件
  24. private System.Windows.Forms.GroupBox groupBox2;
  25. private System.Windows.Forms.Button button5;
  26. private System.Windows.Forms.Label label1;
  27. private System.Windows.Forms.CheckBox checkBox1;
  28. private System.Windows.Forms.Button button1;
  29. private System.Windows.Forms.GroupBox groupBox4;
  30. private System.Windows.Forms.ImageList imageList1;
  31. private System.ComponentModel.IContainer components;
  32. private System.Windows.Forms.ListView listView1;
  33. private System.Windows.Forms.GroupBox groupBox5;
  34. private System.Windows.Forms.NumericUpDown numericUpDown2;
  35. private System.Windows.Forms.NumericUpDown numericUpDown1;
  36. private System.Windows.Forms.CheckBox checkBox4;
  37. private System.Windows.Forms.CheckBox checkBox3;
  38. private System.Windows.Forms.CheckBox checkBox2;
  39. private System.Windows.Forms.GroupBox groupBox6;
  40. private System.Windows.Forms.RadioButton radioButton2;
  41. private System.Windows.Forms.RadioButton radioButton1;
  42. private System.Windows.Forms.GroupBox groupBox7;
  43. private System.Windows.Forms.GroupBox groupBox1;
  44. private System.Windows.Forms.GroupBox groupBox8;
  45. private System.Windows.Forms.GroupBox groupBox3;
  46. private System.Windows.Forms.RadioButton radioButton3;
  47. private System.Windows.Forms.RadioButton radioButton4;
  48. private System.Windows.Forms.GroupBox groupBox9;
  49. private System.Windows.Forms.Label label4;
  50. private System.Windows.Forms.Label label3;
  51. private System.Windows.Forms.RadioButton radioButton5;
  52. private System.Windows.Forms.RadioButton radioButton6;
  53. private System.Windows.Forms.GroupBox groupBox10;
  54. private System.Windows.Forms.RadioButton radioButton9;
  55. private System.Windows.Forms.RadioButton radioButton7;
  56. private System.Windows.Forms.RadioButton radioButton8;
  57. private System.Windows.Forms.GroupBox groupBox11;
  58. private System.Windows.Forms.Button button8;
  59. private System.Windows.Forms.Button button7;
  60. private System.Windows.Forms.Button button6;
  61. private System.Windows.Forms.RadioButton radioButton10;
  62. private System.Windows.Forms.RadioButton radioButton11;
  63. private System.Windows.Forms.NumericUpDown numericUpDown7;
  64. private System.Windows.Forms.NumericUpDown numericUpDown8;
  65. private System.Windows.Forms.Label label6;
  66. private System.Windows.Forms.NumericUpDown numericUpDown5;
  67. private System.Windows.Forms.NumericUpDown numericUpDown6;
  68. private System.Windows.Forms.Label label5;
  69. private System.Windows.Forms.NumericUpDown numericUpDown3;
  70. private System.Windows.Forms.NumericUpDown numericUpDown4;
  71. private System.Windows.Forms.Label label2;
  72. private System.Windows.Forms.RadioButton radioButton12;
  73. private System.Windows.Forms.RadioButton radioButton13;
  74. private System.Windows.Forms.NumericUpDown userTextBox2;
  75. private System.Windows.Forms.NumericUpDown userTextBox1;
  76. private System.Windows.Forms.Button button10;
  77. private System.Windows.Forms.Button button9;
  78. private System.Windows.Forms.Button button4;
  79. private System.Windows.Forms.Button button3;
  80. private System.Windows.Forms.Label label7;
  81. private System.Windows.Forms.Panel panel2;
  82. private System.Windows.Forms.GroupBox groupBox12;
  83. private System.Windows.Forms.Label label9;
  84. private System.Windows.Forms.TrackBar trackBar1;
  85. private System.Windows.Forms.GroupBox groupBox13;
  86. private System.Windows.Forms.Button button2;
  87. private System.Windows.Forms.Button button11;
  88. private System.Windows.Forms.Button button12;
  89. private NumericUpDown numericUpDown9;
  90. private Panel panel1;
  91. private RadioButton radioButton14;
  92. private RadioButton radioButton15;
  93. private Button button13;
  94. private Button button15;
  95. private Button button14;
  96. private CustomControl.HistogramControl histogramControl1;
  97. private Button button16;
  98. private Button button17;
  99. private Button button18;
  100. private CheckBox checkBox5;
  101. private RadioButton radioButton16;
  102. private void InitializeLanguageText()
  103. {
  104. this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
  105. this.label7.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
  106. this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Previous.text");
  107. this.button9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.next.text");
  108. this.button4.Text = PdnResources.GetString("Menu.Add.text");
  109. this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  110. this.button5.Text = PdnResources.GetString("Menu.Edit.Text");
  111. this.checkBox1.Text = PdnResources.GetString("Menu.Createnewgraph.text");
  112. this.button1.Text = PdnResources.GetString("Menu.ensure.text");
  113. this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  114. this.groupBox5.Text = PdnResources.GetString("Menu.Processingdetails.text");
  115. this.checkBox4.Text = PdnResources.GetString("Menu.Clasticdelete.text");
  116. this.checkBox3.Text = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
  117. this.checkBox2.Text = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
  118. this.groupBox6.Text = PdnResources.GetString("Menu.Binarystyle.text");
  119. this.radioButton2.Text = PdnResources.GetString("Menu.Sideline.text");
  120. this.radioButton1.Text = PdnResources.GetString("Menu.solid.text");
  121. this.groupBox7.Text = PdnResources.GetString("Menu.Setting.Text");
  122. this.groupBox1.Text = PdnResources.GetString("Menu.Preview.text");
  123. this.groupBox12.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
  124. this.label9.Text = PdnResources.GetString("Menu.deviation.Text") + ":";
  125. this.groupBox8.Text = PdnResources.GetString("Menu.Tools.Histogram.Text");
  126. this.groupBox3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Extractionmode.text");
  127. this.radioButton3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Singletarget.text");
  128. this.radioButton4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Wholeimage.text");
  129. this.groupBox9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Definetheobject.text");
  130. this.radioButton16.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  131. this.radioButton15.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
  132. this.radioButton14.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
  133. this.label4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Rangesize.text") + ":";
  134. this.label3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.admissiblevalue.text") + ":";
  135. this.radioButton5.Text = PdnResources.GetString("Menu.contour.text");
  136. this.radioButton6.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
  137. this.groupBox10.Text = PdnResources.GetString("Menu.Targetselection.text");
  138. this.radioButton9.Text = PdnResources.GetString("Menu.style.text") + "3";
  139. this.radioButton7.Text = PdnResources.GetString("Menu.style.text") + "2";
  140. this.radioButton8.Text = PdnResources.GetString("Menu.style.text") + "1";
  141. this.groupBox11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
  142. this.button8.Text = PdnResources.GetString("Menu.reinformation.text");
  143. this.button7.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
  144. this.button6.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
  145. this.radioButton10.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  146. this.radioButton11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.append.text");
  147. this.groupBox13.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
  148. this.button2.Text = PdnResources.GetString("Menu.reinformation.text");
  149. this.button11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
  150. this.button12.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
  151. this.checkBox5.Text = PdnResources.GetString("Menu.allShow.Text");
  152. this.Text = "PhaseExtractDialog";
  153. }
  154. private void InitializeComponent()
  155. {
  156. this.components = new System.ComponentModel.Container();
  157. this.groupBox2 = new System.Windows.Forms.GroupBox();
  158. this.checkBox5 = new System.Windows.Forms.CheckBox();
  159. this.label7 = new System.Windows.Forms.Label();
  160. this.panel2 = new System.Windows.Forms.Panel();
  161. this.button10 = new System.Windows.Forms.Button();
  162. this.button9 = new System.Windows.Forms.Button();
  163. this.button4 = new System.Windows.Forms.Button();
  164. this.button3 = new System.Windows.Forms.Button();
  165. this.button5 = new System.Windows.Forms.Button();
  166. this.label1 = new System.Windows.Forms.Label();
  167. this.checkBox1 = new System.Windows.Forms.CheckBox();
  168. this.button1 = new System.Windows.Forms.Button();
  169. this.groupBox4 = new System.Windows.Forms.GroupBox();
  170. this.listView1 = new System.Windows.Forms.ListView();
  171. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  172. this.groupBox5 = new System.Windows.Forms.GroupBox();
  173. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  174. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  175. this.checkBox4 = new System.Windows.Forms.CheckBox();
  176. this.checkBox3 = new System.Windows.Forms.CheckBox();
  177. this.checkBox2 = new System.Windows.Forms.CheckBox();
  178. this.groupBox6 = new System.Windows.Forms.GroupBox();
  179. this.radioButton2 = new System.Windows.Forms.RadioButton();
  180. this.radioButton1 = new System.Windows.Forms.RadioButton();
  181. this.groupBox7 = new System.Windows.Forms.GroupBox();
  182. this.button15 = new System.Windows.Forms.Button();
  183. this.button14 = new System.Windows.Forms.Button();
  184. this.button13 = new System.Windows.Forms.Button();
  185. this.numericUpDown7 = new System.Windows.Forms.NumericUpDown();
  186. this.numericUpDown8 = new System.Windows.Forms.NumericUpDown();
  187. this.label6 = new System.Windows.Forms.Label();
  188. this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
  189. this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
  190. this.label5 = new System.Windows.Forms.Label();
  191. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  192. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  193. this.label2 = new System.Windows.Forms.Label();
  194. this.radioButton12 = new System.Windows.Forms.RadioButton();
  195. this.radioButton13 = new System.Windows.Forms.RadioButton();
  196. this.groupBox1 = new System.Windows.Forms.GroupBox();
  197. this.groupBox12 = new System.Windows.Forms.GroupBox();
  198. this.numericUpDown9 = new System.Windows.Forms.NumericUpDown();
  199. this.trackBar1 = new System.Windows.Forms.TrackBar();
  200. this.label9 = new System.Windows.Forms.Label();
  201. this.groupBox8 = new System.Windows.Forms.GroupBox();
  202. this.histogramControl1 = new PaintDotNet.CustomControl.HistogramControl();
  203. this.groupBox3 = new System.Windows.Forms.GroupBox();
  204. this.radioButton3 = new System.Windows.Forms.RadioButton();
  205. this.radioButton4 = new System.Windows.Forms.RadioButton();
  206. this.groupBox9 = new System.Windows.Forms.GroupBox();
  207. this.panel1 = new System.Windows.Forms.Panel();
  208. this.radioButton16 = new System.Windows.Forms.RadioButton();
  209. this.radioButton15 = new System.Windows.Forms.RadioButton();
  210. this.radioButton14 = new System.Windows.Forms.RadioButton();
  211. this.userTextBox2 = new System.Windows.Forms.NumericUpDown();
  212. this.userTextBox1 = new System.Windows.Forms.NumericUpDown();
  213. this.label4 = new System.Windows.Forms.Label();
  214. this.label3 = new System.Windows.Forms.Label();
  215. this.radioButton5 = new System.Windows.Forms.RadioButton();
  216. this.radioButton6 = new System.Windows.Forms.RadioButton();
  217. this.groupBox10 = new System.Windows.Forms.GroupBox();
  218. this.button18 = new System.Windows.Forms.Button();
  219. this.button17 = new System.Windows.Forms.Button();
  220. this.button16 = new System.Windows.Forms.Button();
  221. this.radioButton9 = new System.Windows.Forms.RadioButton();
  222. this.radioButton7 = new System.Windows.Forms.RadioButton();
  223. this.radioButton8 = new System.Windows.Forms.RadioButton();
  224. this.groupBox11 = new System.Windows.Forms.GroupBox();
  225. this.button8 = new System.Windows.Forms.Button();
  226. this.button7 = new System.Windows.Forms.Button();
  227. this.button6 = new System.Windows.Forms.Button();
  228. this.radioButton10 = new System.Windows.Forms.RadioButton();
  229. this.radioButton11 = new System.Windows.Forms.RadioButton();
  230. this.groupBox13 = new System.Windows.Forms.GroupBox();
  231. this.button2 = new System.Windows.Forms.Button();
  232. this.button11 = new System.Windows.Forms.Button();
  233. this.button12 = new System.Windows.Forms.Button();
  234. this.groupBox2.SuspendLayout();
  235. this.groupBox4.SuspendLayout();
  236. this.groupBox5.SuspendLayout();
  237. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  238. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  239. this.groupBox6.SuspendLayout();
  240. this.groupBox7.SuspendLayout();
  241. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).BeginInit();
  242. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).BeginInit();
  243. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
  244. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();
  245. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  246. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  247. this.groupBox12.SuspendLayout();
  248. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).BeginInit();
  249. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  250. this.groupBox8.SuspendLayout();
  251. this.groupBox3.SuspendLayout();
  252. this.groupBox9.SuspendLayout();
  253. this.panel1.SuspendLayout();
  254. ((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).BeginInit();
  255. ((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).BeginInit();
  256. this.groupBox10.SuspendLayout();
  257. this.groupBox11.SuspendLayout();
  258. this.groupBox13.SuspendLayout();
  259. this.SuspendLayout();
  260. //
  261. // groupBox2
  262. //
  263. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  264. | System.Windows.Forms.AnchorStyles.Right)));
  265. this.groupBox2.Controls.Add(this.checkBox5);
  266. this.groupBox2.Controls.Add(this.label7);
  267. this.groupBox2.Controls.Add(this.panel2);
  268. this.groupBox2.Controls.Add(this.button10);
  269. this.groupBox2.Controls.Add(this.button9);
  270. this.groupBox2.Controls.Add(this.button4);
  271. this.groupBox2.Controls.Add(this.button3);
  272. this.groupBox2.Controls.Add(this.button5);
  273. this.groupBox2.Controls.Add(this.label1);
  274. this.groupBox2.Controls.Add(this.checkBox1);
  275. this.groupBox2.Controls.Add(this.button1);
  276. this.groupBox2.Location = new System.Drawing.Point(13, 12);
  277. this.groupBox2.Name = "groupBox2";
  278. this.groupBox2.Size = new System.Drawing.Size(1261, 52);
  279. this.groupBox2.TabIndex = 7;
  280. this.groupBox2.TabStop = false;
  281. this.groupBox2.Text = "操作";
  282. //
  283. // checkBox5
  284. //
  285. this.checkBox5.AutoSize = true;
  286. this.checkBox5.Location = new System.Drawing.Point(555, 23);
  287. this.checkBox5.Name = "checkBox5";
  288. this.checkBox5.Size = new System.Drawing.Size(72, 16);
  289. this.checkBox5.TabIndex = 23;
  290. this.checkBox5.Text = "显示全部";
  291. this.checkBox5.UseVisualStyleBackColor = true;
  292. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  293. //
  294. // label7
  295. //
  296. this.label7.AutoSize = true;
  297. this.label7.Location = new System.Drawing.Point(421, 26);
  298. this.label7.Name = "label7";
  299. this.label7.Size = new System.Drawing.Size(53, 12);
  300. this.label7.TabIndex = 22;
  301. this.label7.Text = "相颜色:";
  302. //
  303. // panel2
  304. //
  305. this.panel2.BackColor = System.Drawing.Color.Transparent;
  306. this.panel2.Location = new System.Drawing.Point(476, 21);
  307. this.panel2.Name = "panel2";
  308. this.panel2.Size = new System.Drawing.Size(72, 21);
  309. this.panel2.TabIndex = 21;
  310. //
  311. // button10
  312. //
  313. this.button10.Location = new System.Drawing.Point(7, 21);
  314. this.button10.Name = "button10";
  315. this.button10.Size = new System.Drawing.Size(75, 23);
  316. this.button10.TabIndex = 14;
  317. this.button10.Text = "上一个";
  318. this.button10.UseVisualStyleBackColor = true;
  319. this.button10.Click += new System.EventHandler(this.button10_Click);
  320. //
  321. // button9
  322. //
  323. this.button9.Location = new System.Drawing.Point(138, 21);
  324. this.button9.Name = "button9";
  325. this.button9.Size = new System.Drawing.Size(75, 23);
  326. this.button9.TabIndex = 13;
  327. this.button9.Text = "下一个";
  328. this.button9.UseVisualStyleBackColor = true;
  329. this.button9.Click += new System.EventHandler(this.button9_Click);
  330. //
  331. // button4
  332. //
  333. this.button4.Location = new System.Drawing.Point(219, 21);
  334. this.button4.Name = "button4";
  335. this.button4.Size = new System.Drawing.Size(60, 23);
  336. this.button4.TabIndex = 12;
  337. this.button4.Text = "新增";
  338. this.button4.UseVisualStyleBackColor = true;
  339. this.button4.Click += new System.EventHandler(this.button4_Click);
  340. //
  341. // button3
  342. //
  343. this.button3.Location = new System.Drawing.Point(285, 21);
  344. this.button3.Name = "button3";
  345. this.button3.Size = new System.Drawing.Size(60, 23);
  346. this.button3.TabIndex = 11;
  347. this.button3.Text = "删除";
  348. this.button3.UseVisualStyleBackColor = true;
  349. this.button3.Click += new System.EventHandler(this.button3_Click);
  350. //
  351. // button5
  352. //
  353. this.button5.Location = new System.Drawing.Point(351, 21);
  354. this.button5.Name = "button5";
  355. this.button5.Size = new System.Drawing.Size(60, 23);
  356. this.button5.TabIndex = 10;
  357. this.button5.Text = "编辑";
  358. this.button5.UseVisualStyleBackColor = true;
  359. this.button5.Click += new System.EventHandler(this.button5_Click);
  360. //
  361. // label1
  362. //
  363. this.label1.AutoSize = true;
  364. this.label1.Location = new System.Drawing.Point(97, 26);
  365. this.label1.Name = "label1";
  366. this.label1.Size = new System.Drawing.Size(23, 12);
  367. this.label1.TabIndex = 6;
  368. this.label1.Text = "0/0";
  369. //
  370. // checkBox1
  371. //
  372. this.checkBox1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  373. this.checkBox1.AutoSize = true;
  374. this.checkBox1.Location = new System.Drawing.Point(1104, 24);
  375. this.checkBox1.Name = "checkBox1";
  376. this.checkBox1.Size = new System.Drawing.Size(72, 16);
  377. this.checkBox1.TabIndex = 5;
  378. this.checkBox1.Text = "创建新图";
  379. this.checkBox1.UseVisualStyleBackColor = true;
  380. //
  381. // button1
  382. //
  383. this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  384. this.button1.Location = new System.Drawing.Point(1182, 20);
  385. this.button1.Name = "button1";
  386. this.button1.Size = new System.Drawing.Size(75, 23);
  387. this.button1.TabIndex = 3;
  388. this.button1.Text = "确定";
  389. this.button1.UseVisualStyleBackColor = true;
  390. this.button1.Click += new System.EventHandler(this.button1_Click);
  391. //
  392. // groupBox4
  393. //
  394. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  395. | System.Windows.Forms.AnchorStyles.Left)));
  396. this.groupBox4.Controls.Add(this.listView1);
  397. this.groupBox4.Location = new System.Drawing.Point(13, 71);
  398. this.groupBox4.Name = "groupBox4";
  399. this.groupBox4.Size = new System.Drawing.Size(139, 744);
  400. this.groupBox4.TabIndex = 9;
  401. this.groupBox4.TabStop = false;
  402. this.groupBox4.Text = "图像索引";
  403. //
  404. // listView1
  405. //
  406. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  407. | System.Windows.Forms.AnchorStyles.Left)
  408. | System.Windows.Forms.AnchorStyles.Right)));
  409. this.listView1.HideSelection = false;
  410. this.listView1.LargeImageList = this.imageList1;
  411. this.listView1.Location = new System.Drawing.Point(7, 21);
  412. this.listView1.Name = "listView1";
  413. this.listView1.Size = new System.Drawing.Size(126, 717);
  414. this.listView1.TabIndex = 0;
  415. this.listView1.UseCompatibleStateImageBehavior = false;
  416. //
  417. // imageList1
  418. //
  419. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  420. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  421. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  422. //
  423. // groupBox5
  424. //
  425. this.groupBox5.Controls.Add(this.numericUpDown2);
  426. this.groupBox5.Controls.Add(this.numericUpDown1);
  427. this.groupBox5.Controls.Add(this.checkBox4);
  428. this.groupBox5.Controls.Add(this.checkBox3);
  429. this.groupBox5.Controls.Add(this.checkBox2);
  430. this.groupBox5.Location = new System.Drawing.Point(158, 443);
  431. this.groupBox5.Name = "groupBox5";
  432. this.groupBox5.Size = new System.Drawing.Size(200, 74);
  433. this.groupBox5.TabIndex = 11;
  434. this.groupBox5.TabStop = false;
  435. this.groupBox5.Text = "处理细节";
  436. //
  437. // numericUpDown2
  438. //
  439. this.numericUpDown2.Location = new System.Drawing.Point(129, 41);
  440. this.numericUpDown2.Maximum = new decimal(new int[] {
  441. 2147483647,
  442. 0,
  443. 0,
  444. 0});
  445. this.numericUpDown2.Name = "numericUpDown2";
  446. this.numericUpDown2.Size = new System.Drawing.Size(40, 21);
  447. this.numericUpDown2.TabIndex = 6;
  448. this.numericUpDown2.Tag = "max";
  449. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  450. //
  451. // numericUpDown1
  452. //
  453. this.numericUpDown1.Location = new System.Drawing.Point(84, 41);
  454. this.numericUpDown1.Maximum = new decimal(new int[] {
  455. 2147483647,
  456. 0,
  457. 0,
  458. 0});
  459. this.numericUpDown1.Name = "numericUpDown1";
  460. this.numericUpDown1.Size = new System.Drawing.Size(40, 21);
  461. this.numericUpDown1.TabIndex = 5;
  462. this.numericUpDown1.Tag = "min";
  463. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  464. //
  465. // checkBox4
  466. //
  467. this.checkBox4.AutoSize = true;
  468. this.checkBox4.Location = new System.Drawing.Point(7, 44);
  469. this.checkBox4.Name = "checkBox4";
  470. this.checkBox4.Size = new System.Drawing.Size(72, 16);
  471. this.checkBox4.TabIndex = 2;
  472. this.checkBox4.Text = "碎屑删除";
  473. this.checkBox4.UseVisualStyleBackColor = true;
  474. //
  475. // checkBox3
  476. //
  477. this.checkBox3.AutoSize = true;
  478. this.checkBox3.Location = new System.Drawing.Point(119, 20);
  479. this.checkBox3.Name = "checkBox3";
  480. this.checkBox3.Size = new System.Drawing.Size(72, 16);
  481. this.checkBox3.TabIndex = 1;
  482. this.checkBox3.Text = "孔洞填充";
  483. this.checkBox3.UseVisualStyleBackColor = true;
  484. //
  485. // checkBox2
  486. //
  487. this.checkBox2.AutoSize = true;
  488. this.checkBox2.Location = new System.Drawing.Point(7, 20);
  489. this.checkBox2.Name = "checkBox2";
  490. this.checkBox2.Size = new System.Drawing.Size(96, 16);
  491. this.checkBox2.TabIndex = 0;
  492. this.checkBox2.Text = "删除边界对象";
  493. this.checkBox2.UseVisualStyleBackColor = true;
  494. //
  495. // groupBox6
  496. //
  497. this.groupBox6.Controls.Add(this.radioButton2);
  498. this.groupBox6.Controls.Add(this.radioButton1);
  499. this.groupBox6.Location = new System.Drawing.Point(158, 225);
  500. this.groupBox6.Name = "groupBox6";
  501. this.groupBox6.Size = new System.Drawing.Size(200, 46);
  502. this.groupBox6.TabIndex = 12;
  503. this.groupBox6.TabStop = false;
  504. this.groupBox6.Text = "二值样式";
  505. //
  506. // radioButton2
  507. //
  508. this.radioButton2.AutoSize = true;
  509. this.radioButton2.Location = new System.Drawing.Point(70, 20);
  510. this.radioButton2.Name = "radioButton2";
  511. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  512. this.radioButton2.TabIndex = 1;
  513. this.radioButton2.Text = "边线";
  514. this.radioButton2.UseVisualStyleBackColor = true;
  515. //
  516. // radioButton1
  517. //
  518. this.radioButton1.AutoSize = true;
  519. this.radioButton1.Checked = true;
  520. this.radioButton1.Location = new System.Drawing.Point(7, 20);
  521. this.radioButton1.Name = "radioButton1";
  522. this.radioButton1.Size = new System.Drawing.Size(47, 16);
  523. this.radioButton1.TabIndex = 0;
  524. this.radioButton1.TabStop = true;
  525. this.radioButton1.Text = "实心";
  526. this.radioButton1.UseVisualStyleBackColor = true;
  527. //
  528. // groupBox7
  529. //
  530. this.groupBox7.Controls.Add(this.button15);
  531. this.groupBox7.Controls.Add(this.button14);
  532. this.groupBox7.Controls.Add(this.button13);
  533. this.groupBox7.Controls.Add(this.numericUpDown7);
  534. this.groupBox7.Controls.Add(this.numericUpDown8);
  535. this.groupBox7.Controls.Add(this.label6);
  536. this.groupBox7.Controls.Add(this.numericUpDown5);
  537. this.groupBox7.Controls.Add(this.numericUpDown6);
  538. this.groupBox7.Controls.Add(this.label5);
  539. this.groupBox7.Controls.Add(this.numericUpDown3);
  540. this.groupBox7.Controls.Add(this.numericUpDown4);
  541. this.groupBox7.Controls.Add(this.label2);
  542. this.groupBox7.Controls.Add(this.radioButton12);
  543. this.groupBox7.Controls.Add(this.radioButton13);
  544. this.groupBox7.Location = new System.Drawing.Point(158, 685);
  545. this.groupBox7.Name = "groupBox7";
  546. this.groupBox7.Size = new System.Drawing.Size(200, 130);
  547. this.groupBox7.TabIndex = 13;
  548. this.groupBox7.TabStop = false;
  549. this.groupBox7.Text = "设置";
  550. //
  551. // button15
  552. //
  553. this.button15.Location = new System.Drawing.Point(134, 99);
  554. this.button15.Name = "button15";
  555. this.button15.Size = new System.Drawing.Size(34, 21);
  556. this.button15.TabIndex = 34;
  557. this.button15.Text = "B";
  558. this.button15.UseVisualStyleBackColor = true;
  559. this.button15.Click += new System.EventHandler(this.button15_Click);
  560. //
  561. // button14
  562. //
  563. this.button14.Location = new System.Drawing.Point(134, 72);
  564. this.button14.Name = "button14";
  565. this.button14.Size = new System.Drawing.Size(34, 21);
  566. this.button14.TabIndex = 33;
  567. this.button14.Text = "G";
  568. this.button14.UseVisualStyleBackColor = true;
  569. this.button14.Click += new System.EventHandler(this.button14_Click);
  570. //
  571. // button13
  572. //
  573. this.button13.BackColor = System.Drawing.SystemColors.Control;
  574. this.button13.Location = new System.Drawing.Point(134, 45);
  575. this.button13.Margin = new System.Windows.Forms.Padding(0);
  576. this.button13.Name = "button13";
  577. this.button13.Size = new System.Drawing.Size(34, 21);
  578. this.button13.TabIndex = 32;
  579. this.button13.Text = "R";
  580. this.button13.UseVisualStyleBackColor = true;
  581. this.button13.Click += new System.EventHandler(this.button13_Click);
  582. //
  583. // numericUpDown7
  584. //
  585. this.numericUpDown7.Location = new System.Drawing.Point(82, 99);
  586. this.numericUpDown7.Maximum = new decimal(new int[] {
  587. 255,
  588. 0,
  589. 0,
  590. 0});
  591. this.numericUpDown7.Name = "numericUpDown7";
  592. this.numericUpDown7.Size = new System.Drawing.Size(40, 21);
  593. this.numericUpDown7.TabIndex = 30;
  594. this.numericUpDown7.Tag = "max";
  595. this.numericUpDown7.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  596. //
  597. // numericUpDown8
  598. //
  599. this.numericUpDown8.Location = new System.Drawing.Point(37, 99);
  600. this.numericUpDown8.Maximum = new decimal(new int[] {
  601. 255,
  602. 0,
  603. 0,
  604. 0});
  605. this.numericUpDown8.Name = "numericUpDown8";
  606. this.numericUpDown8.Size = new System.Drawing.Size(40, 21);
  607. this.numericUpDown8.TabIndex = 29;
  608. this.numericUpDown8.Tag = "min";
  609. this.numericUpDown8.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  610. //
  611. // label6
  612. //
  613. this.label6.AutoSize = true;
  614. this.label6.Location = new System.Drawing.Point(10, 103);
  615. this.label6.Name = "label6";
  616. this.label6.Size = new System.Drawing.Size(23, 12);
  617. this.label6.TabIndex = 31;
  618. this.label6.Text = "B:";
  619. //
  620. // numericUpDown5
  621. //
  622. this.numericUpDown5.Location = new System.Drawing.Point(82, 72);
  623. this.numericUpDown5.Maximum = new decimal(new int[] {
  624. 255,
  625. 0,
  626. 0,
  627. 0});
  628. this.numericUpDown5.Name = "numericUpDown5";
  629. this.numericUpDown5.Size = new System.Drawing.Size(40, 21);
  630. this.numericUpDown5.TabIndex = 27;
  631. this.numericUpDown5.Tag = "max";
  632. this.numericUpDown5.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  633. //
  634. // numericUpDown6
  635. //
  636. this.numericUpDown6.Location = new System.Drawing.Point(37, 72);
  637. this.numericUpDown6.Maximum = new decimal(new int[] {
  638. 255,
  639. 0,
  640. 0,
  641. 0});
  642. this.numericUpDown6.Name = "numericUpDown6";
  643. this.numericUpDown6.Size = new System.Drawing.Size(40, 21);
  644. this.numericUpDown6.TabIndex = 26;
  645. this.numericUpDown6.Tag = "min";
  646. this.numericUpDown6.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  647. //
  648. // label5
  649. //
  650. this.label5.AutoSize = true;
  651. this.label5.Location = new System.Drawing.Point(10, 76);
  652. this.label5.Name = "label5";
  653. this.label5.Size = new System.Drawing.Size(23, 12);
  654. this.label5.TabIndex = 28;
  655. this.label5.Text = "G:";
  656. //
  657. // numericUpDown3
  658. //
  659. this.numericUpDown3.Location = new System.Drawing.Point(82, 45);
  660. this.numericUpDown3.Maximum = new decimal(new int[] {
  661. 255,
  662. 0,
  663. 0,
  664. 0});
  665. this.numericUpDown3.Name = "numericUpDown3";
  666. this.numericUpDown3.Size = new System.Drawing.Size(40, 21);
  667. this.numericUpDown3.TabIndex = 8;
  668. this.numericUpDown3.Tag = "max";
  669. this.numericUpDown3.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  670. //
  671. // numericUpDown4
  672. //
  673. this.numericUpDown4.Location = new System.Drawing.Point(37, 45);
  674. this.numericUpDown4.Maximum = new decimal(new int[] {
  675. 255,
  676. 0,
  677. 0,
  678. 0});
  679. this.numericUpDown4.Name = "numericUpDown4";
  680. this.numericUpDown4.Size = new System.Drawing.Size(40, 21);
  681. this.numericUpDown4.TabIndex = 7;
  682. this.numericUpDown4.Tag = "min";
  683. this.numericUpDown4.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
  684. //
  685. // label2
  686. //
  687. this.label2.AutoSize = true;
  688. this.label2.Location = new System.Drawing.Point(10, 49);
  689. this.label2.Name = "label2";
  690. this.label2.Size = new System.Drawing.Size(23, 12);
  691. this.label2.TabIndex = 25;
  692. this.label2.Text = "R:";
  693. //
  694. // radioButton12
  695. //
  696. this.radioButton12.AutoSize = true;
  697. this.radioButton12.Location = new System.Drawing.Point(66, 20);
  698. this.radioButton12.Name = "radioButton12";
  699. this.radioButton12.Size = new System.Drawing.Size(41, 16);
  700. this.radioButton12.TabIndex = 4;
  701. this.radioButton12.Text = "HLS";
  702. this.radioButton12.UseVisualStyleBackColor = true;
  703. this.radioButton12.CheckedChanged += new System.EventHandler(this.radioButton12_CheckedChanged);
  704. //
  705. // radioButton13
  706. //
  707. this.radioButton13.AutoSize = true;
  708. this.radioButton13.Checked = true;
  709. this.radioButton13.Location = new System.Drawing.Point(7, 20);
  710. this.radioButton13.Name = "radioButton13";
  711. this.radioButton13.Size = new System.Drawing.Size(41, 16);
  712. this.radioButton13.TabIndex = 3;
  713. this.radioButton13.TabStop = true;
  714. this.radioButton13.Text = "RGB";
  715. this.radioButton13.UseVisualStyleBackColor = true;
  716. this.radioButton13.CheckedChanged += new System.EventHandler(this.radioButton13_CheckedChanged);
  717. //
  718. // groupBox1
  719. //
  720. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  721. | System.Windows.Forms.AnchorStyles.Left)
  722. | System.Windows.Forms.AnchorStyles.Right)));
  723. this.groupBox1.Location = new System.Drawing.Point(364, 70);
  724. this.groupBox1.Name = "groupBox1";
  725. this.groupBox1.Size = new System.Drawing.Size(910, 745);
  726. this.groupBox1.TabIndex = 14;
  727. this.groupBox1.TabStop = false;
  728. this.groupBox1.Text = "预览";
  729. //
  730. // groupBox12
  731. //
  732. this.groupBox12.Controls.Add(this.numericUpDown9);
  733. this.groupBox12.Controls.Add(this.trackBar1);
  734. this.groupBox12.Controls.Add(this.label9);
  735. this.groupBox12.Location = new System.Drawing.Point(158, 120);
  736. this.groupBox12.Name = "groupBox12";
  737. this.groupBox12.Size = new System.Drawing.Size(200, 96);
  738. this.groupBox12.TabIndex = 25;
  739. this.groupBox12.TabStop = false;
  740. this.groupBox12.Text = "定义物体";
  741. this.groupBox12.Visible = false;
  742. //
  743. // numericUpDown9
  744. //
  745. this.numericUpDown9.Location = new System.Drawing.Point(53, 27);
  746. this.numericUpDown9.Name = "numericUpDown9";
  747. this.numericUpDown9.Size = new System.Drawing.Size(127, 21);
  748. this.numericUpDown9.TabIndex = 26;
  749. //
  750. // trackBar1
  751. //
  752. this.trackBar1.AutoSize = false;
  753. this.trackBar1.Location = new System.Drawing.Point(1, 58);
  754. this.trackBar1.Maximum = 100;
  755. this.trackBar1.Name = "trackBar1";
  756. this.trackBar1.Size = new System.Drawing.Size(188, 25);
  757. this.trackBar1.TabIndex = 25;
  758. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  759. //
  760. // label9
  761. //
  762. this.label9.AutoSize = true;
  763. this.label9.Location = new System.Drawing.Point(6, 32);
  764. this.label9.Name = "label9";
  765. this.label9.Size = new System.Drawing.Size(0, 12);
  766. this.label9.TabIndex = 21;
  767. //
  768. // groupBox8
  769. //
  770. this.groupBox8.Controls.Add(this.histogramControl1);
  771. this.groupBox8.Location = new System.Drawing.Point(158, 523);
  772. this.groupBox8.Name = "groupBox8";
  773. this.groupBox8.Size = new System.Drawing.Size(200, 156);
  774. this.groupBox8.TabIndex = 14;
  775. this.groupBox8.TabStop = false;
  776. this.groupBox8.Text = "直方图";
  777. //
  778. // histogramControl1
  779. //
  780. this.histogramControl1.Flag = 1;
  781. this.histogramControl1.Location = new System.Drawing.Point(6, 21);
  782. this.histogramControl1.Name = "histogramControl1";
  783. this.histogramControl1.Size = new System.Drawing.Size(188, 129);
  784. this.histogramControl1.TabIndex = 0;
  785. //
  786. // groupBox3
  787. //
  788. this.groupBox3.Controls.Add(this.radioButton3);
  789. this.groupBox3.Controls.Add(this.radioButton4);
  790. this.groupBox3.Location = new System.Drawing.Point(158, 71);
  791. this.groupBox3.Name = "groupBox3";
  792. this.groupBox3.Size = new System.Drawing.Size(200, 46);
  793. this.groupBox3.TabIndex = 21;
  794. this.groupBox3.TabStop = false;
  795. this.groupBox3.Text = "提取模式";
  796. //
  797. // radioButton3
  798. //
  799. this.radioButton3.AutoSize = true;
  800. this.radioButton3.Location = new System.Drawing.Point(84, 20);
  801. this.radioButton3.Name = "radioButton3";
  802. this.radioButton3.Size = new System.Drawing.Size(71, 16);
  803. this.radioButton3.TabIndex = 1;
  804. this.radioButton3.Text = "单个目标";
  805. this.radioButton3.UseVisualStyleBackColor = true;
  806. //
  807. // radioButton4
  808. //
  809. this.radioButton4.AutoSize = true;
  810. this.radioButton4.Checked = true;
  811. this.radioButton4.Location = new System.Drawing.Point(7, 20);
  812. this.radioButton4.Name = "radioButton4";
  813. this.radioButton4.Size = new System.Drawing.Size(71, 16);
  814. this.radioButton4.TabIndex = 0;
  815. this.radioButton4.TabStop = true;
  816. this.radioButton4.Text = "整个图像";
  817. this.radioButton4.UseVisualStyleBackColor = true;
  818. //
  819. // groupBox9
  820. //
  821. this.groupBox9.Controls.Add(this.panel1);
  822. this.groupBox9.Controls.Add(this.userTextBox2);
  823. this.groupBox9.Controls.Add(this.userTextBox1);
  824. this.groupBox9.Controls.Add(this.label4);
  825. this.groupBox9.Controls.Add(this.label3);
  826. this.groupBox9.Controls.Add(this.radioButton5);
  827. this.groupBox9.Controls.Add(this.radioButton6);
  828. this.groupBox9.Location = new System.Drawing.Point(158, 123);
  829. this.groupBox9.Name = "groupBox9";
  830. this.groupBox9.Size = new System.Drawing.Size(200, 96);
  831. this.groupBox9.TabIndex = 22;
  832. this.groupBox9.TabStop = false;
  833. //
  834. // panel1
  835. //
  836. this.panel1.Controls.Add(this.radioButton16);
  837. this.panel1.Controls.Add(this.radioButton15);
  838. this.panel1.Controls.Add(this.radioButton14);
  839. this.panel1.Location = new System.Drawing.Point(6, 41);
  840. this.panel1.Name = "panel1";
  841. this.panel1.Size = new System.Drawing.Size(174, 47);
  842. this.panel1.TabIndex = 25;
  843. this.panel1.Visible = false;
  844. //
  845. // radioButton16
  846. //
  847. this.radioButton16.AutoSize = true;
  848. this.radioButton16.Location = new System.Drawing.Point(115, 16);
  849. this.radioButton16.Name = "radioButton16";
  850. this.radioButton16.Size = new System.Drawing.Size(14, 13);
  851. this.radioButton16.TabIndex = 2;
  852. this.radioButton16.TabStop = true;
  853. this.radioButton16.UseVisualStyleBackColor = true;
  854. //
  855. // radioButton15
  856. //
  857. this.radioButton15.AutoSize = true;
  858. this.radioButton15.Location = new System.Drawing.Point(66, 16);
  859. this.radioButton15.Name = "radioButton15";
  860. this.radioButton15.Size = new System.Drawing.Size(14, 13);
  861. this.radioButton15.TabIndex = 1;
  862. this.radioButton15.TabStop = true;
  863. this.radioButton15.UseVisualStyleBackColor = true;
  864. //
  865. // radioButton14
  866. //
  867. this.radioButton14.AutoSize = true;
  868. this.radioButton14.Checked = true;
  869. this.radioButton14.Location = new System.Drawing.Point(5, 16);
  870. this.radioButton14.Name = "radioButton14";
  871. this.radioButton14.Size = new System.Drawing.Size(14, 13);
  872. this.radioButton14.TabIndex = 0;
  873. this.radioButton14.TabStop = true;
  874. this.radioButton14.UseVisualStyleBackColor = true;
  875. //
  876. // userTextBox2
  877. //
  878. this.userTextBox2.Location = new System.Drawing.Point(78, 41);
  879. this.userTextBox2.Name = "userTextBox2";
  880. this.userTextBox2.Size = new System.Drawing.Size(100, 21);
  881. this.userTextBox2.TabIndex = 24;
  882. this.userTextBox2.ValueChanged += new System.EventHandler(this.userTextBox2Change);
  883. //
  884. // userTextBox1
  885. //
  886. this.userTextBox1.Location = new System.Drawing.Point(78, 67);
  887. this.userTextBox1.Name = "userTextBox1";
  888. this.userTextBox1.Size = new System.Drawing.Size(100, 21);
  889. this.userTextBox1.TabIndex = 23;
  890. this.userTextBox1.Value = new decimal(new int[] {
  891. 1,
  892. 0,
  893. 0,
  894. 0});
  895. //
  896. // label4
  897. //
  898. this.label4.AutoSize = true;
  899. this.label4.Location = new System.Drawing.Point(6, 72);
  900. this.label4.Name = "label4";
  901. this.label4.Size = new System.Drawing.Size(0, 12);
  902. this.label4.TabIndex = 22;
  903. //
  904. // label3
  905. //
  906. this.label3.AutoSize = true;
  907. this.label3.Location = new System.Drawing.Point(6, 46);
  908. this.label3.Name = "label3";
  909. this.label3.Size = new System.Drawing.Size(0, 12);
  910. this.label3.TabIndex = 21;
  911. //
  912. // radioButton5
  913. //
  914. this.radioButton5.AutoSize = true;
  915. this.radioButton5.Location = new System.Drawing.Point(60, 20);
  916. this.radioButton5.Name = "radioButton5";
  917. this.radioButton5.Size = new System.Drawing.Size(14, 13);
  918. this.radioButton5.TabIndex = 1;
  919. this.radioButton5.UseVisualStyleBackColor = true;
  920. //
  921. // radioButton6
  922. //
  923. this.radioButton6.AutoSize = true;
  924. this.radioButton6.Checked = true;
  925. this.radioButton6.Location = new System.Drawing.Point(7, 20);
  926. this.radioButton6.Name = "radioButton6";
  927. this.radioButton6.Size = new System.Drawing.Size(14, 13);
  928. this.radioButton6.TabIndex = 0;
  929. this.radioButton6.TabStop = true;
  930. this.radioButton6.UseVisualStyleBackColor = true;
  931. //
  932. // groupBox10
  933. //
  934. this.groupBox10.Controls.Add(this.button18);
  935. this.groupBox10.Controls.Add(this.button17);
  936. this.groupBox10.Controls.Add(this.button16);
  937. this.groupBox10.Controls.Add(this.radioButton9);
  938. this.groupBox10.Controls.Add(this.radioButton7);
  939. this.groupBox10.Controls.Add(this.radioButton8);
  940. this.groupBox10.Location = new System.Drawing.Point(158, 357);
  941. this.groupBox10.Name = "groupBox10";
  942. this.groupBox10.Size = new System.Drawing.Size(200, 80);
  943. this.groupBox10.TabIndex = 13;
  944. this.groupBox10.TabStop = false;
  945. this.groupBox10.Text = "目标选择";
  946. //
  947. // button18
  948. //
  949. this.button18.Location = new System.Drawing.Point(99, 24);
  950. this.button18.Name = "button18";
  951. this.button18.Size = new System.Drawing.Size(40, 40);
  952. this.button18.TabIndex = 5;
  953. this.button18.UseVisualStyleBackColor = true;
  954. //
  955. // button17
  956. //
  957. this.button17.Location = new System.Drawing.Point(53, 24);
  958. this.button17.Name = "button17";
  959. this.button17.Size = new System.Drawing.Size(40, 40);
  960. this.button17.TabIndex = 4;
  961. this.button17.UseVisualStyleBackColor = true;
  962. //
  963. // button16
  964. //
  965. this.button16.Location = new System.Drawing.Point(8, 24);
  966. this.button16.Name = "button16";
  967. this.button16.Size = new System.Drawing.Size(40, 40);
  968. this.button16.TabIndex = 3;
  969. this.button16.UseVisualStyleBackColor = true;
  970. //
  971. // radioButton9
  972. //
  973. this.radioButton9.AutoSize = true;
  974. this.radioButton9.Location = new System.Drawing.Point(141, 58);
  975. this.radioButton9.Name = "radioButton9";
  976. this.radioButton9.Size = new System.Drawing.Size(14, 13);
  977. this.radioButton9.TabIndex = 2;
  978. this.radioButton9.UseVisualStyleBackColor = true;
  979. this.radioButton9.Visible = false;
  980. //
  981. // radioButton7
  982. //
  983. this.radioButton7.AutoSize = true;
  984. this.radioButton7.Location = new System.Drawing.Point(141, 36);
  985. this.radioButton7.Name = "radioButton7";
  986. this.radioButton7.Size = new System.Drawing.Size(14, 13);
  987. this.radioButton7.TabIndex = 1;
  988. this.radioButton7.UseVisualStyleBackColor = true;
  989. this.radioButton7.Visible = false;
  990. //
  991. // radioButton8
  992. //
  993. this.radioButton8.AutoSize = true;
  994. this.radioButton8.Checked = true;
  995. this.radioButton8.Location = new System.Drawing.Point(141, 14);
  996. this.radioButton8.Name = "radioButton8";
  997. this.radioButton8.Size = new System.Drawing.Size(14, 13);
  998. this.radioButton8.TabIndex = 0;
  999. this.radioButton8.TabStop = true;
  1000. this.radioButton8.UseVisualStyleBackColor = true;
  1001. this.radioButton8.Visible = false;
  1002. //
  1003. // groupBox11
  1004. //
  1005. this.groupBox11.Controls.Add(this.button8);
  1006. this.groupBox11.Controls.Add(this.button7);
  1007. this.groupBox11.Controls.Add(this.button6);
  1008. this.groupBox11.Controls.Add(this.radioButton10);
  1009. this.groupBox11.Controls.Add(this.radioButton11);
  1010. this.groupBox11.Location = new System.Drawing.Point(158, 277);
  1011. this.groupBox11.Name = "groupBox11";
  1012. this.groupBox11.Size = new System.Drawing.Size(200, 74);
  1013. this.groupBox11.TabIndex = 13;
  1014. this.groupBox11.TabStop = false;
  1015. //
  1016. // button8
  1017. //
  1018. this.button8.Location = new System.Drawing.Point(124, 40);
  1019. this.button8.Name = "button8";
  1020. this.button8.Size = new System.Drawing.Size(52, 23);
  1021. this.button8.TabIndex = 13;
  1022. this.button8.UseVisualStyleBackColor = true;
  1023. this.button8.Click += new System.EventHandler(this.button8_Click);
  1024. //
  1025. // button7
  1026. //
  1027. this.button7.Location = new System.Drawing.Point(66, 40);
  1028. this.button7.Name = "button7";
  1029. this.button7.Size = new System.Drawing.Size(52, 23);
  1030. this.button7.TabIndex = 12;
  1031. this.button7.UseVisualStyleBackColor = true;
  1032. this.button7.Click += new System.EventHandler(this.button11_Click);
  1033. //
  1034. // button6
  1035. //
  1036. this.button6.Location = new System.Drawing.Point(8, 40);
  1037. this.button6.Name = "button6";
  1038. this.button6.Size = new System.Drawing.Size(52, 23);
  1039. this.button6.TabIndex = 11;
  1040. this.button6.UseVisualStyleBackColor = true;
  1041. this.button6.Click += new System.EventHandler(this.button12_Click);
  1042. //
  1043. // radioButton10
  1044. //
  1045. this.radioButton10.AutoSize = true;
  1046. this.radioButton10.Location = new System.Drawing.Point(70, 20);
  1047. this.radioButton10.Name = "radioButton10";
  1048. this.radioButton10.Size = new System.Drawing.Size(14, 13);
  1049. this.radioButton10.TabIndex = 1;
  1050. this.radioButton10.UseVisualStyleBackColor = true;
  1051. //
  1052. // radioButton11
  1053. //
  1054. this.radioButton11.AutoSize = true;
  1055. this.radioButton11.Checked = true;
  1056. this.radioButton11.Location = new System.Drawing.Point(7, 20);
  1057. this.radioButton11.Name = "radioButton11";
  1058. this.radioButton11.Size = new System.Drawing.Size(14, 13);
  1059. this.radioButton11.TabIndex = 0;
  1060. this.radioButton11.TabStop = true;
  1061. this.radioButton11.UseVisualStyleBackColor = true;
  1062. //
  1063. // groupBox13
  1064. //
  1065. this.groupBox13.Controls.Add(this.button2);
  1066. this.groupBox13.Controls.Add(this.button11);
  1067. this.groupBox13.Controls.Add(this.button12);
  1068. this.groupBox13.Location = new System.Drawing.Point(158, 277);
  1069. this.groupBox13.Name = "groupBox13";
  1070. this.groupBox13.Size = new System.Drawing.Size(200, 74);
  1071. this.groupBox13.TabIndex = 14;
  1072. this.groupBox13.TabStop = false;
  1073. this.groupBox13.Text = "目标处理";
  1074. this.groupBox13.Visible = false;
  1075. //
  1076. // button2
  1077. //
  1078. this.button2.Location = new System.Drawing.Point(124, 35);
  1079. this.button2.Name = "button2";
  1080. this.button2.Size = new System.Drawing.Size(52, 23);
  1081. this.button2.TabIndex = 13;
  1082. this.button2.Text = "重置";
  1083. this.button2.UseVisualStyleBackColor = true;
  1084. this.button2.Click += new System.EventHandler(this.button8_Click);
  1085. //
  1086. // button11
  1087. //
  1088. this.button11.Location = new System.Drawing.Point(66, 35);
  1089. this.button11.Name = "button11";
  1090. this.button11.Size = new System.Drawing.Size(52, 23);
  1091. this.button11.TabIndex = 12;
  1092. this.button11.Text = "重做";
  1093. this.button11.UseVisualStyleBackColor = true;
  1094. this.button11.Click += new System.EventHandler(this.button11_Click);
  1095. //
  1096. // button12
  1097. //
  1098. this.button12.Location = new System.Drawing.Point(8, 35);
  1099. this.button12.Name = "button12";
  1100. this.button12.Size = new System.Drawing.Size(52, 23);
  1101. this.button12.TabIndex = 11;
  1102. this.button12.Text = "撤销";
  1103. this.button12.UseVisualStyleBackColor = true;
  1104. this.button12.Click += new System.EventHandler(this.button12_Click);
  1105. //
  1106. // PhaseExtractDialog
  1107. //
  1108. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  1109. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  1110. this.ClientSize = new System.Drawing.Size(1286, 827);
  1111. this.Controls.Add(this.groupBox12);
  1112. this.Controls.Add(this.groupBox13);
  1113. this.Controls.Add(this.groupBox11);
  1114. this.Controls.Add(this.groupBox10);
  1115. this.Controls.Add(this.groupBox9);
  1116. this.Controls.Add(this.groupBox3);
  1117. this.Controls.Add(this.groupBox8);
  1118. this.Controls.Add(this.groupBox1);
  1119. this.Controls.Add(this.groupBox7);
  1120. this.Controls.Add(this.groupBox6);
  1121. this.Controls.Add(this.groupBox5);
  1122. this.Controls.Add(this.groupBox4);
  1123. this.Controls.Add(this.groupBox2);
  1124. this.Name = "PhaseExtractDialog";
  1125. this.ShowInTaskbar = false;
  1126. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  1127. this.Text = "物相提取";
  1128. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PhaseExtractDialog_FormClosing);
  1129. this.Load += new System.EventHandler(this.PhaseExtractDialog_Load);
  1130. this.Controls.SetChildIndex(this.groupBox2, 0);
  1131. this.Controls.SetChildIndex(this.groupBox4, 0);
  1132. this.Controls.SetChildIndex(this.groupBox5, 0);
  1133. this.Controls.SetChildIndex(this.groupBox6, 0);
  1134. this.Controls.SetChildIndex(this.groupBox7, 0);
  1135. this.Controls.SetChildIndex(this.groupBox1, 0);
  1136. this.Controls.SetChildIndex(this.groupBox8, 0);
  1137. this.Controls.SetChildIndex(this.groupBox3, 0);
  1138. this.Controls.SetChildIndex(this.groupBox9, 0);
  1139. this.Controls.SetChildIndex(this.groupBox10, 0);
  1140. this.Controls.SetChildIndex(this.groupBox11, 0);
  1141. this.Controls.SetChildIndex(this.groupBox13, 0);
  1142. this.Controls.SetChildIndex(this.groupBox12, 0);
  1143. this.groupBox2.ResumeLayout(false);
  1144. this.groupBox2.PerformLayout();
  1145. this.groupBox4.ResumeLayout(false);
  1146. this.groupBox5.ResumeLayout(false);
  1147. this.groupBox5.PerformLayout();
  1148. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  1149. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  1150. this.groupBox6.ResumeLayout(false);
  1151. this.groupBox6.PerformLayout();
  1152. this.groupBox7.ResumeLayout(false);
  1153. this.groupBox7.PerformLayout();
  1154. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).EndInit();
  1155. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).EndInit();
  1156. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
  1157. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();
  1158. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  1159. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  1160. this.groupBox12.ResumeLayout(false);
  1161. this.groupBox12.PerformLayout();
  1162. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).EndInit();
  1163. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  1164. this.groupBox8.ResumeLayout(false);
  1165. this.groupBox3.ResumeLayout(false);
  1166. this.groupBox3.PerformLayout();
  1167. this.groupBox9.ResumeLayout(false);
  1168. this.groupBox9.PerformLayout();
  1169. this.panel1.ResumeLayout(false);
  1170. this.panel1.PerformLayout();
  1171. ((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).EndInit();
  1172. ((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).EndInit();
  1173. this.groupBox10.ResumeLayout(false);
  1174. this.groupBox10.PerformLayout();
  1175. this.groupBox11.ResumeLayout(false);
  1176. this.groupBox11.PerformLayout();
  1177. this.groupBox13.ResumeLayout(false);
  1178. this.ResumeLayout(false);
  1179. }
  1180. #endregion
  1181. /// <summary>
  1182. /// 主控件
  1183. /// </summary>
  1184. private AppWorkspace appWorkspace;
  1185. /// <summary>
  1186. /// 公共按钮
  1187. /// </summary>
  1188. private CommonControlButtons commonControlButtons;
  1189. /// <summary>
  1190. /// 图像面板
  1191. /// </summary>
  1192. private DocumentWorkspaceWindow documentWorkspace;
  1193. /// <summary>
  1194. /// 步长 初始值1,依次增加
  1195. /// </summary>
  1196. string stepLength = "001";
  1197. /// <summary>
  1198. /// 参数类
  1199. /// </summary>
  1200. private ParamObject action = new Data.Action.Action902();
  1201. /// <summary>
  1202. /// 当前选择的相颜色
  1203. /// </summary>
  1204. private int color = 0;
  1205. /// <summary>
  1206. /// 当前选择的图片
  1207. /// </summary>
  1208. private Mat mat;
  1209. private Mat mat1;
  1210. /// <summary>
  1211. /// 当前选择的图片
  1212. /// </summary>
  1213. private Mat imageMat;
  1214. /// <summary>
  1215. /// 鼠标移动最后一次的坐标,换算后的
  1216. /// </summary>
  1217. private int x, y;
  1218. /// <summary>
  1219. /// 传递给计算函数的坐标
  1220. /// </summary>
  1221. private int xn, yn;
  1222. /// <summary>
  1223. /// 最后一次坐标,换算前的
  1224. /// </summary>
  1225. private int ox, oy;
  1226. /// <summary>
  1227. /// 当前相model
  1228. /// </summary>
  1229. private PhaseModel model;
  1230. /// <summary>
  1231. /// 当前相
  1232. /// </summary>
  1233. private int currentPhase = 0;
  1234. /// <summary>
  1235. /// 相个数
  1236. /// </summary>
  1237. private int countPhase = 0;
  1238. /// <summary>
  1239. /// 第一次双击的标记
  1240. /// </summary>
  1241. private bool firstFlag = false;
  1242. /// <summary>
  1243. /// 存在视场标记
  1244. /// </summary>
  1245. private bool existViewFlag = false;
  1246. /// <summary>
  1247. /// 循环时用来计算的
  1248. /// </summary>
  1249. private byte maxB = 0, maxG = 0, maxR = 0;
  1250. /// <summary>
  1251. /// 循环时用来计算的
  1252. /// </summary>
  1253. private byte minB = 255, minG = 255, minR = 255;
  1254. /// <summary>
  1255. /// 相颜色
  1256. /// </summary>
  1257. private Vec4b b4;
  1258. /// <summary>
  1259. /// 鼠标点击标记
  1260. /// </summary>
  1261. private bool _mouseClick = false;
  1262. /// <summary>
  1263. /// 当前使用轮廓的形状
  1264. /// </summary>
  1265. private ContourParameters contourParameters;
  1266. /// <summary>
  1267. /// 矩形或椭圆的外接矩形
  1268. /// </summary>
  1269. private RectangleF rectangleF;
  1270. /// <summary>
  1271. /// 多边形的点集合
  1272. /// </summary>
  1273. private List<PointF> points;
  1274. /// <summary>
  1275. /// 容许值
  1276. /// </summary>
  1277. private int tolerance = 0;
  1278. /// <summary>
  1279. /// RGB/HLS 选中那个按钮,默认1=R/H 2=G/L 2=B/S
  1280. /// </summary>
  1281. private int HistogramRGBSelect = 1;
  1282. /// <summary>
  1283. /// 用于撤销恢复
  1284. /// </summary>
  1285. private List<MultiPhaseStepModel> steps = new List<MultiPhaseStepModel>();
  1286. /// <summary>
  1287. /// 用于记录当前的撤销恢复步骤
  1288. /// </summary>
  1289. private int currentPosition = -1;
  1290. /// <summary>
  1291. /// 用于标记是撤销重做,以免再次加入集合
  1292. /// </summary>
  1293. private bool doOrRedo = false;
  1294. /// <summary>
  1295. /// 选中的左侧list的下标
  1296. /// </summary>
  1297. private int index = 0;
  1298. private int menuId;
  1299. #region 保存参数的model和key
  1300. private GrainSizeAnalysisModel analysisModel;
  1301. private const string ParamKey_ShowAll = "showAll";//显示全部
  1302. private const string ParamKey_NewPic = "newPic";//创建新图
  1303. private const string ParamKey_WholePic = "wholePic";//整个图像
  1304. private const string ParamKey_Click = "click";//点击
  1305. private const string ParamKey_CkValue = "ckValue";//点击容许值
  1306. private const string ParamKey_CkRange = "ckRange";//点击范围大小
  1307. private const string ParamKey_Outline = "outline";//轮廓
  1308. private const string ParamKey_OPolygon = "oPolygon";//轮廓多边形
  1309. private const string ParamKey_ORectangle = "oRectangle";//轮廓矩形
  1310. private const string ParamKey_OEllipse = "oEllipse";//轮廓椭圆
  1311. private const string ParamKey_Solid = "solid";//二值实心
  1312. private const string ParamKey_Outer = "outer";//二值边线
  1313. private const string ParamKey_Target1 = "target1";//目标选择1
  1314. private const string ParamKey_Target2 = "target2";//目标选择2
  1315. private const string ParamKey_Target3 = "target3";//目标选择3
  1316. private const string ParamKey_Boundary = "boundary";//处理细节-删除边界对象
  1317. private const string ParamKey_Holes = "holes";//处理细节-孔洞填充
  1318. private const string ParamKey_Detritus = "detritus";//处理细节-碎屑删除
  1319. private const string ParamKey_Single = "single";//单个目标
  1320. private const string ParamKey_SDeviation = "sDeviation";//单个目标-偏差
  1321. #endregion
  1322. /// <summary>
  1323. /// 构造函数
  1324. /// </summary>
  1325. /// <param name="appWorkspace">主空间</param>
  1326. /// <param name="dialogText">标题</param>
  1327. public PhaseExtractDialog(AppWorkspace appWorkspace, string dialogText, int menuId)
  1328. {
  1329. this.menuId = menuId;
  1330. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
  1331. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1332. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  1333. foreach (var item in this.analysisModel.ListParam)
  1334. item.setValue();
  1335. InitializeComponent();
  1336. InitializeLanguageText();
  1337. //
  1338. // 设置Dialog属性
  1339. //
  1340. this.appWorkspace = appWorkspace;
  1341. this.Text = dialogText;
  1342. this.Icon = PdnInfo.AppIcon;
  1343. //
  1344. // 初始化目标选择的背景图
  1345. //
  1346. this.InitButtonBackgroundImage();
  1347. //
  1348. //初始化图像控件
  1349. //
  1350. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  1351. this.documentWorkspace.Dock = DockStyle.Fill;
  1352. this.documentWorkspace.HookMouseEvents();
  1353. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1354. //移除所有事件
  1355. //this.documentWorkspace.SurfaceBox.RemoveMouseEvent();
  1356. documentWorkspace.panel.MouseDown += (s, e) => { _timeMD = DateTime.Now; };
  1357. this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.pictureBox1_MouseMove);
  1358. this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
  1359. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.pictureBox1_Paint);
  1360. this.documentWorkspace.PPhaseActionFinish += new EventHandler<EventArgs<List<Object>>>(this.defineProfile_Change);
  1361. //this.documentWorkspace.panel.MouseEnter += new EventHandler(this.pictureBox1_MouseEnter);
  1362. this.documentWorkspace.Visible = false;
  1363. this.groupBox1.Controls.Add(documentWorkspace);
  1364. //
  1365. //初始化操作按钮
  1366. //
  1367. this.commonControlButtons = new CommonControlButtons();
  1368. this.commonControlButtons.Dock = DockStyle.Top;
  1369. this.commonControlButtons.Height = 30;
  1370. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1371. this.groupBox1.Controls.Add(commonControlButtons);
  1372. //
  1373. // 设置listview事件
  1374. //
  1375. this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
  1376. InitData();
  1377. this.tolerance = (int)this.userTextBox2.Value;
  1378. this.button13.FlatStyle = FlatStyle.Flat;
  1379. this.button13.BackColor = Color.FromArgb(225, 225, 225);
  1380. this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
  1381. this.button13.FlatAppearance.BorderSize = 2;
  1382. InitHistogramDragEvent();
  1383. InitCommonButtonEvent();
  1384. /*
  1385. //初始化一个相
  1386. AddPhase("默认相", Color.Red.ToArgb());*/
  1387. this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
  1388. }
  1389. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  1390. {
  1391. //滚动到指定的行位置
  1392. this.listView1.EnsureVisible(index);
  1393. //初始化数据
  1394. this.imageMat = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreatedAliasedMat();
  1395. Document document = Document.FromImageMat(imageMat.Clone());
  1396. this.documentWorkspace.Document = document;
  1397. this.documentWorkspace.Visible = true;
  1398. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
  1399. }
  1400. private void InitButtonBackgroundImage()
  1401. {
  1402. this.button16.FlatStyle = FlatStyle.Flat;
  1403. this.button16.FlatAppearance.BorderSize = 0;
  1404. this.button16.BackgroundImageLayout = ImageLayout.Zoom;
  1405. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
  1406. this.button16.Click += new EventHandler(this.button16_click);
  1407. this.button17.FlatStyle = FlatStyle.Flat;
  1408. this.button17.FlatAppearance.BorderSize = 0;
  1409. this.button17.BackgroundImageLayout = ImageLayout.Zoom;
  1410. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  1411. this.button17.Click += new EventHandler(this.button17_click);
  1412. this.button18.FlatStyle = FlatStyle.Flat;
  1413. this.button18.FlatAppearance.BorderSize = 0;
  1414. this.button18.BackgroundImageLayout = ImageLayout.Zoom;
  1415. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  1416. this.button18.Click += new EventHandler(this.button18_click);
  1417. }
  1418. private void button16_click(object sender, EventArgs e)
  1419. {
  1420. this.radioButton8.Checked = true;
  1421. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
  1422. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  1423. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  1424. }
  1425. private void button17_click(object sender, EventArgs e)
  1426. {
  1427. this.radioButton7.Checked = true;
  1428. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
  1429. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  1430. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  1431. }
  1432. private void button18_click(object sender, EventArgs e)
  1433. {
  1434. this.radioButton9.Checked = true;
  1435. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
  1436. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  1437. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  1438. }
  1439. private void InitCommonButtonEvent()
  1440. {
  1441. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1442. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1443. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1444. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1445. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1446. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1447. }
  1448. private void zoomInButton_Click(object sender, EventArgs e)
  1449. {
  1450. if (this.imageMat != null)
  1451. this.documentWorkspace.ZoomIn();
  1452. }
  1453. private void zoomOutButton_Click(object sender, EventArgs e)
  1454. {
  1455. if (this.imageMat != null)
  1456. this.documentWorkspace.ZoomOut();
  1457. }
  1458. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1459. {
  1460. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1461. }
  1462. private void actualSizeButton_Click(object sender, EventArgs e)
  1463. {
  1464. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1465. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1466. }
  1467. private void pointerButton_Click(object sender, EventArgs e)
  1468. {
  1469. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1470. }
  1471. private void mobileModeButton_Click(object sender, EventArgs e)
  1472. {
  1473. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1474. }
  1475. /// <summary>
  1476. /// 直方图区间拖动事件
  1477. /// </summary>
  1478. private void InitHistogramDragEvent()
  1479. {
  1480. this.histogramControl1.DragOneEventActionFinish += new EventHandler<EventArgs<int>>(this.DragOneEvent);
  1481. this.histogramControl1.DragTwoEventActionFinish += new EventHandler<EventArgs<int>>(this.DragTwoEvent);
  1482. this.histogramControl1.DragFiveEventActionFinish += new EventHandler<EventArgs<int[]>>(this.DragFiveEvent);
  1483. }
  1484. /// <summary>
  1485. /// 颜色区间1 截止值变化
  1486. /// </summary>
  1487. /// <param name="sender"></param>
  1488. /// <param name="e"></param>
  1489. private void DragTwoEvent(object sender, EventArgs<int> e)
  1490. {
  1491. if (this.HistogramRGBSelect == 1)
  1492. {
  1493. this.numericUpDown3.Value = e.Data;
  1494. }
  1495. if (this.HistogramRGBSelect == 2)
  1496. {
  1497. this.numericUpDown5.Value = e.Data;
  1498. }
  1499. if (this.HistogramRGBSelect == 3)
  1500. {
  1501. this.numericUpDown7.Value = e.Data;
  1502. }
  1503. }
  1504. /// <summary>
  1505. /// 颜色区间1 起始值变化
  1506. /// </summary>
  1507. /// <param name="sender"></param>
  1508. /// <param name="e"></param>
  1509. private void DragOneEvent(object sender, EventArgs<int> e)
  1510. {
  1511. if (this.HistogramRGBSelect == 1)
  1512. {
  1513. this.numericUpDown4.Value = e.Data;
  1514. }
  1515. if (this.HistogramRGBSelect == 2)
  1516. {
  1517. this.numericUpDown6.Value = e.Data;
  1518. }
  1519. if (this.HistogramRGBSelect == 3)
  1520. {
  1521. this.numericUpDown8.Value = e.Data;
  1522. }
  1523. }
  1524. /// <summary>
  1525. /// 拖拽直方图
  1526. /// </summary>
  1527. /// <param name="sender"></param>
  1528. /// <param name="e"></param>
  1529. private void DragFiveEvent(object sender, EventArgs<int[]> e)
  1530. {
  1531. if (this.HistogramRGBSelect == 1)
  1532. {
  1533. this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
  1534. this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
  1535. this.numericUpDown4.Value = e.Data[1];
  1536. this.numericUpDown3.Value = e.Data[0];
  1537. this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
  1538. this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
  1539. }
  1540. if (this.HistogramRGBSelect == 2)
  1541. {
  1542. this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
  1543. this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
  1544. this.numericUpDown6.Value = e.Data[1];
  1545. this.numericUpDown5.Value = e.Data[0];
  1546. this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
  1547. this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
  1548. }
  1549. if (this.HistogramRGBSelect == 3)
  1550. {
  1551. this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
  1552. this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
  1553. this.numericUpDown8.Value = e.Data[1];
  1554. this.numericUpDown7.Value = e.Data[0];
  1555. this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
  1556. this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
  1557. }
  1558. this.RGBoRHLSValue_Changed(null, null);
  1559. }
  1560. /// <summary>
  1561. /// 定义轮廓属性的改变事件
  1562. /// </summary>
  1563. /// <param name="sender"></param>
  1564. /// <param name="e"></param>
  1565. private void defineProfile_Change(object sender, EventArgs<List<Object>> e)
  1566. {
  1567. switch ((ContourParameters)Enum.Parse(typeof(ContourParameters), e.Data[0].ToString()))
  1568. {
  1569. case ContourParameters.Rectangle:
  1570. contourParameters = ContourParameters.Rectangle;
  1571. rectangleF = (RectangleF)e.Data[1];
  1572. defineProfile_Calc();
  1573. break;
  1574. case ContourParameters.Oval:
  1575. contourParameters = ContourParameters.Oval;
  1576. rectangleF = (RectangleF)e.Data[1];
  1577. defineProfile_Calc();
  1578. break;
  1579. case ContourParameters.Polygon:
  1580. contourParameters = ContourParameters.Polygon;
  1581. points = (List<PointF>)e.Data[1];
  1582. defineProfile_Calc();
  1583. break;
  1584. }
  1585. }
  1586. /// <summary>
  1587. /// 计算划取得区域的RGB最大最小值,并进行处理
  1588. /// </summary>
  1589. private unsafe void defineProfile_Calc()
  1590. {
  1591. Mat mat = imageMat.Clone();
  1592. //获取最大最小值
  1593. mat.ForEachAsVec4b(DefineProfileForEachAsVec4b);
  1594. //对于存在视场,不存在进行不同操作
  1595. if (existViewFlag)
  1596. {
  1597. ImageActionWithView();
  1598. }
  1599. else
  1600. {
  1601. ImageActionNoView();
  1602. }
  1603. //添加到步骤中
  1604. SetPhaseModelRGBOrHLS();
  1605. }
  1606. private unsafe void DefineProfileForEachAsVec4b(Vec4b* value, int* position)
  1607. {
  1608. int y = position[0];
  1609. int x = position[1];
  1610. switch (contourParameters)
  1611. {
  1612. case ContourParameters.Rectangle:
  1613. if (rectangleF.Contains(x, y))
  1614. {
  1615. CalcMaxAndMin(value);
  1616. }
  1617. break;
  1618. case ContourParameters.Oval:
  1619. if (BaseTools.isPointInOval(new System.Drawing.Point(x, y),
  1620. new System.Drawing.PointF(rectangleF.X + rectangleF.Width / 2,
  1621. rectangleF.Y + rectangleF.Height / 2),
  1622. rectangleF.Width / 2,
  1623. rectangleF.Height / 2)
  1624. )
  1625. {
  1626. CalcMaxAndMin(value);
  1627. }
  1628. break;
  1629. case ContourParameters.Polygon:
  1630. contourParameters = ContourParameters.Polygon;
  1631. if (BaseTools.isPointInPolygon(new System.Drawing.Point(x, y), points))
  1632. {
  1633. CalcMaxAndMin(value);
  1634. }
  1635. break;
  1636. }
  1637. }
  1638. private unsafe void CalcMaxAndMin(Vec4b* value)
  1639. {
  1640. byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1641. byte vB = value->Item0;
  1642. byte vG = value->Item1;
  1643. byte vR = value->Item2;
  1644. int minb = (int)(vB - relativeValue);
  1645. int ming = (int)(vG - relativeValue);
  1646. int minr = (int)(vR - relativeValue);
  1647. int maxb = (int)(vB + relativeValue);
  1648. int maxg = (int)(vG + relativeValue);
  1649. int maxr = (int)(vR + relativeValue);
  1650. byte vBmin = (minb < 0) ? (byte)'\0' : (byte)minb;
  1651. byte vBmax = (maxb > 255) ? (byte)255 : (byte)maxb;
  1652. byte vGmin = (ming < 0) ? (byte)'\0' : (byte)ming;
  1653. byte vGmax = (maxg > 255) ? (byte)255 : (byte)maxg;
  1654. byte vRmin = (minr < 0) ? (byte)'\0' : (byte)minr;
  1655. byte vRmax = (maxr > 255) ? (byte)255 : (byte)maxr;
  1656. if (vBmax > maxB) maxB = vBmax;
  1657. if (vBmin < minB) minB = vBmin;
  1658. if (vGmax > maxG) maxG = vGmax;
  1659. if (vGmin < minG) minG = vGmin;
  1660. if (vRmax > maxR) maxR = vRmax;
  1661. if (vRmin < minR) minR = vRmin;
  1662. //if (tolerance > 0)
  1663. //{
  1664. // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1665. // //minB = (minB < 0) ? (byte)'\0' : minB;
  1666. // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1667. // //maxB = (maxB > 255) ? (byte)255 : maxB;
  1668. // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1669. // //minG = (minG < 0) ? (byte)'\0' : minG;
  1670. // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1671. // //maxG = (maxG > 255) ? (byte)255 : maxG;
  1672. // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1673. // //minR = (minR < 0) ? (byte)'\0' : minR;
  1674. // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1675. // //maxR = (maxR > 255) ? (byte)255 : maxR;
  1676. // //byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1677. // int minb = (int)(minB - relativeValue);
  1678. // int ming = (int)(minG - relativeValue);
  1679. // int minr = (int)(minR - relativeValue);
  1680. // int maxb = (int)(maxB + relativeValue);
  1681. // int maxg = (int)(maxG + relativeValue);
  1682. // int maxr = (int)(maxR + relativeValue);
  1683. // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1684. // minB = (minb < 0) ? (byte)'\0' : (byte)minb;
  1685. // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1686. // maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
  1687. // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1688. // minG = (ming < 0) ? (byte)'\0' : (byte)ming;
  1689. // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1690. // maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
  1691. // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1692. // minR = (minr < 0) ? (byte)'\0' : (byte)minr;
  1693. // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1694. // maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
  1695. //}
  1696. //byte vB = value->Item0;
  1697. //byte vG = value->Item1;
  1698. //byte vR = value->Item2;
  1699. //if (vB > maxB) maxB = vB;
  1700. //if (vB < minB) minB = vB;
  1701. //if (vG > maxG) maxG = vG;
  1702. //if (vG < minG) minG = vG;
  1703. //if (vR > maxR) maxR = vR;
  1704. //if (vR < minR) minR = vR;
  1705. //if (tolerance > 0)
  1706. //{
  1707. // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1708. // //minB = (minB < 0) ? (byte)'\0' : minB;
  1709. // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1710. // //maxB = (maxB > 255) ? (byte)255 : maxB;
  1711. // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1712. // //minG = (minG < 0) ? (byte)'\0' : minG;
  1713. // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1714. // //maxG = (maxG > 255) ? (byte)255 : maxG;
  1715. // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1716. // //minR = (minR < 0) ? (byte)'\0' : minR;
  1717. // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1718. // //maxR = (maxR > 255) ? (byte)255 : maxR;
  1719. // byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1720. // int minb = (int)(minB - relativeValue);
  1721. // int ming = (int)(minG - relativeValue);
  1722. // int minr = (int)(minR - relativeValue);
  1723. // int maxb = (int)(maxB + relativeValue);
  1724. // int maxg = (int)(maxG + relativeValue);
  1725. // int maxr = (int)(maxR + relativeValue);
  1726. // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1727. // minB = (minb < 0) ? (byte)'\0' : (byte)minb;
  1728. // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1729. // maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
  1730. // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1731. // minG = (ming < 0) ? (byte)'\0' : (byte)ming;
  1732. // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1733. // maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
  1734. // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1735. // minR = (minr < 0) ? (byte)'\0' : (byte)minr;
  1736. // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  1737. // maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
  1738. //}
  1739. }
  1740. /// <summary>
  1741. /// Load事件,初始化参数事件
  1742. /// </summary>
  1743. /// <param name="sender"></param>
  1744. /// <param name="e"></param>
  1745. private void PhaseExtractDialog_Load(object sender, EventArgs e)
  1746. {
  1747. //提取模式
  1748. this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
  1749. this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
  1750. //定义物体
  1751. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  1752. this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
  1753. //定义物体->点击->容许值
  1754. this.userTextBox2.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[0])).numberParam_ValueChanged;
  1755. //定义物体->点击->范围大小
  1756. this.userTextBox1.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[1])).numberParam_ValueChanged;
  1757. //定义物体->轮廓
  1758. this.radioButton14.CheckedChanged += new System.EventHandler(this.radioButton14_CheckedChanged);
  1759. this.radioButton15.CheckedChanged += new System.EventHandler(this.radioButton15_CheckedChanged);
  1760. this.radioButton16.CheckedChanged += new System.EventHandler(this.radioButton16_CheckedChanged);
  1761. //二值样式
  1762. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  1763. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  1764. //目标处理
  1765. this.radioButton10.CheckedChanged += new System.EventHandler(this.radioButton10_CheckedChanged);
  1766. this.radioButton11.CheckedChanged += new System.EventHandler(this.radioButton11_CheckedChanged);
  1767. //目标选择
  1768. this.radioButton7.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
  1769. this.radioButton8.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
  1770. this.radioButton9.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
  1771. ////处理细节
  1772. //删除边界对象
  1773. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  1774. //孔洞填充
  1775. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  1776. //碎屑删除
  1777. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  1778. //碎屑删除,面积范围
  1779. this.numericUpDown2.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
  1780. this.numericUpDown2.ValueChanged += this.applyButtonImpl;
  1781. this.numericUpDown1.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
  1782. this.numericUpDown1.ValueChanged += this.applyButtonImpl;
  1783. //RGB/HLS的值
  1784. this.numericUpDown4.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
  1785. this.numericUpDown3.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
  1786. this.numericUpDown6.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
  1787. this.numericUpDown5.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
  1788. this.numericUpDown8.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
  1789. this.numericUpDown7.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
  1790. //单个目标->容许值
  1791. this.numericUpDown9.ValueChanged += new System.EventHandler(this.numericUpDown9_ValueChanged);
  1792. this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
  1793. GetListParamModel();
  1794. }
  1795. /// <summary>
  1796. /// listView选择改变事件
  1797. /// </summary>
  1798. /// <param name="sender"></param>
  1799. /// <param name="e"></param>
  1800. private void ListViewSelectedIndexChanged(object sender, EventArgs e)
  1801. {
  1802. if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
  1803. {
  1804. this.appWorkspace.ActiveDocumentWorkspace = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index];
  1805. //清空相
  1806. this.documentWorkspace.PhaseModels.Clear();
  1807. this.currentPhase = 0;
  1808. this.countPhase = 0;
  1809. this.model = null;
  1810. this.panel2.BackColor = Color.Transparent;
  1811. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  1812. this.documentWorkspace.Refresh();
  1813. //修改标记
  1814. this.firstFlag = false;
  1815. existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList.IsExsitView();
  1816. imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].CompositionSurface.CreatedAliasedMat();
  1817. if (!existViewFlag)
  1818. mat = imageMat.Clone();
  1819. else
  1820. mat = PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion());
  1821. //如果是hls被选中
  1822. if (this.radioButton12.Checked)
  1823. {
  1824. mat = mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL);
  1825. }
  1826. //创建新Document
  1827. Document document = Document.FromImageMat(imageMat.Clone());
  1828. this.documentWorkspace.Document = document;
  1829. this.documentWorkspace.Visible = true;
  1830. // TODO ZYH 这里需要根据业务判断,是否要copylist还是直接用?
  1831. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList;
  1832. //this.pictureBox1.BackgroundImage = map;
  1833. //this.applyButtonImpl(sender, e);
  1834. //清空所有相
  1835. this.documentWorkspace.PhaseModels.Clear();
  1836. //显示直方图
  1837. this.histogramControl1.CreateHistogram(this.imageMat, false, 187, 129, HistogramRGBSelect);
  1838. //添加一个默认相
  1839. //初始化一个相
  1840. AddPhase("默认相", Color.Red.ToArgb());
  1841. }
  1842. }
  1843. /// <summary>
  1844. /// 初始化图片列表数据
  1845. /// </summary>
  1846. public void InitData()
  1847. {
  1848. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1849. {
  1850. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);//.CreateAliasedBitmap()
  1851. this.listView1.Items.Add("", i);
  1852. this.listView1.Items[i].ImageIndex = i;
  1853. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1854. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1855. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1856. {
  1857. index = i;
  1858. }
  1859. }
  1860. //
  1861. // 初始化选中的数据
  1862. //
  1863. this.listView1.Items[index].Selected = true; //选中行
  1864. }
  1865. /// <summary>
  1866. /// 创建新图片
  1867. /// </summary>
  1868. /// <param name="mat"></param>
  1869. private void OpenFileImpl()
  1870. {
  1871. if (imageMat != null)
  1872. {
  1873. DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
  1874. dw.Document = Document.FromImageMat(imageMat.Clone());
  1875. // TODO ZYH 这里的图像名称,需要走系统的配置
  1876. dw.fileText = this.Text + "-00" + Startup.instance.step_length;
  1877. //获取图像对应标尺
  1878. dw.xmlSaveModel = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].xmlSaveModel;
  1879. dw.rules = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].rules;
  1880. this.appWorkspace.ActiveDocumentWorkspace = dw;
  1881. //this.appWorkspace.ActiveDocumentWorkspace.PanelBottom.documentStrip.ShowPictures = false;
  1882. this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.documentWorkspace.PhaseModels;
  1883. Startup.instance.step_length += 1;
  1884. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  1885. }
  1886. }
  1887. /// <summary>
  1888. /// 应用
  1889. /// </summary>
  1890. /// <param name="sender"></param>
  1891. /// <param name="e"></param>
  1892. private void applyButtonImpl(object sender, EventArgs e)
  1893. {
  1894. if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
  1895. {
  1896. if (model != null && model.mat != null)
  1897. {
  1898. if (existViewFlag)
  1899. {
  1900. ImageActionWithView();
  1901. }
  1902. else
  1903. {
  1904. ImageActionNoView();
  1905. }
  1906. }
  1907. }
  1908. }
  1909. /// <summary>
  1910. /// 实心
  1911. /// </summary>
  1912. /// <param name="sender"></param>
  1913. /// <param name="e"></param>
  1914. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  1915. {
  1916. StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
  1917. arr.Value = StyleParameters.Solid;
  1918. this.applyButtonImpl(sender, e);
  1919. }
  1920. /// <summary>
  1921. /// 边线
  1922. /// </summary>
  1923. /// <param name="sender"></param>
  1924. /// <param name="e"></param>
  1925. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  1926. {
  1927. StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
  1928. arr.Value = StyleParameters.Sideline;
  1929. this.applyButtonImpl(sender, e);
  1930. }
  1931. /// <summary>
  1932. /// 整个图像
  1933. /// </summary>
  1934. /// <param name="sender"></param>
  1935. /// <param name="e"></param>
  1936. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  1937. {
  1938. if (this.radioButton4.Checked)
  1939. {
  1940. BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
  1941. booleanObject0.Value = true;
  1942. BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
  1943. booleanObject1.Value = false;
  1944. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1945. this.groupBox12.Visible = false;
  1946. this.groupBox13.Visible = false;
  1947. this.groupBox5.Visible = true;
  1948. this.groupBox7.Visible = true;
  1949. this.groupBox8.Visible = true;
  1950. this.groupBox9.Visible = true;
  1951. this.groupBox11.Visible = true;
  1952. }
  1953. }
  1954. /// <summary>
  1955. /// 容许值
  1956. /// </summary>
  1957. /// <param name="sender"></param>
  1958. /// <param name="e"></param>
  1959. private void userTextBox2Change(object sender, EventArgs e)
  1960. {
  1961. tolerance = (int)this.userTextBox2.Value;
  1962. }
  1963. /// <summary>
  1964. /// 单个目标
  1965. /// </summary>
  1966. /// <param name="sender"></param>
  1967. /// <param name="e"></param>
  1968. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  1969. {
  1970. if (this.radioButton3.Checked)
  1971. {
  1972. BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
  1973. booleanObject0.Value = false;
  1974. BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
  1975. booleanObject1.Value = true;
  1976. this.documentWorkspace.ActiveTool = DrawToolType.ColorPicker;
  1977. this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
  1978. this.groupBox5.Visible = false;
  1979. this.groupBox7.Visible = false;
  1980. this.groupBox8.Visible = false;
  1981. this.groupBox9.Visible = false;
  1982. this.groupBox11.Visible = false;
  1983. this.groupBox12.Visible = true;
  1984. this.groupBox13.Visible = true;
  1985. }
  1986. if (this.radioButton4.Checked)
  1987. {
  1988. this.documentWorkspace.panel.Cursor = Cursors.Default;
  1989. }
  1990. }
  1991. /// <summary>
  1992. /// 上一个
  1993. /// </summary>
  1994. /// <param name="sender"></param>
  1995. /// <param name="e"></param>
  1996. private void button10_Click(object sender, EventArgs e)
  1997. {
  1998. if (this.currentPhase > 1)
  1999. {
  2000. this.checkBox5.Checked = false;
  2001. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
  2002. this.currentPhase--;
  2003. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
  2004. this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
  2005. this.documentWorkspace.Refresh();
  2006. this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
  2007. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  2008. this.SetRGBOrHLSNumericValue();
  2009. }
  2010. }
  2011. /// <summary>
  2012. /// 下一个
  2013. /// </summary>
  2014. /// <param name="sender"></param>
  2015. /// <param name="e"></param>
  2016. private void button9_Click(object sender, EventArgs e)
  2017. {
  2018. if (this.currentPhase < this.countPhase)
  2019. {
  2020. this.checkBox5.Checked = false;
  2021. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
  2022. this.currentPhase++;
  2023. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
  2024. this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
  2025. this.documentWorkspace.Refresh();
  2026. this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
  2027. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  2028. this.SetRGBOrHLSNumericValue();
  2029. }
  2030. }
  2031. /// <summary>
  2032. /// 切换上一个下一个的时候设置RGB/HLS区间的值
  2033. /// </summary>
  2034. private void SetRGBOrHLSNumericValue()
  2035. {
  2036. this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
  2037. this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
  2038. this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
  2039. this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
  2040. this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
  2041. this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
  2042. if (this.model.rgborhls == 1)
  2043. {
  2044. this.radioButton13.Checked = true;
  2045. this.numericUpDown4.Value = this.model.minB;
  2046. this.numericUpDown3.Value = this.model.maxB;
  2047. this.numericUpDown6.Value = this.model.minG;
  2048. this.numericUpDown5.Value = this.model.maxG;
  2049. this.numericUpDown8.Value = this.model.minR;
  2050. this.numericUpDown7.Value = this.model.maxR;
  2051. }
  2052. else if (this.model.rgborhls == 2)
  2053. {
  2054. this.radioButton12.Checked = true;
  2055. this.numericUpDown4.Value = this.model.minH;
  2056. this.numericUpDown3.Value = this.model.maxH;
  2057. this.numericUpDown6.Value = this.model.minL;
  2058. this.numericUpDown5.Value = this.model.maxL;
  2059. this.numericUpDown8.Value = this.model.minS;
  2060. this.numericUpDown7.Value = this.model.maxS;
  2061. }
  2062. switch (this.HistogramRGBSelect)
  2063. {
  2064. case 1:
  2065. //处理直方图
  2066. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
  2067. break;
  2068. case 2:
  2069. //处理直方图
  2070. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
  2071. break;
  2072. case 3:
  2073. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
  2074. break;
  2075. }
  2076. this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
  2077. this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
  2078. this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
  2079. this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
  2080. this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
  2081. this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
  2082. }
  2083. /// <summary>
  2084. /// 新增
  2085. /// </summary>
  2086. /// <param name="sender"></param>
  2087. /// <param name="e"></param>
  2088. private void button4_Click(object sender, EventArgs e)
  2089. {
  2090. if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
  2091. {
  2092. Color color = (this.documentWorkspace.phaseModels.Count > 0) ? BaseTools.GetRandomColor(Color.FromArgb(this.documentWorkspace.phaseModels[this.documentWorkspace.phaseModels.Count - 1].color)) : Color.Red;
  2093. using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, "相" + (this.documentWorkspace.phaseModels.Count + 1), color, false))
  2094. {
  2095. addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
  2096. addPhaseDialog.ShowDialog();
  2097. }
  2098. }
  2099. else
  2100. {
  2101. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  2102. }
  2103. }
  2104. /// <summary>
  2105. /// 删除
  2106. /// </summary>
  2107. /// <param name="sender"></param>
  2108. /// <param name="e"></param>
  2109. private void button3_Click(object sender, EventArgs e)
  2110. {
  2111. if (model != null)
  2112. {
  2113. if (MessageBox.Show(PdnResources.GetString("Menu.Confirmtodeletecurrentphase.text") + "?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
  2114. {
  2115. //删除相
  2116. this.documentWorkspace.PhaseModels.Remove(model);
  2117. if (this.documentWorkspace.PhaseModels.Count > 0)
  2118. {
  2119. this.currentPhase--;
  2120. //如果当前的相不是第一个,就--
  2121. if (this.currentPhase == 0)
  2122. this.currentPhase++;
  2123. this.countPhase = this.documentWorkspace.PhaseModels.Count;
  2124. this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
  2125. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
  2126. }
  2127. else
  2128. {
  2129. this.currentPhase = 0;
  2130. this.countPhase = 0;
  2131. this.model = null;
  2132. }
  2133. if (this.currentPhase == 0)
  2134. this.panel2.BackColor = Color.Transparent;
  2135. else
  2136. this.panel2.BackColor = Color.FromArgb(this.model.color);
  2137. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  2138. this.documentWorkspace.Refresh();
  2139. }
  2140. }
  2141. }
  2142. /// <summary>
  2143. /// 编辑
  2144. /// </summary>
  2145. /// <param name="sender"></param>
  2146. /// <param name="e"></param>
  2147. private void button5_Click(object sender, EventArgs e)
  2148. {
  2149. if (model != null)
  2150. {
  2151. using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, model.name, Color.FromArgb(model.color), true))
  2152. {
  2153. addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
  2154. addPhaseDialog.ShowDialog();
  2155. }
  2156. }
  2157. }
  2158. /// <summary>
  2159. /// 点击确定
  2160. /// </summary>
  2161. /// <param name="sender"></param>
  2162. /// <param name="e"></param>
  2163. private void button1_Click(object sender, EventArgs e)
  2164. {
  2165. if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
  2166. {
  2167. //生成新图-是
  2168. if (this.checkBox1.Checked)
  2169. {
  2170. this.OpenFileImpl();
  2171. }
  2172. else
  2173. {
  2174. if (this.documentWorkspace.PhaseModels.Count > 0)
  2175. {
  2176. List<PhaseModel> models = new List<PhaseModel>();
  2177. foreach (PhaseModel temp in this.documentWorkspace.PhaseModels)
  2178. {
  2179. PhaseModel model = new PhaseModel();
  2180. model.choise = temp.choise;
  2181. model.color = temp.color;
  2182. model.mat = temp.mat;
  2183. model.name = temp.name;
  2184. model.position = temp.position;
  2185. models.Add(model);
  2186. }
  2187. this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].PhaseModels = models;
  2188. this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].Refresh();
  2189. }
  2190. }
  2191. }
  2192. //this.Close();
  2193. }
  2194. /// <summary>
  2195. /// RGB radio改变事件
  2196. /// </summary>
  2197. /// <param name="sender"></param>
  2198. /// <param name="e"></param>
  2199. private void radioButton13_CheckedChanged(object sender, EventArgs e)
  2200. {
  2201. if (this.radioButton13.Checked)
  2202. {
  2203. ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = true;
  2204. ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = false;
  2205. this.label2.Text = "R";
  2206. this.label5.Text = "G";
  2207. this.label6.Text = "B";
  2208. this.button13.Text = "R";
  2209. this.button14.Text = "G";
  2210. this.button15.Text = "B";
  2211. this.firstFlag = false;
  2212. this.numericUpDown3.Value = 0;
  2213. this.numericUpDown4.Value = 0;
  2214. this.numericUpDown5.Value = 0;
  2215. this.numericUpDown6.Value = 0;
  2216. this.numericUpDown7.Value = 0;
  2217. this.numericUpDown8.Value = 0;
  2218. this.mat = this.mat != null ? this.imageMat.Clone() : null;
  2219. //清空所有相,应该是清空相的内容
  2220. if (this.model != null)
  2221. {
  2222. this.model.mat = null;
  2223. this.model.rgborhls = 1;
  2224. }
  2225. this.documentWorkspace.Refresh();
  2226. //更新直方图
  2227. if (this.imageMat != null)
  2228. this.histogramControl1.CreateHistogram(this.imageMat, false, 187, 129, HistogramRGBSelect);
  2229. //this.documentWorkspace.PhaseModels.Clear();
  2230. }
  2231. }
  2232. /// <summary>
  2233. /// HLS radio改变事件
  2234. /// </summary>
  2235. /// <param name="sender"></param>
  2236. /// <param name="e"></param>
  2237. private void radioButton12_CheckedChanged(object sender, EventArgs e)
  2238. {
  2239. if (this.radioButton12.Checked)
  2240. {
  2241. ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = false;
  2242. ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = true;
  2243. this.label2.Text = "H";
  2244. this.label5.Text = "L";
  2245. this.label6.Text = "S";
  2246. this.button13.Text = "H";
  2247. this.button14.Text = "L";
  2248. this.button15.Text = "S";
  2249. this.firstFlag = false;
  2250. this.numericUpDown3.Value = 0;
  2251. this.numericUpDown4.Value = 0;
  2252. this.numericUpDown5.Value = 0;
  2253. this.numericUpDown6.Value = 0;
  2254. this.numericUpDown7.Value = 0;
  2255. this.numericUpDown8.Value = 0;
  2256. this.mat = this.mat != null ? this.mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL) : null;
  2257. //清空所有相,应该是清空相的内容
  2258. if (this.model != null)
  2259. {
  2260. this.model.mat = null;
  2261. this.model.rgborhls = 2;
  2262. }
  2263. this.documentWorkspace.Refresh();
  2264. //更新直方图
  2265. if (this.mat != null)
  2266. {
  2267. this.histogramControl1.CreateHistogram(this.mat, false, 187, 129, HistogramRGBSelect);//###
  2268. }
  2269. }
  2270. }
  2271. /// <summary>
  2272. /// 绘制
  2273. /// </summary>
  2274. /// <param name="sender"></param>
  2275. /// <param name="e"></param>
  2276. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  2277. {
  2278. if (this.mat != null)
  2279. {
  2280. if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
  2281. {
  2282. Vec3b a = mat.At<Vec3b>(y, x);
  2283. string b = x + "," + y;
  2284. b += "\r\n" + "R:" + a.Item2;
  2285. b += "\r\n" + "G:" + a.Item1;
  2286. b += "\r\n" + "B:" + a.Item0;
  2287. e.Graphics.DrawString(b, new Font("宋体", 12), new SolidBrush(Color.Red), ox + 5, oy + 5);
  2288. }
  2289. }
  2290. }
  2291. /// <summary>
  2292. /// surfaceBox双击事件
  2293. /// 目前是参考AxioVision
  2294. /// 应该是把每次选的点都取最高和最低的BGR
  2295. /// </summary>
  2296. /// <param name="sender"></param>
  2297. /// <param name="e"></param>
  2298. private unsafe void pictureBox1_Click(object sender, EventArgs e)
  2299. {
  2300. try
  2301. {
  2302. if (this.documentWorkspace.ActiveTool == DrawToolType.MoveMode)
  2303. return;
  2304. if (!this.radioButton3.Checked && !this.radioButton6.Checked)
  2305. {
  2306. return;
  2307. }
  2308. if (color == 0)
  2309. {
  2310. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text"));
  2311. return;
  2312. }
  2313. if (mat == null)
  2314. {
  2315. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  2316. return;
  2317. }
  2318. //判断点击位置,是否是图片上
  2319. if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
  2320. {
  2321. //删除
  2322. if (this.radioButton10.Checked)
  2323. {
  2324. if (this.model.mat != null)
  2325. {
  2326. //当前相颜色
  2327. Color currentColor = Color.FromArgb(color);
  2328. b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
  2329. //如果存在视场 需要判断是否在视场内
  2330. if (existViewFlag)
  2331. {
  2332. if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
  2333. {
  2334. return;
  2335. }
  2336. /*else
  2337. {
  2338. Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
  2339. mat = PaintDotNet.Camera.Tools.ToMat(bitmap);
  2340. }*/
  2341. }
  2342. //获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
  2343. //vec3b = mat.At<Vec3b>(y, x);
  2344. //容许值
  2345. tolerance = (int)this.userTextBox2.Value;
  2346. //范围大小
  2347. int range = (int)this.userTextBox1.Value;
  2348. //对每个像素点的操作
  2349. byte* pixels = (byte*)mat.Data;
  2350. //循环范围大小内的所有点
  2351. //maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
  2352. int y1 = (y - range) < 0 ? 0 : (y - range);
  2353. int x1 = (x - range) < 0 ? 0 : (x - range);
  2354. int hw = range * 2 + 1;
  2355. int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
  2356. int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
  2357. this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
  2358. this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
  2359. this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
  2360. this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
  2361. this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
  2362. this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
  2363. Vec3b vec3B = mat.At<Vec3b>(y, x);
  2364. byte b = vec3B.Item0;
  2365. byte g = vec3B.Item1;
  2366. byte r = vec3B.Item2;
  2367. if (b > this.numericUpDown8.Value && b < this.numericUpDown7.Value)
  2368. {
  2369. int b2 = (int)(-this.numericUpDown8.Value + this.numericUpDown7.Value) / 2;
  2370. if (b > b2)
  2371. {
  2372. maxB = b;
  2373. this.numericUpDown7.Value = maxB;
  2374. }
  2375. else
  2376. {
  2377. minB = b;
  2378. this.numericUpDown8.Value = minB;
  2379. }
  2380. }
  2381. if (g > this.numericUpDown6.Value && g < this.numericUpDown5.Value)
  2382. {
  2383. int g2 = (int)(-this.numericUpDown6.Value + this.numericUpDown5.Value) / 2;
  2384. if (g > g2)
  2385. {
  2386. maxG = g;
  2387. this.numericUpDown5.Value = maxG;
  2388. }
  2389. else
  2390. {
  2391. minG = g;
  2392. this.numericUpDown6.Value = minG;
  2393. }
  2394. }
  2395. if (r > this.numericUpDown4.Value && r < this.numericUpDown3.Value)
  2396. {
  2397. int r2 = (int)(-this.numericUpDown4.Value + this.numericUpDown3.Value) / 2;
  2398. if (r > r2)
  2399. {
  2400. maxR = r;
  2401. this.numericUpDown3.Value = maxR;
  2402. }
  2403. else
  2404. {
  2405. minR = r;
  2406. this.numericUpDown4.Value = minR;
  2407. }
  2408. }
  2409. if (tolerance > 0)
  2410. {
  2411. if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2412. minB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2413. else
  2414. minB = 0;
  2415. if (255 - maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2416. maxB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2417. else
  2418. maxB = 255;
  2419. if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2420. minG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2421. else
  2422. minG = 0;
  2423. if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2424. maxG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2425. else
  2426. maxG = 255;
  2427. if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2428. minR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2429. else
  2430. minR = 0;
  2431. if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2432. maxR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2433. else
  2434. maxR = 255;
  2435. }
  2436. this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
  2437. this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
  2438. this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
  2439. this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
  2440. this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
  2441. this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
  2442. xn = x;
  2443. yn = y;
  2444. //对于存在视场,不存在进行不同操作
  2445. if (existViewFlag)
  2446. {
  2447. ImageActionWithViewForDelete();
  2448. }
  2449. else
  2450. {
  2451. ImageActionNoViewForDelete();
  2452. }
  2453. if (this.radioButton4.Checked)
  2454. {
  2455. this.SetPhaseModelRGBOrHLS();
  2456. }
  2457. else if (this.radioButton3.Checked)
  2458. {
  2459. this.AddDictStepByClick();
  2460. }
  2461. this.UpdateHistogramStartAndEnd();
  2462. }
  2463. }
  2464. else
  2465. {
  2466. //当前相颜色
  2467. Color currentColor = Color.FromArgb(color);
  2468. b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
  2469. //如果存在视场 需要判断是否在视场内
  2470. if (existViewFlag)
  2471. {
  2472. if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
  2473. {
  2474. return;
  2475. }
  2476. /*else
  2477. {
  2478. Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
  2479. mat = PaintDotNet.Camera.Tools.ToMat(bitmap);
  2480. }*/
  2481. }
  2482. //获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
  2483. //vec3b = mat.At<Vec3b>(y, x);
  2484. //容许值
  2485. tolerance = (int)this.userTextBox2.Value;
  2486. //范围大小
  2487. int range = (int)this.userTextBox1.Value;
  2488. //对每个像素点的操作
  2489. byte* pixels = (byte*)mat.Data;
  2490. //循环范围大小内的所有点
  2491. maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
  2492. int y1 = (y - range) < 0 ? 0 : (y - range);
  2493. int x1 = (x - range) < 0 ? 0 : (x - range);
  2494. int hw = range * 2 + 1;
  2495. int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
  2496. int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
  2497. for (int m = y1; m < nh; m++)
  2498. {
  2499. int offsetRow = m * this.documentWorkspace.CompositionSurface.Width;
  2500. for (int n = x1; n < nw; n++)
  2501. {
  2502. int offset = (offsetRow + n) * this.mat.Channels();
  2503. byte vB = pixels[offset];
  2504. byte vG = pixels[offset + 1];
  2505. byte vR = pixels[offset + 2];
  2506. if (vB > maxB) maxB = vB;
  2507. if (vB < minB) minB = vB;
  2508. if (vG > maxG) maxG = vG;
  2509. if (vG < minG) minG = vG;
  2510. if (vR > maxR) maxR = vR;
  2511. if (vR < minR) minR = vR;
  2512. }
  2513. }
  2514. if (tolerance > 0)
  2515. {
  2516. if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2517. minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2518. else
  2519. minB = 0;
  2520. if (255 - maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2521. maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2522. else
  2523. maxB = 255;
  2524. if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2525. minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2526. else
  2527. minG = 0;
  2528. if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2529. maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2530. else
  2531. maxG = 255;
  2532. if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2533. minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2534. else
  2535. minR = 0;
  2536. if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
  2537. maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
  2538. else
  2539. maxR = 255;
  2540. }
  2541. xn = x;
  2542. yn = y;
  2543. //对于存在视场,不存在进行不同操作
  2544. if (existViewFlag)
  2545. {
  2546. ImageActionWithView();
  2547. }
  2548. else
  2549. {
  2550. ImageActionNoView();
  2551. }
  2552. if (this.radioButton4.Checked)
  2553. {
  2554. this.SetPhaseModelRGBOrHLS();
  2555. }
  2556. else if (this.radioButton3.Checked)
  2557. {
  2558. this.AddDictStepByClick();
  2559. }
  2560. this.UpdateHistogramStartAndEnd();
  2561. }
  2562. }
  2563. }
  2564. catch (Exception e1)
  2565. {
  2566. System.Console.WriteLine(e1.ToString());
  2567. }
  2568. finally
  2569. {
  2570. if (mat1 != null && mat1.IsDisposed) mat1.Dispose();
  2571. }
  2572. }
  2573. private unsafe void DelForEachAsVec3b(Vec3b* value, int* position)
  2574. {
  2575. if (value->Item0 == 0 && value->Item1 == 0 && value->Item2 == 0)
  2576. {
  2577. this.model.mat.Set<Vec4b>(position[0], position[1], new Vec4b(0, 0, 0, 0));
  2578. }
  2579. }
  2580. bool _working = false;
  2581. //鼠标按下时间
  2582. private DateTime _timeMD = DateTime.MaxValue;
  2583. /// <summary>
  2584. /// 有视场的图像处理
  2585. /// </summary>
  2586. private void ImageActionWithView()
  2587. {
  2588. if ((DateTime.Now - _timeMD).TotalMilliseconds > 150)
  2589. return;
  2590. if (_working) return;
  2591. _working = true;
  2592. //如果是整个图像
  2593. if (this.radioButton4.Checked && !this.doOrRedo)
  2594. this.CalcRGBOrHLSValue();
  2595. TransferProgressDialog.ShowDialog(
  2596. "物相提取", "正在进行物相提取,该过程可能执行较长时间请耐心等待......",
  2597. () =>
  2598. {
  2599. ImageActionWithView1();
  2600. _working = false;
  2601. });
  2602. }
  2603. private void ImageActionWithView1()
  2604. {
  2605. if (model == null)
  2606. {
  2607. MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
  2608. return;
  2609. }
  2610. //如果是整个图像
  2611. if (this.radioButton4.Checked)
  2612. {
  2613. //获取颜色区间
  2614. _mouseClick = true;
  2615. if (radioButton12.Checked) //hls
  2616. {
  2617. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
  2618. this.imageMat.Clone(),
  2619. model, new System.Drawing.Point());
  2620. }
  2621. else
  2622. {
  2623. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
  2624. }
  2625. _mouseClick = false;
  2626. }
  2627. //如果是单个目标,参考单个提取
  2628. else if (this.radioButton3.Checked)
  2629. {
  2630. if (radioButton12.Checked) //hls
  2631. {
  2632. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
  2633. this.imageMat.Clone(),
  2634. model, new System.Drawing.Point(xn, yn));
  2635. }
  2636. else
  2637. {
  2638. mat1 = this.action.PerformProcess(mat, imageMat.Clone(), model, new System.Drawing.Point(xn, yn));
  2639. }
  2640. }
  2641. this.Invoke(new Action(() =>
  2642. {
  2643. Mat temp = new Mat();
  2644. mat1.CopyTo(temp);
  2645. model.mat = temp;
  2646. this.documentWorkspace.Refresh();
  2647. firstFlag = true;
  2648. }));
  2649. }
  2650. /// <summary>
  2651. /// 无视场的图像处理
  2652. /// </summary>
  2653. private void ImageActionNoView()
  2654. {
  2655. if (model == null)
  2656. {
  2657. MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
  2658. return;
  2659. }
  2660. //如果是整个图像
  2661. if (this.radioButton4.Checked)
  2662. {
  2663. //获取颜色区间
  2664. _mouseClick = true;
  2665. if (!this.doOrRedo)
  2666. this.CalcRGBOrHLSValue();
  2667. mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
  2668. _mouseClick = false;
  2669. }
  2670. //如果是单个目标,参考单个提取
  2671. else if (this.radioButton3.Checked)
  2672. {
  2673. mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
  2674. }
  2675. Mat temp = new Mat();
  2676. mat1.CopyTo(temp);
  2677. model.mat = temp;
  2678. this.documentWorkspace.Refresh();
  2679. firstFlag = true;
  2680. }
  2681. private void ImageActionWithViewForDelete()
  2682. {
  2683. if (model == null)
  2684. {
  2685. MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
  2686. return;
  2687. }
  2688. //如果是整个图像
  2689. if (this.radioButton4.Checked)
  2690. {
  2691. //获取颜色区间
  2692. _mouseClick = true;
  2693. if (!this.doOrRedo)
  2694. //this.CalcRGBOrHLSValue();
  2695. if (radioButton12.Checked) //hls
  2696. {
  2697. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
  2698. this.imageMat.Clone(),
  2699. model, new System.Drawing.Point());
  2700. }
  2701. else
  2702. {
  2703. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
  2704. }
  2705. _mouseClick = false;
  2706. }
  2707. //如果是单个目标,参考单个提取
  2708. else if (this.radioButton3.Checked)
  2709. {
  2710. if (radioButton12.Checked) //hls
  2711. {
  2712. mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
  2713. this.imageMat.Clone(),
  2714. model, new System.Drawing.Point(xn, yn));
  2715. }
  2716. else
  2717. {
  2718. mat1 = this.action.PerformProcess(mat, imageMat.Clone(), model, new System.Drawing.Point(xn, yn));
  2719. }
  2720. }
  2721. Mat temp = new Mat();
  2722. mat1.CopyTo(temp);
  2723. model.mat = temp;
  2724. this.documentWorkspace.Refresh();
  2725. firstFlag = true;
  2726. }
  2727. private void ImageActionNoViewForDelete()
  2728. {
  2729. if (model == null)
  2730. {
  2731. MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
  2732. return;
  2733. }
  2734. //如果是整个图像
  2735. if (this.radioButton4.Checked)
  2736. {
  2737. //获取颜色区间
  2738. _mouseClick = true;
  2739. if (!this.doOrRedo)
  2740. //this.CalcRGBOrHLSValueForDelete();
  2741. mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
  2742. _mouseClick = false;
  2743. }
  2744. //如果是单个目标,参考单个提取
  2745. else if (this.radioButton3.Checked)
  2746. {
  2747. mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
  2748. }
  2749. Mat temp = new Mat();
  2750. mat1.CopyTo(temp);
  2751. model.mat = temp;
  2752. this.documentWorkspace.Refresh();
  2753. firstFlag = true;
  2754. }
  2755. /// <summary>
  2756. /// 鼠标进入pictureBox
  2757. /// </summary>
  2758. /// <param name="sender"></param>
  2759. /// <param name="e"></param>
  2760. private void pictureBox1_MouseEnter(object sender, EventArgs e)
  2761. {
  2762. this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
  2763. }
  2764. private void pictureBox1_MouseLeave(object sender, EventArgs e)
  2765. {
  2766. this.Cursor = Cursors.Default;
  2767. }
  2768. private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
  2769. {
  2770. ox = e.X;
  2771. oy = e.Y;
  2772. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(new System.Drawing.Point(e.X, e.Y));
  2773. y = point.Y;
  2774. x = point.X;
  2775. this.documentWorkspace.Refresh();
  2776. }
  2777. /// <summary>
  2778. /// 更新相
  2779. /// </summary>
  2780. /// <param name="name"></param>
  2781. /// <param name="color"></param>
  2782. public void UpdatePhase(string name, int color)
  2783. {
  2784. this.model.name = name;
  2785. this.model.color = color;
  2786. Color currentColor = Color.FromArgb(color);
  2787. this.b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
  2788. this.panel2.BackColor = currentColor;
  2789. //如果是整个图像
  2790. if (this.radioButton4.Checked)
  2791. {
  2792. this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
  2793. }
  2794. else
  2795. {
  2796. this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(x, y));
  2797. }
  2798. Mat temp = new Mat();
  2799. this.mat1.CopyTo(temp);
  2800. this.model.mat = temp;
  2801. this.documentWorkspace.Refresh();
  2802. }
  2803. /// <summary>
  2804. /// 新增相
  2805. /// </summary>
  2806. /// <param name="name"></param>
  2807. /// <param name="color"></param>
  2808. public void AddPhase(string name, int color)
  2809. {
  2810. //设置之前的相都不绘制
  2811. if (!this.checkBox5.Checked)
  2812. {
  2813. for (int i = 0; i < this.documentWorkspace.PhaseModels.Count; i++)
  2814. {
  2815. this.documentWorkspace.PhaseModels[i].choise = false;
  2816. }
  2817. this.documentWorkspace.Refresh();
  2818. }
  2819. //标记初始化
  2820. this.firstFlag = false;
  2821. //创建并添加相
  2822. this.model = new PhaseModel();
  2823. this.model.choise = true;
  2824. this.model.mat = null;
  2825. this.model.color = color;
  2826. this.model.position = this.documentWorkspace.PhaseModels.Count + 1;
  2827. this.model.name = name;
  2828. this.documentWorkspace.PhaseModels.Add(model);
  2829. this.color = color;
  2830. this.panel2.BackColor = Color.FromArgb(color);
  2831. this.countPhase++;
  2832. this.currentPhase = this.countPhase;
  2833. this.label1.Text = this.countPhase + "/" + this.countPhase;
  2834. //处理rgb/hls界面
  2835. this.radioButton13.Checked = true;
  2836. this.numericUpDown4.Value = 0;
  2837. this.numericUpDown3.Value = 0;
  2838. this.numericUpDown6.Value = 0;
  2839. this.numericUpDown5.Value = 0;
  2840. this.numericUpDown8.Value = 0;
  2841. this.numericUpDown7.Value = 0;
  2842. //添加到步骤
  2843. MultiPhaseStepModel temp = new MultiPhaseStepModel();
  2844. temp.currentPhase = this.currentPhase;
  2845. this.steps.Add(temp);
  2846. this.currentPosition++;
  2847. }
  2848. /// <summary>
  2849. /// 撤销
  2850. /// </summary>
  2851. /// <param name="sender"></param>
  2852. /// <param name="e"></param>
  2853. private void button12_Click(object sender, EventArgs e)
  2854. {
  2855. if (this.currentPosition <= 0)
  2856. return;
  2857. this.doOrRedo = true;
  2858. this.currentPosition--;
  2859. MultiPhaseStepModel temp = this.steps[this.currentPosition];
  2860. //判断相是否变化,相变化则进行切换
  2861. if (temp.currentPhase != this.currentPhase)
  2862. {
  2863. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
  2864. this.currentPhase = temp.currentPhase;
  2865. this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
  2866. this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
  2867. this.documentWorkspace.Refresh();
  2868. this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
  2869. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  2870. if (this.radioButton4.Checked)
  2871. this.SetRGBOrHLSNumericValue();
  2872. }
  2873. else
  2874. {
  2875. this.model.rgborhls = temp.rgborhls;
  2876. this.model.minR = temp.minR;
  2877. this.model.maxR = temp.maxR;
  2878. this.model.minG = temp.minG;
  2879. this.model.maxG = temp.maxG;
  2880. this.model.minB = temp.minB;
  2881. this.model.maxB = temp.maxB;
  2882. this.model.minH = temp.minH;
  2883. this.model.maxH = temp.maxH;
  2884. this.model.minL = temp.minL;
  2885. this.model.maxL = temp.maxL;
  2886. this.model.minS = temp.minS;
  2887. this.model.maxS = temp.maxS;
  2888. if (this.radioButton4.Checked)
  2889. this.SetRGBOrHLSNumericValue();
  2890. }
  2891. this.applyButtonImpl(null, null);
  2892. this.doOrRedo = false;
  2893. }
  2894. /// <summary>
  2895. /// 重做
  2896. /// </summary>
  2897. /// <param name="sender"></param>
  2898. /// <param name="e"></param>
  2899. private void button11_Click(object sender, EventArgs e)
  2900. {
  2901. if (this.currentPosition >= this.steps.Count - 1)
  2902. return;
  2903. this.doOrRedo = true;
  2904. this.currentPosition++;
  2905. MultiPhaseStepModel temp = this.steps[this.currentPosition];
  2906. //判断相是否变化,相变化则进行切换
  2907. if (temp.currentPhase != this.currentPhase)
  2908. {
  2909. this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = false;
  2910. this.currentPhase = temp.currentPhase;
  2911. this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = true;
  2912. this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
  2913. this.documentWorkspace.Refresh();
  2914. this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
  2915. this.label1.Text = this.currentPhase + "/" + this.countPhase;
  2916. if (this.radioButton4.Checked)
  2917. this.SetRGBOrHLSNumericValue();
  2918. }
  2919. else
  2920. {
  2921. this.model.rgborhls = temp.rgborhls;
  2922. this.model.minR = temp.minR;
  2923. this.model.maxR = temp.maxR;
  2924. this.model.minG = temp.minG;
  2925. this.model.maxG = temp.maxG;
  2926. this.model.minB = temp.minB;
  2927. this.model.maxB = temp.maxB;
  2928. this.model.minH = temp.minH;
  2929. this.model.maxH = temp.maxH;
  2930. this.model.minL = temp.minL;
  2931. this.model.maxL = temp.maxL;
  2932. this.model.minS = temp.minS;
  2933. this.model.maxS = temp.maxS;
  2934. if (this.radioButton4.Checked)
  2935. this.SetRGBOrHLSNumericValue();
  2936. }
  2937. this.applyButtonImpl(null, null);
  2938. this.doOrRedo = false;
  2939. }
  2940. /// <summary>
  2941. /// 重置
  2942. /// </summary>
  2943. /// <param name="sender"></param>
  2944. /// <param name="e"></param>
  2945. private void button8_Click(object sender, EventArgs e)
  2946. {
  2947. if (this.documentWorkspace.PhaseModels != null
  2948. && this.currentPhase > 0)
  2949. {
  2950. this.documentWorkspace.PhaseModels[this.currentPhase - 1].mat = null;
  2951. this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
  2952. this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
  2953. this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
  2954. this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
  2955. this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
  2956. this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
  2957. this.numericUpDown8.Value = 0;
  2958. this.numericUpDown7.Value = 0;
  2959. this.numericUpDown6.Value = 0;
  2960. this.numericUpDown5.Value = 0;
  2961. this.numericUpDown4.Value = 0;
  2962. this.numericUpDown3.Value = 0;
  2963. //this.numericUpDown9.Value = 0;
  2964. this.maxB = 0;
  2965. this.minB = 255;
  2966. this.maxG = 0;
  2967. this.minG = 255;
  2968. this.maxR = 0;
  2969. this.minR = 255;
  2970. this.firstFlag = false;
  2971. this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
  2972. this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
  2973. this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
  2974. this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
  2975. this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
  2976. this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
  2977. this.documentWorkspace.Refresh();
  2978. }
  2979. //清空所有步骤
  2980. this.steps.Clear();
  2981. //设置当前步骤为-1
  2982. this.currentPosition = -1;
  2983. }
  2984. /// <summary>
  2985. /// 删除边界对象
  2986. /// </summary>
  2987. /// <param name="sender"></param>
  2988. /// <param name="e"></param>
  2989. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  2990. {
  2991. BooleanObject choiseArray = (BooleanObject)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("deleteRect"));
  2992. choiseArray.Value = this.checkBox2.Checked;
  2993. this.applyButtonImpl(sender, e);
  2994. }
  2995. /// <summary>
  2996. /// 孔洞填充
  2997. /// </summary>
  2998. /// <param name="sender"></param>
  2999. /// <param name="e"></param>
  3000. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  3001. {
  3002. action.Lists[0].choiseList[0].lists[4].Value = this.checkBox3.Checked;
  3003. this.applyButtonImpl(sender, e);
  3004. }
  3005. /// <summary>
  3006. /// 碎屑删除
  3007. /// </summary>
  3008. /// <param name="sender"></param>
  3009. /// <param name="e"></param>
  3010. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  3011. {
  3012. action.Lists[0].choiseList[0].lists[5].Value = this.checkBox4.Checked;
  3013. this.applyButtonImpl(sender, e);
  3014. }
  3015. /// <summary>
  3016. /// 单个目标->偏差
  3017. /// </summary>
  3018. /// <param name="sender"></param>
  3019. /// <param name="e"></param>
  3020. private void numericUpDown9_ValueChanged(object sender, EventArgs e)
  3021. {
  3022. this.action.Lists[0].choiseList[1].Lists[0].Value = this.numericUpDown9.Value;
  3023. this.trackBar1.Value = (int)(this.numericUpDown9.Value);
  3024. }
  3025. /// <summary>
  3026. /// 单个目标->偏差
  3027. /// </summary>
  3028. /// <param name="sender"></param>
  3029. /// <param name="e"></param>
  3030. private void trackBar1_ValueChanged(object sender, EventArgs e)
  3031. {
  3032. this.numericUpDown9.Value = this.trackBar1.Value;
  3033. this.action.Lists[0].choiseList[1].Lists[0].Value = this.trackBar1.Value;
  3034. //this.applyButtonImpl(sender, e);
  3035. }
  3036. /// <summary>
  3037. /// 定义物体 - 轮廓
  3038. /// </summary>
  3039. /// <param name="sender"></param>
  3040. /// <param name="e"></param>
  3041. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  3042. {
  3043. if (this.radioButton5.Checked)
  3044. {
  3045. ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
  3046. BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
  3047. booleanObject1.Value = true;
  3048. BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
  3049. booleanObject0.Value = false;
  3050. this.panel1.Visible = true;
  3051. this.radioButton14_CheckedChanged(null, null);
  3052. }
  3053. }
  3054. /// <summary>
  3055. /// RGB/HLS的Button的R/H点击事件
  3056. /// </summary>
  3057. /// <param name="sender"></param>
  3058. /// <param name="e"></param>
  3059. private void button13_Click(object sender, EventArgs e)
  3060. {
  3061. this.HistogramRGBSelect = 1;
  3062. this.button13.FlatStyle = FlatStyle.Flat;
  3063. this.button13.BackColor = Color.FromArgb(225, 225, 225);
  3064. this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
  3065. this.button13.FlatAppearance.BorderSize = 1;
  3066. this.button14.FlatStyle = FlatStyle.Standard;
  3067. this.button14.BackColor = Control.DefaultBackColor;
  3068. this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3069. this.button15.FlatStyle = FlatStyle.Standard;
  3070. this.button15.BackColor = Control.DefaultBackColor;
  3071. this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3072. //处理直方图
  3073. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
  3074. }
  3075. /// <summary>
  3076. /// RGB/HLS的Button的G/L点击事件
  3077. /// </summary>
  3078. /// <param name="sender"></param>
  3079. /// <param name="e"></param>
  3080. private void button14_Click(object sender, EventArgs e)
  3081. {
  3082. this.HistogramRGBSelect = 2;
  3083. this.button13.FlatStyle = FlatStyle.Standard;
  3084. this.button13.BackColor = Control.DefaultBackColor;
  3085. this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3086. this.button14.FlatStyle = FlatStyle.Flat;
  3087. this.button14.BackColor = Color.FromArgb(225, 225, 225);
  3088. this.button14.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
  3089. this.button14.FlatAppearance.BorderSize = 1;
  3090. this.button15.FlatStyle = FlatStyle.Standard;
  3091. this.button15.BackColor = Control.DefaultBackColor;
  3092. this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3093. //处理直方图
  3094. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
  3095. //this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
  3096. }
  3097. /// <summary>
  3098. /// RGB/HLS的Button的B/S点击事件
  3099. /// </summary>
  3100. /// <param name="sender"></param>
  3101. /// <param name="e"></param>
  3102. private void button15_Click(object sender, EventArgs e)
  3103. {
  3104. this.HistogramRGBSelect = 3;
  3105. this.button13.FlatStyle = FlatStyle.Standard;
  3106. this.button13.BackColor = Control.DefaultBackColor;
  3107. this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3108. this.button14.FlatStyle = FlatStyle.Standard;
  3109. this.button14.BackColor = Control.DefaultBackColor;
  3110. this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
  3111. this.button15.FlatStyle = FlatStyle.Flat;
  3112. this.button15.BackColor = Color.FromArgb(225, 225, 225);
  3113. this.button15.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
  3114. this.button15.FlatAppearance.BorderSize = 1;
  3115. //处理直方图
  3116. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
  3117. //this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
  3118. }
  3119. /// <summary>
  3120. /// 定义物体 - 点击
  3121. /// </summary>
  3122. /// <param name="sender"></param>
  3123. /// <param name="e"></param>
  3124. private void radioButton6_CheckedChanged(object sender, EventArgs e)
  3125. {
  3126. if (this.radioButton6.Checked)
  3127. {
  3128. ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
  3129. BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
  3130. booleanObject1.Value = false;
  3131. BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
  3132. booleanObject0.Value = true;
  3133. this.panel1.Visible = false;
  3134. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  3135. }
  3136. }
  3137. /// <summary>
  3138. /// 移除未完成的定义物体的轮廓的对象
  3139. /// </summary>
  3140. /// <param name="sender"></param>
  3141. /// <param name="e"></param>
  3142. private void PhaseExtractDialog_FormClosing(object sender, FormClosingEventArgs e)
  3143. {
  3144. this.documentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.PhaseExtraction);
  3145. SaveDialogParam();
  3146. }
  3147. /// <summary>
  3148. /// 定义物体 - 轮廓 - 多边形
  3149. /// </summary>
  3150. /// <param name="sender"></param>
  3151. /// <param name="e"></param>
  3152. private void radioButton14_CheckedChanged(object sender, EventArgs e)
  3153. {
  3154. if (this.radioButton5.Checked && this.radioButton14.Checked)
  3155. {
  3156. ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
  3157. StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
  3158. choiseArray1.Value = ContourParameters.Polygon;
  3159. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhasePolygon;
  3160. }
  3161. }
  3162. /// <summary>
  3163. /// 定义物体 - 轮廓 - 矩形
  3164. /// </summary>
  3165. /// <param name="sender"></param>
  3166. /// <param name="e"></param>
  3167. private void radioButton15_CheckedChanged(object sender, EventArgs e)
  3168. {
  3169. if (this.radioButton5.Checked && this.radioButton15.Checked)
  3170. {
  3171. ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
  3172. StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
  3173. choiseArray1.Value = ContourParameters.Rectangle;
  3174. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhaseRectangle;
  3175. }
  3176. }
  3177. /// <summary>
  3178. /// 定义物体 - 轮廓 - 椭圆
  3179. /// </summary>
  3180. /// <param name="sender"></param>
  3181. /// <param name="e"></param>
  3182. private void radioButton16_CheckedChanged(object sender, EventArgs e)
  3183. {
  3184. if (this.radioButton5.Checked && this.radioButton16.Checked)
  3185. {
  3186. ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
  3187. StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
  3188. choiseArray1.Value = ContourParameters.Oval;
  3189. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhaseOval;
  3190. }
  3191. }
  3192. /// <summary>
  3193. /// RGB或HLS值变化
  3194. /// </summary>
  3195. /// <param name="sender"></param>
  3196. /// <param name="e"></param>
  3197. private void RGBoRHLSValue_Changed(object sender, EventArgs e)
  3198. {
  3199. if (!_mouseClick)
  3200. {
  3201. if (color == 0)
  3202. {
  3203. return;
  3204. }
  3205. if (mat == null)
  3206. {
  3207. return;
  3208. }
  3209. //处理直方图相关
  3210. this.UpdateHistogramStartAndEnd();
  3211. //修改当前model的rgb或hls
  3212. this.SetPhaseModelRGBOrHLS((NumericUpDown)sender);
  3213. this.applyButtonImpl(null, null);
  3214. /*mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
  3215. Mat temp = new Mat();
  3216. mat1.CopyTo(temp);
  3217. model.mat = temp;
  3218. this.documentWorkspace.Refresh();*/
  3219. }
  3220. }
  3221. /// <summary>
  3222. /// 修改当前model的rgb或hls
  3223. /// </summary>
  3224. private void SetPhaseModelRGBOrHLS(NumericUpDown numericUpDown = null)
  3225. {
  3226. if (this.model == null)
  3227. return;
  3228. if (this.radioButton13.Checked)
  3229. {
  3230. //修改当前model的值
  3231. this.model.minB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
  3232. this.model.maxB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
  3233. this.model.minG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
  3234. this.model.maxG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
  3235. this.model.minR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
  3236. this.model.maxR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
  3237. this.AddDictStep(1);
  3238. }
  3239. else if (this.radioButton12.Checked)
  3240. {
  3241. //修改当前model的值
  3242. this.model.minH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
  3243. this.model.maxH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
  3244. this.model.minL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
  3245. this.model.maxL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
  3246. this.model.minS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
  3247. this.model.maxS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
  3248. this.AddDictStep(2);
  3249. }
  3250. }
  3251. private void AddDictStepByClick()
  3252. {
  3253. MultiPhaseStepModel temp = new MultiPhaseStepModel();
  3254. temp.currentPhase = currentPhase;
  3255. temp.wholeorsingle = 2;
  3256. temp.point = new System.Drawing.Point(xn, yn);
  3257. this.steps.Add(temp);
  3258. this.currentPosition++;
  3259. }
  3260. /// <summary>
  3261. /// 向字典内添加步骤
  3262. /// </summary>
  3263. /// <param name="type"></param>
  3264. private void AddDictStep(int type)
  3265. {
  3266. if (this.doOrRedo)
  3267. return;
  3268. MultiPhaseStepModel temp = new MultiPhaseStepModel();
  3269. temp.currentPhase = currentPhase;
  3270. temp.rgborhls = type;
  3271. if (temp.rgborhls == 1)
  3272. {
  3273. temp.minR = this.model.minR;
  3274. temp.maxR = this.model.maxR;
  3275. temp.minG = this.model.minG;
  3276. temp.maxG = this.model.maxG;
  3277. temp.minB = this.model.minB;
  3278. temp.maxB = this.model.maxB;
  3279. }
  3280. else if (temp.rgborhls == 2)
  3281. {
  3282. temp.minH = this.model.minH;
  3283. temp.maxH = this.model.maxH;
  3284. temp.minL = this.model.minL;
  3285. temp.maxL = this.model.maxL;
  3286. temp.minS = this.model.minS;
  3287. temp.maxS = this.model.maxS;
  3288. }
  3289. this.steps.Add(temp);
  3290. this.currentPosition++;
  3291. }
  3292. /// <summary>
  3293. /// 显示全部
  3294. /// </summary>
  3295. /// <param name="sender"></param>
  3296. /// <param name="e"></param>
  3297. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  3298. {
  3299. if (this.checkBox5.Checked)
  3300. {
  3301. foreach (PhaseModel model in this.documentWorkspace.PhaseModels)
  3302. {
  3303. model.choise = true;
  3304. }
  3305. this.documentWorkspace.Refresh();
  3306. }
  3307. else
  3308. {
  3309. foreach (PhaseModel model in this.documentWorkspace.PhaseModels)
  3310. {
  3311. model.choise = false;
  3312. }
  3313. this.model.choise = true;
  3314. this.documentWorkspace.Refresh();
  3315. }
  3316. }
  3317. private void UpdateHistogramStartAndEnd()
  3318. {
  3319. if (this.HistogramRGBSelect == 1)
  3320. {
  3321. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
  3322. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
  3323. }
  3324. if (this.HistogramRGBSelect == 2)
  3325. {
  3326. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
  3327. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
  3328. }
  3329. if (this.HistogramRGBSelect == 3)
  3330. {
  3331. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
  3332. this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
  3333. }
  3334. }
  3335. /// <summary>
  3336. /// 鼠标点击的时候调用
  3337. /// </summary>
  3338. private void CalcRGBOrHLSValue()
  3339. {
  3340. int rl = (int)this.numericUpDown4.Value; //r起
  3341. int rr = (int)this.numericUpDown3.Value; //r止
  3342. if (firstFlag)
  3343. {
  3344. this.numericUpDown4.Value = minR < rl ? minR : rl;
  3345. this.numericUpDown3.Value = rr > maxR ? rr : maxR;
  3346. }
  3347. else
  3348. {
  3349. this.numericUpDown4.Value = minR;
  3350. this.numericUpDown3.Value = maxR;
  3351. }
  3352. int gl = (int)this.numericUpDown6.Value; //g起
  3353. int gr = (int)this.numericUpDown5.Value; //g止
  3354. if (firstFlag)
  3355. {
  3356. this.numericUpDown6.Value = minG < gl ? minG : gl;
  3357. this.numericUpDown5.Value = gr > maxG ? gr : maxG;
  3358. }
  3359. else
  3360. {
  3361. this.numericUpDown6.Value = minG;
  3362. this.numericUpDown5.Value = maxG;
  3363. }
  3364. int bl = (int)this.numericUpDown8.Value; //b起
  3365. int br = (int)this.numericUpDown7.Value; //b止
  3366. if (firstFlag)
  3367. {
  3368. this.numericUpDown8.Value = minB < bl ? minB : bl;
  3369. this.numericUpDown7.Value = br > maxB ? br : maxB;
  3370. }
  3371. else
  3372. {
  3373. this.numericUpDown8.Value = minB;
  3374. this.numericUpDown7.Value = maxB;
  3375. }
  3376. }
  3377. private void CalcRGBOrHLSValueForDelete()
  3378. {
  3379. int rl = (int)this.numericUpDown4.Value; //r起
  3380. int rr = (int)this.numericUpDown3.Value; //r止
  3381. if (firstFlag)
  3382. {
  3383. this.numericUpDown4.Value = minR > rl ? minR : rl;
  3384. this.numericUpDown3.Value = rr < maxR ? rr : maxR;
  3385. }
  3386. else
  3387. {
  3388. this.numericUpDown4.Value = minR;
  3389. this.numericUpDown3.Value = maxR;
  3390. }
  3391. int gl = (int)this.numericUpDown6.Value; //g起
  3392. int gr = (int)this.numericUpDown5.Value; //g止
  3393. if (firstFlag)
  3394. {
  3395. this.numericUpDown6.Value = minG > gl ? minG : gl;
  3396. this.numericUpDown5.Value = gr < maxG ? gr : maxG;
  3397. }
  3398. else
  3399. {
  3400. this.numericUpDown6.Value = minG;
  3401. this.numericUpDown5.Value = maxG;
  3402. }
  3403. int bl = (int)this.numericUpDown8.Value; //b起
  3404. int br = (int)this.numericUpDown7.Value; //b止
  3405. if (firstFlag)
  3406. {
  3407. this.numericUpDown8.Value = minB > bl ? minB : bl;
  3408. this.numericUpDown7.Value = br < maxB ? br : maxB;
  3409. }
  3410. else
  3411. {
  3412. this.numericUpDown8.Value = minB;
  3413. this.numericUpDown7.Value = maxB;
  3414. }
  3415. }
  3416. /// <summary>
  3417. /// 删除
  3418. /// </summary>
  3419. /// <param name="sender"></param>
  3420. /// <param name="e"></param>
  3421. private void radioButton10_CheckedChanged(object sender, EventArgs e)
  3422. {
  3423. if (this.radioButton10.Checked)
  3424. {
  3425. this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Delete;
  3426. }
  3427. }
  3428. /// <summary>
  3429. /// 追加
  3430. /// </summary>
  3431. /// <param name="sender"></param>
  3432. /// <param name="e"></param>
  3433. private void radioButton11_CheckedChanged(object sender, EventArgs e)
  3434. {
  3435. if (this.radioButton11.Checked)
  3436. {
  3437. this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Add;
  3438. }
  3439. }
  3440. /// <summary>
  3441. /// 目标选择
  3442. /// </summary>
  3443. /// <param name="sender"></param>
  3444. /// <param name="e"></param>
  3445. private void objectSelect_CheckChanged(object sender, EventArgs e)
  3446. {
  3447. if (this.radioButton8.Checked)
  3448. {
  3449. StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
  3450. choiseArray.Value = FieldOfViewParameters.One;
  3451. }
  3452. else if (this.radioButton7.Checked)
  3453. {
  3454. StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
  3455. choiseArray.Value = FieldOfViewParameters.Two;
  3456. }
  3457. else if (this.radioButton9.Checked)
  3458. {
  3459. StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
  3460. choiseArray.Value = FieldOfViewParameters.Three;
  3461. }
  3462. this.applyButtonImpl(sender, e);
  3463. }
  3464. /// <summary>
  3465. /// 碎屑删除 范围参数1
  3466. /// </summary>
  3467. /// <param name="sender"></param>
  3468. /// <param name="e"></param>
  3469. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  3470. {
  3471. numericUpDown2.Value = Math.Max(numericUpDown2.Value, numericUpDown1.Value);
  3472. //参数改变
  3473. foreach (Args args in action.Lists)
  3474. {
  3475. if (args.Key == "scope4")
  3476. {
  3477. ((List<double>)args.Value)[0] = (double)numericUpDown1.Value;
  3478. ((List<double>)args.Value)[1] = (double)numericUpDown2.Value;
  3479. break;
  3480. }
  3481. }
  3482. }
  3483. /// <summary>
  3484. /// 碎屑删除 范围参数2
  3485. /// </summary>
  3486. /// <param name="sender"></param>
  3487. /// <param name="e"></param>
  3488. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  3489. {
  3490. numericUpDown1.Value = Math.Min(numericUpDown1.Value, numericUpDown2.Value);
  3491. //参数改变
  3492. foreach (Args args in action.Lists)
  3493. {
  3494. if (args.Key == "scope4")
  3495. {
  3496. ((List<double>)args.Value)[0] = (double)numericUpDown1.Value;
  3497. ((List<double>)args.Value)[1] = (double)numericUpDown2.Value;
  3498. break;
  3499. }
  3500. }
  3501. }
  3502. #region 参数保存及提取
  3503. /// <summary>
  3504. /// 保存参数的key,value和type
  3505. /// </summary>
  3506. /// <param name="param_key"></param>
  3507. /// <param name="param_value"></param>
  3508. /// <param name="param_type"></param>
  3509. private void saveParamValue(string param_key, string param_value, int param_type)
  3510. {
  3511. bool foundItem = false;
  3512. foreach (var item in this.analysisModel.ListParam)
  3513. {
  3514. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  3515. {
  3516. item.param_value = param_value;
  3517. item.setValue();
  3518. foundItem = true;
  3519. break;
  3520. }
  3521. }
  3522. if (!foundItem)
  3523. {
  3524. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  3525. analysisItem.menuId = this.menuId;
  3526. analysisItem.param_key = param_key;
  3527. analysisItem.param_type = param_type;
  3528. analysisItem.param_value = param_value;
  3529. analysisItem.setValue();
  3530. this.analysisModel.ListParam.Add(analysisItem);
  3531. }
  3532. }
  3533. /// <summary>
  3534. /// 保存界面中的参数到model
  3535. /// </summary>
  3536. private void saveDialogParamValues()
  3537. {
  3538. saveParamValue(ParamKey_ShowAll, this.checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示全部
  3539. saveParamValue(ParamKey_NewPic, this.checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//创建新图
  3540. saveParamValue(ParamKey_WholePic, this.radioButton4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
  3541. saveParamValue(ParamKey_Click, this.radioButton6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
  3542. saveParamValue(ParamKey_CkValue, this.userTextBox2.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标
  3543. saveParamValue(ParamKey_CkRange, this.userTextBox1.Value.ToString(), (int)Base.Dtryt.Decimal);//整个图像
  3544. saveParamValue(ParamKey_Outline, this.radioButton5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//轮廓
  3545. saveParamValue(ParamKey_OPolygon, this.radioButton14.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//多边形
  3546. saveParamValue(ParamKey_ORectangle, this.radioButton15.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//矩形
  3547. saveParamValue(ParamKey_OEllipse, this.radioButton16.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//椭圆
  3548. saveParamValue(ParamKey_Solid, this.radioButton1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值实心
  3549. saveParamValue(ParamKey_Outer, this.radioButton2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值边线
  3550. saveParamValue(ParamKey_Target1, this.radioButton8.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择1
  3551. saveParamValue(ParamKey_Target2, this.radioButton7.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择2
  3552. saveParamValue(ParamKey_Target3, this.radioButton9.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择3
  3553. saveParamValue(ParamKey_Boundary, this.checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-删除边界对象
  3554. saveParamValue(ParamKey_Holes, this.checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-孔洞填充
  3555. saveParamValue(ParamKey_Detritus, this.checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-碎屑删除
  3556. saveParamValue(ParamKey_Single, this.radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//单个目标
  3557. saveParamValue(ParamKey_SDeviation, this.numericUpDown9.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标-偏差
  3558. }
  3559. /// <summary>
  3560. /// 获取保存的参数
  3561. /// </summary>
  3562. private void GetListParamModel()
  3563. {
  3564. if (this.analysisModel != null)
  3565. {
  3566. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  3567. {
  3568. switch (this.analysisModel.ListParam[i].param_key)
  3569. {
  3570. case ParamKey_ShowAll:
  3571. this.checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3572. break;
  3573. case ParamKey_NewPic:
  3574. this.checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3575. break;
  3576. case ParamKey_WholePic:
  3577. this.radioButton4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3578. //radioButton4_CheckedChanged(null, null);
  3579. break;
  3580. //点击
  3581. case ParamKey_Click:
  3582. this.radioButton6.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3583. //radioButton6_CheckedChanged(null, null);
  3584. break;
  3585. case ParamKey_CkValue:
  3586. this.userTextBox2.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  3587. break;
  3588. case ParamKey_CkRange:
  3589. this.userTextBox1.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  3590. break;
  3591. //轮廓
  3592. case ParamKey_Outline:
  3593. this.radioButton5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3594. //radioButton5_CheckedChanged(null,null);
  3595. break;
  3596. case ParamKey_OPolygon:
  3597. this.radioButton14.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3598. //if(this.radioButton5.Checked && this.radioButton14.Checked)
  3599. // radioButton14_CheckedChanged(null, null);
  3600. break;
  3601. case ParamKey_ORectangle:
  3602. this.radioButton15.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3603. //if (this.radioButton5.Checked && this.radioButton15.Checked)
  3604. //radioButton15_CheckedChanged(null, null);
  3605. break;
  3606. case ParamKey_OEllipse:
  3607. this.radioButton16.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3608. //if (this.radioButton5.Checked && this.radioButton16.Checked)
  3609. //radioButton16_CheckedChanged(null, null);
  3610. break;
  3611. //二值样式和目标选择
  3612. case ParamKey_Solid:
  3613. this.radioButton1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3614. //radioButton1_CheckedChanged(null, null);
  3615. break;
  3616. case ParamKey_Outer:
  3617. this.radioButton2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3618. //radioButton2_CheckedChanged(null, null);
  3619. break;
  3620. case ParamKey_Target1:
  3621. this.radioButton8.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3622. //radioButton8_CheckedChanged(null, null);
  3623. break;
  3624. case ParamKey_Target2:
  3625. this.radioButton7.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3626. //radioButton7_CheckedChanged(null, null);
  3627. break;
  3628. case ParamKey_Target3:
  3629. this.radioButton9.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3630. //radioButton9_CheckedChanged(null, null);
  3631. break;
  3632. //处理细节
  3633. case ParamKey_Boundary:
  3634. this.checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3635. break;
  3636. case ParamKey_Holes:
  3637. this.checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3638. break;
  3639. case ParamKey_Detritus:
  3640. this.checkBox4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3641. break;
  3642. //单个处理
  3643. case ParamKey_Single:
  3644. this.radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3645. //radioButton3_CheckedChanged(null, null);
  3646. break;
  3647. case ParamKey_SDeviation:
  3648. this.numericUpDown9.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  3649. //numericUpDown9_ValueChanged(null, null);
  3650. break;
  3651. }
  3652. }
  3653. BackgroundImageSwitch();
  3654. }
  3655. }
  3656. //目标切换
  3657. private void BackgroundImageSwitch()
  3658. {
  3659. if (this.radioButton8.Checked)
  3660. {
  3661. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
  3662. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  3663. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  3664. }
  3665. if (this.radioButton7.Checked)
  3666. {
  3667. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
  3668. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  3669. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  3670. }
  3671. if (this.radioButton9.Checked)
  3672. {
  3673. this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
  3674. this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  3675. this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  3676. }
  3677. }
  3678. private void SaveDialogParam()
  3679. {
  3680. this.saveDialogParamValues();
  3681. //xml保存路径
  3682. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
  3683. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  3684. foreach (var analysisItem in this.analysisModel.ListParam)
  3685. {
  3686. bool foundItem = false;
  3687. foreach (var item in analysisModelXml.ListParam)
  3688. {
  3689. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  3690. {
  3691. item.param_value = analysisItem.param_value;
  3692. foundItem = true;
  3693. break;
  3694. }
  3695. }
  3696. if (!foundItem)
  3697. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  3698. }
  3699. //按路径和名称保存xml文件
  3700. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  3701. //保存xml
  3702. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  3703. }
  3704. #endregion
  3705. }
  3706. }