PhaseExtractDialog.cs 178 KB

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