12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995 |
- 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.Threading;
- 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 Mat imageMat;
- /// <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();
- documentWorkspace.panel.MouseDown += (s, e) => { _timeMD = DateTime.Now; };
- 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.imageMat = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreatedAliasedMat();
- Document document = Document.FromImageMat(imageMat.Clone());
- 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.imageMat != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != 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 = imageMat.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();
- imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].CompositionSurface.CreatedAliasedMat();
- if (!existViewFlag)
- mat = imageMat.Clone();
- else
- mat = PaintDotNet.Camera.Tools.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.FromImageMat(imageMat.Clone());
- 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.imageMat, 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 (imageMat != null)
- {
- DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
- dw.Document = Document.FromImageMat(imageMat.Clone());
- // 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 ? this.imageMat.Clone() : null;
- //清空所有相,应该是清空相的内容
- if (this.model != null)
- {
- this.model.mat = null;
- this.model.rgborhls = 1;
- }
- this.documentWorkspace.Refresh();
- //更新直方图
- if (this.imageMat != null)
- this.histogramControl1.CreateHistogram(this.imageMat, 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(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 = PaintDotNet.Camera.Tools.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 = PaintDotNet.Camera.Tools.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));
- }
- }
- bool _working = false;
- //鼠标按下时间
- private DateTime _timeMD = DateTime.MaxValue;
- /// <summary>
- /// 有视场的图像处理
- /// </summary>
- private void ImageActionWithView()
- {
- if ((DateTime.Now - _timeMD).TotalMilliseconds > 150)
- return;
- if (_working) return;
- _working = true;
- //如果是整个图像
- if (this.radioButton4.Checked && !this.doOrRedo)
- this.CalcRGBOrHLSValue();
- TransferProgressDialog.ShowDialog(
- "物相提取", "正在进行物相提取,该过程可能执行较长时间请耐心等待......",
- () =>
- {
- ImageActionWithView1();
- _working = false;
- });
- }
- private void ImageActionWithView1()
- {
- if (model == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
- return;
- }
- //如果是整个图像
- if (this.radioButton4.Checked)
- {
- //获取颜色区间
- _mouseClick = true;
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
- this.imageMat.Clone(),
- model, new System.Drawing.Point());
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
- }
- _mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
- this.imageMat.Clone(),
- model, new System.Drawing.Point(xn, yn));
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, imageMat.Clone(), model, new System.Drawing.Point(xn, yn));
- }
- }
- this.Invoke(new Action(() =>
- {
- 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, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
- this.imageMat.Clone(),
- model, new System.Drawing.Point());
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
- }
- _mouseClick = false;
- }
- //如果是单个目标,参考单个提取
- else if (this.radioButton3.Checked)
- {
- if (radioButton12.Checked) //hls
- {
- mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
- this.imageMat.Clone(),
- model, new System.Drawing.Point(xn, yn));
- }
- else
- {
- mat1 = this.action.PerformProcess(mat, imageMat.Clone(), 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
- }
- }
|