123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975 |
- using Metis.ParameterSet;
- using OpenCvSharp;
- using PaintDotNet.Adjust.BaseImage;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Enum;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.Data.Param;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- namespace PaintDotNet.Binarization
- {
- /// <summary>
- /// 物相提取
- /// </summary>
- internal class PhaseExtractDialog : PdnBaseForm
- {
- #region 控件
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Button button5;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.ImageList imageList1;
- private System.ComponentModel.IContainer components;
- private System.Windows.Forms.ListView listView1;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.NumericUpDown numericUpDown2;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
- private System.Windows.Forms.CheckBox checkBox4;
- private System.Windows.Forms.CheckBox checkBox3;
- private System.Windows.Forms.CheckBox checkBox2;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.RadioButton radioButton2;
- private System.Windows.Forms.RadioButton radioButton1;
- private System.Windows.Forms.GroupBox groupBox7;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox8;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.RadioButton radioButton3;
- private System.Windows.Forms.RadioButton radioButton4;
- private System.Windows.Forms.GroupBox groupBox9;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.RadioButton radioButton5;
- private System.Windows.Forms.RadioButton radioButton6;
- private System.Windows.Forms.GroupBox groupBox10;
- private System.Windows.Forms.RadioButton radioButton9;
- private System.Windows.Forms.RadioButton radioButton7;
- private System.Windows.Forms.RadioButton radioButton8;
- private System.Windows.Forms.GroupBox groupBox11;
- private System.Windows.Forms.Button button8;
- private System.Windows.Forms.Button button7;
- private System.Windows.Forms.Button button6;
- private System.Windows.Forms.RadioButton radioButton10;
- private System.Windows.Forms.RadioButton radioButton11;
- private System.Windows.Forms.NumericUpDown numericUpDown7;
- private System.Windows.Forms.NumericUpDown numericUpDown8;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.NumericUpDown numericUpDown5;
- private System.Windows.Forms.NumericUpDown numericUpDown6;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.NumericUpDown numericUpDown3;
- private System.Windows.Forms.NumericUpDown numericUpDown4;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.RadioButton radioButton12;
- private System.Windows.Forms.RadioButton radioButton13;
- private System.Windows.Forms.NumericUpDown userTextBox2;
- private System.Windows.Forms.NumericUpDown userTextBox1;
- private System.Windows.Forms.Button button10;
- private System.Windows.Forms.Button button9;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Panel panel2;
- private System.Windows.Forms.GroupBox groupBox12;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.TrackBar trackBar1;
- private System.Windows.Forms.GroupBox groupBox13;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.Button button11;
- private System.Windows.Forms.Button button12;
- private NumericUpDown numericUpDown9;
- private Panel panel1;
- private RadioButton radioButton14;
- private RadioButton radioButton15;
- private Button button13;
- private Button button15;
- private Button button14;
- private CustomControl.HistogramControl histogramControl1;
- private Button button16;
- private Button button17;
- private Button button18;
- private CheckBox checkBox5;
- private RadioButton radioButton16;
- private void InitializeLanguageText()
- {
- this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
- this.label7.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
- this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Previous.text");
- this.button9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.next.text");
- this.button4.Text = PdnResources.GetString("Menu.Add.text");
- this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button5.Text = PdnResources.GetString("Menu.Edit.Text");
- this.checkBox1.Text = PdnResources.GetString("Menu.Createnewgraph.text");
- this.button1.Text = PdnResources.GetString("Menu.ensure.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox5.Text = PdnResources.GetString("Menu.Processingdetails.text");
- this.checkBox4.Text = PdnResources.GetString("Menu.Clasticdelete.text");
- this.checkBox3.Text = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
- this.checkBox2.Text = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
- this.groupBox6.Text = PdnResources.GetString("Menu.Binarystyle.text");
- this.radioButton2.Text = PdnResources.GetString("Menu.Sideline.text");
- this.radioButton1.Text = PdnResources.GetString("Menu.solid.text");
- this.groupBox7.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox1.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox12.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
- this.label9.Text = PdnResources.GetString("Menu.deviation.Text") + ":";
- this.groupBox8.Text = PdnResources.GetString("Menu.Tools.Histogram.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Extractionmode.text");
- this.radioButton3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Singletarget.text");
- this.radioButton4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Wholeimage.text");
- this.groupBox9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Definetheobject.text");
- this.radioButton16.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
- this.radioButton15.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
- this.radioButton14.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
- this.label4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Rangesize.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.admissiblevalue.text") + ":";
- this.radioButton5.Text = PdnResources.GetString("Menu.contour.text");
- this.radioButton6.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
- this.groupBox10.Text = PdnResources.GetString("Menu.Targetselection.text");
- this.radioButton9.Text = PdnResources.GetString("Menu.style.text") + "3";
- this.radioButton7.Text = PdnResources.GetString("Menu.style.text") + "2";
- this.radioButton8.Text = PdnResources.GetString("Menu.style.text") + "1";
- this.groupBox11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
- this.button8.Text = PdnResources.GetString("Menu.reinformation.text");
- this.button7.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
- this.button6.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
- this.radioButton10.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.radioButton11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.append.text");
- this.groupBox13.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
- this.button2.Text = PdnResources.GetString("Menu.reinformation.text");
- this.button11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
- this.checkBox5.Text = PdnResources.GetString("Menu.allShow.Text");
- this.Text = "PhaseExtractDialog";
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.label7 = new System.Windows.Forms.Label();
- this.panel2 = new System.Windows.Forms.Panel();
- this.button10 = new System.Windows.Forms.Button();
- this.button9 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.checkBox3 = new System.Windows.Forms.CheckBox();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.button15 = new System.Windows.Forms.Button();
- this.button14 = new System.Windows.Forms.Button();
- this.button13 = new System.Windows.Forms.Button();
- this.numericUpDown7 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown8 = new System.Windows.Forms.NumericUpDown();
- this.label6 = new System.Windows.Forms.Label();
- this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
- this.label5 = new System.Windows.Forms.Label();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- this.label2 = new System.Windows.Forms.Label();
- this.radioButton12 = new System.Windows.Forms.RadioButton();
- this.radioButton13 = new System.Windows.Forms.RadioButton();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.groupBox12 = new System.Windows.Forms.GroupBox();
- this.numericUpDown9 = new System.Windows.Forms.NumericUpDown();
- this.trackBar1 = new System.Windows.Forms.TrackBar();
- this.label9 = new System.Windows.Forms.Label();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.histogramControl1 = new PaintDotNet.CustomControl.HistogramControl();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.radioButton3 = new System.Windows.Forms.RadioButton();
- this.radioButton4 = new System.Windows.Forms.RadioButton();
- this.groupBox9 = new System.Windows.Forms.GroupBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.radioButton16 = new System.Windows.Forms.RadioButton();
- this.radioButton15 = new System.Windows.Forms.RadioButton();
- this.radioButton14 = new System.Windows.Forms.RadioButton();
- this.userTextBox2 = new System.Windows.Forms.NumericUpDown();
- this.userTextBox1 = new System.Windows.Forms.NumericUpDown();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.radioButton5 = new System.Windows.Forms.RadioButton();
- this.radioButton6 = new System.Windows.Forms.RadioButton();
- this.groupBox10 = new System.Windows.Forms.GroupBox();
- this.button18 = new System.Windows.Forms.Button();
- this.button17 = new System.Windows.Forms.Button();
- this.button16 = new System.Windows.Forms.Button();
- this.radioButton9 = new System.Windows.Forms.RadioButton();
- this.radioButton7 = new System.Windows.Forms.RadioButton();
- this.radioButton8 = new System.Windows.Forms.RadioButton();
- this.groupBox11 = new System.Windows.Forms.GroupBox();
- this.button8 = new System.Windows.Forms.Button();
- this.button7 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.radioButton10 = new System.Windows.Forms.RadioButton();
- this.radioButton11 = new System.Windows.Forms.RadioButton();
- this.groupBox13 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button11 = new System.Windows.Forms.Button();
- this.button12 = new System.Windows.Forms.Button();
- this.groupBox2.SuspendLayout();
- this.groupBox4.SuspendLayout();
- this.groupBox5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.groupBox6.SuspendLayout();
- this.groupBox7.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- this.groupBox12.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
- this.groupBox8.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox9.SuspendLayout();
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).BeginInit();
- this.groupBox10.SuspendLayout();
- this.groupBox11.SuspendLayout();
- this.groupBox13.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.Controls.Add(this.checkBox5);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.panel2);
- this.groupBox2.Controls.Add(this.button10);
- this.groupBox2.Controls.Add(this.button9);
- this.groupBox2.Controls.Add(this.button4);
- this.groupBox2.Controls.Add(this.button3);
- this.groupBox2.Controls.Add(this.button5);
- this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Controls.Add(this.checkBox1);
- this.groupBox2.Controls.Add(this.button1);
- this.groupBox2.Location = new System.Drawing.Point(13, 12);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(1261, 52);
- this.groupBox2.TabIndex = 7;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "操作";
- //
- // checkBox5
- //
- this.checkBox5.AutoSize = true;
- this.checkBox5.Location = new System.Drawing.Point(555, 23);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(72, 16);
- this.checkBox5.TabIndex = 23;
- this.checkBox5.Text = "显示全部";
- this.checkBox5.UseVisualStyleBackColor = true;
- this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(421, 26);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(53, 12);
- this.label7.TabIndex = 22;
- this.label7.Text = "相颜色:";
- //
- // panel2
- //
- this.panel2.BackColor = System.Drawing.Color.Transparent;
- this.panel2.Location = new System.Drawing.Point(476, 21);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(72, 21);
- this.panel2.TabIndex = 21;
- //
- // button10
- //
- this.button10.Location = new System.Drawing.Point(7, 21);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(75, 23);
- this.button10.TabIndex = 14;
- this.button10.Text = "上一个";
- this.button10.UseVisualStyleBackColor = true;
- this.button10.Click += new System.EventHandler(this.button10_Click);
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(138, 21);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(75, 23);
- this.button9.TabIndex = 13;
- this.button9.Text = "下一个";
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(219, 21);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(60, 23);
- this.button4.TabIndex = 12;
- this.button4.Text = "新增";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(285, 21);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(60, 23);
- this.button3.TabIndex = 11;
- this.button3.Text = "删除";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(351, 21);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(60, 23);
- this.button5.TabIndex = 10;
- this.button5.Text = "编辑";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(97, 26);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(23, 12);
- this.label1.TabIndex = 6;
- this.label1.Text = "0/0";
- //
- // checkBox1
- //
- this.checkBox1.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(1104, 24);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(72, 16);
- this.checkBox1.TabIndex = 5;
- this.checkBox1.Text = "创建新图";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.button1.Location = new System.Drawing.Point(1182, 20);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 3;
- this.button1.Text = "确定";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox4.Controls.Add(this.listView1);
- this.groupBox4.Location = new System.Drawing.Point(13, 71);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(139, 744);
- this.groupBox4.TabIndex = 9;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "图像索引";
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.HideSelection = false;
- this.listView1.LargeImageList = this.imageList1;
- this.listView1.Location = new System.Drawing.Point(7, 21);
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(126, 717);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.numericUpDown2);
- this.groupBox5.Controls.Add(this.numericUpDown1);
- this.groupBox5.Controls.Add(this.checkBox4);
- this.groupBox5.Controls.Add(this.checkBox3);
- this.groupBox5.Controls.Add(this.checkBox2);
- this.groupBox5.Location = new System.Drawing.Point(158, 443);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(200, 74);
- this.groupBox5.TabIndex = 11;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "处理细节";
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(129, 41);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 2147483647,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown2.TabIndex = 6;
- this.numericUpDown2.Tag = "max";
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(84, 41);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 2147483647,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown1.TabIndex = 5;
- this.numericUpDown1.Tag = "min";
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // checkBox4
- //
- this.checkBox4.AutoSize = true;
- this.checkBox4.Location = new System.Drawing.Point(7, 44);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(72, 16);
- this.checkBox4.TabIndex = 2;
- this.checkBox4.Text = "碎屑删除";
- this.checkBox4.UseVisualStyleBackColor = true;
- //
- // checkBox3
- //
- this.checkBox3.AutoSize = true;
- this.checkBox3.Location = new System.Drawing.Point(119, 20);
- this.checkBox3.Name = "checkBox3";
- this.checkBox3.Size = new System.Drawing.Size(72, 16);
- this.checkBox3.TabIndex = 1;
- this.checkBox3.Text = "孔洞填充";
- this.checkBox3.UseVisualStyleBackColor = true;
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.Location = new System.Drawing.Point(7, 20);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(96, 16);
- this.checkBox2.TabIndex = 0;
- this.checkBox2.Text = "删除边界对象";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // groupBox6
- //
- this.groupBox6.Controls.Add(this.radioButton2);
- this.groupBox6.Controls.Add(this.radioButton1);
- this.groupBox6.Location = new System.Drawing.Point(158, 225);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(200, 46);
- this.groupBox6.TabIndex = 12;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "二值样式";
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(70, 20);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(47, 16);
- this.radioButton2.TabIndex = 1;
- this.radioButton2.Text = "边线";
- this.radioButton2.UseVisualStyleBackColor = true;
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(7, 20);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(47, 16);
- this.radioButton1.TabIndex = 0;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "实心";
- this.radioButton1.UseVisualStyleBackColor = true;
- //
- // groupBox7
- //
- this.groupBox7.Controls.Add(this.button15);
- this.groupBox7.Controls.Add(this.button14);
- this.groupBox7.Controls.Add(this.button13);
- this.groupBox7.Controls.Add(this.numericUpDown7);
- this.groupBox7.Controls.Add(this.numericUpDown8);
- this.groupBox7.Controls.Add(this.label6);
- this.groupBox7.Controls.Add(this.numericUpDown5);
- this.groupBox7.Controls.Add(this.numericUpDown6);
- this.groupBox7.Controls.Add(this.label5);
- this.groupBox7.Controls.Add(this.numericUpDown3);
- this.groupBox7.Controls.Add(this.numericUpDown4);
- this.groupBox7.Controls.Add(this.label2);
- this.groupBox7.Controls.Add(this.radioButton12);
- this.groupBox7.Controls.Add(this.radioButton13);
- this.groupBox7.Location = new System.Drawing.Point(158, 685);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(200, 130);
- this.groupBox7.TabIndex = 13;
- this.groupBox7.TabStop = false;
- this.groupBox7.Text = "设置";
- //
- // button15
- //
- this.button15.Location = new System.Drawing.Point(134, 99);
- this.button15.Name = "button15";
- this.button15.Size = new System.Drawing.Size(34, 21);
- this.button15.TabIndex = 34;
- this.button15.Text = "B";
- this.button15.UseVisualStyleBackColor = true;
- this.button15.Click += new System.EventHandler(this.button15_Click);
- //
- // button14
- //
- this.button14.Location = new System.Drawing.Point(134, 72);
- this.button14.Name = "button14";
- this.button14.Size = new System.Drawing.Size(34, 21);
- this.button14.TabIndex = 33;
- this.button14.Text = "G";
- this.button14.UseVisualStyleBackColor = true;
- this.button14.Click += new System.EventHandler(this.button14_Click);
- //
- // button13
- //
- this.button13.BackColor = System.Drawing.SystemColors.Control;
- this.button13.Location = new System.Drawing.Point(134, 45);
- this.button13.Margin = new System.Windows.Forms.Padding(0);
- this.button13.Name = "button13";
- this.button13.Size = new System.Drawing.Size(34, 21);
- this.button13.TabIndex = 32;
- this.button13.Text = "R";
- this.button13.UseVisualStyleBackColor = true;
- this.button13.Click += new System.EventHandler(this.button13_Click);
- //
- // numericUpDown7
- //
- this.numericUpDown7.Location = new System.Drawing.Point(82, 99);
- this.numericUpDown7.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown7.Name = "numericUpDown7";
- this.numericUpDown7.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown7.TabIndex = 30;
- this.numericUpDown7.Tag = "max";
- this.numericUpDown7.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // numericUpDown8
- //
- this.numericUpDown8.Location = new System.Drawing.Point(37, 99);
- this.numericUpDown8.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown8.Name = "numericUpDown8";
- this.numericUpDown8.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown8.TabIndex = 29;
- this.numericUpDown8.Tag = "min";
- this.numericUpDown8.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(10, 103);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(23, 12);
- this.label6.TabIndex = 31;
- this.label6.Text = "B:";
- //
- // numericUpDown5
- //
- this.numericUpDown5.Location = new System.Drawing.Point(82, 72);
- this.numericUpDown5.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown5.Name = "numericUpDown5";
- this.numericUpDown5.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown5.TabIndex = 27;
- this.numericUpDown5.Tag = "max";
- this.numericUpDown5.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // numericUpDown6
- //
- this.numericUpDown6.Location = new System.Drawing.Point(37, 72);
- this.numericUpDown6.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown6.Name = "numericUpDown6";
- this.numericUpDown6.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown6.TabIndex = 26;
- this.numericUpDown6.Tag = "min";
- this.numericUpDown6.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(10, 76);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(23, 12);
- this.label5.TabIndex = 28;
- this.label5.Text = "G:";
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(82, 45);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown3.TabIndex = 8;
- this.numericUpDown3.Tag = "max";
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(37, 45);
- this.numericUpDown4.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(40, 21);
- this.numericUpDown4.TabIndex = 7;
- this.numericUpDown4.Tag = "min";
- this.numericUpDown4.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(10, 49);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(23, 12);
- this.label2.TabIndex = 25;
- this.label2.Text = "R:";
- //
- // radioButton12
- //
- this.radioButton12.AutoSize = true;
- this.radioButton12.Location = new System.Drawing.Point(66, 20);
- this.radioButton12.Name = "radioButton12";
- this.radioButton12.Size = new System.Drawing.Size(41, 16);
- this.radioButton12.TabIndex = 4;
- this.radioButton12.Text = "HLS";
- this.radioButton12.UseVisualStyleBackColor = true;
- this.radioButton12.CheckedChanged += new System.EventHandler(this.radioButton12_CheckedChanged);
- //
- // radioButton13
- //
- this.radioButton13.AutoSize = true;
- this.radioButton13.Checked = true;
- this.radioButton13.Location = new System.Drawing.Point(7, 20);
- this.radioButton13.Name = "radioButton13";
- this.radioButton13.Size = new System.Drawing.Size(41, 16);
- this.radioButton13.TabIndex = 3;
- this.radioButton13.TabStop = true;
- this.radioButton13.Text = "RGB";
- this.radioButton13.UseVisualStyleBackColor = true;
- this.radioButton13.CheckedChanged += new System.EventHandler(this.radioButton13_CheckedChanged);
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Location = new System.Drawing.Point(364, 70);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(910, 745);
- this.groupBox1.TabIndex = 14;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "预览";
- //
- // groupBox12
- //
- this.groupBox12.Controls.Add(this.numericUpDown9);
- this.groupBox12.Controls.Add(this.trackBar1);
- this.groupBox12.Controls.Add(this.label9);
- this.groupBox12.Location = new System.Drawing.Point(158, 120);
- this.groupBox12.Name = "groupBox12";
- this.groupBox12.Size = new System.Drawing.Size(200, 96);
- this.groupBox12.TabIndex = 25;
- this.groupBox12.TabStop = false;
- this.groupBox12.Text = "定义物体";
- this.groupBox12.Visible = false;
- //
- // numericUpDown9
- //
- this.numericUpDown9.Location = new System.Drawing.Point(53, 27);
- this.numericUpDown9.Name = "numericUpDown9";
- this.numericUpDown9.Size = new System.Drawing.Size(127, 21);
- this.numericUpDown9.TabIndex = 26;
- //
- // trackBar1
- //
- this.trackBar1.AutoSize = false;
- this.trackBar1.Location = new System.Drawing.Point(1, 58);
- this.trackBar1.Maximum = 100;
- this.trackBar1.Name = "trackBar1";
- this.trackBar1.Size = new System.Drawing.Size(188, 25);
- this.trackBar1.TabIndex = 25;
- this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(6, 32);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(0, 12);
- this.label9.TabIndex = 21;
- //
- // groupBox8
- //
- this.groupBox8.Controls.Add(this.histogramControl1);
- this.groupBox8.Location = new System.Drawing.Point(158, 523);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(200, 156);
- this.groupBox8.TabIndex = 14;
- this.groupBox8.TabStop = false;
- this.groupBox8.Text = "直方图";
- //
- // histogramControl1
- //
- this.histogramControl1.Flag = 1;
- this.histogramControl1.Location = new System.Drawing.Point(6, 21);
- this.histogramControl1.Name = "histogramControl1";
- this.histogramControl1.Size = new System.Drawing.Size(188, 129);
- this.histogramControl1.TabIndex = 0;
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.radioButton3);
- this.groupBox3.Controls.Add(this.radioButton4);
- this.groupBox3.Location = new System.Drawing.Point(158, 71);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(200, 46);
- this.groupBox3.TabIndex = 21;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "提取模式";
- //
- // radioButton3
- //
- this.radioButton3.AutoSize = true;
- this.radioButton3.Location = new System.Drawing.Point(84, 20);
- this.radioButton3.Name = "radioButton3";
- this.radioButton3.Size = new System.Drawing.Size(71, 16);
- this.radioButton3.TabIndex = 1;
- this.radioButton3.Text = "单个目标";
- this.radioButton3.UseVisualStyleBackColor = true;
- //
- // radioButton4
- //
- this.radioButton4.AutoSize = true;
- this.radioButton4.Checked = true;
- this.radioButton4.Location = new System.Drawing.Point(7, 20);
- this.radioButton4.Name = "radioButton4";
- this.radioButton4.Size = new System.Drawing.Size(71, 16);
- this.radioButton4.TabIndex = 0;
- this.radioButton4.TabStop = true;
- this.radioButton4.Text = "整个图像";
- this.radioButton4.UseVisualStyleBackColor = true;
- //
- // groupBox9
- //
- this.groupBox9.Controls.Add(this.panel1);
- this.groupBox9.Controls.Add(this.userTextBox2);
- this.groupBox9.Controls.Add(this.userTextBox1);
- this.groupBox9.Controls.Add(this.label4);
- this.groupBox9.Controls.Add(this.label3);
- this.groupBox9.Controls.Add(this.radioButton5);
- this.groupBox9.Controls.Add(this.radioButton6);
- this.groupBox9.Location = new System.Drawing.Point(158, 123);
- this.groupBox9.Name = "groupBox9";
- this.groupBox9.Size = new System.Drawing.Size(200, 96);
- this.groupBox9.TabIndex = 22;
- this.groupBox9.TabStop = false;
- //
- // panel1
- //
- this.panel1.Controls.Add(this.radioButton16);
- this.panel1.Controls.Add(this.radioButton15);
- this.panel1.Controls.Add(this.radioButton14);
- this.panel1.Location = new System.Drawing.Point(6, 41);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(174, 47);
- this.panel1.TabIndex = 25;
- this.panel1.Visible = false;
- //
- // radioButton16
- //
- this.radioButton16.AutoSize = true;
- this.radioButton16.Location = new System.Drawing.Point(115, 16);
- this.radioButton16.Name = "radioButton16";
- this.radioButton16.Size = new System.Drawing.Size(14, 13);
- this.radioButton16.TabIndex = 2;
- this.radioButton16.TabStop = true;
- this.radioButton16.UseVisualStyleBackColor = true;
- //
- // radioButton15
- //
- this.radioButton15.AutoSize = true;
- this.radioButton15.Location = new System.Drawing.Point(66, 16);
- this.radioButton15.Name = "radioButton15";
- this.radioButton15.Size = new System.Drawing.Size(14, 13);
- this.radioButton15.TabIndex = 1;
- this.radioButton15.TabStop = true;
- this.radioButton15.UseVisualStyleBackColor = true;
- //
- // radioButton14
- //
- this.radioButton14.AutoSize = true;
- this.radioButton14.Checked = true;
- this.radioButton14.Location = new System.Drawing.Point(5, 16);
- this.radioButton14.Name = "radioButton14";
- this.radioButton14.Size = new System.Drawing.Size(14, 13);
- this.radioButton14.TabIndex = 0;
- this.radioButton14.TabStop = true;
- this.radioButton14.UseVisualStyleBackColor = true;
- //
- // userTextBox2
- //
- this.userTextBox2.Location = new System.Drawing.Point(78, 41);
- this.userTextBox2.Name = "userTextBox2";
- this.userTextBox2.Size = new System.Drawing.Size(100, 21);
- this.userTextBox2.TabIndex = 24;
- this.userTextBox2.ValueChanged += new System.EventHandler(this.userTextBox2Change);
- //
- // userTextBox1
- //
- this.userTextBox1.Location = new System.Drawing.Point(78, 67);
- this.userTextBox1.Name = "userTextBox1";
- this.userTextBox1.Size = new System.Drawing.Size(100, 21);
- this.userTextBox1.TabIndex = 23;
- this.userTextBox1.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(6, 72);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(0, 12);
- this.label4.TabIndex = 22;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(6, 46);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(0, 12);
- this.label3.TabIndex = 21;
- //
- // radioButton5
- //
- this.radioButton5.AutoSize = true;
- this.radioButton5.Location = new System.Drawing.Point(60, 20);
- this.radioButton5.Name = "radioButton5";
- this.radioButton5.Size = new System.Drawing.Size(14, 13);
- this.radioButton5.TabIndex = 1;
- this.radioButton5.UseVisualStyleBackColor = true;
- //
- // radioButton6
- //
- this.radioButton6.AutoSize = true;
- this.radioButton6.Checked = true;
- this.radioButton6.Location = new System.Drawing.Point(7, 20);
- this.radioButton6.Name = "radioButton6";
- this.radioButton6.Size = new System.Drawing.Size(14, 13);
- this.radioButton6.TabIndex = 0;
- this.radioButton6.TabStop = true;
- this.radioButton6.UseVisualStyleBackColor = true;
- //
- // groupBox10
- //
- this.groupBox10.Controls.Add(this.button18);
- this.groupBox10.Controls.Add(this.button17);
- this.groupBox10.Controls.Add(this.button16);
- this.groupBox10.Controls.Add(this.radioButton9);
- this.groupBox10.Controls.Add(this.radioButton7);
- this.groupBox10.Controls.Add(this.radioButton8);
- this.groupBox10.Location = new System.Drawing.Point(158, 357);
- this.groupBox10.Name = "groupBox10";
- this.groupBox10.Size = new System.Drawing.Size(200, 80);
- this.groupBox10.TabIndex = 13;
- this.groupBox10.TabStop = false;
- this.groupBox10.Text = "目标选择";
- //
- // button18
- //
- this.button18.Location = new System.Drawing.Point(99, 24);
- this.button18.Name = "button18";
- this.button18.Size = new System.Drawing.Size(40, 40);
- this.button18.TabIndex = 5;
- this.button18.UseVisualStyleBackColor = true;
- //
- // button17
- //
- this.button17.Location = new System.Drawing.Point(53, 24);
- this.button17.Name = "button17";
- this.button17.Size = new System.Drawing.Size(40, 40);
- this.button17.TabIndex = 4;
- this.button17.UseVisualStyleBackColor = true;
- //
- // button16
- //
- this.button16.Location = new System.Drawing.Point(8, 24);
- this.button16.Name = "button16";
- this.button16.Size = new System.Drawing.Size(40, 40);
- this.button16.TabIndex = 3;
- this.button16.UseVisualStyleBackColor = true;
- //
- // radioButton9
- //
- this.radioButton9.AutoSize = true;
- this.radioButton9.Location = new System.Drawing.Point(141, 58);
- this.radioButton9.Name = "radioButton9";
- this.radioButton9.Size = new System.Drawing.Size(14, 13);
- this.radioButton9.TabIndex = 2;
- this.radioButton9.UseVisualStyleBackColor = true;
- this.radioButton9.Visible = false;
- //
- // radioButton7
- //
- this.radioButton7.AutoSize = true;
- this.radioButton7.Location = new System.Drawing.Point(141, 36);
- this.radioButton7.Name = "radioButton7";
- this.radioButton7.Size = new System.Drawing.Size(14, 13);
- this.radioButton7.TabIndex = 1;
- this.radioButton7.UseVisualStyleBackColor = true;
- this.radioButton7.Visible = false;
- //
- // radioButton8
- //
- this.radioButton8.AutoSize = true;
- this.radioButton8.Checked = true;
- this.radioButton8.Location = new System.Drawing.Point(141, 14);
- this.radioButton8.Name = "radioButton8";
- this.radioButton8.Size = new System.Drawing.Size(14, 13);
- this.radioButton8.TabIndex = 0;
- this.radioButton8.TabStop = true;
- this.radioButton8.UseVisualStyleBackColor = true;
- this.radioButton8.Visible = false;
- //
- // groupBox11
- //
- this.groupBox11.Controls.Add(this.button8);
- this.groupBox11.Controls.Add(this.button7);
- this.groupBox11.Controls.Add(this.button6);
- this.groupBox11.Controls.Add(this.radioButton10);
- this.groupBox11.Controls.Add(this.radioButton11);
- this.groupBox11.Location = new System.Drawing.Point(158, 277);
- this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(200, 74);
- this.groupBox11.TabIndex = 13;
- this.groupBox11.TabStop = false;
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(124, 40);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(52, 23);
- this.button8.TabIndex = 13;
- this.button8.UseVisualStyleBackColor = true;
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(66, 40);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(52, 23);
- this.button7.TabIndex = 12;
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button11_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(8, 40);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(52, 23);
- this.button6.TabIndex = 11;
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button12_Click);
- //
- // radioButton10
- //
- this.radioButton10.AutoSize = true;
- this.radioButton10.Location = new System.Drawing.Point(70, 20);
- this.radioButton10.Name = "radioButton10";
- this.radioButton10.Size = new System.Drawing.Size(14, 13);
- this.radioButton10.TabIndex = 1;
- this.radioButton10.UseVisualStyleBackColor = true;
- //
- // radioButton11
- //
- this.radioButton11.AutoSize = true;
- this.radioButton11.Checked = true;
- this.radioButton11.Location = new System.Drawing.Point(7, 20);
- this.radioButton11.Name = "radioButton11";
- this.radioButton11.Size = new System.Drawing.Size(14, 13);
- this.radioButton11.TabIndex = 0;
- this.radioButton11.TabStop = true;
- this.radioButton11.UseVisualStyleBackColor = true;
- //
- // groupBox13
- //
- this.groupBox13.Controls.Add(this.button2);
- this.groupBox13.Controls.Add(this.button11);
- this.groupBox13.Controls.Add(this.button12);
- this.groupBox13.Location = new System.Drawing.Point(158, 277);
- this.groupBox13.Name = "groupBox13";
- this.groupBox13.Size = new System.Drawing.Size(200, 74);
- this.groupBox13.TabIndex = 14;
- this.groupBox13.TabStop = false;
- this.groupBox13.Text = "目标处理";
- this.groupBox13.Visible = false;
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(124, 35);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(52, 23);
- this.button2.TabIndex = 13;
- this.button2.Text = "重置";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button8_Click);
- //
- // button11
- //
- this.button11.Location = new System.Drawing.Point(66, 35);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(52, 23);
- this.button11.TabIndex = 12;
- this.button11.Text = "重做";
- this.button11.UseVisualStyleBackColor = true;
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // button12
- //
- this.button12.Location = new System.Drawing.Point(8, 35);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(52, 23);
- this.button12.TabIndex = 11;
- this.button12.Text = "撤销";
- this.button12.UseVisualStyleBackColor = true;
- this.button12.Click += new System.EventHandler(this.button12_Click);
- //
- // PhaseExtractDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1286, 827);
- this.Controls.Add(this.groupBox12);
- this.Controls.Add(this.groupBox13);
- this.Controls.Add(this.groupBox11);
- this.Controls.Add(this.groupBox10);
- this.Controls.Add(this.groupBox9);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox8);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox2);
- this.Name = "PhaseExtractDialog";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "物相提取";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PhaseExtractDialog_FormClosing);
- this.Load += new System.EventHandler(this.PhaseExtractDialog_Load);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox8, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox9, 0);
- this.Controls.SetChildIndex(this.groupBox10, 0);
- this.Controls.SetChildIndex(this.groupBox11, 0);
- this.Controls.SetChildIndex(this.groupBox13, 0);
- this.Controls.SetChildIndex(this.groupBox12, 0);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- this.groupBox12.ResumeLayout(false);
- this.groupBox12.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
- this.groupBox8.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.groupBox9.ResumeLayout(false);
- this.groupBox9.PerformLayout();
- this.panel1.ResumeLayout(false);
- this.panel1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).EndInit();
- this.groupBox10.ResumeLayout(false);
- this.groupBox10.PerformLayout();
- this.groupBox11.ResumeLayout(false);
- this.groupBox11.PerformLayout();
- this.groupBox13.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 步长 初始值1,依次增加
- /// </summary>
- string stepLength = "001";
- /// <summary>
- /// 参数类
- /// </summary>
- private ParamObject action = new Data.Action.Action902();
- /// <summary>
- /// 当前选择的相颜色
- /// </summary>
- private int color = 0;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- private Mat mat;
- private Mat mat1;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- private Bitmap bitmap;
- /// <summary>
- /// 鼠标移动最后一次的坐标,换算后的
- /// </summary>
- private int x, y;
- /// <summary>
- /// 传递给计算函数的坐标
- /// </summary>
- private int xn, yn;
- /// <summary>
- /// 最后一次坐标,换算前的
- /// </summary>
- private int ox, oy;
- /// <summary>
- /// 当前相model
- /// </summary>
- private PhaseModel model;
- /// <summary>
- /// 当前相
- /// </summary>
- private int currentPhase = 0;
- /// <summary>
- /// 相个数
- /// </summary>
- private int countPhase = 0;
- /// <summary>
- /// 第一次双击的标记
- /// </summary>
- private bool firstFlag = false;
- /// <summary>
- /// 存在视场标记
- /// </summary>
- private bool existViewFlag = false;
- /// <summary>
- /// 循环时用来计算的
- /// </summary>
- private byte maxB = 0, maxG = 0, maxR = 0;
- /// <summary>
- /// 循环时用来计算的
- /// </summary>
- private byte minB = 255, minG = 255, minR = 255;
- /// <summary>
- /// 相颜色
- /// </summary>
- private Vec4b b4;
- /// <summary>
- /// 鼠标点击标记
- /// </summary>
- private bool mouseClick = false;
- /// <summary>
- /// 当前使用轮廓的形状
- /// </summary>
- private ContourParameters contourParameters;
- /// <summary>
- /// 矩形或椭圆的外接矩形
- /// </summary>
- private RectangleF rectangleF;
- /// <summary>
- /// 多边形的点集合
- /// </summary>
- private List<PointF> points;
- /// <summary>
- /// 容许值
- /// </summary>
- private int tolerance = 0;
- /// <summary>
- /// RGB/HLS 选中那个按钮,默认1=R/H 2=G/L 2=B/S
- /// </summary>
- private int HistogramRGBSelect = 1;
- /// <summary>
- /// 用于撤销恢复
- /// </summary>
- private List<MultiPhaseStepModel> steps = new List<MultiPhaseStepModel>();
- /// <summary>
- /// 用于记录当前的撤销恢复步骤
- /// </summary>
- private int currentPosition = -1;
- /// <summary>
- /// 用于标记是撤销重做,以免再次加入集合
- /// </summary>
- private bool doOrRedo = false;
- /// <summary>
- /// 选中的左侧list的下标
- /// </summary>
- private int index = 0;
- private int menuId;
- #region 保存参数的model和key
- private GrainSizeAnalysisModel analysisModel;
- private const string ParamKey_ShowAll = "showAll";//显示全部
- private const string ParamKey_NewPic = "newPic";//创建新图
- private const string ParamKey_WholePic = "wholePic";//整个图像
-
- private const string ParamKey_Click = "click";//点击
- private const string ParamKey_CkValue = "ckValue";//点击容许值
- private const string ParamKey_CkRange = "ckRange";//点击范围大小
- private const string ParamKey_Outline = "outline";//轮廓
- private const string ParamKey_OPolygon = "oPolygon";//轮廓多边形
- private const string ParamKey_ORectangle = "oRectangle";//轮廓矩形
- private const string ParamKey_OEllipse = "oEllipse";//轮廓椭圆
- private const string ParamKey_Solid = "solid";//二值实心
- private const string ParamKey_Outer = "outer";//二值边线
- private const string ParamKey_Target1 = "target1";//目标选择1
- private const string ParamKey_Target2 = "target2";//目标选择2
- private const string ParamKey_Target3 = "target3";//目标选择3
- private const string ParamKey_Boundary = "boundary";//处理细节-删除边界对象
- private const string ParamKey_Holes = "holes";//处理细节-孔洞填充
- private const string ParamKey_Detritus = "detritus";//处理细节-碎屑删除
- private const string ParamKey_Single = "single";//单个目标
- private const string ParamKey_SDeviation = "sDeviation";//单个目标-偏差
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="appWorkspace">主空间</param>
- /// <param name="dialogText">标题</param>
- public PhaseExtractDialog(AppWorkspace appWorkspace, string dialogText, int menuId)
- {
- this.menuId = menuId;
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
- foreach (var item in this.analysisModel.ListParam)
- item.setValue();
- InitializeComponent();
- InitializeLanguageText();
-
- //
- // 设置Dialog属性
- //
- this.appWorkspace = appWorkspace;
- this.Text = dialogText;
- this.Icon = PdnInfo.AppIcon;
- //
- // 初始化目标选择的背景图
- //
- this.InitButtonBackgroundImage();
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- //移除所有事件
- //this.documentWorkspace.SurfaceBox.RemoveMouseEvent();
- this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.pictureBox1_MouseMove);
- this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
- this.documentWorkspace.panel.Paint += new PaintEventHandler(this.pictureBox1_Paint);
- this.documentWorkspace.PPhaseActionFinish += new EventHandler<EventArgs<List<Object>>>(this.defineProfile_Change);
- //this.documentWorkspace.panel.MouseEnter += new EventHandler(this.pictureBox1_MouseEnter);
- this.documentWorkspace.Visible = false;
- this.groupBox1.Controls.Add(documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox1.Controls.Add(commonControlButtons);
-
- //
- // 设置listview事件
- //
- this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
-
- InitData();
- this.tolerance = (int)this.userTextBox2.Value;
- this.button13.FlatStyle = FlatStyle.Flat;
- this.button13.BackColor = Color.FromArgb(225, 225, 225);
- this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
- this.button13.FlatAppearance.BorderSize = 2;
- InitHistogramDragEvent();
- InitCommonButtonEvent();
- /*
- //初始化一个相
- AddPhase("默认相", Color.Red.ToArgb());*/
- this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
-
- }
- private void ShownChoiseItemAndInitData(object sender, EventArgs e)
- {
- //滚动到指定的行位置
- this.listView1.EnsureVisible(index);
- //初始化数据
- this.bitmap = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreateAliasedBitmap();
- Document document = Document.FromImage(bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
- }
- private void InitButtonBackgroundImage()
- {
- this.button16.FlatStyle = FlatStyle.Flat;
- this.button16.FlatAppearance.BorderSize = 0;
- this.button16.BackgroundImageLayout = ImageLayout.Zoom;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
- this.button16.Click += new EventHandler(this.button16_click);
- this.button17.FlatStyle = FlatStyle.Flat;
- this.button17.FlatAppearance.BorderSize = 0;
- this.button17.BackgroundImageLayout = ImageLayout.Zoom;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- this.button17.Click += new EventHandler(this.button17_click);
- this.button18.FlatStyle = FlatStyle.Flat;
- this.button18.FlatAppearance.BorderSize = 0;
- this.button18.BackgroundImageLayout = ImageLayout.Zoom;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- this.button18.Click += new EventHandler(this.button18_click);
- }
-
- private void button16_click(object sender, EventArgs e)
- {
- this.radioButton8.Checked = true;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- private void button17_click(object sender, EventArgs e)
- {
- this.radioButton7.Checked = true;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- private void button18_click(object sender, EventArgs e)
- {
- this.radioButton9.Checked = true;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- }
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if(this.bitmap!=null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != null)
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- /// <summary>
- /// 直方图区间拖动事件
- /// </summary>
- private void InitHistogramDragEvent()
- {
- this.histogramControl1.DragOneEventActionFinish += new EventHandler<EventArgs<int>>(this.DragOneEvent);
- this.histogramControl1.DragTwoEventActionFinish += new EventHandler<EventArgs<int>>(this.DragTwoEvent);
- this.histogramControl1.DragFiveEventActionFinish += new EventHandler<EventArgs<int[]>>(this.DragFiveEvent);
- }
- /// <summary>
- /// 颜色区间1 截止值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragTwoEvent(object sender, EventArgs<int> e)
- {
- if (this.HistogramRGBSelect == 1)
- {
- this.numericUpDown3.Value = e.Data;
- }
- if (this.HistogramRGBSelect == 2)
- {
- this.numericUpDown5.Value = e.Data;
- }
- if (this.HistogramRGBSelect == 3)
- {
- this.numericUpDown7.Value = e.Data;
- }
- }
- /// <summary>
- /// 颜色区间1 起始值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragOneEvent(object sender, EventArgs<int> e)
- {
- if (this.HistogramRGBSelect == 1)
- {
- this.numericUpDown4.Value = e.Data;
- }
- if (this.HistogramRGBSelect == 2)
- {
- this.numericUpDown6.Value = e.Data;
- }
- if (this.HistogramRGBSelect == 3)
- {
- this.numericUpDown8.Value = e.Data;
- }
- }
- /// <summary>
- /// 拖拽直方图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragFiveEvent(object sender, EventArgs<int[]> e)
- {
- if (this.HistogramRGBSelect == 1)
- {
- this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown4.Value = e.Data[1];
- this.numericUpDown3.Value = e.Data[0];
- this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
- }
- if (this.HistogramRGBSelect == 2)
- {
- this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown6.Value = e.Data[1];
- this.numericUpDown5.Value = e.Data[0];
- this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
- }
- if (this.HistogramRGBSelect == 3)
- {
- this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown8.Value = e.Data[1];
- this.numericUpDown7.Value = e.Data[0];
- this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
- }
- this.RGBoRHLSValue_Changed(null, null);
- }
- /// <summary>
- /// 定义轮廓属性的改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void defineProfile_Change(object sender, EventArgs<List<Object>> e)
- {
- switch ((ContourParameters)Enum.Parse(typeof(ContourParameters), e.Data[0].ToString()))
- {
- case ContourParameters.Rectangle:
- contourParameters = ContourParameters.Rectangle;
- rectangleF = (RectangleF)e.Data[1];
- defineProfile_Calc();
- break;
- case ContourParameters.Oval:
- contourParameters = ContourParameters.Oval;
- rectangleF = (RectangleF)e.Data[1];
- defineProfile_Calc();
- break;
- case ContourParameters.Polygon:
- contourParameters = ContourParameters.Polygon;
- points = (List<PointF>)e.Data[1];
- defineProfile_Calc();
- break;
- }
- }
- /// <summary>
- /// 计算划取得区域的RGB最大最小值,并进行处理
- /// </summary>
- private unsafe void defineProfile_Calc()
- {
- Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap).Clone();
- //获取最大最小值
- mat.ForEachAsVec4b(DefineProfileForEachAsVec4b);
- //对于存在视场,不存在进行不同操作
- if (existViewFlag)
- {
- ImageActionWithView();
- }
- else
- {
- ImageActionNoView();
- }
- //添加到步骤中
- SetPhaseModelRGBOrHLS();
- }
- private unsafe void DefineProfileForEachAsVec4b(Vec4b* value, int* position)
- {
- int y = position[0];
- int x = position[1];
- switch (contourParameters)
- {
- case ContourParameters.Rectangle:
- if (rectangleF.Contains(x, y))
- {
- CalcMaxAndMin(value);
- }
- break;
- case ContourParameters.Oval:
- if (BaseTools.isPointInOval(new System.Drawing.Point(x, y),
- new System.Drawing.PointF(rectangleF.X + rectangleF.Width / 2,
- rectangleF.Y + rectangleF.Height / 2),
- rectangleF.Width / 2,
- rectangleF.Height / 2)
- )
- {
- CalcMaxAndMin(value);
- }
- break;
- case ContourParameters.Polygon:
- contourParameters = ContourParameters.Polygon;
- if (BaseTools.isPointInPolygon(new System.Drawing.Point(x, y), points))
- {
- CalcMaxAndMin(value);
- }
- break;
- }
- }
- private unsafe void CalcMaxAndMin(Vec4b* value)
- {
- byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- byte vB = value->Item0;
- byte vG = value->Item1;
- byte vR = value->Item2;
- int minb = (int)(vB - relativeValue);
- int ming = (int)(vG - relativeValue);
- int minr = (int)(vR - relativeValue);
- int maxb = (int)(vB + relativeValue);
- int maxg = (int)(vG + relativeValue);
- int maxr = (int)(vR + relativeValue);
- byte vBmin = (minb < 0) ? (byte)'\0' : (byte)minb;
- byte vBmax = (maxb > 255) ? (byte)255 : (byte)maxb;
- byte vGmin = (ming < 0) ? (byte)'\0' : (byte)ming;
- byte vGmax = (maxg > 255) ? (byte)255 : (byte)maxg;
- byte vRmin = (minr < 0) ? (byte)'\0' : (byte)minr;
- byte vRmax = (maxr > 255) ? (byte)255 : (byte)maxr;
- if (vBmax > maxB) maxB = vBmax;
- if (vBmin < minB) minB = vBmin;
- if (vGmax > maxG) maxG = vGmax;
- if (vGmin < minG) minG = vGmin;
- if (vRmax > maxR) maxR = vRmax;
- if (vRmin < minR) minR = vRmin;
- //if (tolerance > 0)
- //{
- // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minB = (minB < 0) ? (byte)'\0' : minB;
- // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxB = (maxB > 255) ? (byte)255 : maxB;
- // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minG = (minG < 0) ? (byte)'\0' : minG;
- // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxG = (maxG > 255) ? (byte)255 : maxG;
- // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minR = (minR < 0) ? (byte)'\0' : minR;
- // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxR = (maxR > 255) ? (byte)255 : maxR;
- // //byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // int minb = (int)(minB - relativeValue);
- // int ming = (int)(minG - relativeValue);
- // int minr = (int)(minR - relativeValue);
- // int maxb = (int)(maxB + relativeValue);
- // int maxg = (int)(maxG + relativeValue);
- // int maxr = (int)(maxR + relativeValue);
- // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minB = (minb < 0) ? (byte)'\0' : (byte)minb;
- // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
- // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minG = (ming < 0) ? (byte)'\0' : (byte)ming;
- // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
- // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minR = (minr < 0) ? (byte)'\0' : (byte)minr;
- // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
- //}
- //byte vB = value->Item0;
- //byte vG = value->Item1;
- //byte vR = value->Item2;
- //if (vB > maxB) maxB = vB;
- //if (vB < minB) minB = vB;
- //if (vG > maxG) maxG = vG;
- //if (vG < minG) minG = vG;
- //if (vR > maxR) maxR = vR;
- //if (vR < minR) minR = vR;
- //if (tolerance > 0)
- //{
- // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minB = (minB < 0) ? (byte)'\0' : minB;
- // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxB = (maxB > 255) ? (byte)255 : maxB;
- // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minG = (minG < 0) ? (byte)'\0' : minG;
- // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxG = (maxG > 255) ? (byte)255 : maxG;
- // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //minR = (minR < 0) ? (byte)'\0' : minR;
- // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // //maxR = (maxR > 255) ? (byte)255 : maxR;
- // byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // int minb = (int)(minB - relativeValue);
- // int ming = (int)(minG - relativeValue);
- // int minr = (int)(minR - relativeValue);
- // int maxb = (int)(maxB + relativeValue);
- // int maxg = (int)(maxG + relativeValue);
- // int maxr = (int)(maxR + relativeValue);
- // //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minB = (minb < 0) ? (byte)'\0' : (byte)minb;
- // //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
- // //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minG = (ming < 0) ? (byte)'\0' : (byte)ming;
- // //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
- // //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // minR = (minr < 0) ? (byte)'\0' : (byte)minr;
- // //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- // maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
- //}
- }
- /// <summary>
- /// Load事件,初始化参数事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PhaseExtractDialog_Load(object sender, EventArgs e)
- {
- //提取模式
- this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
- this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
-
- //定义物体
- this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
- this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
- //定义物体->点击->容许值
- this.userTextBox2.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[0])).numberParam_ValueChanged;
- //定义物体->点击->范围大小
- this.userTextBox1.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[1])).numberParam_ValueChanged;
- //定义物体->轮廓
- this.radioButton14.CheckedChanged += new System.EventHandler(this.radioButton14_CheckedChanged);
- this.radioButton15.CheckedChanged += new System.EventHandler(this.radioButton15_CheckedChanged);
- this.radioButton16.CheckedChanged += new System.EventHandler(this.radioButton16_CheckedChanged);
- //二值样式
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- //目标处理
- this.radioButton10.CheckedChanged += new System.EventHandler(this.radioButton10_CheckedChanged);
- this.radioButton11.CheckedChanged += new System.EventHandler(this.radioButton11_CheckedChanged);
- //目标选择
- this.radioButton7.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
- this.radioButton8.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
- this.radioButton9.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
-
- ////处理细节
- //删除边界对象
- this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
- //孔洞填充
- this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
- //碎屑删除
- this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
- //碎屑删除,面积范围
- this.numericUpDown2.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
- this.numericUpDown2.ValueChanged += this.applyButtonImpl;
- this.numericUpDown1.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
- this.numericUpDown1.ValueChanged += this.applyButtonImpl;
- //RGB/HLS的值
- this.numericUpDown4.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
- this.numericUpDown3.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
- this.numericUpDown6.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
- this.numericUpDown5.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
- this.numericUpDown8.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
- this.numericUpDown7.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
- //单个目标->容许值
- this.numericUpDown9.ValueChanged += new System.EventHandler(this.numericUpDown9_ValueChanged);
- this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
- GetListParamModel();
- }
- /// <summary>
- /// listView选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ListViewSelectedIndexChanged(object sender, EventArgs e)
- {
- if(this.listView1.SelectedItems!=null && this.listView1.SelectedItems.Count>0)
- {
- this.appWorkspace.ActiveDocumentWorkspace = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index];
- //清空相
- this.documentWorkspace.PhaseModels.Clear();
- this.currentPhase = 0;
- this.countPhase = 0;
- this.model = null;
- this.panel2.BackColor = Color.Transparent;
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- this.documentWorkspace.Refresh();
- //修改标记
- this.firstFlag = false;
- existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList.IsExsitView();
- bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].CompositionSurface.CreateAliasedBitmap();
- if (!existViewFlag)
- {
- mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
- }
- else
- {
- mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion());
- }
- //如果是hls被选中
- if (this.radioButton12.Checked)
- {
- mat = mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL);
- }
- //创建新Document
- Document document = Document.FromImage(bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- // TODO ZYH 这里需要根据业务判断,是否要copylist还是直接用?
- this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList;
- //this.pictureBox1.BackgroundImage = map;
- //this.applyButtonImpl(sender, e);
- //清空所有相
- this.documentWorkspace.PhaseModels.Clear();
- //显示直方图
- this.histogramControl1.CreateHistogram(this.bitmap, false, 187, 129, HistogramRGBSelect);
- //添加一个默认相
- //初始化一个相
- AddPhase("默认相", Color.Red.ToArgb());
- }
- }
- /// <summary>
- /// 初始化图片列表数据
- /// </summary>
- public void InitData()
- {
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);//.CreateAliasedBitmap()
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- index = i;
- }
- }
- //
- // 初始化选中的数据
- //
- this.listView1.Items[index].Selected = true; //选中行
- }
- /// <summary>
- /// 创建新图片
- /// </summary>
- /// <param name="mat"></param>
- private void OpenFileImpl()
- {
- if(bitmap != null)
- {
- DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
- dw.Document = Document.FromImage(bitmap);
- // TODO ZYH 这里的图像名称,需要走系统的配置
- dw.fileText = this.Text + "-00" + Startup.instance.step_length;
- //获取图像对应标尺
- dw.xmlSaveModel = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].xmlSaveModel;
- dw.rules = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].rules;
- this.appWorkspace.ActiveDocumentWorkspace = dw;
- //this.appWorkspace.ActiveDocumentWorkspace.PanelBottom.documentStrip.ShowPictures = false;
- this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.documentWorkspace.PhaseModels;
- Startup.instance.step_length += 1;
- this.appWorkspace.ActiveDocumentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 应用
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void applyButtonImpl(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count>0)
- {
- if (model != null && model.mat != null)
- {
- if (existViewFlag)
- {
- ImageActionWithView();
- }
- else
- {
- ImageActionNoView();
- }
- }
- }
- }
- /// <summary>
- /// 实心
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
- arr.Value = StyleParameters.Solid;
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 边线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
- arr.Value = StyleParameters.Sideline;
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 整个图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton4_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton4.Checked)
- {
- BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
- booleanObject0.Value = true;
- BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
- booleanObject1.Value = false;
- this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
- this.groupBox12.Visible = false;
- this.groupBox13.Visible = false;
- this.groupBox5.Visible = true;
- this.groupBox7.Visible = true;
- this.groupBox8.Visible = true;
- this.groupBox9.Visible = true;
- this.groupBox11.Visible = true;
- }
- }
- /// <summary>
- /// 容许值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void userTextBox2Change(object sender, EventArgs e)
- {
- tolerance = (int)this.userTextBox2.Value;
- }
- /// <summary>
- /// 单个目标
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton3_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton3.Checked)
- {
- BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
- booleanObject0.Value = false;
- BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
- booleanObject1.Value = true;
- this.documentWorkspace.ActiveTool = DrawToolType.ColorPicker;
- this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
- this.groupBox5.Visible = false;
- this.groupBox7.Visible = false;
- this.groupBox8.Visible = false;
- this.groupBox9.Visible = false;
- this.groupBox11.Visible = false;
- this.groupBox12.Visible = true;
- this.groupBox13.Visible = true;
- }
- if (this.radioButton4.Checked)
- {
- this.documentWorkspace.panel.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 上一个
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button10_Click(object sender, EventArgs e)
- {
- if (this.currentPhase > 1)
- {
- this.checkBox5.Checked = false;
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
- this.currentPhase--;
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
- this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
- this.documentWorkspace.Refresh();
- this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- this.SetRGBOrHLSNumericValue();
- }
- }
- /// <summary>
- /// 下一个
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.currentPhase < this.countPhase)
- {
- this.checkBox5.Checked = false;
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
- this.currentPhase++;
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
- this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
- this.documentWorkspace.Refresh();
- this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- this.SetRGBOrHLSNumericValue();
- }
- }
- /// <summary>
- /// 切换上一个下一个的时候设置RGB/HLS区间的值
- /// </summary>
- private void SetRGBOrHLSNumericValue()
- {
- this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
- if (this.model.rgborhls == 1)
- {
- this.radioButton13.Checked = true;
- this.numericUpDown4.Value = this.model.minB;
- this.numericUpDown3.Value = this.model.maxB;
- this.numericUpDown6.Value = this.model.minG;
- this.numericUpDown5.Value = this.model.maxG;
- this.numericUpDown8.Value = this.model.minR;
- this.numericUpDown7.Value = this.model.maxR;
- }
- else if (this.model.rgborhls == 2)
- {
- this.radioButton12.Checked = true;
- this.numericUpDown4.Value = this.model.minH;
- this.numericUpDown3.Value = this.model.maxH;
- this.numericUpDown6.Value = this.model.minL;
- this.numericUpDown5.Value = this.model.maxL;
- this.numericUpDown8.Value = this.model.minS;
- this.numericUpDown7.Value = this.model.maxS;
- }
- switch(this.HistogramRGBSelect)
- {
- case 1:
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
- break;
- case 2:
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
- break;
- case 3:
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
- break;
- }
-
- this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
- {
- Color color = (this.documentWorkspace.phaseModels.Count>0) ? BaseTools.GetRandomColor(Color.FromArgb(this.documentWorkspace.phaseModels[this.documentWorkspace.phaseModels.Count - 1].color)) : Color.Red;
- using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, "相"+(this.documentWorkspace.phaseModels.Count+1), color, false))
- {
- addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
- addPhaseDialog.ShowDialog();
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if(model!=null)
- {
- if (MessageBox.Show(PdnResources.GetString("Menu.Confirmtodeletecurrentphase.text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- //删除相
- this.documentWorkspace.PhaseModels.Remove(model);
- if (this.documentWorkspace.PhaseModels.Count > 0)
- {
- this.currentPhase--;
- //如果当前的相不是第一个,就--
- if (this.currentPhase == 0)
- this.currentPhase++;
- this.countPhase = this.documentWorkspace.PhaseModels.Count;
- this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
- }
- else
- {
- this.currentPhase = 0;
- this.countPhase = 0;
- this.model = null;
- }
- if(this.currentPhase==0)
- this.panel2.BackColor = Color.Transparent;
- else
- this.panel2.BackColor = Color.FromArgb(this.model.color);
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- this.documentWorkspace.Refresh();
- }
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if(model!=null)
- {
- using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, model.name, Color.FromArgb(model.color), true))
- {
- addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
- addPhaseDialog.ShowDialog();
- }
- }
- }
- /// <summary>
- /// 点击确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
- {
- //生成新图-是
- if (this.checkBox1.Checked)
- {
- this.OpenFileImpl();
- }
- else
- {
- if (this.documentWorkspace.PhaseModels.Count > 0)
- {
- List<PhaseModel> models = new List<PhaseModel>();
- foreach (PhaseModel temp in this.documentWorkspace.PhaseModels)
- {
- PhaseModel model = new PhaseModel();
- model.choise = temp.choise;
- model.color = temp.color;
- model.mat = temp.mat;
- model.name = temp.name;
- model.position = temp.position;
- models.Add(model);
- }
- this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].PhaseModels = models;
- this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].Refresh();
- }
- }
- }
- //this.Close();
- }
- /// <summary>
- /// RGB radio改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton13_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton13.Checked)
- {
- ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = true;
- ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = false;
- this.label2.Text = "R";
- this.label5.Text = "G";
- this.label6.Text = "B";
- this.button13.Text = "R";
- this.button14.Text = "G";
- this.button15.Text = "B";
- this.firstFlag = false;
- this.numericUpDown3.Value = 0;
- this.numericUpDown4.Value = 0;
- this.numericUpDown5.Value = 0;
- this.numericUpDown6.Value = 0;
- this.numericUpDown7.Value = 0;
- this.numericUpDown8.Value = 0;
- this.mat = this.mat != null ? OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap) : null;
- //清空所有相,应该是清空相的内容
- if (this.model != null)
- {
- this.model.mat = null;
- this.model.rgborhls = 1;
- }
- this.documentWorkspace.Refresh();
- //更新直方图
- if(this.bitmap!=null)
- this.histogramControl1.CreateHistogram(this.bitmap, false, 187, 129, HistogramRGBSelect);
- //this.documentWorkspace.PhaseModels.Clear();
- }
- }
- /// <summary>
- /// HLS radio改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton12_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton12.Checked)
- {
- ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = false;
- ((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = true;
- this.label2.Text = "H";
- this.label5.Text = "L";
- this.label6.Text = "S";
- this.button13.Text = "H";
- this.button14.Text = "L";
- this.button15.Text = "S";
- this.firstFlag = false;
- this.numericUpDown3.Value = 0;
- this.numericUpDown4.Value = 0;
- this.numericUpDown5.Value = 0;
- this.numericUpDown6.Value = 0;
- this.numericUpDown7.Value = 0;
- this.numericUpDown8.Value = 0;
- this.mat = this.mat!=null ? this.mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL) : null;
- //清空所有相,应该是清空相的内容
- if(this.model!=null)
- {
- this.model.mat = null;
- this.model.rgborhls = 2;
- }
- this.documentWorkspace.Refresh();
- //更新直方图
- if (this.mat != null)
- {
- this.histogramControl1.CreateHistogram(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.mat), false, 187, 129, HistogramRGBSelect);
- }
- }
- }
- /// <summary>
- /// 绘制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void pictureBox1_Paint(object sender, PaintEventArgs e)
- {
- if(this.mat!=null)
- {
- if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
- {
- Vec3b a = mat.At<Vec3b>(y, x);
- string b = x + "," + y;
- b += "\r\n" + "R:" + a.Item2;
- b += "\r\n" + "G:" + a.Item1;
- b += "\r\n" + "B:" + a.Item0;
- e.Graphics.DrawString(b, new Font("宋体", 12), new SolidBrush(Color.Red), ox + 5, oy + 5);
- }
- }
- }
- /// <summary>
- /// surfaceBox双击事件
- /// 目前是参考AxioVision
- /// 应该是把每次选的点都取最高和最低的BGR
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private unsafe void pictureBox1_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.documentWorkspace.activeTool == DrawToolType.MoveMode)
- return;
- if (!this.radioButton3.Checked && !this.radioButton6.Checked) {
- return;
- }
- if (color == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text"));
- return;
- }
- if (mat == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
- return;
- }
- //判断点击位置,是否是图片上
- if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
- {
- //删除
- if (this.radioButton10.Checked)
- {
- if(this.model.mat!=null)
- {
- //当前相颜色
- Color currentColor = Color.FromArgb(color);
- b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
- //如果存在视场 需要判断是否在视场内
- if (existViewFlag)
- {
- if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
- {
- return;
- }
- /*else
- {
- Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
- mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
- }*/
- }
- //获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
- //vec3b = mat.At<Vec3b>(y, x);
- //容许值
- tolerance = (int)this.userTextBox2.Value;
- //范围大小
- int range = (int)this.userTextBox1.Value;
- //对每个像素点的操作
- byte* pixels = (byte*)mat.Data;
- //循环范围大小内的所有点
- //maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
- int y1 = (y - range) < 0 ? 0 : (y - range);
- int x1 = (x - range) < 0 ? 0 : (x - range);
- int hw = range * 2 + 1;
- int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
- int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
-
- this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
- Vec3b vec3B = mat.At<Vec3b>(y, x);
- byte b = vec3B.Item0;
- byte g = vec3B.Item1;
- byte r = vec3B.Item2;
- if (b> this.numericUpDown8.Value && b< this.numericUpDown7.Value)
- {
- int b2 = (int)(-this.numericUpDown8.Value + this.numericUpDown7.Value) / 2;
- if (b > b2)
- {
- maxB = b;
- this.numericUpDown7.Value = maxB;
- }
- else
- {
- minB = b;
- this.numericUpDown8.Value = minB;
- }
- }
- if (g > this.numericUpDown6.Value && g < this.numericUpDown5.Value)
- {
- int g2 = (int)(-this.numericUpDown6.Value + this.numericUpDown5.Value) / 2;
- if (g > g2)
- {
- maxG = g;
- this.numericUpDown5.Value = maxG;
- }
- else
- {
- minG = g;
- this.numericUpDown6.Value = minG;
- }
- }
- if (r > this.numericUpDown4.Value && r < this.numericUpDown3.Value)
- {
- int r2 = (int)(-this.numericUpDown4.Value + this.numericUpDown3.Value) / 2;
- if (r > r2)
- {
- maxR = r;
- this.numericUpDown3.Value = maxR;
- }
- else
- {
- minR = r;
- this.numericUpDown4.Value = minR;
- }
- }
- if (tolerance > 0)
- {
- if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minB = 0;
- if (255 - maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxB = 255;
- if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minG = 0;
- if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxG = 255;
- if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minR = 0;
- if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxR = 255;
- }
- this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
- xn = x;
- yn = y;
- //对于存在视场,不存在进行不同操作
- if (existViewFlag)
- {
- ImageActionWithViewForDelete();
- }
- else
- {
- ImageActionNoViewForDelete();
- }
- if (this.radioButton4.Checked)
- {
- this.SetPhaseModelRGBOrHLS();
- }
- else if (this.radioButton3.Checked)
- {
- this.AddDictStepByClick();
- }
- this.UpdateHistogramStartAndEnd();
- }
- }
- else
- {
- //当前相颜色
- Color currentColor = Color.FromArgb(color);
- b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
- //如果存在视场 需要判断是否在视场内
- if (existViewFlag)
- {
- if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
- {
- return;
- }
- /*else
- {
- Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
- mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
- }*/
- }
- //获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
- //vec3b = mat.At<Vec3b>(y, x);
- //容许值
- tolerance = (int)this.userTextBox2.Value;
- //范围大小
- int range = (int)this.userTextBox1.Value;
- //对每个像素点的操作
- byte* pixels = (byte*)mat.Data;
- //循环范围大小内的所有点
- maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
- int y1 = (y - range) < 0 ? 0 : (y - range);
- int x1 = (x - range) < 0 ? 0 : (x - range);
- int hw = range * 2 + 1;
- int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
- int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
- for (int m = y1; m < nh; m++)
- {
- int offsetRow = m * this.documentWorkspace.CompositionSurface.Width;
- for (int n = x1; n < nw; n++)
- {
- int offset = (offsetRow + n) * this.mat.Channels();
- byte vB = pixels[offset];
- byte vG = pixels[offset + 1];
- byte vR = pixels[offset + 2];
- if (vB > maxB) maxB = vB;
- if (vB < minB) minB = vB;
- if (vG > maxG) maxG = vG;
- if (vG < minG) minG = vG;
- if (vR > maxR) maxR = vR;
- if (vR < minR) minR = vR;
- }
- }
- if (tolerance > 0)
- {
- if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minB = 0;
-
- if(255- maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxB = 255;
- if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minG = 0;
- if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxG = 255;
- if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- minR = 0;
- if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
- maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
- else
- maxR = 255;
- }
- xn = x;
- yn = y;
- //对于存在视场,不存在进行不同操作
- if (existViewFlag)
- {
- ImageActionWithView();
- }
- else
- {
- ImageActionNoView();
- }
- if (this.radioButton4.Checked)
- {
- this.SetPhaseModelRGBOrHLS();
- }
- else if (this.radioButton3.Checked)
- {
- this.AddDictStepByClick();
- }
- this.UpdateHistogramStartAndEnd();
- }
- }
- }
- catch(Exception e1)
- {
- System.Console.WriteLine(e1.ToString());
- }
- finally
- {
- if (mat1 != null && mat1.IsDisposed) mat1.Dispose();
- }
- }
- private unsafe void DelForEachAsVec3b(Vec3b* value, int* position)
- {
- if (value->Item0 == 0 && value->Item1 == 0 && value->Item2 == 0)
- {
- this.model.mat.Set<Vec4b>(position[0], position[1], new Vec4b(0, 0, 0, 0));
- }
- }
- /// <summary>
- /// 有视场的图像处理
- /// </summary>
- private void ImageActionWithView()
- {
- if (model == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
- return;
- }
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- //获取颜色区间
- mouseClick = true;
- if (!this.doOrRedo)
- this.CalcRGBOrHLSValue();
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
- OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap),
- model, new System.Drawing.Point());
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap), model, new System.Drawing.Point());
- }
- mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
- OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap),
- model, new System.Drawing.Point(xn, yn));
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap), model, new System.Drawing.Point(xn, yn));
- }
- }
- Mat temp = new Mat();
- mat1.CopyTo(temp);
- model.mat = temp;
- this.documentWorkspace.Refresh();
- firstFlag = true;
- }
- /// <summary>
- /// 无视场的图像处理
- /// </summary>
- private void ImageActionNoView()
- {
- if(model==null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
- return;
- }
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- //获取颜色区间
- mouseClick = true;
- if (!this.doOrRedo)
- this.CalcRGBOrHLSValue();
- mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
- mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
- }
- Mat temp = new Mat();
- mat1.CopyTo(temp);
- model.mat = temp;
- this.documentWorkspace.Refresh();
- firstFlag = true;
- }
- private void ImageActionWithViewForDelete()
- {
- if (model == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
- return;
- }
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- //获取颜色区间
- mouseClick = true;
- if (!this.doOrRedo)
- //this.CalcRGBOrHLSValue();
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
- OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap),
- model, new System.Drawing.Point());
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap), model, new System.Drawing.Point());
- }
- mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
- OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap),
- model, new System.Drawing.Point(xn, yn));
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap), model, new System.Drawing.Point(xn, yn));
- }
- }
- Mat temp = new Mat();
- mat1.CopyTo(temp);
- model.mat = temp;
- this.documentWorkspace.Refresh();
- firstFlag = true;
- }
- private void ImageActionNoViewForDelete()
- {
- if (model == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
- return;
- }
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- //获取颜色区间
- mouseClick = true;
- if (!this.doOrRedo)
- //this.CalcRGBOrHLSValueForDelete();
- mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
- mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
- }
- Mat temp = new Mat();
- mat1.CopyTo(temp);
- model.mat = temp;
- this.documentWorkspace.Refresh();
- firstFlag = true;
- }
-
- /// <summary>
- /// 鼠标进入pictureBox
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void pictureBox1_MouseEnter(object sender, EventArgs e)
- {
- this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
- }
- private void pictureBox1_MouseLeave(object sender, EventArgs e)
- {
- this.Cursor = Cursors.Default;
- }
- private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
- {
- ox = e.X;
- oy = e.Y;
- System.Drawing.Point point = this.documentWorkspace.GetScalePoint(new System.Drawing.Point(e.X, e.Y));
- y = point.Y;
- x = point.X;
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 更新相
- /// </summary>
- /// <param name="name"></param>
- /// <param name="color"></param>
- public void UpdatePhase(string name, int color)
- {
- this.model.name = name;
- this.model.color = color;
- Color currentColor = Color.FromArgb(color);
- this.b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
- this.panel2.BackColor = currentColor;
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
- }
- else
- {
- this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(x, y));
- }
- Mat temp = new Mat();
- this.mat1.CopyTo(temp);
- this.model.mat = temp;
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 新增相
- /// </summary>
- /// <param name="name"></param>
- /// <param name="color"></param>
- public void AddPhase(string name, int color)
- {
- //设置之前的相都不绘制
- if(!this.checkBox5.Checked)
- {
- for (int i = 0; i < this.documentWorkspace.PhaseModels.Count; i++)
- {
- this.documentWorkspace.PhaseModels[i].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- //标记初始化
- this.firstFlag = false;
- //创建并添加相
- this.model = new PhaseModel();
- this.model.choise = true;
- this.model.mat = null;
- this.model.color = color;
- this.model.position = this.documentWorkspace.PhaseModels.Count + 1;
- this.model.name = name;
- this.documentWorkspace.PhaseModels.Add(model);
- this.color = color;
- this.panel2.BackColor = Color.FromArgb(color);
- this.countPhase++;
- this.currentPhase = this.countPhase;
- this.label1.Text = this.countPhase + "/" + this.countPhase;
- //处理rgb/hls界面
- this.radioButton13.Checked = true;
- this.numericUpDown4.Value = 0;
- this.numericUpDown3.Value = 0;
- this.numericUpDown6.Value = 0;
- this.numericUpDown5.Value = 0;
- this.numericUpDown8.Value = 0;
- this.numericUpDown7.Value = 0;
- //添加到步骤
- MultiPhaseStepModel temp = new MultiPhaseStepModel();
- temp.currentPhase = this.currentPhase;
- this.steps.Add(temp);
- this.currentPosition++;
- }
- /// <summary>
- /// 撤销
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button12_Click(object sender, EventArgs e)
- {
- if (this.currentPosition <= 0)
- return;
- this.doOrRedo = true;
- this.currentPosition--;
- MultiPhaseStepModel temp = this.steps[this.currentPosition];
- //判断相是否变化,相变化则进行切换
- if(temp.currentPhase != this.currentPhase)
- {
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
- this.currentPhase = temp.currentPhase;
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
- this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
- this.documentWorkspace.Refresh();
- this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- if (this.radioButton4.Checked)
- this.SetRGBOrHLSNumericValue();
- }
- else
- {
- this.model.rgborhls = temp.rgborhls;
- this.model.minR = temp.minR;
- this.model.maxR = temp.maxR;
- this.model.minG = temp.minG;
- this.model.maxG = temp.maxG;
- this.model.minB = temp.minB;
- this.model.maxB = temp.maxB;
- this.model.minH = temp.minH;
- this.model.maxH = temp.maxH;
- this.model.minL = temp.minL;
- this.model.maxL = temp.maxL;
- this.model.minS = temp.minS;
- this.model.maxS = temp.maxS;
- if (this.radioButton4.Checked)
- this.SetRGBOrHLSNumericValue();
- }
-
- this.applyButtonImpl(null, null);
-
- this.doOrRedo = false;
- }
- /// <summary>
- /// 重做
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button11_Click(object sender, EventArgs e)
- {
- if (this.currentPosition >= this.steps.Count-1)
- return;
- this.doOrRedo = true;
- this.currentPosition++;
- MultiPhaseStepModel temp = this.steps[this.currentPosition];
- //判断相是否变化,相变化则进行切换
- if (temp.currentPhase != this.currentPhase)
- {
- this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = false;
- this.currentPhase = temp.currentPhase;
- this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = true;
- this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
- this.documentWorkspace.Refresh();
- this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
- this.label1.Text = this.currentPhase + "/" + this.countPhase;
- if (this.radioButton4.Checked)
- this.SetRGBOrHLSNumericValue();
- }
- else
- {
- this.model.rgborhls = temp.rgborhls;
- this.model.minR = temp.minR;
- this.model.maxR = temp.maxR;
- this.model.minG = temp.minG;
- this.model.maxG = temp.maxG;
- this.model.minB = temp.minB;
- this.model.maxB = temp.maxB;
- this.model.minH = temp.minH;
- this.model.maxH = temp.maxH;
- this.model.minL = temp.minL;
- this.model.maxL = temp.maxL;
- this.model.minS = temp.minS;
- this.model.maxS = temp.maxS;
- if (this.radioButton4.Checked)
- this.SetRGBOrHLSNumericValue();
- }
- this.applyButtonImpl(null, null);
- this.doOrRedo = false;
- }
- /// <summary>
- /// 重置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button8_Click(object sender, EventArgs e)
- {
- if(this.documentWorkspace.PhaseModels != null
- && this.currentPhase > 0)
- {
- this.documentWorkspace.PhaseModels[this.currentPhase - 1].mat = null;
- this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
- this.numericUpDown8.Value = 0;
- this.numericUpDown7.Value = 0;
- this.numericUpDown6.Value = 0;
- this.numericUpDown5.Value = 0;
- this.numericUpDown4.Value = 0;
- this.numericUpDown3.Value = 0;
- //this.numericUpDown9.Value = 0;
- this.maxB = 0;
- this.minB = 255;
- this.maxG = 0;
- this.minG = 255;
- this.maxR = 0;
- this.minR = 255;
- this.firstFlag = false;
- this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
- this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
- this.documentWorkspace.Refresh();
- }
- //清空所有步骤
- this.steps.Clear();
- //设置当前步骤为-1
- this.currentPosition = -1;
- }
- /// <summary>
- /// 删除边界对象
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox2_CheckedChanged(object sender, EventArgs e)
- {
- BooleanObject choiseArray = (BooleanObject)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("deleteRect"));
- choiseArray.Value = this.checkBox2.Checked;
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 孔洞填充
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox3_CheckedChanged(object sender, EventArgs e)
- {
- action.Lists[0].choiseList[0].lists[4].Value = this.checkBox3.Checked;
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 碎屑删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox4_CheckedChanged(object sender, EventArgs e)
- {
- action.Lists[0].choiseList[0].lists[5].Value = this.checkBox4.Checked;
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 单个目标->偏差
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown9_ValueChanged(object sender, EventArgs e)
- {
- this.action.Lists[0].choiseList[1].Lists[0].Value = this.numericUpDown9.Value;
- this.trackBar1.Value = (int)(this.numericUpDown9.Value);
- }
- /// <summary>
- /// 单个目标->偏差
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void trackBar1_ValueChanged(object sender, EventArgs e)
- {
- this.numericUpDown9.Value = this.trackBar1.Value;
- this.action.Lists[0].choiseList[1].Lists[0].Value = this.trackBar1.Value;
- //this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 定义物体 - 轮廓
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton5_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton5.Checked)
- {
- ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
- BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
- booleanObject1.Value = true;
- BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
- booleanObject0.Value = false;
- this.panel1.Visible = true;
- this.radioButton14_CheckedChanged(null, null);
- }
- }
- /// <summary>
- /// RGB/HLS的Button的R/H点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button13_Click(object sender, EventArgs e)
- {
- this.HistogramRGBSelect = 1;
- this.button13.FlatStyle = FlatStyle.Flat;
- this.button13.BackColor = Color.FromArgb(225,225,225);
- this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
- this.button13.FlatAppearance.BorderSize = 1;
- this.button14.FlatStyle = FlatStyle.Standard;
- this.button14.BackColor = Control.DefaultBackColor;
- this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
- this.button15.FlatStyle = FlatStyle.Standard;
- this.button15.BackColor = Control.DefaultBackColor;
- this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
-
- }
- /// <summary>
- /// RGB/HLS的Button的G/L点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button14_Click(object sender, EventArgs e)
- {
- this.HistogramRGBSelect = 2;
- this.button13.FlatStyle = FlatStyle.Standard;
- this.button13.BackColor = Control.DefaultBackColor;
- this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
- this.button14.FlatStyle = FlatStyle.Flat;
- this.button14.BackColor = Color.FromArgb(225, 225, 225);
- this.button14.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
- this.button14.FlatAppearance.BorderSize = 1;
- this.button15.FlatStyle = FlatStyle.Standard;
- this.button15.BackColor = Control.DefaultBackColor;
- this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
- //this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
- }
- /// <summary>
- /// RGB/HLS的Button的B/S点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button15_Click(object sender, EventArgs e)
- {
- this.HistogramRGBSelect = 3;
- this.button13.FlatStyle = FlatStyle.Standard;
- this.button13.BackColor = Control.DefaultBackColor;
- this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
- this.button14.FlatStyle = FlatStyle.Standard;
- this.button14.BackColor = Control.DefaultBackColor;
- this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
- this.button15.FlatStyle = FlatStyle.Flat;
- this.button15.BackColor = Color.FromArgb(225, 225, 225);
- this.button15.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
- this.button15.FlatAppearance.BorderSize = 1;
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
- //this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
- }
- /// <summary>
- /// 定义物体 - 点击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton6_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton6.Checked)
- {
- ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
- BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
- booleanObject1.Value = false;
- BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
- booleanObject0.Value = true;
- this.panel1.Visible = false;
- this.documentWorkspace.activeTool = DrawToolType.Pointer;
- }
- }
- /// <summary>
- /// 移除未完成的定义物体的轮廓的对象
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PhaseExtractDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- this.documentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.PhaseExtraction);
- SaveDialogParam();
- }
- /// <summary>
- /// 定义物体 - 轮廓 - 多边形
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton14_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton5.Checked && this.radioButton14.Checked)
- {
- ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
- StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
- choiseArray1.Value = ContourParameters.Polygon;
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.PPhasePolygon;
- }
- }
- /// <summary>
- /// 定义物体 - 轮廓 - 矩形
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton15_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton5.Checked && this.radioButton15.Checked)
- {
- ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
- StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
- choiseArray1.Value = ContourParameters.Rectangle;
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.PPhaseRectangle;
- }
- }
- /// <summary>
- /// 定义物体 - 轮廓 - 椭圆
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton16_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton5.Checked && this.radioButton16.Checked)
- {
- ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
- StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
- choiseArray1.Value = ContourParameters.Oval;
- this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.PPhaseOval;
- }
- }
- /// <summary>
- /// RGB或HLS值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void RGBoRHLSValue_Changed(object sender, EventArgs e)
- {
- if (!mouseClick)
- {
- if (color == 0)
- {
- return;
- }
- if (mat == null)
- {
- return;
- }
- //处理直方图相关
- this.UpdateHistogramStartAndEnd();
- //修改当前model的rgb或hls
- this.SetPhaseModelRGBOrHLS((NumericUpDown)sender);
- this.applyButtonImpl(null, null);
- /*mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
- Mat temp = new Mat();
- mat1.CopyTo(temp);
- model.mat = temp;
- this.documentWorkspace.Refresh();*/
- }
- }
- /// <summary>
- /// 修改当前model的rgb或hls
- /// </summary>
- private void SetPhaseModelRGBOrHLS(NumericUpDown numericUpDown = null)
- {
- if (this.model == null)
- return;
- if (this.radioButton13.Checked)
- {
- //修改当前model的值
- this.model.minB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
- this.model.maxB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
- this.model.minG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
- this.model.maxG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
- this.model.minR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
- this.model.maxR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
-
- this.AddDictStep(1);
- }
- else if (this.radioButton12.Checked)
- {
- //修改当前model的值
- this.model.minH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
- this.model.maxH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
- this.model.minL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
- this.model.maxL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
- this.model.minS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
- this.model.maxS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
- this.AddDictStep(2);
- }
- }
- private void AddDictStepByClick()
- {
- MultiPhaseStepModel temp = new MultiPhaseStepModel();
- temp.currentPhase = currentPhase;
- temp.wholeorsingle = 2;
- temp.point = new System.Drawing.Point(xn, yn);
- this.steps.Add(temp);
- this.currentPosition++;
- }
- /// <summary>
- /// 向字典内添加步骤
- /// </summary>
- /// <param name="type"></param>
- private void AddDictStep(int type)
- {
- if (this.doOrRedo)
- return;
-
- MultiPhaseStepModel temp = new MultiPhaseStepModel();
- temp.currentPhase = currentPhase;
- temp.rgborhls = type;
- if(temp.rgborhls==1)
- {
- temp.minR = this.model.minR;
- temp.maxR = this.model.maxR;
- temp.minG = this.model.minG;
- temp.maxG = this.model.maxG;
- temp.minB = this.model.minB;
- temp.maxB = this.model.maxB;
- }
- else if(temp.rgborhls == 2)
- {
- temp.minH = this.model.minH;
- temp.maxH = this.model.maxH;
- temp.minL = this.model.minL;
- temp.maxL = this.model.maxL;
- temp.minS = this.model.minS;
- temp.maxS = this.model.maxS;
- }
- this.steps.Add(temp);
- this.currentPosition++;
- }
- /// <summary>
- /// 显示全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox5_CheckedChanged(object sender, EventArgs e)
- {
- if(this.checkBox5.Checked)
- {
- foreach(PhaseModel model in this.documentWorkspace.PhaseModels)
- {
- model.choise = true;
- }
- this.documentWorkspace.Refresh();
- }
- else
- {
- foreach (PhaseModel model in this.documentWorkspace.PhaseModels)
- {
- model.choise = false;
- }
- this.model.choise = true;
- this.documentWorkspace.Refresh();
- }
- }
- private void UpdateHistogramStartAndEnd()
- {
- if (this.HistogramRGBSelect == 1)
- {
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
- }
- if (this.HistogramRGBSelect == 2)
- {
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
- }
- if (this.HistogramRGBSelect == 3)
- {
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
- }
- }
- /// <summary>
- /// 鼠标点击的时候调用
- /// </summary>
- private void CalcRGBOrHLSValue()
- {
- int rl = (int)this.numericUpDown4.Value; //r起
- int rr = (int)this.numericUpDown3.Value; //r止
- if (firstFlag)
- {
- this.numericUpDown4.Value = minR < rl ? minR : rl;
- this.numericUpDown3.Value = rr > maxR ? rr : maxR;
- }
- else
- {
- this.numericUpDown4.Value = minR;
- this.numericUpDown3.Value = maxR;
- }
- int gl = (int)this.numericUpDown6.Value; //g起
- int gr = (int)this.numericUpDown5.Value; //g止
- if (firstFlag)
- {
- this.numericUpDown6.Value = minG < gl ? minG : gl;
- this.numericUpDown5.Value = gr > maxG ? gr : maxG;
- }
- else
- {
- this.numericUpDown6.Value = minG;
- this.numericUpDown5.Value = maxG;
- }
- int bl = (int)this.numericUpDown8.Value; //b起
- int br = (int)this.numericUpDown7.Value; //b止
- if (firstFlag)
- {
- this.numericUpDown8.Value = minB < bl ? minB : bl;
- this.numericUpDown7.Value = br > maxB ? br : maxB;
- }
- else
- {
- this.numericUpDown8.Value = minB;
- this.numericUpDown7.Value = maxB;
- }
- }
- private void CalcRGBOrHLSValueForDelete()
- {
- int rl = (int)this.numericUpDown4.Value; //r起
- int rr = (int)this.numericUpDown3.Value; //r止
- if (firstFlag)
- {
- this.numericUpDown4.Value = minR > rl ? minR : rl;
- this.numericUpDown3.Value = rr < maxR ? rr : maxR;
- }
- else
- {
- this.numericUpDown4.Value = minR;
- this.numericUpDown3.Value = maxR;
- }
- int gl = (int)this.numericUpDown6.Value; //g起
- int gr = (int)this.numericUpDown5.Value; //g止
- if (firstFlag)
- {
- this.numericUpDown6.Value = minG > gl ? minG : gl;
- this.numericUpDown5.Value = gr < maxG ? gr : maxG;
- }
- else
- {
- this.numericUpDown6.Value = minG;
- this.numericUpDown5.Value = maxG;
- }
- int bl = (int)this.numericUpDown8.Value; //b起
- int br = (int)this.numericUpDown7.Value; //b止
- if (firstFlag)
- {
- this.numericUpDown8.Value = minB > bl ? minB : bl;
- this.numericUpDown7.Value = br < maxB ? br : maxB;
- }
- else
- {
- this.numericUpDown8.Value = minB;
- this.numericUpDown7.Value = maxB;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton10_CheckedChanged(object sender, EventArgs e)
- {
- if(this.radioButton10.Checked)
- {
- this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Delete;
- }
- }
- /// <summary>
- /// 追加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton11_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton11.Checked)
- {
- this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Add;
- }
- }
- /// <summary>
- /// 目标选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void objectSelect_CheckChanged(object sender, EventArgs e)
- {
- if (this.radioButton8.Checked)
- {
- StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
- choiseArray.Value = FieldOfViewParameters.One;
- }
- else if (this.radioButton7.Checked)
- {
- StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
- choiseArray.Value = FieldOfViewParameters.Two;
- }
- else if (this.radioButton9.Checked)
- {
- StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
- choiseArray.Value = FieldOfViewParameters.Three;
- }
- this.applyButtonImpl(sender, e);
- }
- /// <summary>
- /// 碎屑删除 范围参数1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- numericUpDown2.Value = Math.Max(numericUpDown2.Value, numericUpDown1.Value);
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "scope4")
- {
- ((List<double>)args.Value)[0] = (double)numericUpDown1.Value;
- ((List<double>)args.Value)[1] = (double)numericUpDown2.Value;
- break;
- }
- }
- }
- /// <summary>
- /// 碎屑删除 范围参数2
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- numericUpDown1.Value = Math.Min(numericUpDown1.Value, numericUpDown2.Value);
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "scope4")
- {
- ((List<double>)args.Value)[0] = (double)numericUpDown1.Value;
- ((List<double>)args.Value)[1] = (double)numericUpDown2.Value;
- break;
- }
- }
- }
- #region 参数保存及提取
- /// <summary>
- /// 保存参数的key,value和type
- /// </summary>
- /// <param name="param_key"></param>
- /// <param name="param_value"></param>
- /// <param name="param_type"></param>
- private void saveParamValue(string param_key, string param_value, int param_type)
- {
- bool foundItem = false;
- foreach (var item in this.analysisModel.ListParam)
- {
- if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
- {
- item.param_value = param_value;
- item.setValue();
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- {
- GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
- analysisItem.menuId = this.menuId;
- analysisItem.param_key = param_key;
- analysisItem.param_type = param_type;
- analysisItem.param_value = param_value;
- analysisItem.setValue();
- this.analysisModel.ListParam.Add(analysisItem);
- }
- }
- /// <summary>
- /// 保存界面中的参数到model
- /// </summary>
- private void saveDialogParamValues()
- {
- saveParamValue(ParamKey_ShowAll, this.checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示全部
- saveParamValue(ParamKey_NewPic, this.checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//创建新图
- saveParamValue(ParamKey_WholePic, this.radioButton4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
-
- saveParamValue(ParamKey_Click, this.radioButton6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
- saveParamValue(ParamKey_CkValue, this.userTextBox2.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标
- saveParamValue(ParamKey_CkRange, this.userTextBox1.Value.ToString(), (int)Base.Dtryt.Decimal);//整个图像
- saveParamValue(ParamKey_Outline, this.radioButton5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//轮廓
- saveParamValue(ParamKey_OPolygon, this.radioButton14.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//多边形
- saveParamValue(ParamKey_ORectangle, this.radioButton15.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//矩形
- saveParamValue(ParamKey_OEllipse, this.radioButton16.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//椭圆
- saveParamValue(ParamKey_Solid, this.radioButton1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值实心
- saveParamValue(ParamKey_Outer, this.radioButton2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值边线
- saveParamValue(ParamKey_Target1, this.radioButton8.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择1
- saveParamValue(ParamKey_Target2, this.radioButton7.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择2
- saveParamValue(ParamKey_Target3, this.radioButton9.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择3
- saveParamValue(ParamKey_Boundary, this.checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-删除边界对象
- saveParamValue(ParamKey_Holes, this.checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-孔洞填充
- saveParamValue(ParamKey_Detritus, this.checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-碎屑删除
- saveParamValue(ParamKey_Single, this.radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//单个目标
- saveParamValue(ParamKey_SDeviation, this.numericUpDown9.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标-偏差
- }
- /// <summary>
- /// 获取保存的参数
- /// </summary>
- private void GetListParamModel()
- {
- if (this.analysisModel != null)
- {
- for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
- {
- switch (this.analysisModel.ListParam[i].param_key)
- {
- case ParamKey_ShowAll:
- this.checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_NewPic:
- this.checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_WholePic:
- this.radioButton4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton4_CheckedChanged(null, null);
- break;
-
- //点击
- case ParamKey_Click:
- this.radioButton6.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton6_CheckedChanged(null, null);
- break;
- case ParamKey_CkValue:
- this.userTextBox2.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
- break;
- case ParamKey_CkRange:
- this.userTextBox1.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
- break;
- //轮廓
- case ParamKey_Outline:
- this.radioButton5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton5_CheckedChanged(null,null);
- break;
- case ParamKey_OPolygon:
- this.radioButton14.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //if(this.radioButton5.Checked && this.radioButton14.Checked)
- // radioButton14_CheckedChanged(null, null);
- break;
- case ParamKey_ORectangle:
- this.radioButton15.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //if (this.radioButton5.Checked && this.radioButton15.Checked)
- //radioButton15_CheckedChanged(null, null);
- break;
- case ParamKey_OEllipse:
- this.radioButton16.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //if (this.radioButton5.Checked && this.radioButton16.Checked)
- //radioButton16_CheckedChanged(null, null);
- break;
- //二值样式和目标选择
- case ParamKey_Solid:
- this.radioButton1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton1_CheckedChanged(null, null);
- break;
- case ParamKey_Outer:
- this.radioButton2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton2_CheckedChanged(null, null);
- break;
- case ParamKey_Target1:
- this.radioButton8.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton8_CheckedChanged(null, null);
- break;
- case ParamKey_Target2:
- this.radioButton7.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton7_CheckedChanged(null, null);
- break;
- case ParamKey_Target3:
- this.radioButton9.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton9_CheckedChanged(null, null);
- break;
- //处理细节
- case ParamKey_Boundary:
- this.checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_Holes:
- this.checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- case ParamKey_Detritus:
- this.checkBox4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- break;
- //单个处理
- case ParamKey_Single:
- this.radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
- //radioButton3_CheckedChanged(null, null);
- break;
- case ParamKey_SDeviation:
- this.numericUpDown9.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
- //numericUpDown9_ValueChanged(null, null);
- break;
- }
- }
- BackgroundImageSwitch();
- }
- }
- //目标切换
- private void BackgroundImageSwitch()
- {
- if (this.radioButton8.Checked)
- {
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- if (this.radioButton7.Checked)
- {
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- if (this.radioButton9.Checked)
- {
- this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
- this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- }
- }
- private void SaveDialogParam()
- {
- this.saveDialogParamValues();
- //xml保存路径
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- foreach (var analysisItem in this.analysisModel.ListParam)
- {
- bool foundItem = false;
- foreach (var item in analysisModelXml.ListParam)
- {
- if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
- {
- item.param_value = analysisItem.param_value;
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- analysisModelXml.ListParam.Add(analysisItem.cloneModel());
- }
- //按路径和名称保存xml文件
- string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
- //保存xml
- FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
- }
- #endregion
- }
- }
|