CarbideNumberDialog.cs 222 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602
  1. using OpenCvSharp;
  2. using OpenCvSharp.Extensions;
  3. using PaintDotNet.Annotation;
  4. using PaintDotNet.Annotation.Enum;
  5. using PaintDotNet.Base.Functionodel;
  6. using PaintDotNet.CustomControl;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Drawing.Drawing2D;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using PaintDotNet.DbOpreate.DbBll;
  18. using PaintDotNet.DbOpreate.DbModel;
  19. using PaintDotNet.Base.CommTool;
  20. using System.IO;
  21. using PaintDotNet.Base.SettingModel;
  22. using PaintDotNet.Data.Param;
  23. using PaintDotNet.Base;
  24. using PaintDotNet.GeneralAnalysis;
  25. using PaintDotNet.DedicatedAnalysis.DuctileIron.Common;
  26. using PaintDotNet;
  27. using Metis.ParameterSet;
  28. namespace Metis.DedicatedAnalysis.DuctileIron.GBT9441_2009.CarbideNumber
  29. {
  30. internal class CarbideNumberDialog : PdnBaseForm
  31. {
  32. #region
  33. /// <summary>
  34. /// Required designer variable.
  35. /// </summary>
  36. private System.ComponentModel.IContainer components = null;
  37. /// <summary>
  38. /// Clean up any resources being used.
  39. /// </summary>
  40. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  41. protected override void Dispose(bool disposing)
  42. {
  43. if (disposing && (components != null))
  44. {
  45. components.Dispose();
  46. }
  47. base.Dispose(disposing);
  48. }
  49. #region Windows Form Designer generated code
  50. private void InitializeLanguageText()
  51. {
  52. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  53. //
  54. // bc
  55. //
  56. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  57. this.bc.BinaryChecked = false;
  58. this.bc.BinaryStyle = 1;
  59. this.bc.Location = new System.Drawing.Point(151, 56);
  60. this.bc.Name = "bc";
  61. this.bc.OriginChecked = false;
  62. this.bc.scope1End = 0D;
  63. this.bc.scope1Start = 0D;
  64. this.bc.scope2End = 0D;
  65. this.bc.scope2Start = 0D;
  66. this.bc.scope3End = 0D;
  67. this.bc.scope3Start = 0D;
  68. this.bc.Size = new System.Drawing.Size(360, 292);
  69. this.bc.TabIndex = 28;
  70. this.Controls.Add(this.bc);
  71. this.Controls.SetChildIndex(this.bc, 0);
  72. this.groupBox7.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Graphitearearaterange.text") + "(%)";
  73. this.checkBox2.Text = PdnResources.GetString("Menu.filter.text");
  74. this.label5.Text = PdnResources.GetString("Menu.max.text");
  75. this.label4.Text = PdnResources.GetString("Menu.minimum.text");
  76. this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");
  77. this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
  78. this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  79. this.button9.Text = PdnResources.GetString("Menu.Exportresults.text");
  80. this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  81. this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  82. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  83. this.groupBox8.Text = PdnResources.GetString("Menu.Theesultshow.text");
  84. this.groupBox6.Text = PdnResources.GetString("Menu.paramssettings.text");
  85. this.checkBox6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Particleshecalculation.text");
  86. this.btnDisplay.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  87. this.btnColour.Text = PdnResources.GetString("Menu.Colorsetting.text");
  88. this.checkBox5.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Displayarearate.text");
  89. this.checkBox4.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Showdifofcolor.text");
  90. this.groupBox5.Text = PdnResources.GetString("Menu.Particlescreening.text");
  91. this.label3.Text = PdnResources.GetString("Menu.range.text") + ":";
  92. this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");
  93. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  94. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  95. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  96. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  97. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  98. this.btnSetUp.Text = PdnResources.GetString("Menu.Setting.Text");
  99. this.Text = "GBT9441-2009(" + PdnResources.GetString("Menu.Quantityofcarbide.Text") + ")";
  100. this.button3.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
  101. this.button4.Text = PdnResources.GetString("Menu.Applyall.text");
  102. }
  103. /// <summary>
  104. /// Required method for Designer support - do not modify
  105. /// the contents of this method with the code editor.
  106. /// </summary>
  107. private void InitializeComponent()
  108. {
  109. this.components = new System.ComponentModel.Container();
  110. this.groupBox7 = new System.Windows.Forms.GroupBox();
  111. this.checkBox2 = new System.Windows.Forms.CheckBox();
  112. this.trackBar6 = new System.Windows.Forms.TrackBar();
  113. this.trackBar5 = new System.Windows.Forms.TrackBar();
  114. this.numericUpDown7 = new System.Windows.Forms.NumericUpDown();
  115. this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
  116. this.label5 = new System.Windows.Forms.Label();
  117. this.label4 = new System.Windows.Forms.Label();
  118. this.groupBox9 = new System.Windows.Forms.GroupBox();
  119. this.dataGridView3 = new System.Windows.Forms.DataGridView();
  120. this.button1 = new System.Windows.Forms.Button();
  121. this.label10 = new System.Windows.Forms.Label();
  122. this.label9 = new System.Windows.Forms.Label();
  123. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  124. this.label8 = new System.Windows.Forms.Label();
  125. this.button9 = new System.Windows.Forms.Button();
  126. this.button8 = new System.Windows.Forms.Button();
  127. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  128. this.listView2 = new System.Windows.Forms.ListView();
  129. this.button7 = new System.Windows.Forms.Button();
  130. this.button6 = new System.Windows.Forms.Button();
  131. this.groupBox8 = new System.Windows.Forms.GroupBox();
  132. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  133. this.groupBox6 = new System.Windows.Forms.GroupBox();
  134. this.checkBox6 = new System.Windows.Forms.CheckBox();
  135. this.btnDisplay = new System.Windows.Forms.Button();
  136. this.btnColour = new System.Windows.Forms.Button();
  137. this.checkBox5 = new System.Windows.Forms.CheckBox();
  138. this.checkBox4 = new System.Windows.Forms.CheckBox();
  139. this.groupBox5 = new System.Windows.Forms.GroupBox();
  140. this.trackBar4 = new System.Windows.Forms.TrackBar();
  141. this.trackBar2 = new System.Windows.Forms.TrackBar();
  142. this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
  143. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  144. this.label3 = new System.Windows.Forms.Label();
  145. this.checkBox3 = new System.Windows.Forms.CheckBox();
  146. this.groupBox3 = new System.Windows.Forms.GroupBox();
  147. this.groupBox2 = new System.Windows.Forms.GroupBox();
  148. this.listView1 = new System.Windows.Forms.ListView();
  149. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  150. this.groupBox1 = new System.Windows.Forms.GroupBox();
  151. this.button3 = new System.Windows.Forms.Button();
  152. this.button4 = new System.Windows.Forms.Button();
  153. this.button2 = new System.Windows.Forms.Button();
  154. this.checkBox1 = new System.Windows.Forms.CheckBox();
  155. this.btnSetUp = new System.Windows.Forms.Button();
  156. this.groupBox7.SuspendLayout();
  157. ((System.ComponentModel.ISupportInitialize)(this.trackBar6)).BeginInit();
  158. ((System.ComponentModel.ISupportInitialize)(this.trackBar5)).BeginInit();
  159. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).BeginInit();
  160. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();
  161. this.groupBox9.SuspendLayout();
  162. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit();
  163. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  164. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  165. this.groupBox8.SuspendLayout();
  166. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  167. this.groupBox6.SuspendLayout();
  168. this.groupBox5.SuspendLayout();
  169. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();
  170. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
  171. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
  172. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  173. this.groupBox2.SuspendLayout();
  174. this.groupBox1.SuspendLayout();
  175. this.SuspendLayout();
  176. //
  177. // groupBox7
  178. //
  179. this.groupBox7.Controls.Add(this.checkBox2);
  180. this.groupBox7.Controls.Add(this.trackBar6);
  181. this.groupBox7.Controls.Add(this.trackBar5);
  182. this.groupBox7.Controls.Add(this.numericUpDown7);
  183. this.groupBox7.Controls.Add(this.numericUpDown6);
  184. this.groupBox7.Controls.Add(this.label5);
  185. this.groupBox7.Controls.Add(this.label4);
  186. this.groupBox7.Location = new System.Drawing.Point(153, 503);
  187. this.groupBox7.Name = "groupBox7";
  188. this.groupBox7.Size = new System.Drawing.Size(358, 59);
  189. this.groupBox7.TabIndex = 27;
  190. this.groupBox7.TabStop = false;
  191. //
  192. // checkBox2
  193. //
  194. this.checkBox2.AutoSize = true;
  195. this.checkBox2.Location = new System.Drawing.Point(17, 14);
  196. this.checkBox2.Name = "checkBox2";
  197. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  198. this.checkBox2.TabIndex = 18;
  199. this.checkBox2.UseVisualStyleBackColor = true;
  200. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  201. //
  202. // trackBar6
  203. //
  204. this.trackBar6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  205. this.trackBar6.AutoSize = false;
  206. this.trackBar6.Location = new System.Drawing.Point(181, 31);
  207. this.trackBar6.Maximum = 0;
  208. this.trackBar6.Name = "trackBar6";
  209. this.trackBar6.Size = new System.Drawing.Size(87, 25);
  210. this.trackBar6.TabIndex = 17;
  211. this.trackBar6.TickStyle = System.Windows.Forms.TickStyle.None;
  212. //
  213. // trackBar5
  214. //
  215. this.trackBar5.AutoSize = false;
  216. this.trackBar5.Location = new System.Drawing.Point(88, 31);
  217. this.trackBar5.Maximum = 0;
  218. this.trackBar5.Name = "trackBar5";
  219. this.trackBar5.Size = new System.Drawing.Size(87, 25);
  220. this.trackBar5.TabIndex = 16;
  221. this.trackBar5.TickStyle = System.Windows.Forms.TickStyle.None;
  222. //
  223. // numericUpDown7
  224. //
  225. this.numericUpDown7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  226. this.numericUpDown7.Location = new System.Drawing.Point(278, 30);
  227. this.numericUpDown7.Maximum = new decimal(new int[] {
  228. 0,
  229. 0,
  230. 0,
  231. 0});
  232. this.numericUpDown7.Name = "numericUpDown7";
  233. this.numericUpDown7.Size = new System.Drawing.Size(46, 21);
  234. this.numericUpDown7.TabIndex = 15;
  235. //
  236. // numericUpDown6
  237. //
  238. this.numericUpDown6.Location = new System.Drawing.Point(35, 30);
  239. this.numericUpDown6.Maximum = new decimal(new int[] {
  240. 0,
  241. 0,
  242. 0,
  243. 0});
  244. this.numericUpDown6.Name = "numericUpDown6";
  245. this.numericUpDown6.Size = new System.Drawing.Size(48, 21);
  246. this.numericUpDown6.TabIndex = 14;
  247. //
  248. // label5
  249. //
  250. this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  251. this.label5.AutoSize = true;
  252. this.label5.Location = new System.Drawing.Point(325, 34);
  253. this.label5.Name = "label5";
  254. this.label5.Size = new System.Drawing.Size(0, 12);
  255. this.label5.TabIndex = 11;
  256. //
  257. // label4
  258. //
  259. this.label4.AutoSize = true;
  260. this.label4.Location = new System.Drawing.Point(5, 35);
  261. this.label4.Name = "label4";
  262. this.label4.Size = new System.Drawing.Size(0, 12);
  263. this.label4.TabIndex = 10;
  264. //
  265. // groupBox9
  266. //
  267. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  268. | System.Windows.Forms.AnchorStyles.Right)));
  269. this.groupBox9.Controls.Add(this.dataGridView3);
  270. this.groupBox9.Controls.Add(this.button1);
  271. this.groupBox9.Controls.Add(this.label10);
  272. this.groupBox9.Controls.Add(this.label9);
  273. this.groupBox9.Controls.Add(this.numericUpDown1);
  274. this.groupBox9.Controls.Add(this.label8);
  275. this.groupBox9.Controls.Add(this.button9);
  276. this.groupBox9.Controls.Add(this.button8);
  277. this.groupBox9.Controls.Add(this.dataGridView2);
  278. this.groupBox9.Controls.Add(this.listView2);
  279. this.groupBox9.Controls.Add(this.button7);
  280. this.groupBox9.Controls.Add(this.button6);
  281. this.groupBox9.Location = new System.Drawing.Point(13, 759);
  282. this.groupBox9.Name = "groupBox9";
  283. this.groupBox9.Size = new System.Drawing.Size(1196, 204);
  284. this.groupBox9.TabIndex = 26;
  285. this.groupBox9.TabStop = false;
  286. //
  287. // dataGridView3
  288. //
  289. this.dataGridView3.AllowUserToAddRows = false;
  290. this.dataGridView3.AllowUserToDeleteRows = false;
  291. this.dataGridView3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  292. | System.Windows.Forms.AnchorStyles.Left)
  293. | System.Windows.Forms.AnchorStyles.Right)));
  294. this.dataGridView3.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  295. this.dataGridView3.BackgroundColor = System.Drawing.Color.White;
  296. this.dataGridView3.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  297. this.dataGridView3.Location = new System.Drawing.Point(227, 122);
  298. this.dataGridView3.MultiSelect = false;
  299. this.dataGridView3.Name = "dataGridView3";
  300. this.dataGridView3.RowHeadersVisible = false;
  301. this.dataGridView3.RowTemplate.Height = 23;
  302. this.dataGridView3.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  303. this.dataGridView3.Size = new System.Drawing.Size(801, 76);
  304. this.dataGridView3.TabIndex = 11;
  305. //
  306. // button1
  307. //
  308. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  309. this.button1.Location = new System.Drawing.Point(1054, 108);
  310. this.button1.Name = "button1";
  311. this.button1.Size = new System.Drawing.Size(128, 26);
  312. this.button1.TabIndex = 10;
  313. this.button1.UseVisualStyleBackColor = true;
  314. this.button1.Click += new System.EventHandler(this.button1_Click);
  315. //
  316. // label10
  317. //
  318. this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  319. | System.Windows.Forms.AnchorStyles.Right)));
  320. this.label10.AutoSize = true;
  321. this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
  322. this.label10.Location = new System.Drawing.Point(1034, 9);
  323. this.label10.Name = "label10";
  324. this.label10.Size = new System.Drawing.Size(11, 192);
  325. this.label10.TabIndex = 9;
  326. this.label10.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  327. //
  328. // label9
  329. //
  330. this.label9.AutoSize = true;
  331. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  332. this.label9.Location = new System.Drawing.Point(210, 9);
  333. this.label9.Name = "label9";
  334. this.label9.Size = new System.Drawing.Size(11, 192);
  335. this.label9.TabIndex = 8;
  336. this.label9.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  337. //
  338. // numericUpDown1
  339. //
  340. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  341. this.numericUpDown1.Location = new System.Drawing.Point(1106, 162);
  342. this.numericUpDown1.Maximum = new decimal(new int[] {
  343. 10,
  344. 0,
  345. 0,
  346. 0});
  347. this.numericUpDown1.Name = "numericUpDown1";
  348. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  349. this.numericUpDown1.TabIndex = 7;
  350. this.numericUpDown1.Value = new decimal(new int[] {
  351. 2,
  352. 0,
  353. 0,
  354. 0});
  355. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  356. //
  357. // label8
  358. //
  359. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  360. this.label8.AutoSize = true;
  361. this.label8.Location = new System.Drawing.Point(1067, 167);
  362. this.label8.Name = "label8";
  363. this.label8.Size = new System.Drawing.Size(0, 12);
  364. this.label8.TabIndex = 6;
  365. //
  366. // button9
  367. //
  368. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  369. this.button9.Location = new System.Drawing.Point(1054, 71);
  370. this.button9.Name = "button9";
  371. this.button9.Size = new System.Drawing.Size(128, 26);
  372. this.button9.TabIndex = 5;
  373. this.button9.UseVisualStyleBackColor = true;
  374. this.button9.Click += new System.EventHandler(this.button9_Click);
  375. //
  376. // button8
  377. //
  378. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  379. this.button8.Location = new System.Drawing.Point(1054, 34);
  380. this.button8.Name = "button8";
  381. this.button8.Size = new System.Drawing.Size(128, 26);
  382. this.button8.TabIndex = 4;
  383. this.button8.UseVisualStyleBackColor = true;
  384. this.button8.Click += new System.EventHandler(this.button8_Click);
  385. //
  386. // dataGridView2
  387. //
  388. this.dataGridView2.AllowUserToAddRows = false;
  389. this.dataGridView2.AllowUserToDeleteRows = false;
  390. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  391. | System.Windows.Forms.AnchorStyles.Left)
  392. | System.Windows.Forms.AnchorStyles.Right)));
  393. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  394. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  395. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  396. this.dataGridView2.Location = new System.Drawing.Point(228, 14);
  397. this.dataGridView2.MultiSelect = false;
  398. this.dataGridView2.Name = "dataGridView2";
  399. this.dataGridView2.RowHeadersVisible = false;
  400. this.dataGridView2.RowTemplate.Height = 23;
  401. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  402. this.dataGridView2.Size = new System.Drawing.Size(800, 102);
  403. this.dataGridView2.TabIndex = 3;
  404. //
  405. // listView2
  406. //
  407. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  408. | System.Windows.Forms.AnchorStyles.Left)));
  409. this.listView2.HideSelection = false;
  410. this.listView2.Location = new System.Drawing.Point(16, 56);
  411. this.listView2.Name = "listView2";
  412. this.listView2.Size = new System.Drawing.Size(181, 140);
  413. this.listView2.TabIndex = 2;
  414. this.listView2.UseCompatibleStateImageBehavior = false;
  415. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  416. //
  417. // button7
  418. //
  419. this.button7.Location = new System.Drawing.Point(145, 20);
  420. this.button7.Name = "button7";
  421. this.button7.Size = new System.Drawing.Size(52, 26);
  422. this.button7.TabIndex = 1;
  423. this.button7.UseVisualStyleBackColor = true;
  424. this.button7.Click += new System.EventHandler(this.button7_Click);
  425. //
  426. // button6
  427. //
  428. this.button6.Location = new System.Drawing.Point(16, 20);
  429. this.button6.Name = "button6";
  430. this.button6.Size = new System.Drawing.Size(93, 26);
  431. this.button6.TabIndex = 0;
  432. this.button6.UseVisualStyleBackColor = true;
  433. this.button6.Click += new System.EventHandler(this.button6_Click);
  434. //
  435. // groupBox8
  436. //
  437. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  438. | System.Windows.Forms.AnchorStyles.Left)));
  439. this.groupBox8.Controls.Add(this.dataGridView1);
  440. this.groupBox8.Location = new System.Drawing.Point(153, 562);
  441. this.groupBox8.Name = "groupBox8";
  442. this.groupBox8.Size = new System.Drawing.Size(357, 191);
  443. this.groupBox8.TabIndex = 25;
  444. this.groupBox8.TabStop = false;
  445. //
  446. // dataGridView1
  447. //
  448. this.dataGridView1.AllowUserToAddRows = false;
  449. this.dataGridView1.AllowUserToDeleteRows = false;
  450. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  451. | System.Windows.Forms.AnchorStyles.Left)));
  452. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  453. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  454. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  455. this.dataGridView1.Location = new System.Drawing.Point(7, 21);
  456. this.dataGridView1.MultiSelect = false;
  457. this.dataGridView1.Name = "dataGridView1";
  458. this.dataGridView1.RowHeadersVisible = false;
  459. this.dataGridView1.RowTemplate.Height = 23;
  460. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  461. this.dataGridView1.Size = new System.Drawing.Size(345, 164);
  462. this.dataGridView1.TabIndex = 0;
  463. //
  464. // groupBox6
  465. //
  466. this.groupBox6.Controls.Add(this.checkBox6);
  467. this.groupBox6.Controls.Add(this.btnDisplay);
  468. this.groupBox6.Controls.Add(this.btnColour);
  469. this.groupBox6.Controls.Add(this.checkBox5);
  470. this.groupBox6.Controls.Add(this.checkBox4);
  471. this.groupBox6.Location = new System.Drawing.Point(152, 415);
  472. this.groupBox6.Name = "groupBox6";
  473. this.groupBox6.Size = new System.Drawing.Size(358, 86);
  474. this.groupBox6.TabIndex = 24;
  475. this.groupBox6.TabStop = false;
  476. //
  477. // checkBox6
  478. //
  479. this.checkBox6.AutoSize = true;
  480. this.checkBox6.Location = new System.Drawing.Point(18, 17);
  481. this.checkBox6.Name = "checkBox6";
  482. this.checkBox6.Size = new System.Drawing.Size(15, 14);
  483. this.checkBox6.TabIndex = 11;
  484. this.checkBox6.UseVisualStyleBackColor = true;
  485. this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
  486. //
  487. // btnDisplay
  488. //
  489. this.btnDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  490. this.btnDisplay.Location = new System.Drawing.Point(251, 57);
  491. this.btnDisplay.Name = "btnDisplay";
  492. this.btnDisplay.Size = new System.Drawing.Size(85, 20);
  493. this.btnDisplay.TabIndex = 10;
  494. this.btnDisplay.UseVisualStyleBackColor = true;
  495. this.btnDisplay.Click += new System.EventHandler(this.btnDisplay_Click);
  496. //
  497. // btnColour
  498. //
  499. this.btnColour.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  500. this.btnColour.Location = new System.Drawing.Point(261, 33);
  501. this.btnColour.Name = "btnColour";
  502. this.btnColour.Size = new System.Drawing.Size(75, 20);
  503. this.btnColour.TabIndex = 9;
  504. this.btnColour.UseVisualStyleBackColor = true;
  505. this.btnColour.Click += new System.EventHandler(this.btnColour_Click);
  506. //
  507. // checkBox5
  508. //
  509. this.checkBox5.AutoSize = true;
  510. this.checkBox5.Location = new System.Drawing.Point(18, 63);
  511. this.checkBox5.Name = "checkBox5";
  512. this.checkBox5.Size = new System.Drawing.Size(15, 14);
  513. this.checkBox5.TabIndex = 8;
  514. this.checkBox5.UseVisualStyleBackColor = true;
  515. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  516. //
  517. // checkBox4
  518. //
  519. this.checkBox4.AutoSize = true;
  520. this.checkBox4.Location = new System.Drawing.Point(18, 40);
  521. this.checkBox4.Name = "checkBox4";
  522. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  523. this.checkBox4.TabIndex = 7;
  524. this.checkBox4.UseVisualStyleBackColor = true;
  525. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  526. //
  527. // groupBox5
  528. //
  529. this.groupBox5.Controls.Add(this.trackBar4);
  530. this.groupBox5.Controls.Add(this.trackBar2);
  531. this.groupBox5.Controls.Add(this.numericUpDown5);
  532. this.groupBox5.Controls.Add(this.numericUpDown4);
  533. this.groupBox5.Controls.Add(this.label3);
  534. this.groupBox5.Controls.Add(this.checkBox3);
  535. this.groupBox5.Location = new System.Drawing.Point(152, 347);
  536. this.groupBox5.Name = "groupBox5";
  537. this.groupBox5.Size = new System.Drawing.Size(358, 65);
  538. this.groupBox5.TabIndex = 23;
  539. this.groupBox5.TabStop = false;
  540. //
  541. // trackBar4
  542. //
  543. this.trackBar4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  544. this.trackBar4.AutoSize = false;
  545. this.trackBar4.Location = new System.Drawing.Point(182, 33);
  546. this.trackBar4.Maximum = 0;
  547. this.trackBar4.Name = "trackBar4";
  548. this.trackBar4.Size = new System.Drawing.Size(87, 25);
  549. this.trackBar4.TabIndex = 15;
  550. this.trackBar4.TickStyle = System.Windows.Forms.TickStyle.None;
  551. //
  552. // trackBar2
  553. //
  554. this.trackBar2.AutoSize = false;
  555. this.trackBar2.Location = new System.Drawing.Point(91, 32);
  556. this.trackBar2.Maximum = 0;
  557. this.trackBar2.Name = "trackBar2";
  558. this.trackBar2.Size = new System.Drawing.Size(87, 25);
  559. this.trackBar2.TabIndex = 14;
  560. this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None;
  561. //
  562. // numericUpDown5
  563. //
  564. this.numericUpDown5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  565. this.numericUpDown5.Location = new System.Drawing.Point(280, 33);
  566. this.numericUpDown5.Maximum = new decimal(new int[] {
  567. 0,
  568. 0,
  569. 0,
  570. 0});
  571. this.numericUpDown5.Name = "numericUpDown5";
  572. this.numericUpDown5.Size = new System.Drawing.Size(62, 21);
  573. this.numericUpDown5.TabIndex = 12;
  574. //
  575. // numericUpDown4
  576. //
  577. this.numericUpDown4.Location = new System.Drawing.Point(27, 33);
  578. this.numericUpDown4.Maximum = new decimal(new int[] {
  579. 0,
  580. 0,
  581. 0,
  582. 0});
  583. this.numericUpDown4.Name = "numericUpDown4";
  584. this.numericUpDown4.Size = new System.Drawing.Size(62, 21);
  585. this.numericUpDown4.TabIndex = 10;
  586. //
  587. // label3
  588. //
  589. this.label3.AutoSize = true;
  590. this.label3.Location = new System.Drawing.Point(9, 67);
  591. this.label3.Name = "label3";
  592. this.label3.Size = new System.Drawing.Size(0, 12);
  593. this.label3.TabIndex = 9;
  594. //
  595. // checkBox3
  596. //
  597. this.checkBox3.AutoSize = true;
  598. this.checkBox3.Location = new System.Drawing.Point(18, 14);
  599. this.checkBox3.Name = "checkBox3";
  600. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  601. this.checkBox3.TabIndex = 0;
  602. this.checkBox3.UseVisualStyleBackColor = true;
  603. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  604. //
  605. // groupBox3
  606. //
  607. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  608. | System.Windows.Forms.AnchorStyles.Left)
  609. | System.Windows.Forms.AnchorStyles.Right)));
  610. this.groupBox3.Location = new System.Drawing.Point(517, 61);
  611. this.groupBox3.Name = "groupBox3";
  612. this.groupBox3.Size = new System.Drawing.Size(692, 692);
  613. this.groupBox3.TabIndex = 22;
  614. this.groupBox3.TabStop = false;
  615. //
  616. // groupBox2
  617. //
  618. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  619. | System.Windows.Forms.AnchorStyles.Left)));
  620. this.groupBox2.Controls.Add(this.listView1);
  621. this.groupBox2.Location = new System.Drawing.Point(13, 61);
  622. this.groupBox2.Name = "groupBox2";
  623. this.groupBox2.Size = new System.Drawing.Size(135, 693);
  624. this.groupBox2.TabIndex = 21;
  625. this.groupBox2.TabStop = false;
  626. //
  627. // listView1
  628. //
  629. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  630. | System.Windows.Forms.AnchorStyles.Left)
  631. | System.Windows.Forms.AnchorStyles.Right)));
  632. this.listView1.HideSelection = false;
  633. this.listView1.LargeImageList = this.imageList1;
  634. this.listView1.Location = new System.Drawing.Point(5, 17);
  635. this.listView1.MultiSelect = false;
  636. this.listView1.Name = "listView1";
  637. this.listView1.Size = new System.Drawing.Size(124, 670);
  638. this.listView1.TabIndex = 0;
  639. this.listView1.UseCompatibleStateImageBehavior = false;
  640. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  641. this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
  642. //
  643. // imageList1
  644. //
  645. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  646. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  647. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  648. //
  649. // groupBox1
  650. //
  651. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  652. | System.Windows.Forms.AnchorStyles.Right)));
  653. this.groupBox1.Controls.Add(this.button3);
  654. this.groupBox1.Controls.Add(this.button4);
  655. this.groupBox1.Controls.Add(this.button2);
  656. this.groupBox1.Controls.Add(this.checkBox1);
  657. this.groupBox1.Controls.Add(this.btnSetUp);
  658. this.groupBox1.Location = new System.Drawing.Point(13, 4);
  659. this.groupBox1.Name = "groupBox1";
  660. this.groupBox1.Size = new System.Drawing.Size(1196, 50);
  661. this.groupBox1.TabIndex = 20;
  662. this.groupBox1.TabStop = false;
  663. //
  664. // button3
  665. //
  666. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  667. this.button3.Location = new System.Drawing.Point(1106, 14);
  668. this.button3.Name = "button3";
  669. this.button3.Size = new System.Drawing.Size(84, 30);
  670. this.button3.TabIndex = 15;
  671. this.button3.Text = "保存全部";
  672. this.button3.UseVisualStyleBackColor = true;
  673. this.button3.Click += new System.EventHandler(this.button3_Click);
  674. //
  675. // button4
  676. //
  677. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  678. this.button4.Location = new System.Drawing.Point(926, 14);
  679. this.button4.Name = "button4";
  680. this.button4.Size = new System.Drawing.Size(84, 30);
  681. this.button4.TabIndex = 14;
  682. this.button4.Text = "应用全部";
  683. this.button4.UseVisualStyleBackColor = true;
  684. this.button4.Click += new System.EventHandler(this.button4_Click);
  685. //
  686. // button2
  687. //
  688. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  689. | System.Windows.Forms.AnchorStyles.Right)));
  690. this.button2.Location = new System.Drawing.Point(1016, 14);
  691. this.button2.Name = "button2";
  692. this.button2.Size = new System.Drawing.Size(84, 30);
  693. this.button2.TabIndex = 2;
  694. this.button2.UseVisualStyleBackColor = true;
  695. this.button2.Click += new System.EventHandler(this.button2_Click);
  696. //
  697. // checkBox1
  698. //
  699. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  700. | System.Windows.Forms.AnchorStyles.Left)));
  701. this.checkBox1.AutoSize = true;
  702. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  703. this.checkBox1.Name = "checkBox1";
  704. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  705. this.checkBox1.TabIndex = 1;
  706. this.checkBox1.UseVisualStyleBackColor = true;
  707. //
  708. // btnSetUp
  709. //
  710. this.btnSetUp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  711. | System.Windows.Forms.AnchorStyles.Left)));
  712. this.btnSetUp.Location = new System.Drawing.Point(15, 14);
  713. this.btnSetUp.Name = "btnSetUp";
  714. this.btnSetUp.Size = new System.Drawing.Size(84, 30);
  715. this.btnSetUp.TabIndex = 0;
  716. this.btnSetUp.UseVisualStyleBackColor = true;
  717. this.btnSetUp.Click += new System.EventHandler(this.btnSetUp_Click);
  718. //
  719. // CarbideNumberDialog
  720. //
  721. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  722. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  723. this.ClientSize = new System.Drawing.Size(1222, 967);
  724. this.Controls.Add(this.groupBox7);
  725. this.Controls.Add(this.groupBox9);
  726. this.Controls.Add(this.groupBox8);
  727. this.Controls.Add(this.groupBox6);
  728. this.Controls.Add(this.groupBox5);
  729. this.Controls.Add(this.groupBox3);
  730. this.Controls.Add(this.groupBox2);
  731. this.Controls.Add(this.groupBox1);
  732. this.Name = "CarbideNumberDialog";
  733. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing);
  734. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  735. this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
  736. this.Controls.SetChildIndex(this.groupBox1, 0);
  737. this.Controls.SetChildIndex(this.groupBox2, 0);
  738. this.Controls.SetChildIndex(this.groupBox3, 0);
  739. this.Controls.SetChildIndex(this.groupBox5, 0);
  740. this.Controls.SetChildIndex(this.groupBox6, 0);
  741. this.Controls.SetChildIndex(this.groupBox8, 0);
  742. this.Controls.SetChildIndex(this.groupBox9, 0);
  743. this.Controls.SetChildIndex(this.groupBox7, 0);
  744. this.groupBox7.ResumeLayout(false);
  745. this.groupBox7.PerformLayout();
  746. ((System.ComponentModel.ISupportInitialize)(this.trackBar6)).EndInit();
  747. ((System.ComponentModel.ISupportInitialize)(this.trackBar5)).EndInit();
  748. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).EndInit();
  749. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();
  750. this.groupBox9.ResumeLayout(false);
  751. this.groupBox9.PerformLayout();
  752. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit();
  753. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  754. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  755. this.groupBox8.ResumeLayout(false);
  756. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  757. this.groupBox6.ResumeLayout(false);
  758. this.groupBox6.PerformLayout();
  759. this.groupBox5.ResumeLayout(false);
  760. this.groupBox5.PerformLayout();
  761. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();
  762. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
  763. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
  764. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  765. this.groupBox2.ResumeLayout(false);
  766. this.groupBox1.ResumeLayout(false);
  767. this.groupBox1.PerformLayout();
  768. this.ResumeLayout(false);
  769. }
  770. #endregion
  771. private PaintDotNet.CustomControl.BinaryControl bc;
  772. private System.Windows.Forms.GroupBox groupBox7;
  773. private System.Windows.Forms.TrackBar trackBar6;
  774. private System.Windows.Forms.TrackBar trackBar5;
  775. private System.Windows.Forms.NumericUpDown numericUpDown7;
  776. private System.Windows.Forms.NumericUpDown numericUpDown6;
  777. private System.Windows.Forms.Label label5;
  778. private System.Windows.Forms.Label label4;
  779. private System.Windows.Forms.GroupBox groupBox9;
  780. private System.Windows.Forms.DataGridView dataGridView3;
  781. private System.Windows.Forms.Button button1;
  782. private System.Windows.Forms.Label label10;
  783. private System.Windows.Forms.Label label9;
  784. private System.Windows.Forms.NumericUpDown numericUpDown1;
  785. private System.Windows.Forms.Label label8;
  786. private System.Windows.Forms.Button button9;
  787. private System.Windows.Forms.Button button8;
  788. private System.Windows.Forms.DataGridView dataGridView2;
  789. private System.Windows.Forms.ListView listView2;
  790. private System.Windows.Forms.Button button7;
  791. private System.Windows.Forms.Button button6;
  792. private System.Windows.Forms.GroupBox groupBox8;
  793. private System.Windows.Forms.DataGridView dataGridView1;
  794. private System.Windows.Forms.GroupBox groupBox6;
  795. private System.Windows.Forms.CheckBox checkBox6;
  796. private System.Windows.Forms.Button btnDisplay;
  797. private System.Windows.Forms.Button btnColour;
  798. public System.Windows.Forms.CheckBox checkBox5;
  799. public System.Windows.Forms.CheckBox checkBox4;
  800. private System.Windows.Forms.GroupBox groupBox5;
  801. private System.Windows.Forms.TrackBar trackBar4;
  802. private System.Windows.Forms.TrackBar trackBar2;
  803. private System.Windows.Forms.NumericUpDown numericUpDown5;
  804. private System.Windows.Forms.NumericUpDown numericUpDown4;
  805. private System.Windows.Forms.Label label3;
  806. private System.Windows.Forms.CheckBox checkBox3;
  807. private System.Windows.Forms.GroupBox groupBox3;
  808. private System.Windows.Forms.GroupBox groupBox2;
  809. private System.Windows.Forms.ListView listView1;
  810. private System.Windows.Forms.GroupBox groupBox1;
  811. private System.Windows.Forms.Button button2;
  812. private System.Windows.Forms.CheckBox checkBox1;
  813. private System.Windows.Forms.Button btnSetUp;
  814. private System.Windows.Forms.ImageList imageList1;
  815. private System.Windows.Forms.CheckBox checkBox2;
  816. #endregion
  817. public static CarbideNumberDialog carbideNumberDialog;
  818. /// <summary>
  819. /// 调色板
  820. /// </summary>
  821. PaintDotNet.ColorsForm colorsForm1;
  822. PaintDotNet.ColorsForm colorsForm2;
  823. /// <summary>
  824. /// 主控件
  825. /// </summary>
  826. private AppWorkspace appWorkspace;
  827. /// <summary>
  828. /// 图像面板
  829. /// </summary>
  830. public DocumentWorkspaceWindow documentWorkspace;
  831. /// <summary>
  832. /// 公共按钮
  833. /// </summary>
  834. private CommonControlButtons commonControlButtons;
  835. /// <summary>
  836. /// 选中图片的bitmap
  837. /// </summary>
  838. private Bitmap bitmap;
  839. /// <summary>
  840. /// 计算结果的表格集合
  841. /// </summary>
  842. private List<DataTable> resultTableList = new List<DataTable>();
  843. /// <summary>
  844. /// 保存用于生成报告的图片
  845. /// </summary>
  846. private List<Bitmap> bitList;
  847. /// <summary>
  848. /// 储存点击保存结果后的所有原图与分析图
  849. /// </summary>
  850. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  851. /// <summary>
  852. /// 是否显示全部
  853. /// </summary>
  854. private bool showAll = false;
  855. /// <summary>
  856. /// 当前图片是否有视场
  857. /// </summary>
  858. private bool isHadView = false;
  859. /// <summary>
  860. /// 原图mat-包括视场
  861. /// </summary>
  862. private Mat mat;
  863. /// <summary>
  864. /// 二值处理后的mat
  865. /// </summary>
  866. private Mat binarizationMat;
  867. /// <summary>
  868. /// 面积率为0.8-1的mat
  869. /// </summary>
  870. private Mat binarizationMat08_1;
  871. /// <summary>
  872. /// 面积率为0.6-0.8的mat
  873. /// </summary>
  874. private Mat binarizationMat06_08;
  875. /// <summary>
  876. /// 面积率为0.4-0.6的mat
  877. /// </summary>
  878. private Mat binarizationMat04_06;
  879. /// <summary>
  880. /// 面积率为0.2-0.4的mat
  881. /// </summary>
  882. private Mat binarizationMat02_04;
  883. /// <summary>
  884. /// 面积率为0.1-0.2的mat
  885. /// </summary>
  886. private Mat binarizationMat01_02;
  887. /// <summary>
  888. /// 面积率为0-0.1的mat
  889. /// </summary>
  890. private Mat binarizationMat0_01;
  891. /// <summary>
  892. /// 相的集合
  893. /// </summary>
  894. private PhaseModel phaseModel;
  895. /// <summary>
  896. /// 相的集合
  897. /// </summary>
  898. private PhaseModel phaseModel08_1;
  899. /// <summary>
  900. /// 相的集合
  901. /// </summary>
  902. private PhaseModel phaseModel06_08;
  903. /// <summary>
  904. /// 相的集合
  905. /// </summary>
  906. private PhaseModel phaseModel04_06;
  907. /// <summary>
  908. /// 相的集合
  909. /// </summary>
  910. private PhaseModel phaseModel02_04;
  911. /// <summary>
  912. /// 相的集合
  913. /// </summary>
  914. private PhaseModel phaseModel01_02;
  915. /// <summary>
  916. /// 相的集合
  917. /// </summary>
  918. private PhaseModel phaseModel0_01;
  919. /// <summary>
  920. /// 单位标尺
  921. /// </summary>
  922. private double unitLength = 1;
  923. /// <summary>
  924. /// 放大倍数
  925. /// </summary>
  926. private double multiple = 1;
  927. /// <summary>
  928. /// 坐标集合
  929. /// </summary>
  930. private List<OpenCvSharp.Point> pointList = new List<OpenCvSharp.Point>();
  931. /// <summary>
  932. /// 绘制点
  933. /// </summary>
  934. private List<double> leList = new List<double>();
  935. /// <summary>
  936. /// 最大点碳化物点集合
  937. /// </summary>
  938. private List<List<OpenCvSharp.Point>> maxPoint;
  939. /// <summary>
  940. /// 面积率0.8_1碳化物点集合
  941. /// </summary>
  942. private List<List<OpenCvSharp.Point>> lstPoint08_1;
  943. /// <summary>
  944. /// 面积率0.6_0.8化物点集合
  945. /// </summary>
  946. private List<List<OpenCvSharp.Point>> lstPoint06_08;
  947. /// <summary>
  948. /// 面积率0.4_0.6化物点集合
  949. /// </summary>
  950. private List<List<OpenCvSharp.Point>> lstPoint04_06;
  951. /// <summary>
  952. /// 面积率0.2_0.4化物点集合
  953. /// </summary>
  954. private List<List<OpenCvSharp.Point>> lstPoint02_04;
  955. /// <summary>
  956. /// 面积率0.1_0.2化物点集合
  957. /// </summary>
  958. private List<List<OpenCvSharp.Point>> lstPoint01_02;
  959. /// <summary>
  960. /// 面积率0_0.1化物点集合
  961. /// </summary>
  962. private List<List<OpenCvSharp.Point>> lstPoint0_01;
  963. /// <summary>
  964. /// 钨系A标准
  965. /// </summary>
  966. private double[] tungstenA = new double[] { 18, 21, 23, 25 };
  967. /// <summary>
  968. /// 钨系B标准
  969. /// </summary>
  970. private double[] tungstenB = new double[] { 16, 18, 21, 23 };
  971. /// <summary>
  972. /// 钼系标准
  973. /// </summary>
  974. private double[] molybdenum = new double[] { 6.1, 8.3, 12.5, 15.6, 22.1 };
  975. /// <summary>
  976. /// 面积率
  977. /// </summary>
  978. private double areaRatio = 0;
  979. /// <summary>
  980. /// 面积率最大值
  981. /// </summary>
  982. double maxAreaRatio = 0;
  983. /// <summary>
  984. /// 面积率最小值
  985. /// </summary>
  986. double minAreaRatio = 100;
  987. /// <summary>
  988. /// 存储面积率颜色字典
  989. /// </summary>
  990. public Dictionary<string, Color> colour = new Dictionary<string, Color>();
  991. // <summary>
  992. /// 存储字号与颜色字典
  993. /// </summary>
  994. public Dictionary<string, Color> colourFont = new Dictionary<string, Color>();
  995. /// <summary>
  996. /// 碳化物尺寸最大值
  997. /// </summary>
  998. private double maxSize = 0;
  999. /// <summary>
  1000. /// 是否仅修改相的颜色
  1001. /// </summary>
  1002. private bool changeColor = false;
  1003. /// <summary>
  1004. /// 是否未对图片做其他操作
  1005. /// </summary>
  1006. private bool isFirstSwitch = false;
  1007. /// <summary>
  1008. /// 中间数据
  1009. /// </summary>
  1010. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  1011. private bool needChange = true;
  1012. /// <summary>
  1013. /// 类型(球铁-1,蠕铁GBT26656-2,蠕铁JBT3829-3,蠕铁GBT26656磷共晶-4,蠕铁JBT3829磷共晶-5)
  1014. /// </summary>
  1015. private int IronType = 0;
  1016. private int defaultIndex = -1;
  1017. private bool isExportResults = false;
  1018. private bool isExportReports = false;
  1019. private bool isExportProjects = false;
  1020. /// <summary>
  1021. /// 是否脚本运行
  1022. /// </summary>
  1023. private Boolean initScriptValues = false;
  1024. /// <summary>
  1025. /// 保存窗口参数
  1026. /// </summary>
  1027. /// <summary>
  1028. /// 各个图片对应数据
  1029. /// </summary>
  1030. private Dictionary<string, GrainSizeAnalysisModel> eachData = new Dictionary<string, GrainSizeAnalysisModel>();
  1031. private const string ParamKey_Report = "report";//报告设置
  1032. private const string ParamKey_Screen = "screen";//筛选
  1033. private const string ParamKey_ScreenMin = "screenMin";//面积最小值
  1034. private const string ParamKey_ScreenMax = "screenMax";//面积最大值
  1035. private const string ParamKey_Diameter = "diameter";//直径小于20um不参与计算
  1036. private const string ParamKey_Colour = "colour";//显示不同级别颜色
  1037. private const string ParamKey_AreaRatio = "areaRatio";//显示面积率
  1038. private const string ParamKey_AreaRatioRange = "areaRatioRange";//面积率区间
  1039. private const string ParamKey_AreaRatioRangeMin = "areaRatioRangeMin";//面积率区间最小值
  1040. private const string ParamKey_AreaRatioRangeMax = "areaRatioRangeMax";//面积率区间最大值
  1041. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  1042. private const string ParamKey_panelColour1_08 = "panelColour1_08";//不同区间颜色
  1043. private const string ParamKey_panelColour08_06 = "panelColour08_06";//不同区间颜色
  1044. private const string ParamKey_panelColour06_04 = "panelColour06_04";//不同区间颜色
  1045. private const string ParamKey_panelColour04_02 = "panelColour04_02";//不同区间颜色
  1046. private const string ParamKey_panelColour02_01 = "panelColour02_01";//不同区间颜色
  1047. private const string ParamKey_panelColour01_0 = "panelColour01_0";//不同区间颜色
  1048. private const string ParamKey_FontSize = "fontSize";//字体大小
  1049. private const string ParamKey_FontColour = "fontColour";//字体颜色
  1050. private decimal areaRatioRangeMin = -1;
  1051. private decimal areaRatioRangeMax = -1;
  1052. private decimal areaMin = -1;//面积区间最小
  1053. private decimal areaMax = -1;//面积区间最大
  1054. private string fontSize = "12";
  1055. private Color fontColour = Color.Black;
  1056. #region 二值化相关
  1057. /// <summary>
  1058. /// 调色板
  1059. /// </summary>
  1060. private ColorsForm colorsFormGrid;
  1061. //二值化集成1
  1062. BinaryClass binaryClass;
  1063. private Button button3;
  1064. private Button button4;
  1065. private int menuId;
  1066. private string menuName;
  1067. #endregion
  1068. public CarbideNumberDialog(AppWorkspace appWorkspace, int type, PdnMenuItem menuItem)
  1069. {
  1070. this.menuId = menuItem.MenuId;
  1071. this.menuName = menuItem.Text;
  1072. binaryClass = new BinaryClass(menuId);
  1073. IronType = type;
  1074. carbideNumberDialog = this;
  1075. this.appWorkspace = appWorkspace;
  1076. NullKey();
  1077. InitializeComponent();
  1078. InitializeLanguageText();
  1079. InitColour();
  1080. InitPicList();
  1081. InitOtherTools();
  1082. InitCommonButtonEvent();
  1083. InitGridHeader();
  1084. if (IronType == 1)
  1085. {
  1086. SetAnalyzeModelFromXml("Template.Manager.item3.DuctileIronGBT9441Carbide");
  1087. this.Text = "GBT9441-2009("+ PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")";
  1088. }
  1089. else if (IronType == 2)
  1090. {
  1091. SetAnalyzeModelFromXml("Template.Manager.item3.VermiculateCastGBT26656CN");
  1092. this.Text = "GBT26656-2011("+ PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")";
  1093. }
  1094. else if (IronType == 3)
  1095. {
  1096. SetAnalyzeModelFromXml("Template.Manager.item3.VermiculateCastJBT3829CN");
  1097. this.Text = "JBT3829_1999("+ PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")";
  1098. }
  1099. else if (IronType == 4)
  1100. {
  1101. SetAnalyzeModelFromXml("Template.Manager.item3.VermiculateCastGBT26656P");
  1102. this.Text = "GBT26656-2011("+ PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+ ")";
  1103. }
  1104. else if (IronType == 5)
  1105. {
  1106. SetAnalyzeModelFromXml("Template.Manager.item3.VermiculateCastJBT3829P");
  1107. this.Text = "JBT3829_1999("+ PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+ ")";
  1108. }
  1109. }
  1110. private void ShowImgEvent(object sender, EventArgs e)
  1111. {
  1112. listView1.Focus();
  1113. if (this.defaultIndex != -1)
  1114. {
  1115. this.listView1.Items[defaultIndex].Focused = true;
  1116. this.listView1.Items[defaultIndex].Selected = true;
  1117. //如果是脚本执行,将参数带入
  1118. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  1119. {
  1120. this.initScriptValues = true;//ScriptAutomatic
  1121. //Boolean initScriptValues = true;
  1122. ////在这里反射出对应功能的参数类
  1123. string className = InvariantData.path_Action + ".Action" + menuId;
  1124. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1125. foreach (Args arg in param.Lists)
  1126. {
  1127. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  1128. if (param1.value != null)
  1129. arg.Value = param1.value;
  1130. getValue(arg.key, arg.Value);
  1131. }
  1132. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1133. }
  1134. else
  1135. {//读取上次关闭窗口时保存的参数
  1136. GetXmlParameter();
  1137. GetListParamModel();
  1138. }
  1139. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1140. this.startScriptAutomaticAction();
  1141. }
  1142. }
  1143. /// <summary>
  1144. /// 初始化面积率颜色、字号颜色
  1145. /// </summary>
  1146. private void InitColour()
  1147. {
  1148. colour.Add("panelColour1_08", Color.Orange);
  1149. colour.Add("panelColour08_06", Color.Blue);
  1150. colour.Add("panelColour06_04", Color.Green);
  1151. colour.Add("panelColour04_02", Color.Pink);
  1152. colour.Add("panelColour02_01", Color.Violet);
  1153. colour.Add("panelColour01_0", Color.Yellow);
  1154. colourFont.Add("10", Color.Black);
  1155. }
  1156. /// <summary>
  1157. /// 初始化表头
  1158. /// </summary>
  1159. private void InitGridHeader()
  1160. {
  1161. //
  1162. //结果展示表
  1163. //
  1164. this.dataGridView1.ColumnHeadersHeight = 30;
  1165. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1166. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1167. h1.Width = 125;
  1168. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1169. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1170. h2.Width = 125;
  1171. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1172. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1173. h3.Width = 125;
  1174. this.dataGridView1.Columns.Add(h1);
  1175. this.dataGridView1.Columns.Add(h2);
  1176. this.dataGridView1.Columns.Add(h3);
  1177. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1178. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.view.text")));
  1179. if (IronType == 4 || IronType == 5)
  1180. {
  1181. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)"));
  1182. }
  1183. else
  1184. {
  1185. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)"));
  1186. }
  1187. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Levelname.text")));
  1188. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1189. this.dataGridView1.Columns[0].ReadOnly = true;
  1190. this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1191. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1192. this.dataGridView1.Columns[1].ReadOnly = true;
  1193. this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1194. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1195. this.dataGridView1.Columns[2].ReadOnly = true;
  1196. this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1197. this.dataGridView1.AllowUserToResizeRows = false;
  1198. this.dataGridView1.AllowUserToResizeColumns = false;
  1199. //
  1200. //分析结果表
  1201. //
  1202. this.dataGridView2.ColumnHeadersHeight = 30;
  1203. DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
  1204. //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1205. h11.Width = 187;
  1206. DataGridViewTextBoxColumn h12 = new DataGridViewTextBoxColumn();
  1207. //h12.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1208. h12.Width = 187;
  1209. DataGridViewTextBoxColumn h13 = new DataGridViewTextBoxColumn();
  1210. //h13.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1211. h13.Width = 187;
  1212. DataGridViewTextBoxColumn h14 = new DataGridViewTextBoxColumn();
  1213. //h14.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1214. h14.Width = 187;
  1215. this.dataGridView2.Columns.Add(h11);
  1216. this.dataGridView2.Columns.Add(h12);
  1217. this.dataGridView2.Columns.Add(h13);
  1218. this.dataGridView2.Columns.Add(h14);
  1219. DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  1220. helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1221. helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.view.text")));
  1222. if (IronType == 4 || IronType == 5)
  1223. {
  1224. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)"));
  1225. }
  1226. else
  1227. {
  1228. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)"));
  1229. }
  1230. helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Levelname.text")));
  1231. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1232. this.dataGridView2.Columns[0].ReadOnly = true;
  1233. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1234. this.dataGridView2.Columns[1].ReadOnly = true;
  1235. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1236. this.dataGridView2.Columns[2].ReadOnly = true;
  1237. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1238. this.dataGridView2.Columns[3].ReadOnly = true;
  1239. this.dataGridView2.AllowUserToResizeRows = false;
  1240. this.dataGridView2.AllowUserToResizeColumns = false;
  1241. this.dataGridView3.ColumnHeadersHeight = 30;
  1242. DataGridViewTextBoxColumn h22 = new DataGridViewTextBoxColumn();
  1243. //h22.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1244. h22.Width = 187;
  1245. DataGridViewTextBoxColumn h23 = new DataGridViewTextBoxColumn();
  1246. //h23.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1247. h23.Width = 187;
  1248. DataGridViewTextBoxColumn h24 = new DataGridViewTextBoxColumn();
  1249. //h24.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1250. h24.Width = 187;
  1251. DataGridViewTextBoxColumn h25 = new DataGridViewTextBoxColumn();
  1252. //h25.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1253. h25.Width = 187;
  1254. this.dataGridView3.Columns.Add(h22);
  1255. this.dataGridView3.Columns.Add(h23);
  1256. this.dataGridView3.Columns.Add(h24);
  1257. this.dataGridView3.Columns.Add(h25);
  1258. DataGridViewHelper helper3 = new DataGridViewHelper(this.dataGridView3);
  1259. helper3.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1260. helper3.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.view.text")));
  1261. if (IronType == 4 || IronType == 5)
  1262. {
  1263. helper3.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)"));
  1264. }
  1265. else
  1266. {
  1267. helper3.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)"));
  1268. }
  1269. helper3.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Levelname.text")));
  1270. this.dataGridView3.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1271. this.dataGridView3.Columns[0].ReadOnly = true;
  1272. this.dataGridView3.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1273. this.dataGridView3.Columns[1].ReadOnly = true;
  1274. this.dataGridView3.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1275. this.dataGridView3.Columns[2].ReadOnly = true;
  1276. this.dataGridView3.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1277. this.dataGridView3.Columns[3].ReadOnly = true;
  1278. this.dataGridView3.AllowUserToResizeRows = false;
  1279. this.dataGridView3.AllowUserToResizeColumns = false;
  1280. //
  1281. //左下表
  1282. //
  1283. this.listView2.View = View.Details;
  1284. ColumnHeader header0 = new ColumnHeader();
  1285. header0.Text = PdnResources.GetString("Menu.Imagelist.Text");
  1286. header0.Width = 175;
  1287. this.listView2.Columns.Add(header0);
  1288. }
  1289. /// <summary>
  1290. /// 初始化画布按键功能
  1291. /// </summary>
  1292. private void InitCommonButtonEvent()
  1293. {
  1294. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1295. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1296. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1297. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1298. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1299. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1300. }
  1301. private void zoomInButton_Click(object sender, EventArgs e)
  1302. {
  1303. this.documentWorkspace.ZoomIn();
  1304. }
  1305. private void zoomOutButton_Click(object sender, EventArgs e)
  1306. {
  1307. this.documentWorkspace.ZoomOut();
  1308. }
  1309. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1310. {
  1311. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1312. }
  1313. private void actualSizeButton_Click(object sender, EventArgs e)
  1314. {
  1315. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1316. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1317. }
  1318. private void pointerButton_Click(object sender, EventArgs e)
  1319. {
  1320. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  1321. }
  1322. private void mobileModeButton_Click(object sender, EventArgs e)
  1323. {
  1324. this.documentWorkspace.ActiveTool = DrawToolType.MoveMode;
  1325. }
  1326. /// <summary>
  1327. /// 调色板回调函数
  1328. /// </summary>
  1329. /// <param name="sender"></param>
  1330. /// <param name="ce"></param>
  1331. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1332. {
  1333. }
  1334. /// <summary>
  1335. /// 初始化其他控件
  1336. /// </summary>
  1337. private void InitOtherTools()
  1338. {
  1339. //
  1340. //初始化图像控件
  1341. //
  1342. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  1343. this.documentWorkspace.Dock = DockStyle.Fill;
  1344. this.documentWorkspace.HookMouseEvents();
  1345. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1346. this.documentWorkspace.Visible = false;
  1347. this.documentWorkspace.activeTool = DrawToolType.NullTool;
  1348. this.groupBox3.Controls.Add(documentWorkspace);
  1349. //
  1350. //初始化操作按钮
  1351. //
  1352. this.commonControlButtons = new CommonControlButtons();
  1353. this.commonControlButtons.Dock = DockStyle.Top;
  1354. this.commonControlButtons.Height = 30;
  1355. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1356. this.commonControlButtons.Visible = false;
  1357. this.groupBox3.Controls.Add(commonControlButtons);
  1358. //二值化集成2
  1359. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  1360. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Particlescreening.text") }
  1361. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  1362. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1363. //
  1364. //调色板
  1365. //
  1366. //this.colorsForm1 = new ColorsForm();
  1367. //this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  1368. //this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  1369. //
  1370. //调色板
  1371. //
  1372. this.colorsForm1 = new ColorsForm();
  1373. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  1374. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  1375. this.colorsFormGrid = new ColorsForm();
  1376. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1377. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  1378. //
  1379. //颜色panel给定初始值
  1380. //
  1381. //this.panel1.BackColor = Color.Red;
  1382. ////获取系统标尺-微米
  1383. ////
  1384. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  1385. //
  1386. //获取系统标尺-放大倍数
  1387. //
  1388. if (this.documentWorkspace.GetGainMultiple() != 0)
  1389. {
  1390. multiple = double.Parse(this.documentWorkspace.GetGainMultiple().ToString());
  1391. }
  1392. }
  1393. //二值化集成3
  1394. #region 二值化相关方法
  1395. private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
  1396. {
  1397. #region [开启脚本录制]
  1398. if (appWorkspace.startScriptRecording)
  1399. {
  1400. getScriptRecording();
  1401. }
  1402. #endregion
  1403. this.saveDialogParamValues();
  1404. binaryClass.saveParams();
  1405. //xml保存路径
  1406. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  1407. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1408. foreach (var analysisItem in this.eachData[GetImgKey()].ListParam)
  1409. {
  1410. bool foundItem = false;
  1411. foreach (var item in analysisModelXml.ListParam)
  1412. {
  1413. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  1414. {
  1415. item.param_value = analysisItem.param_value;
  1416. foundItem = true;
  1417. break;
  1418. }
  1419. }
  1420. if (!foundItem)
  1421. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  1422. }
  1423. //按路径和名称保存xml文件
  1424. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  1425. //保存xml
  1426. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  1427. }
  1428. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  1429. {
  1430. binaryClass.RefreshHistogramControl1Values();
  1431. }
  1432. /// <summary>
  1433. /// 添加参数改变的监听
  1434. /// </summary>
  1435. /// <param name="sender"></param>
  1436. /// <param name="e"></param>
  1437. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1438. {
  1439. this.binaryClass.loadParams();
  1440. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1441. this.startScriptAutomaticAction();
  1442. }
  1443. private bool bcBinaryChecked()
  1444. {
  1445. return bc != null && bc.BinaryChecked;
  1446. }
  1447. private bool bcOriginChecked()
  1448. {
  1449. return bc != null && bc.OriginChecked;
  1450. }
  1451. /// <summary>
  1452. /// Panel2的调色板颜色改变
  1453. /// </summary>
  1454. /// <param name="sender"></param>
  1455. /// <param name="e"></param>
  1456. private void gridColorChanged(object sender, EventArgs e)
  1457. {
  1458. this.colorsForm1.Close();
  1459. changeColor = true;
  1460. //ReLoadBinarization();
  1461. this.documentWorkspace.Refresh();
  1462. }
  1463. /// <summary>
  1464. /// 参数改变时,重新处理图像
  1465. /// </summary>
  1466. /// <param name="sender"></param>
  1467. /// <param name="e"></param>
  1468. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1469. {
  1470. if (phaseModel != null)
  1471. {
  1472. sum++;
  1473. this.documentWorkspace.PhaseModels[0].choise = false;
  1474. if (bcBinaryChecked())
  1475. {
  1476. if (bcOriginChecked())
  1477. {
  1478. phaseModel.choise = false;
  1479. }
  1480. else
  1481. {
  1482. phaseModel.choise = true;
  1483. }
  1484. binarizationMat = this.documentWorkspace.PhaseModels[0].mat;
  1485. //changeColor = false;
  1486. ResetAreaAndContent();
  1487. ReloadDebrisSelection();
  1488. //appCommonDisplay.DisplayData(this.dataGridView1, true);
  1489. }
  1490. else
  1491. {
  1492. phaseModel.choise = false;
  1493. if (this.checkBox5.Checked)
  1494. {
  1495. this.documentWorkspace.panel.Paint -= new PaintEventHandler(this.BoxPaintHandler);
  1496. }
  1497. appCommonDisplay.DisplayData(this.dataGridView1, false);
  1498. }
  1499. this.documentWorkspace.Refresh();
  1500. }
  1501. else
  1502. {
  1503. //MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1504. }
  1505. }
  1506. AppCommon appCommonDisplay = new AppCommon();
  1507. /// <summary>
  1508. /// 显示原图/原图+二值图
  1509. /// </summary>
  1510. /// <param name="sender"></param>
  1511. /// <param name="e"></param>
  1512. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1513. {
  1514. if (phaseModel != null)
  1515. {
  1516. this.documentWorkspace.PhaseModels[0].choise = false;
  1517. if (!bcBinaryChecked())
  1518. {
  1519. phaseModel.choise = false;
  1520. appCommonDisplay.DisplayData(this.dataGridView1, false);
  1521. }
  1522. else
  1523. {
  1524. if (bcOriginChecked())
  1525. {
  1526. phaseModel.choise = false;
  1527. if (this.checkBox5.Checked)
  1528. {
  1529. this.documentWorkspace.panel.Paint -= new PaintEventHandler(this.BoxPaintHandler);
  1530. }
  1531. appCommonDisplay.DisplayData(this.dataGridView1, false);
  1532. }
  1533. else
  1534. {
  1535. phaseModel.choise = true;
  1536. if (this.checkBox5.Checked)
  1537. {
  1538. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);
  1539. }
  1540. appCommonDisplay.DisplayData(this.dataGridView1, true);
  1541. }
  1542. }
  1543. this.documentWorkspace.Refresh();
  1544. }
  1545. else
  1546. {
  1547. //MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1548. }
  1549. }
  1550. #endregion
  1551. /// <summary>
  1552. /// 初始化图片列表数据
  1553. /// </summary>
  1554. public void InitPicList()
  1555. {
  1556. //初始化图片列表
  1557. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1558. {
  1559. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1560. this.listView1.Items.Add("", i);
  1561. this.listView1.Items[i].ImageIndex = i;
  1562. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1563. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1564. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1565. {
  1566. defaultIndex = i;
  1567. }
  1568. }
  1569. this.Shown += ShowImgEvent;
  1570. }
  1571. /// <summary>
  1572. /// 颜色设置设置按钮
  1573. /// </summary>
  1574. /// <param name="sender"></param>
  1575. /// <param name="e"></param>
  1576. private void btnColour_Click(object sender, EventArgs e)
  1577. {
  1578. ColorSetting colorSetting = new ColorSetting();
  1579. colorSetting.ShowDialog();
  1580. }
  1581. /// <summary>
  1582. /// 显示参数设置按钮
  1583. /// </summary>
  1584. /// <param name="sender"></param>
  1585. /// <param name="e"></param>
  1586. private void btnDisplay_Click(object sender, EventArgs e)
  1587. {
  1588. DisplaySetting displaySetting = new DisplaySetting();
  1589. displaySetting.ShowDialog();
  1590. }
  1591. /// <summary>
  1592. /// 设置按钮
  1593. /// </summary>
  1594. /// <param name="sender"></param>
  1595. /// <param name="e"></param>
  1596. private void btnSetUp_Click(object sender, EventArgs e)
  1597. {
  1598. AnalyzeSettingDialog metallographicMethodSetDialog = null;
  1599. if (IronType == 1)
  1600. {
  1601. metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.DuctileIronGBT9441Carbide");
  1602. }
  1603. else if (IronType == 2)
  1604. {
  1605. metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.VermiculateCastGBT26656CN");
  1606. }
  1607. else if (IronType == 3)
  1608. {
  1609. metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.VermiculateCastJBT3829CN");
  1610. }
  1611. else if (IronType == 4)
  1612. {
  1613. metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.VermiculateCastGBT26656P");
  1614. }
  1615. else if (IronType == 5)
  1616. {
  1617. metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.VermiculateCastJBT3829P");
  1618. }
  1619. if (metallographicMethodSetDialog.hasModule)
  1620. {
  1621. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1622. metallographicMethodSetDialog.ShowDialog();
  1623. }
  1624. else
  1625. {
  1626. metallographicMethodSetDialog = null;
  1627. }
  1628. }
  1629. /// <summary>
  1630. /// 图像索引切换选中事件
  1631. /// </summary>
  1632. /// <param name="sender"></param>
  1633. /// <param name="e"></param>
  1634. double picArea = 0;//图片面积
  1635. int sum;//统计是否二值过
  1636. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1637. {
  1638. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1639. {
  1640. //获取标尺-微米
  1641. unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1642. GetListParamModel();
  1643. sum = 0;
  1644. if (this.checkBox5.Checked)
  1645. {
  1646. this.documentWorkspace.panel.Paint -= new PaintEventHandler(this.BoxPaintHandler);
  1647. }
  1648. this.dataGridView1.Rows.Clear();
  1649. if (this.documentWorkspace.PhaseModels.Count > 1)
  1650. this.documentWorkspace.PhaseModels.Remove(this.documentWorkspace.PhaseModels[1]);
  1651. this.commonControlButtons.Visible = true;
  1652. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
  1653. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1654. //总面积
  1655. picArea = AnalysisTools.GetPointsFromMat(BitmapConverter.ToMat(this.bitmap));
  1656. changeColor = false;
  1657. phaseModel = new PhaseModel();//同上
  1658. phaseModel.choise = true;
  1659. //二值化集成4
  1660. binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.bitmap, this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]);
  1661. if (binaryClass.getModelMat(this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]) != null)
  1662. {
  1663. this.binarizationMat = binaryClass.getModelMat(this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]).Clone();
  1664. }
  1665. else
  1666. {
  1667. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1668. {
  1669. this.binarizationMat = new Mat();
  1670. }
  1671. else
  1672. {
  1673. this.binarizationMat = this.documentWorkspace.PhaseModels[0].mat.Clone();
  1674. }
  1675. }
  1676. this.documentWorkspace.PhaseModels[0].choise = false;
  1677. this.documentWorkspace.phaseModels.Add(phaseModel);
  1678. if (sum == 0)
  1679. {
  1680. if (bcOriginChecked() || !bcBinaryChecked())
  1681. {
  1682. phaseModel.choise = false;
  1683. }
  1684. ResetAreaAndContent();
  1685. ReloadDebrisSelection();
  1686. }
  1687. else
  1688. {
  1689. if (bcOriginChecked() || !bcBinaryChecked())
  1690. {
  1691. phaseModel.choise = false;
  1692. }
  1693. else
  1694. {
  1695. phaseModel.choise = true;
  1696. }
  1697. this.documentWorkspace.Refresh();
  1698. }
  1699. sum = 0;
  1700. }
  1701. }
  1702. Mat temp;//中间变量
  1703. List<List<OpenCvSharp.Point>> ps;//轮廓的拓扑信息
  1704. DataTable dtDataGridView1 = null;
  1705. DataTable dtResult = null;
  1706. AppCommon appCommon = new AppCommon();
  1707. List<double> lstCarbideArea;//碳化物面积集合
  1708. List<double> lstCarbideAreaRatio;//碳化物面积率集合
  1709. /// <summary>
  1710. /// 刷新颗粒筛选颜色面积率效果
  1711. /// </summary>
  1712. private void ReloadDebrisSelection()
  1713. {
  1714. if (binarizationMat != null && bcBinaryChecked())
  1715. {
  1716. this.dataGridView1.Rows.Clear();
  1717. dtDataGridView1 = new DataTable();
  1718. //记录条件范围内石墨
  1719. lstPoint08_1 = new List<List<OpenCvSharp.Point>>();
  1720. lstPoint06_08 = new List<List<OpenCvSharp.Point>>();
  1721. lstPoint04_06 = new List<List<OpenCvSharp.Point>>();
  1722. lstPoint02_04 = new List<List<OpenCvSharp.Point>>();
  1723. lstPoint01_02 = new List<List<OpenCvSharp.Point>>();
  1724. lstPoint0_01 = new List<List<OpenCvSharp.Point>>();
  1725. //记录视场珠光体含量总和
  1726. double carbideNumSum = 0;
  1727. lstCarbideArea = new List<double>();//碳化物面积集合
  1728. lstCarbideAreaRatio = new List<double>();//碳化物面积率集合
  1729. ps = new List<List<OpenCvSharp.Point>>();//轮廓的拓扑信息
  1730. pointList.Clear();
  1731. leList.Clear();
  1732. temp = new Mat();
  1733. if (this.documentWorkspace.GraphicsList.IsExsitView())
  1734. {
  1735. List<OpenCvSharp.Point[][]> points = new List<OpenCvSharp.Point[][]>();//各石墨轮廓集合
  1736. List<List<int>> lstAttribute = new List<List<int>>();//各个视场属性集合,索引0-横坐标,1-纵坐标,2-视场宽度,3-视场高度,4-视场面积
  1737. int sumFieldl = 0; //视场个数
  1738. Mat tempCopy = BinaryClass.BGRA2GRAY(binarizationMat);
  1739. //调用处理视场方法
  1740. appCommon.MultiFieldView(appWorkspace, binarizationMat, listView1, documentWorkspace, out points, out lstAttribute, out sumFieldl);
  1741. int h = 0;
  1742. foreach (OpenCvSharp.Point[][] contours in points)
  1743. {
  1744. h++;
  1745. double totalAreaSum = 0;//面积总数
  1746. double screenArea = 0;//筛选的面积
  1747. for (int i = 0; i < contours.Length; i++)
  1748. {
  1749. for (int f = 0; f < contours[i].Length; f++)
  1750. {
  1751. contours[i][f].X = contours[i][f].X + lstAttribute[h - 1][0];
  1752. contours[i][f].Y = contours[i][f].Y + lstAttribute[h - 1][1];
  1753. }
  1754. double radius; //外接圆半径
  1755. double area = appCommon.Area(tempCopy, contours[i][0]);
  1756. double equalDiameter = Math.Sqrt(area / Math.PI) * 2 * unitLength;
  1757. if (this.checkBox3.Checked)
  1758. {
  1759. if (this.checkBox6.Checked)
  1760. {
  1761. if (equalDiameter < 20)
  1762. {
  1763. ps.Add(contours[i].ToList());
  1764. continue;
  1765. }
  1766. if (area >= (this.trackBar2.Value / (unitLength * unitLength)) && area <= (this.trackBar4.Value / (unitLength * unitLength)))
  1767. {
  1768. ps.Add(contours[i].ToList());
  1769. }
  1770. else
  1771. {
  1772. if (contours[i].Length < 5)
  1773. {
  1774. continue;
  1775. }
  1776. else
  1777. {
  1778. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  1779. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  1780. double outerCircle = radius * radius * Math.PI;//外接圆面积
  1781. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  1782. if (areaRatio > 0 && areaRatio <= 1)
  1783. {
  1784. totalAreaSum += area;
  1785. if (this.checkBox2.Checked)
  1786. {
  1787. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  1788. {
  1789. screenArea += area;
  1790. }
  1791. else
  1792. {
  1793. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1794. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1795. }
  1796. }
  1797. else
  1798. {
  1799. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1800. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1801. }
  1802. pointList.Add(contours[i][0]);
  1803. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  1804. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  1805. if (areaRatio > 0.8 && areaRatio <= 1)
  1806. {
  1807. lstPoint08_1.Add(contours[i].ToList());
  1808. }
  1809. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  1810. {
  1811. lstPoint06_08.Add(contours[i].ToList());
  1812. }
  1813. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  1814. {
  1815. lstPoint04_06.Add(contours[i].ToList());
  1816. }
  1817. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  1818. {
  1819. lstPoint02_04.Add(contours[i].ToList());
  1820. }
  1821. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  1822. {
  1823. lstPoint01_02.Add(contours[i].ToList());
  1824. }
  1825. else if (areaRatio > 0 && areaRatio <= 0.1)
  1826. {
  1827. lstPoint0_01.Add(contours[i].ToList());
  1828. }
  1829. }
  1830. else
  1831. {
  1832. ps.Add(contours[i].ToList());
  1833. }
  1834. }
  1835. }
  1836. }
  1837. else
  1838. {
  1839. if (area >= (this.trackBar2.Value / (unitLength * unitLength)) && area <= (this.trackBar4.Value / (unitLength * unitLength)))
  1840. {
  1841. ps.Add(contours[i].ToList());
  1842. }
  1843. else
  1844. {
  1845. if (contours[i].Length < 5)
  1846. {
  1847. continue;
  1848. }
  1849. else
  1850. {
  1851. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  1852. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  1853. double outerCircle = radius * radius * Math.PI;//外接圆面积
  1854. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  1855. if (areaRatio > 0 && areaRatio <= 1)
  1856. {
  1857. totalAreaSum += area;
  1858. if (this.checkBox2.Checked)
  1859. {
  1860. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  1861. {
  1862. screenArea += area;
  1863. }
  1864. else
  1865. {
  1866. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1867. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1868. }
  1869. }
  1870. else
  1871. {
  1872. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1873. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1874. }
  1875. pointList.Add(contours[i][0]);
  1876. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  1877. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  1878. if (areaRatio > 0.8 && areaRatio <= 1)
  1879. {
  1880. lstPoint08_1.Add(contours[i].ToList());
  1881. }
  1882. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  1883. {
  1884. lstPoint06_08.Add(contours[i].ToList());
  1885. }
  1886. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  1887. {
  1888. lstPoint04_06.Add(contours[i].ToList());
  1889. }
  1890. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  1891. {
  1892. lstPoint02_04.Add(contours[i].ToList());
  1893. }
  1894. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  1895. {
  1896. lstPoint01_02.Add(contours[i].ToList());
  1897. }
  1898. else if (areaRatio > 0 && areaRatio <= 0.1)
  1899. {
  1900. lstPoint0_01.Add(contours[i].ToList());
  1901. }
  1902. }
  1903. else
  1904. {
  1905. ps.Add(contours[i].ToList());
  1906. }
  1907. }
  1908. }
  1909. }
  1910. }
  1911. else
  1912. {
  1913. if (this.checkBox6.Checked)
  1914. {
  1915. if (equalDiameter < 20)
  1916. {
  1917. ps.Add(contours[i].ToList());
  1918. }
  1919. }
  1920. if (contours[i].Length < 5)
  1921. continue;
  1922. else
  1923. {
  1924. if (this.checkBox6.Checked)
  1925. {
  1926. //if (equalDiameter < 20)
  1927. //{
  1928. // ps.Add(contours[i].ToList());
  1929. //}
  1930. if (equalDiameter >= 20)
  1931. {
  1932. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  1933. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  1934. double outerCircle = radius * radius * Math.PI;//外接圆面积
  1935. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  1936. if (areaRatio > 0 && areaRatio <= 1)
  1937. {
  1938. totalAreaSum += area;
  1939. if (this.checkBox2.Checked)
  1940. {
  1941. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  1942. {
  1943. screenArea += area;
  1944. }
  1945. else
  1946. {
  1947. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1948. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1949. }
  1950. }
  1951. else
  1952. {
  1953. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  1954. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  1955. }
  1956. pointList.Add(contours[i][0]);
  1957. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  1958. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  1959. if (areaRatio > 0.8 && areaRatio <= 1)
  1960. {
  1961. lstPoint08_1.Add(contours[i].ToList());
  1962. }
  1963. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  1964. {
  1965. lstPoint06_08.Add(contours[i].ToList());
  1966. }
  1967. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  1968. {
  1969. lstPoint04_06.Add(contours[i].ToList());
  1970. }
  1971. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  1972. {
  1973. lstPoint02_04.Add(contours[i].ToList());
  1974. }
  1975. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  1976. {
  1977. lstPoint01_02.Add(contours[i].ToList());
  1978. }
  1979. else if (areaRatio > 0 && areaRatio <= 0.1)
  1980. {
  1981. lstPoint0_01.Add(contours[i].ToList());
  1982. }
  1983. }
  1984. else
  1985. {
  1986. ps.Add(contours[i].ToList());
  1987. }
  1988. }
  1989. }
  1990. else
  1991. {
  1992. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  1993. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  1994. double outerCircle = radius * radius * Math.PI;//外接圆面积
  1995. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  1996. if (areaRatio > 0 && areaRatio <= 1)
  1997. {
  1998. totalAreaSum += area;
  1999. if (this.checkBox2.Checked)
  2000. {
  2001. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  2002. {
  2003. screenArea += area;
  2004. }
  2005. else
  2006. {
  2007. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2008. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2009. }
  2010. }
  2011. else
  2012. {
  2013. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2014. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2015. }
  2016. pointList.Add(contours[i][0]);
  2017. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  2018. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  2019. if (areaRatio > 0.8 && areaRatio <= 1)
  2020. {
  2021. lstPoint08_1.Add(contours[i].ToList());
  2022. }
  2023. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  2024. {
  2025. lstPoint06_08.Add(contours[i].ToList());
  2026. }
  2027. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  2028. {
  2029. lstPoint04_06.Add(contours[i].ToList());
  2030. }
  2031. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  2032. {
  2033. lstPoint02_04.Add(contours[i].ToList());
  2034. }
  2035. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  2036. {
  2037. lstPoint01_02.Add(contours[i].ToList());
  2038. }
  2039. else if (areaRatio > 0 && areaRatio <= 0.1)
  2040. {
  2041. lstPoint0_01.Add(contours[i].ToList());
  2042. }
  2043. }
  2044. else
  2045. {
  2046. ps.Add(contours[i].ToList());
  2047. }
  2048. }
  2049. }
  2050. }
  2051. }
  2052. string level = string.Empty; //碳化物级别
  2053. double carbideNum = (totalAreaSum - screenArea) / (lstAttribute[h - 1][4] - screenArea); //碳化物数量
  2054. if (IronType == 4 || IronType == 5)
  2055. {
  2056. if (carbideNum >= 0 && carbideNum <= 0.005)
  2057. {
  2058. level = PdnResources.GetString("Menu.phosphorus.Text")+"0.5";
  2059. }
  2060. else if (carbideNum > 0.005 && carbideNum <= 0.01)
  2061. {
  2062. level = PdnResources.GetString("Menu.phosphorus.Text")+"1";
  2063. }
  2064. else if (carbideNum > 0.01 && carbideNum <= 0.02)
  2065. {
  2066. level = PdnResources.GetString("Menu.phosphorus.Text")+"2";
  2067. }
  2068. else if (carbideNum > 0.02 && carbideNum <= 0.03)
  2069. {
  2070. level = PdnResources.GetString("Menu.phosphorus.Text")+"3";
  2071. }
  2072. else if (carbideNum > 0.03 && carbideNum <= 0.05)
  2073. {
  2074. level = PdnResources.GetString("Menu.phosphorus.Text")+"5";
  2075. }
  2076. else
  2077. {
  2078. level = "-";
  2079. }
  2080. }
  2081. else
  2082. {
  2083. if (carbideNum >= 0 && carbideNum <= 0.01)
  2084. {
  2085. level = PdnResources.GetString("Menu.carbon.Text")+"1";
  2086. }
  2087. else if (carbideNum > 0.01 && carbideNum <= 0.02)
  2088. {
  2089. level = PdnResources.GetString("Menu.carbon.Text")+"2";
  2090. }
  2091. else if (carbideNum > 0.02 && carbideNum <= 0.03)
  2092. {
  2093. level = PdnResources.GetString("Menu.carbon.Text")+"3";
  2094. }
  2095. else if (carbideNum > 0.03 && carbideNum <= 0.05)
  2096. {
  2097. level = PdnResources.GetString("Menu.carbon.Text")+"5";
  2098. }
  2099. else if (carbideNum > 0.05 && carbideNum <= 0.07)
  2100. {
  2101. level = PdnResources.GetString("Menu.carbon.Text") + "7";
  2102. }
  2103. else if (carbideNum > 0.07 && carbideNum <= 0.1)
  2104. {
  2105. level = PdnResources.GetString("Menu.carbon.Text")+"10";
  2106. }
  2107. else
  2108. {
  2109. level = "-";
  2110. }
  2111. }
  2112. this.dataGridView1.Rows.Add($"{PdnResources.GetString("Menu.view.text")}{h}", carbideNum * 100, level);
  2113. carbideNumSum += carbideNum;
  2114. }
  2115. if (sumFieldl > 1)
  2116. {
  2117. string avgLevel = string.Empty;
  2118. double avgCarbideNum = carbideNumSum / sumFieldl;
  2119. if (IronType == 4 || IronType == 5)
  2120. {
  2121. if (avgCarbideNum >= 0 && avgCarbideNum <= 0.005)
  2122. {
  2123. avgLevel = PdnResources.GetString("Menu.phosphorus.Text")+"0.5";
  2124. }
  2125. else if (avgCarbideNum > 0.005 && avgCarbideNum <= 0.01)
  2126. {
  2127. avgLevel = PdnResources.GetString("Menu.phosphorus.Text")+"1";
  2128. }
  2129. else if (avgCarbideNum > 0.01 && avgCarbideNum <= 0.02)
  2130. {
  2131. avgLevel = PdnResources.GetString("Menu.phosphorus.Text")+"2";
  2132. }
  2133. else if (avgCarbideNum > 0.02 && avgCarbideNum <= 0.03)
  2134. {
  2135. avgLevel = PdnResources.GetString("Menu.phosphorus.Text")+"3";
  2136. }
  2137. else if (avgCarbideNum > 0.03 && avgCarbideNum <= 0.05)
  2138. {
  2139. avgLevel = PdnResources.GetString("Menu.phosphorus.Text")+"5";
  2140. }
  2141. else
  2142. {
  2143. avgLevel = "-";
  2144. }
  2145. }
  2146. else
  2147. {
  2148. if (avgCarbideNum > 0 && avgCarbideNum <= 0.01)
  2149. {
  2150. avgLevel = PdnResources.GetString("Menu.carbon.Text")+"1";
  2151. }
  2152. else if (avgCarbideNum > 0.01 && avgCarbideNum <= 0.02)
  2153. {
  2154. avgLevel = PdnResources.GetString("Menu.carbon.Text")+"2";
  2155. }
  2156. else if (avgCarbideNum > 0.02 && avgCarbideNum <= 0.03)
  2157. {
  2158. avgLevel = PdnResources.GetString("Menu.carbon.Text")+"3";
  2159. }
  2160. else if (avgCarbideNum > 0.03 && avgCarbideNum <= 0.05)
  2161. {
  2162. avgLevel = PdnResources.GetString("Menu.carbon.Text")+"5";
  2163. }
  2164. else if (avgCarbideNum > 0.05 && avgCarbideNum <= 0.07)
  2165. {
  2166. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "7";
  2167. }
  2168. else if (avgCarbideNum > 0.07 && avgCarbideNum <= 0.1)
  2169. {
  2170. avgLevel = PdnResources.GetString("Menu.carbon.Text")+"10";
  2171. }
  2172. else
  2173. {
  2174. avgLevel = "-";
  2175. }
  2176. }
  2177. this.dataGridView1.Rows.Add(PdnResources.GetString("Menu.Image.Average.Text"), 100 * avgCarbideNum, avgLevel);
  2178. }
  2179. }
  2180. else
  2181. {
  2182. OpenCvSharp.Point[][] contours;//原始轮廓信息
  2183. HierarchyIndex[] hierachy;
  2184. Mat tempCopy = BinaryClass.BGRA2GRAY(binarizationMat);
  2185. Cv2.FindContours(BinaryClass.BGRA2GRAY(binarizationMat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  2186. double spheroidizationSum = 0;//石墨个数
  2187. double totalSum = 0;//石墨总数
  2188. double totalAreaSum = 0;//面积总数
  2189. double screenArea = 0;
  2190. for (int i = 0; i < hierachy.Length; i++)
  2191. {
  2192. if (hierachy[i].Parent == -1)
  2193. {
  2194. double radius; //外接圆半径
  2195. double area = appCommon.Area(tempCopy, contours[i][0]);
  2196. double equalDiameter = Math.Sqrt(area / Math.PI) * 2 * unitLength;
  2197. if (this.checkBox3.Checked)
  2198. {
  2199. if (this.checkBox6.Checked)
  2200. {
  2201. if (equalDiameter < 20)
  2202. {
  2203. ps.Add(contours[i].ToList());
  2204. continue;
  2205. }
  2206. if (area >= (this.trackBar2.Value / (unitLength * unitLength)) && area <= (this.trackBar4.Value / (unitLength * unitLength)))
  2207. {
  2208. ps.Add(contours[i].ToList());
  2209. }
  2210. else
  2211. {
  2212. if (contours[i].Length < 5)
  2213. {
  2214. continue;
  2215. }
  2216. else
  2217. {
  2218. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2219. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  2220. double outerCircle = radius * radius * Math.PI;//外接圆面积
  2221. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  2222. if (areaRatio > 0 && areaRatio <= 1)
  2223. {
  2224. totalAreaSum += area;
  2225. totalSum++;
  2226. if (this.checkBox2.Checked)
  2227. {
  2228. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  2229. {
  2230. spheroidizationSum++;
  2231. screenArea += area;
  2232. }
  2233. else
  2234. {
  2235. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2236. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2237. }
  2238. }
  2239. else
  2240. {
  2241. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2242. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2243. }
  2244. pointList.Add(contours[i][0]);
  2245. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  2246. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  2247. if (areaRatio > 0.8 && areaRatio <= 1)
  2248. {
  2249. lstPoint08_1.Add(contours[i].ToList());
  2250. }
  2251. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  2252. {
  2253. lstPoint06_08.Add(contours[i].ToList());
  2254. }
  2255. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  2256. {
  2257. lstPoint04_06.Add(contours[i].ToList());
  2258. }
  2259. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  2260. {
  2261. lstPoint02_04.Add(contours[i].ToList());
  2262. }
  2263. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  2264. {
  2265. lstPoint01_02.Add(contours[i].ToList());
  2266. }
  2267. else if (areaRatio > 0 && areaRatio <= 0.1)
  2268. {
  2269. lstPoint0_01.Add(contours[i].ToList());
  2270. }
  2271. }
  2272. else
  2273. {
  2274. ps.Add(contours[i].ToList());
  2275. }
  2276. }
  2277. }
  2278. }
  2279. else
  2280. {
  2281. if (area >= (this.trackBar2.Value / (unitLength * unitLength)) && area <= (this.trackBar4.Value / (unitLength * unitLength)))
  2282. {
  2283. ps.Add(contours[i].ToList());
  2284. }
  2285. else
  2286. {
  2287. if (contours[i].Length < 5)
  2288. {
  2289. continue;
  2290. }
  2291. else
  2292. {
  2293. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2294. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  2295. double outerCircle = radius * radius * Math.PI;//外接圆面积
  2296. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  2297. if (areaRatio > 0 && areaRatio <= 1)
  2298. {
  2299. totalAreaSum += area;
  2300. totalSum++;
  2301. if (this.checkBox2.Checked)
  2302. {
  2303. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  2304. {
  2305. spheroidizationSum++;
  2306. screenArea += area;
  2307. }
  2308. else
  2309. {
  2310. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2311. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2312. }
  2313. }
  2314. else
  2315. {
  2316. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2317. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2318. }
  2319. pointList.Add(contours[i][0]);
  2320. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  2321. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  2322. if (areaRatio > 0.8 && areaRatio <= 1)
  2323. {
  2324. lstPoint08_1.Add(contours[i].ToList());
  2325. }
  2326. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  2327. {
  2328. lstPoint06_08.Add(contours[i].ToList());
  2329. }
  2330. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  2331. {
  2332. lstPoint04_06.Add(contours[i].ToList());
  2333. }
  2334. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  2335. {
  2336. lstPoint02_04.Add(contours[i].ToList());
  2337. }
  2338. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  2339. {
  2340. lstPoint01_02.Add(contours[i].ToList());
  2341. }
  2342. else if (areaRatio > 0 && areaRatio <= 0.1)
  2343. {
  2344. lstPoint0_01.Add(contours[i].ToList());
  2345. }
  2346. }
  2347. else
  2348. {
  2349. ps.Add(contours[i].ToList());
  2350. }
  2351. }
  2352. }
  2353. }
  2354. }
  2355. else
  2356. {
  2357. if (this.checkBox6.Checked)
  2358. {
  2359. if (equalDiameter < 20)
  2360. {
  2361. ps.Add(contours[i].ToList());
  2362. }
  2363. }
  2364. if (contours[i].Length < 5)
  2365. continue;
  2366. else
  2367. {
  2368. if (this.checkBox6.Checked)
  2369. {
  2370. //if (equalDiameter < 20)
  2371. //{
  2372. // ps.Add(contours[i].ToList());
  2373. //}
  2374. if (equalDiameter >= 20)
  2375. {
  2376. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2377. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  2378. double outerCircle = radius * radius * Math.PI;//外接圆面积
  2379. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  2380. if (areaRatio > 0 && areaRatio <= 1)
  2381. {
  2382. totalAreaSum += area;
  2383. totalSum++;
  2384. if (this.checkBox2.Checked)
  2385. {
  2386. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  2387. {
  2388. spheroidizationSum++;
  2389. screenArea += area;
  2390. }
  2391. else
  2392. {
  2393. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2394. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2395. }
  2396. }
  2397. else
  2398. {
  2399. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2400. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2401. }
  2402. pointList.Add(contours[i][0]);
  2403. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  2404. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  2405. if (areaRatio > 0.8 && areaRatio <= 1)
  2406. {
  2407. lstPoint08_1.Add(contours[i].ToList());
  2408. }
  2409. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  2410. {
  2411. lstPoint06_08.Add(contours[i].ToList());
  2412. }
  2413. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  2414. {
  2415. lstPoint04_06.Add(contours[i].ToList());
  2416. }
  2417. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  2418. {
  2419. lstPoint02_04.Add(contours[i].ToList());
  2420. }
  2421. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  2422. {
  2423. lstPoint01_02.Add(contours[i].ToList());
  2424. }
  2425. else if (areaRatio > 0 && areaRatio <= 0.1)
  2426. {
  2427. lstPoint0_01.Add(contours[i].ToList());
  2428. }
  2429. }
  2430. else
  2431. {
  2432. ps.Add(contours[i].ToList());
  2433. }
  2434. }
  2435. }
  2436. else
  2437. {
  2438. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2439. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  2440. double outerCircle = radius * radius * Math.PI;//外接圆面积
  2441. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  2442. if (areaRatio > 0 && areaRatio <= 1)
  2443. {
  2444. totalAreaSum += area;
  2445. totalSum++;
  2446. if (this.checkBox2.Checked)
  2447. {
  2448. if (areaRatio * 100 >= this.trackBar5.Value && areaRatio * 100 <= this.trackBar6.Value)
  2449. {
  2450. spheroidizationSum++;
  2451. screenArea += area;
  2452. }
  2453. else
  2454. {
  2455. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2456. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2457. }
  2458. }
  2459. else
  2460. {
  2461. lstCarbideArea.Add(area * unitLength * unitLength);//碳化物面积集合
  2462. lstCarbideAreaRatio.Add(areaRatio);//碳化物面积率集合
  2463. }
  2464. pointList.Add(contours[i][0]);
  2465. leList.Add(Math.Round(double.Parse(string.IsNullOrEmpty(areaRatio.ToString()) ? "0" :
  2466. areaRatio.ToString()), Convert.ToInt32(this.numericUpDown1.Value)));
  2467. if (areaRatio > 0.8 && areaRatio <= 1)
  2468. {
  2469. lstPoint08_1.Add(contours[i].ToList());
  2470. }
  2471. else if (areaRatio > 0.6 && areaRatio <= 0.8)
  2472. {
  2473. lstPoint06_08.Add(contours[i].ToList());
  2474. }
  2475. else if (areaRatio > 0.4 && areaRatio <= 0.6)
  2476. {
  2477. lstPoint04_06.Add(contours[i].ToList());
  2478. }
  2479. else if (areaRatio > 0.2 && areaRatio <= 0.4)
  2480. {
  2481. lstPoint02_04.Add(contours[i].ToList());
  2482. }
  2483. else if (areaRatio > 0.1 && areaRatio <= 0.2)
  2484. {
  2485. lstPoint01_02.Add(contours[i].ToList());
  2486. }
  2487. else if (areaRatio > 0 && areaRatio <= 0.1)
  2488. {
  2489. lstPoint0_01.Add(contours[i].ToList());
  2490. }
  2491. }
  2492. else
  2493. {
  2494. ps.Add(contours[i].ToList());
  2495. }
  2496. }
  2497. }
  2498. }
  2499. }
  2500. }
  2501. string level = string.Empty; //球化级别
  2502. double carbideNum = (totalAreaSum - screenArea) / (picArea - screenArea); //碳化物数量
  2503. if (IronType == 4 || IronType == 5)
  2504. {
  2505. if (carbideNum >= 0 && carbideNum <= 0.005)
  2506. {
  2507. level = PdnResources.GetString("Menu.phosphorus.Text")+"0.5";
  2508. }
  2509. else if (carbideNum > 0.005 && carbideNum <= 0.01)
  2510. {
  2511. level = PdnResources.GetString("Menu.phosphorus.Text")+"1";
  2512. }
  2513. else if (carbideNum > 0.01 && carbideNum <= 0.02)
  2514. {
  2515. level = PdnResources.GetString("Menu.phosphorus.Text")+"2";
  2516. }
  2517. else if (carbideNum > 0.02 && carbideNum <= 0.03)
  2518. {
  2519. level = PdnResources.GetString("Menu.phosphorus.Text")+"3";
  2520. }
  2521. else if (carbideNum > 0.03 && carbideNum <= 0.05)
  2522. {
  2523. level = PdnResources.GetString("Menu.phosphorus.Text")+"5";
  2524. }
  2525. else
  2526. {
  2527. level = "-";
  2528. }
  2529. }
  2530. else
  2531. {
  2532. if (carbideNum > 0 && carbideNum <= 0.01)
  2533. {
  2534. level = PdnResources.GetString("Menu.carbon.Text")+"1";
  2535. }
  2536. else if (carbideNum > 0.01 && carbideNum <= 0.02)
  2537. {
  2538. level = PdnResources.GetString("Menu.carbon.Text")+"2";
  2539. }
  2540. else if (carbideNum > 0.02 && carbideNum <= 0.03)
  2541. {
  2542. level = PdnResources.GetString("Menu.carbon.Text")+"3";
  2543. }
  2544. else if (carbideNum > 0.03 && carbideNum <= 0.05)
  2545. {
  2546. level = PdnResources.GetString("Menu.carbon.Text")+"5";
  2547. }
  2548. else if (carbideNum > 0.05 && carbideNum <= 0.07)
  2549. {
  2550. level = PdnResources.GetString("Menu.carbon.Text") + "7";
  2551. }
  2552. else if (carbideNum > 0.07 && carbideNum <= 0.1)
  2553. {
  2554. level = PdnResources.GetString("Menu.carbon.Text")+"10";
  2555. }
  2556. else
  2557. {
  2558. level = "-";
  2559. }
  2560. }
  2561. if (pointList.Count > 0)
  2562. {
  2563. this.dataGridView1.Rows.Add(PdnResources.GetString("Menu.view.text")+"1", carbideNum * 100, level);
  2564. }
  2565. }
  2566. binarizationMat.CopyTo(temp);
  2567. if (checkBox4.Checked)
  2568. {
  2569. DisplayColor();
  2570. }
  2571. if (checkBox5.Checked && !bcOriginChecked())
  2572. {
  2573. AddPictureBoxEvent();
  2574. }
  2575. Cv2.FillPoly(temp, ps, new Scalar(0, 0, 0, 0)); //筛选颜色
  2576. phaseModel.mat = temp;
  2577. //RefreshDataGridView1();
  2578. this.documentWorkspace.Refresh();
  2579. //数据结果保存
  2580. dtDataGridView1 = appCommon.ResultDataSaving(dataGridView1);
  2581. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  2582. string tag = this.imageList1.Images.Keys[this.listView1.FocusedItem.Index];
  2583. //dtResult = new DataTable(tag);
  2584. //分析数据保存
  2585. dtResult = appCommon.AnalysisDataSaving(dataGridView1, imgName, tag);
  2586. if (dtDataGridView1.Rows.Count > 0)
  2587. {
  2588. RefreshDataGridView1();
  2589. }
  2590. if (bcOriginChecked())
  2591. {
  2592. appCommonDisplay.DisplayData(this.dataGridView1, false);
  2593. }
  2594. }
  2595. }
  2596. /// <summary>
  2597. /// 显示不同颜色方法
  2598. /// </summary>
  2599. public void DisplayColor()
  2600. {
  2601. //this.documentWorkspace.PhaseModels[0].choise = false;
  2602. //填充颜色
  2603. if (this.checkBox4.Checked)
  2604. {
  2605. Mat[] arr = temp.Split();
  2606. temp = temp.CvtColor(ColorConversionCodes.BGRA2BGR);
  2607. for (int i = 0; i < lstPoint08_1.Count; i++)
  2608. {
  2609. int length = Cv2.FloodFill(temp, lstPoint08_1[i][lstPoint08_1[i].Count - 1], new Scalar(colour["panelColour1_08"].B, colour["panelColour1_08"].G, colour["panelColour1_08"].R));
  2610. }
  2611. for (int i = 0; i < lstPoint06_08.Count; i++)
  2612. {
  2613. int length = Cv2.FloodFill(temp, lstPoint06_08[i][lstPoint06_08[i].Count - 1], new Scalar(colour["panelColour08_06"].B, colour["panelColour08_06"].G, colour["panelColour08_06"].R));
  2614. }
  2615. for (int i = 0; i < lstPoint04_06.Count; i++)
  2616. {
  2617. int length = Cv2.FloodFill(temp, lstPoint04_06[i][lstPoint04_06[i].Count - 1], new Scalar(colour["panelColour06_04"].B, colour["panelColour06_04"].G, colour["panelColour06_04"].R));
  2618. }
  2619. for (int i = 0; i < lstPoint02_04.Count; i++)
  2620. {
  2621. int length = Cv2.FloodFill(temp, lstPoint02_04[i][lstPoint02_04[i].Count - 1], new Scalar(colour["panelColour04_02"].B, colour["panelColour04_02"].G, colour["panelColour04_02"].R));
  2622. }
  2623. for (int i = 0; i < lstPoint01_02.Count; i++)
  2624. {
  2625. int length = Cv2.FloodFill(temp, lstPoint01_02[i][lstPoint01_02[i].Count - 1], new Scalar(colour["panelColour02_01"].B, colour["panelColour02_01"].G, colour["panelColour02_01"].R));
  2626. }
  2627. for (int i = 0; i < lstPoint0_01.Count; i++)
  2628. {
  2629. int length = Cv2.FloodFill(temp, lstPoint0_01[i][lstPoint0_01[i].Count - 1], new Scalar(colour["panelColour01_0"].B, colour["panelColour01_0"].G, colour["panelColour01_0"].R));
  2630. }
  2631. Mat[] arr2 = temp.Split();
  2632. arr[0] = arr2[0];
  2633. arr[1] = arr2[1];
  2634. arr[2] = arr2[2];
  2635. Cv2.Merge(arr, temp);
  2636. phaseModel.mat = temp;
  2637. }
  2638. this.documentWorkspace.Refresh();
  2639. }
  2640. /// <summary>
  2641. /// 添加内容单元格
  2642. /// </summary>
  2643. /// <param name="text"></param>
  2644. /// <param name="tag"></param>
  2645. /// <returns></returns>
  2646. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  2647. {
  2648. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  2649. textboxcell.Value = text;
  2650. textboxcell.Tag = tag;
  2651. return textboxcell;
  2652. }
  2653. /// <summary>
  2654. /// 刷新其他信息
  2655. /// </summary>
  2656. private void ResetAreaAndContent()
  2657. {
  2658. if (binarizationMat != null && bcBinaryChecked())
  2659. {
  2660. OpenCvSharp.Point[][] contours;//原始轮廓信息
  2661. HierarchyIndex[] hierachy;
  2662. Mat tempCopy = BinaryClass.BGRA2GRAY(binarizationMat);
  2663. //Mat temp = new Mat();
  2664. //binarizationMat.CopyTo(temp);
  2665. Cv2.FindContours(BinaryClass.BGRA2GRAY(binarizationMat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  2666. if (hierachy.Length > 0)
  2667. {
  2668. double maxArea = 0;//面积最大值
  2669. double minArea = 9999999999;//面积最小值
  2670. double maxAreaRatio = 0;//面积率最大值
  2671. double minAreaRatio = 100;//面积率最小值
  2672. double radius = 0;//外接圆半径
  2673. double area = 0;
  2674. for (int i = 0; i < hierachy.Length; i++)
  2675. {
  2676. if (hierachy[i].Parent == -1)
  2677. {
  2678. area = appCommon.Area(tempCopy, contours[i][0]);
  2679. if (maxArea < area)
  2680. maxArea = area;
  2681. if (minArea > area)
  2682. minArea = area;
  2683. }
  2684. if (contours[i].Length < 5)
  2685. continue;
  2686. else
  2687. {
  2688. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2689. radius = BasicCalculationHelper.CalcLongTrail(contours[i]);
  2690. double outerCircle = radius * radius * Math.PI;//外接圆面积
  2691. double areaRatio = (area - contours[i].Length / 2.0) / outerCircle;
  2692. if (areaRatio >= 0 && areaRatio <= 1)
  2693. {
  2694. if (maxAreaRatio < areaRatio * 100)
  2695. maxAreaRatio = areaRatio * 100;
  2696. if (minAreaRatio > areaRatio * 100)
  2697. minAreaRatio = areaRatio * 100;
  2698. }
  2699. }
  2700. }
  2701. //phaseModel.mat = temp;
  2702. if (!changeColor)
  2703. {
  2704. maxArea = maxArea * unitLength * unitLength;
  2705. minArea = minArea * unitLength * unitLength;
  2706. //maxAreaRatio = maxAreaRatio;
  2707. //minAreaRatio = minAreaRatio;
  2708. int maxNum = (int)Math.Ceiling(maxArea);//获取面积最大值
  2709. int minNum = (int)Math.Floor(minArea);//获取面积最小值
  2710. int maxNumRatio = (int)Math.Ceiling(maxAreaRatio);//获取面积率最大值
  2711. int minNumRatio = (int)Math.Floor(minAreaRatio);//获取面积率最小值
  2712. //先解绑事件以防数据赋值异常
  2713. this.numericUpDown4.ValueChanged -= numericUpDown4_ValueChanged;
  2714. this.numericUpDown5.ValueChanged -= numericUpDown5_ValueChanged;
  2715. this.numericUpDown6.ValueChanged -= numericUpDown6_ValueChanged;
  2716. this.numericUpDown7.ValueChanged -= numericUpDown7_ValueChanged;
  2717. this.trackBar2.Scroll -= trackBar2_Scroll;
  2718. this.trackBar4.Scroll -= trackBar4_Scroll;
  2719. this.trackBar5.Scroll -= trackBar5_Scroll;
  2720. this.trackBar6.Scroll -= trackBar6_Scroll;
  2721. this.numericUpDown4.Maximum = maxNum;
  2722. this.numericUpDown4.Minimum = minNum;
  2723. this.trackBar2.Maximum = maxNum;
  2724. this.trackBar2.Minimum = minNum;
  2725. this.numericUpDown5.Maximum = maxNum;
  2726. this.numericUpDown5.Minimum = minNum;
  2727. this.trackBar4.Maximum = maxNum;
  2728. this.trackBar4.Minimum = minNum;
  2729. this.numericUpDown4.Value = minNum;
  2730. this.trackBar2.Value = minNum;
  2731. this.numericUpDown5.Value = maxNum;
  2732. this.trackBar4.Value = maxNum;
  2733. if (maxNumRatio != 0 || minNumRatio != 100)
  2734. {
  2735. this.numericUpDown6.Maximum = maxNumRatio;
  2736. this.numericUpDown6.Minimum = minNumRatio;
  2737. this.trackBar5.Maximum = maxNumRatio;
  2738. this.trackBar5.Minimum = minNumRatio;
  2739. this.numericUpDown7.Maximum = maxNumRatio;
  2740. this.numericUpDown7.Minimum = minNumRatio;
  2741. this.trackBar6.Maximum = maxNumRatio;
  2742. this.trackBar6.Minimum = minNumRatio;
  2743. if (maxNumRatio > 60 && minNumRatio < 60)
  2744. {
  2745. this.trackBar5.Value = 60;
  2746. this.numericUpDown6.Value = 60;
  2747. }
  2748. this.numericUpDown7.Value = maxNumRatio;
  2749. this.trackBar6.Value = maxNumRatio;
  2750. }
  2751. if (areaRatioRangeMin != -1 && areaRatioRangeMin >= this.numericUpDown6.Minimum && areaRatioRangeMin <= this.numericUpDown7.Maximum)
  2752. {
  2753. trackBar5.Value = (int)areaRatioRangeMin;
  2754. this.numericUpDown6.Value = areaRatioRangeMin;
  2755. }
  2756. if (areaRatioRangeMax != -1 && areaRatioRangeMax >= this.numericUpDown6.Value && areaRatioRangeMax <= this.numericUpDown7.Maximum)
  2757. {
  2758. trackBar6.Value = (int)areaRatioRangeMax;
  2759. this.numericUpDown7.Value = areaRatioRangeMax;
  2760. }
  2761. if (areaMin != -1 && areaMin >= this.numericUpDown4.Minimum && areaMin <= this.numericUpDown5.Maximum)
  2762. {
  2763. trackBar2.Value = (int)areaMin;
  2764. this.numericUpDown4.Value = areaMin;
  2765. }
  2766. if (areaMax != -1 && areaMax >= this.numericUpDown4.Value && areaMax <= this.numericUpDown5.Maximum)
  2767. {
  2768. trackBar4.Value = (int)areaMax;
  2769. this.numericUpDown5.Value = areaMax;
  2770. }
  2771. this.numericUpDown4.ValueChanged += new EventHandler(numericUpDown4_ValueChanged);
  2772. this.numericUpDown5.ValueChanged += new EventHandler(numericUpDown5_ValueChanged);
  2773. this.numericUpDown6.ValueChanged += new EventHandler(numericUpDown6_ValueChanged);
  2774. this.numericUpDown7.ValueChanged += new EventHandler(numericUpDown7_ValueChanged);
  2775. this.trackBar2.Scroll += new EventHandler(trackBar2_Scroll);
  2776. this.trackBar4.Scroll += new EventHandler(trackBar4_Scroll);
  2777. this.trackBar5.Scroll += new EventHandler(trackBar5_Scroll);
  2778. this.trackBar6.Scroll += new EventHandler(trackBar6_Scroll);
  2779. //RefreshDataGridView1();
  2780. }
  2781. }
  2782. else
  2783. {
  2784. this.trackBar2.Maximum = 0;
  2785. this.trackBar2.Minimum = 0;
  2786. this.trackBar4.Maximum = 0;
  2787. this.trackBar4.Minimum = 0;
  2788. this.trackBar5.Maximum = 0;
  2789. this.trackBar5.Minimum = 0;
  2790. this.trackBar6.Maximum = 0;
  2791. this.trackBar6.Minimum = 0;
  2792. this.numericUpDown4.Maximum = 0;
  2793. this.numericUpDown4.Minimum = 0;
  2794. this.numericUpDown5.Maximum = 0;
  2795. this.numericUpDown5.Minimum = 0;
  2796. this.numericUpDown6.Maximum = 0;
  2797. this.numericUpDown6.Minimum = 0;
  2798. this.numericUpDown7.Maximum = 0;
  2799. this.numericUpDown7.Minimum = 0;
  2800. }
  2801. }
  2802. }
  2803. /// <summary>
  2804. /// 小数数字框值改变
  2805. /// </summary>
  2806. /// <param name="sender"></param>
  2807. /// <param name="e"></param>
  2808. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  2809. {
  2810. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  2811. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  2812. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  2813. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  2814. RefreshDataGridView1();
  2815. RefreshDataGridView2();
  2816. ReloadDebrisSelection();
  2817. }
  2818. /// <summary>
  2819. /// 是否筛选
  2820. /// </summary>
  2821. /// <param name="sender"></param>
  2822. /// <param name="e"></param>
  2823. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  2824. {
  2825. if (this.documentWorkspace != null && this.documentWorkspace.CompositionSurface == null)
  2826. return;
  2827. ResetAreaAndContent();
  2828. ReloadDebrisSelection();
  2829. }
  2830. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  2831. {
  2832. if (this.documentWorkspace != null && this.documentWorkspace.CompositionSurface == null)
  2833. return;
  2834. //ResetAreaAndContent();
  2835. ReloadDebrisSelection();
  2836. }
  2837. /// <summary>
  2838. /// 颗粒筛选范围最小值
  2839. /// </summary>
  2840. /// <param name="sender"></param>
  2841. /// <param name="e"></param>
  2842. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2843. {
  2844. if (this.numericUpDown4.Value > this.numericUpDown5.Value)
  2845. this.numericUpDown4.Value = this.numericUpDown5.Value;
  2846. this.trackBar2.Value = Convert.ToInt32(this.numericUpDown4.Value);
  2847. areaMin = this.numericUpDown4.Value;
  2848. areaMax = this.numericUpDown5.Value;
  2849. //二值判断
  2850. if (this.checkBox3.Checked && bcBinaryChecked() && !this.checkBox4.Checked)
  2851. {
  2852. ReloadDebrisSelection();
  2853. }
  2854. if (this.checkBox3.Checked && bcBinaryChecked() && this.checkBox4.Checked)
  2855. {
  2856. ReloadDebrisSelection();
  2857. }
  2858. }
  2859. /// <summary>
  2860. /// 颗粒筛选范围最大值
  2861. /// </summary>
  2862. /// <param name="sender"></param>
  2863. /// <param name="e"></param>
  2864. private void numericUpDown5_ValueChanged(object sender, EventArgs e)
  2865. {
  2866. if (this.numericUpDown5.Value < this.numericUpDown4.Value)
  2867. this.numericUpDown5.Value = this.numericUpDown4.Value;
  2868. this.trackBar4.Value = Convert.ToInt32(this.numericUpDown5.Value);
  2869. areaMin = this.numericUpDown4.Value;
  2870. areaMax = this.numericUpDown5.Value;
  2871. //二值判断
  2872. if (this.checkBox3.Checked && bcBinaryChecked() && !this.checkBox4.Checked)
  2873. {
  2874. ReloadDebrisSelection();
  2875. }
  2876. if (this.checkBox3.Checked && bcBinaryChecked() && this.checkBox4.Checked)
  2877. {
  2878. ReloadDebrisSelection();
  2879. }
  2880. }
  2881. /// <summary>
  2882. /// 颗粒筛选最小值滚动条
  2883. /// </summary>
  2884. /// <param name="sender"></param>
  2885. /// <param name="e"></param>
  2886. private void trackBar2_Scroll(object sender, EventArgs e)
  2887. {
  2888. this.numericUpDown4.Value = this.trackBar2.Value;
  2889. }
  2890. /// <summary>
  2891. /// 颗粒筛选最大值滚动条
  2892. /// </summary>
  2893. /// <param name="sender"></param>
  2894. /// <param name="e"></param>
  2895. private void trackBar4_Scroll(object sender, EventArgs e)
  2896. {
  2897. this.numericUpDown5.Value = this.trackBar4.Value;
  2898. }
  2899. /// <summary>
  2900. /// 石墨面积率区间最小
  2901. /// </summary>
  2902. /// <param name="sender"></param>
  2903. /// <param name="e"></param>
  2904. private void numericUpDown6_ValueChanged(object sender, EventArgs e)
  2905. {
  2906. if (this.numericUpDown6.Value > this.numericUpDown7.Value)
  2907. this.numericUpDown6.Value = this.numericUpDown7.Value;
  2908. this.trackBar5.Value = Convert.ToInt32(this.numericUpDown6.Value);
  2909. areaRatioRangeMin = this.numericUpDown6.Value;
  2910. areaRatioRangeMax = this.numericUpDown7.Value;
  2911. ReloadDebrisSelection();
  2912. }
  2913. /// <summary>
  2914. /// 石墨面积率区间最大
  2915. /// </summary>
  2916. /// <param name="sender"></param>
  2917. /// <param name="e"></param>
  2918. private void numericUpDown7_ValueChanged(object sender, EventArgs e)
  2919. {
  2920. if (this.numericUpDown7.Value < this.numericUpDown6.Value)
  2921. this.numericUpDown7.Value = this.numericUpDown6.Value;
  2922. this.trackBar6.Value = Convert.ToInt32(this.numericUpDown7.Value);
  2923. areaRatioRangeMin = this.numericUpDown6.Value;
  2924. areaRatioRangeMax = this.numericUpDown7.Value;
  2925. ReloadDebrisSelection();
  2926. }
  2927. /// <summary>
  2928. /// 石墨面积率最小值滚动条
  2929. /// </summary>
  2930. /// <param name="sender"></param>
  2931. /// <param name="e"></param>
  2932. private void trackBar5_Scroll(object sender, EventArgs e)
  2933. {
  2934. this.numericUpDown6.Value = this.trackBar5.Value;
  2935. }
  2936. /// <summary>
  2937. /// 石墨面积率最大值滚动条
  2938. /// </summary>
  2939. /// <param name="sender"></param>
  2940. /// <param name="e"></param>
  2941. private void trackBar6_Scroll(object sender, EventArgs e)
  2942. {
  2943. this.numericUpDown7.Value = this.trackBar6.Value;
  2944. }
  2945. /// <summary>
  2946. /// 显示不同颜色
  2947. /// </summary>
  2948. /// <param name="sender"></param>
  2949. /// <param name="e"></param>
  2950. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  2951. {
  2952. ReloadDebrisSelection();
  2953. }
  2954. /// <summary>
  2955. /// 添加画布绑定事件
  2956. /// </summary>
  2957. public void AddPictureBoxEvent()
  2958. {
  2959. this.documentWorkspace.panel.Paint -= new PaintEventHandler(this.BoxPaintHandler);
  2960. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);
  2961. }
  2962. /// <summary>
  2963. /// 绘制事件
  2964. /// </summary>
  2965. /// <param name="sender"></param>
  2966. /// <param name="e"></param>
  2967. private void BoxPaintHandler(object sender, PaintEventArgs e)
  2968. {
  2969. if (this.documentWorkspace.CompositionSurface != null)
  2970. {
  2971. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2972. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  2973. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  2974. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  2975. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  2976. e.Graphics.TranslateTransform(x, y);
  2977. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2978. Draw(e.Graphics);
  2979. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2980. e.Graphics.TranslateTransform(-x, -y);
  2981. }
  2982. }
  2983. /// <summary>
  2984. /// 绘制
  2985. /// </summary>
  2986. private void Draw(Graphics graphics)
  2987. {
  2988. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  2989. Pen rectPen = new Pen(Color.Black);
  2990. rectPen.DashStyle = DashStyle.Custom;
  2991. float[] dashArray = { 2.0f, 3.0f };
  2992. rectPen.DashPattern = dashArray;
  2993. if (pointList.Count > 0 && leList.Count > 0)
  2994. {
  2995. for (int i = 0; i < pointList.Count; i++)
  2996. {
  2997. graphics.DrawString(leList[i].ToString(), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), pointList[i].X, pointList[i].Y);
  2998. }
  2999. }
  3000. }
  3001. /// <summary>
  3002. /// 显示面积率
  3003. /// </summary>
  3004. /// <param name="sender"></param>
  3005. /// <param name="e"></param>
  3006. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  3007. {
  3008. if (bcBinaryChecked() && !bcOriginChecked())
  3009. {
  3010. if (checkBox5.Checked)
  3011. {
  3012. ReloadDebrisSelection();
  3013. this.documentWorkspace.Refresh();
  3014. }
  3015. else
  3016. {
  3017. this.documentWorkspace.panel.Paint -= new PaintEventHandler(this.BoxPaintHandler);
  3018. this.documentWorkspace.Refresh();
  3019. }
  3020. }
  3021. }
  3022. /// <summary>
  3023. /// 等积圆直径小于20um的颗粒不参与计算
  3024. /// </summary>
  3025. /// <param name="sender"></param>
  3026. /// <param name="e"></param>
  3027. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  3028. {
  3029. ReloadDebrisSelection();
  3030. }
  3031. DialogResult dr;
  3032. /// <summary>
  3033. /// 保存结果
  3034. /// </summary>
  3035. /// <param name="sender"></param>
  3036. /// <param name="e"></param>
  3037. private void button2_Click(object sender, EventArgs e)
  3038. {
  3039. if (picArea == 0)
  3040. {
  3041. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  3042. return;
  3043. }
  3044. else
  3045. {
  3046. //二值判断
  3047. if (!bcBinaryChecked())
  3048. {
  3049. MessageBox.Show(PdnResources.GetString("Menu.PleaseBinarize.text")+"!");
  3050. return;
  3051. }
  3052. }
  3053. if (this.listView1.SelectedItems.Count > 0)
  3054. {
  3055. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  3056. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  3057. bool replace = false;
  3058. int rowIndex = 0;
  3059. if (this.dataGridView1.Rows.Count > 0 && dataGridView1.Rows[0].Visible)
  3060. {
  3061. if (this.listView2.Items.Count > 0)
  3062. {
  3063. foreach (ListViewItem item in this.listView2.Items)
  3064. {
  3065. if (!blSaveAll && item.Name.Equals(tag))
  3066. {
  3067. dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3068. break;
  3069. }
  3070. }
  3071. foreach (ListViewItem item in this.listView2.Items)
  3072. {
  3073. if (item.Name.Equals(tag))
  3074. {
  3075. if (dr == DialogResult.OK || blSaveAll)
  3076. {
  3077. replace = true;
  3078. }
  3079. else
  3080. {
  3081. return;
  3082. }
  3083. break;
  3084. }
  3085. }
  3086. }
  3087. //添加结果,有重名需要替换
  3088. if (replace)
  3089. {
  3090. for (int i = 0; i < this.resultTableList.Count; i++)
  3091. {
  3092. if (this.resultTableList[i].TableName.Equals(tag))
  3093. {
  3094. rowIndex = i;
  3095. this.resultTableList.Remove(this.resultTableList[i]);
  3096. if (this.pointList.Count > 0)
  3097. {
  3098. resultTableList.Insert(rowIndex, dtResult);
  3099. }
  3100. }
  3101. }
  3102. }
  3103. else
  3104. {
  3105. ListViewItem listViewItem = new ListViewItem();
  3106. listViewItem.Name = tag;
  3107. listViewItem.SubItems[0].Text = imgName;
  3108. this.listView2.Items.Add(listViewItem);
  3109. this.listView2.SelectedItems.Clear();
  3110. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  3111. if (this.pointList.Count > 0)
  3112. {
  3113. resultTableList.Insert(rowIndex, dtResult);
  3114. }
  3115. }
  3116. RefreshDataGridView2();
  3117. //保存处理后的图片
  3118. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  3119. List<Bitmap> tempBit = new List<Bitmap>();
  3120. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  3121. originalBit.Tag = pantographRatio;
  3122. tempBit.Add(originalBit);
  3123. Bitmap processedBit = BitmapConverter.ToBitmap(phaseModel.mat);
  3124. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  3125. Graphics graphics = Graphics.FromImage(newBit);
  3126. graphics.DrawImage(processedBit, new PointF(0, 0));
  3127. if (this.checkBox4.Checked)
  3128. {
  3129. DisplayColor();
  3130. }
  3131. if (this.checkBox5.Checked)
  3132. {
  3133. Draw(graphics);
  3134. }
  3135. newBit.Tag = pantographRatio;
  3136. tempBit.Add(newBit);
  3137. if (bitDic.ContainsKey(tag))
  3138. bitDic[tag] = tempBit;
  3139. else
  3140. bitDic.Add(tag, tempBit);
  3141. //拼接中间数据
  3142. List<List<string>> dataList = new List<List<string>>();
  3143. List<string> columnName = new List<string>();
  3144. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  3145. if (IronType == 4 || IronType == 5)
  3146. {
  3147. columnName.Add(PdnResources.GetString("Menu.Phosphoruseutecticarea.Text"));
  3148. columnName.Add(PdnResources.GetString("Menu.sphoruseutecticarea.Text"));
  3149. }
  3150. else
  3151. {
  3152. columnName.Add(PdnResources.GetString("Menu.Carbidearea.Text"));
  3153. columnName.Add(PdnResources.GetString("Menu.Carbidearearatio.Text"));
  3154. }
  3155. dataList.Add(columnName);
  3156. if (this.lstCarbideArea.Count > 0)
  3157. {
  3158. for (int i = 0; i < this.lstCarbideArea.Count; i++)
  3159. {
  3160. List<string> strList = new List<string>();
  3161. strList.Add((i + 1).ToString());
  3162. strList.Add(this.lstCarbideArea[i].ToString());
  3163. strList.Add(this.lstCarbideAreaRatio[i].ToString());
  3164. dataList.Add(strList);
  3165. }
  3166. }
  3167. bool isExist = false;//是否已存在进行替换
  3168. int modelIndex = -1;//要替换的下标
  3169. for (int j = 0; j < tempDataModel.Count; j++)
  3170. {
  3171. if (tempDataModel[j].tagName.Equals(tag))
  3172. {
  3173. isExist = true;
  3174. modelIndex = j;
  3175. break;
  3176. }
  3177. }
  3178. if (isExist && modelIndex > -1)
  3179. tempDataModel[modelIndex].dataList = dataList;
  3180. else
  3181. {
  3182. ExportProjectModel newModel = new ExportProjectModel();
  3183. newModel.tagName = tag;
  3184. newModel.picName = imgName;
  3185. newModel.dataList = dataList;
  3186. tempDataModel.Add(newModel);
  3187. }
  3188. }
  3189. else
  3190. {
  3191. MessageBox.Show(PdnResources.GetString("Menu.Nodatatosave.text"));
  3192. }
  3193. }
  3194. }
  3195. /// <summary>
  3196. /// 刷新数据展示表
  3197. /// </summary>
  3198. private void RefreshDataGridView1()
  3199. {
  3200. this.dataGridView1.Rows.Clear();
  3201. if (dtDataGridView1 != null && dtDataGridView1.Rows.Count > 0)
  3202. {
  3203. dataGridView1.Rows.Add(dtDataGridView1.Rows.Count);//增加同等数量的行数
  3204. int i = 0;
  3205. foreach (DataRow row in dtDataGridView1.Rows)//逐个读取单元格的内容;
  3206. {
  3207. DataGridViewRow r1 = dataGridView1.Rows[i];
  3208. r1.Cells[0].Value = row.RowState.ToString();
  3209. for (int j = 0; j < dtDataGridView1.Columns.Count; j++)
  3210. {
  3211. if (j == 0 || j == 2)
  3212. {
  3213. r1.Cells[j].Value = row[j].ToString();
  3214. }
  3215. else
  3216. {
  3217. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  3218. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  3219. }
  3220. }
  3221. i++;
  3222. }
  3223. }
  3224. }
  3225. /// <summary>
  3226. /// 刷新分析结果表
  3227. /// </summary>
  3228. private void RefreshDataGridView2()
  3229. {
  3230. //需要计算平均值的集合
  3231. List<double> lstCarbideNum = new List<double>();
  3232. //综合平均值
  3233. double avgCarbideNum = 0;
  3234. if (resultTableList.Count > 0)
  3235. {
  3236. dataGridView2.Rows.Clear();
  3237. dataGridView3.Rows.Clear();
  3238. if (this.showAll)
  3239. {
  3240. //dataGridView2.Rows.Clear();
  3241. int i = 0;
  3242. for (int k = 0; k < resultTableList.Count; k++)
  3243. {
  3244. dataGridView2.Rows.Add(resultTableList[k].Rows.Count);//增加同等数量的行数
  3245. foreach (DataRow row in resultTableList[k].Rows)//逐个读取单元格的内容;
  3246. {
  3247. DataGridViewRow r1 = dataGridView2.Rows[i];
  3248. r1.Cells[0].Value = row.RowState.ToString();
  3249. for (int j = 0; j < resultTableList[k].Columns.Count; j++)
  3250. {
  3251. if (j == 0 || j == 1 || j == 3)
  3252. {
  3253. r1.Cells[j].Value = row[j].ToString();
  3254. }
  3255. else
  3256. {
  3257. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  3258. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  3259. }
  3260. //r1.Cells[j].Value = row[j];
  3261. if (!row[1].Equals(PdnResources.GetString("Menu.Image.Average.Text")))
  3262. {
  3263. if (j == 2)
  3264. {
  3265. lstCarbideNum.Add(double.Parse(row[j].ToString()));
  3266. }
  3267. }
  3268. }
  3269. i++;
  3270. }
  3271. }
  3272. }
  3273. else
  3274. {
  3275. //dataGridView2.Rows.Clear();
  3276. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3277. {
  3278. int h = 0;
  3279. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  3280. {
  3281. string tableName = this.listView2.SelectedItems[i].Name;
  3282. foreach (DataTable dt in resultTableList)
  3283. {
  3284. if (dt.TableName.Equals(tableName))
  3285. {
  3286. dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  3287. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  3288. {
  3289. DataGridViewRow r1 = dataGridView2.Rows[h];
  3290. r1.Cells[0].Value = row.RowState.ToString();
  3291. for (int j = 0; j < dt.Columns.Count; j++)
  3292. {
  3293. if (j == 0 || j == 1 || j == 3)
  3294. {
  3295. r1.Cells[j].Value = row[j].ToString();
  3296. }
  3297. else
  3298. {
  3299. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  3300. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  3301. }
  3302. //r1.Cells[j].Value = row[j];
  3303. if (!row[1].Equals(PdnResources.GetString("Menu.Image.Average.Text")))
  3304. {
  3305. if (j == 2)
  3306. {
  3307. lstCarbideNum.Add(double.Parse(row[j].ToString()));
  3308. }
  3309. }
  3310. }
  3311. h++;
  3312. }
  3313. }
  3314. }
  3315. }
  3316. }
  3317. }
  3318. if (dataGridView2.Rows.Count > 0)
  3319. {
  3320. if (lstCarbideNum.Count > 0)
  3321. {
  3322. avgCarbideNum = (double)lstCarbideNum.Average();
  3323. }
  3324. string avgLevel = string.Empty;
  3325. if (IronType == 4 || IronType == 5)
  3326. {
  3327. if (avgCarbideNum / 100 >= 0 && avgCarbideNum / 100 <= 0.005)
  3328. {
  3329. avgLevel = PdnResources.GetString("Menu.phosphorus.Text") + "0.5";
  3330. }
  3331. else if (avgCarbideNum / 100 > 0.005 && avgCarbideNum / 100 <= 0.01)
  3332. {
  3333. avgLevel = PdnResources.GetString("Menu.phosphorus.Text") + "1";
  3334. }
  3335. else if (avgCarbideNum / 100 > 0.01 && avgCarbideNum / 100 <= 0.02)
  3336. {
  3337. avgLevel = PdnResources.GetString("Menu.phosphorus.Text") + "2";
  3338. }
  3339. else if (avgCarbideNum / 100 > 0.02 && avgCarbideNum / 100 <= 0.03)
  3340. {
  3341. avgLevel = PdnResources.GetString("Menu.phosphorus.Text") + "3";
  3342. }
  3343. else if (avgCarbideNum / 100 > 0.03 && avgCarbideNum / 100 <= 0.05)
  3344. {
  3345. avgLevel = PdnResources.GetString("Menu.phosphorus.Text") + "5";
  3346. }
  3347. else
  3348. {
  3349. avgLevel = "-";
  3350. }
  3351. }
  3352. else
  3353. {
  3354. if (avgCarbideNum / 100 > 0 && avgCarbideNum / 100 <= 0.01)
  3355. {
  3356. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "1";
  3357. }
  3358. else if (avgCarbideNum / 100 > 0.01 && avgCarbideNum / 100 <= 0.02)
  3359. {
  3360. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "2";
  3361. }
  3362. else if (avgCarbideNum / 100 > 0.02 && avgCarbideNum / 100 <= 0.03)
  3363. {
  3364. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "3";
  3365. }
  3366. else if (avgCarbideNum / 100 > 0.03 && avgCarbideNum / 100 <= 0.05)
  3367. {
  3368. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "5";
  3369. }
  3370. else if (avgCarbideNum / 100 > 0.05 && avgCarbideNum / 100 <= 0.07)
  3371. {
  3372. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "7";
  3373. }
  3374. else if (avgCarbideNum / 100 > 0.07 && avgCarbideNum / 100 <= 0.1)
  3375. {
  3376. avgLevel = PdnResources.GetString("Menu.carbon.Text") + "10";
  3377. }
  3378. else
  3379. {
  3380. avgLevel = "-";
  3381. }
  3382. }
  3383. this.dataGridView3.Rows.Add(PdnResources.GetString("Menu.comprehensive.text"), PdnResources.GetString("Menu.Comprehensivaverage.text"), Math.Round(double.Parse(string.IsNullOrEmpty(avgCarbideNum.ToString()) ? "0" : avgCarbideNum.ToString()), Convert.ToInt32(this.numericUpDown1.Value)), avgLevel);
  3384. }
  3385. }
  3386. else
  3387. {
  3388. dataGridView2.Rows.Clear();
  3389. dataGridView3.Rows.Clear();
  3390. }
  3391. }
  3392. /// <summary>
  3393. /// 生成报告
  3394. /// </summary>
  3395. /// <param name="sender"></param>
  3396. /// <param name="e"></param>
  3397. private void button8_Click(object sender, EventArgs e)
  3398. {
  3399. if (dataGridView2.Rows.Count == 0)
  3400. {
  3401. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  3402. return;
  3403. }
  3404. if (this.checkBox1.Checked)
  3405. this.btnSetUp.PerformClick();
  3406. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3407. {
  3408. //获取word书签与excel单元格的关系,以字典方式存储
  3409. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3410. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3411. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3412. {
  3413. foreach (mic_module_infos info in mic_module_infos)
  3414. {
  3415. tagInfos.Add(info.tag_name, info.cell_position);
  3416. }
  3417. }
  3418. //分析结果
  3419. List<List<string>> analysisContent = new List<List<string>>();
  3420. List<string> contentHead = new List<string>();
  3421. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  3422. contentHead.Add(PdnResources.GetString("Menu.view.text"));
  3423. if (IronType == 4 || IronType == 5)
  3424. {
  3425. contentHead.Add(PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)");
  3426. }
  3427. else
  3428. {
  3429. contentHead.Add(PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)");
  3430. }
  3431. contentHead.Add(PdnResources.GetString("Menu.Levelname.text"));
  3432. analysisContent.Add(contentHead);
  3433. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  3434. {
  3435. List<string> content = new List<string>();
  3436. content.Add(item.Cells[0].Value.ToString());
  3437. content.Add(item.Cells[1].Value.ToString());
  3438. content.Add(item.Cells[2].Value.ToString());
  3439. content.Add(item.Cells[3].Value.ToString());
  3440. analysisContent.Add(content);
  3441. }
  3442. analysisContent.Add(new List<string>() { "\r" });
  3443. foreach (DataGridViewRow item in this.dataGridView3.Rows)
  3444. {
  3445. List<string> content = new List<string>();
  3446. content.Add(item.Cells[0].Value.ToString());
  3447. content.Add(item.Cells[1].Value.ToString());
  3448. content.Add(item.Cells[2].Value.ToString());
  3449. content.Add(item.Cells[3].Value.ToString());
  3450. analysisContent.Add(content);
  3451. }
  3452. //图片
  3453. bitList = new List<Bitmap>();
  3454. if (this.showAll)
  3455. {
  3456. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  3457. {
  3458. bitList.Add(kv.Value[0]);
  3459. bitList.Add(kv.Value[1]);
  3460. }
  3461. }
  3462. else
  3463. {
  3464. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3465. {
  3466. foreach (ListViewItem item in this.listView2.SelectedItems)
  3467. {
  3468. if (bitDic.ContainsKey(item.Name))
  3469. {
  3470. bitList.Add(bitDic[item.Name][0]);
  3471. bitList.Add(bitDic[item.Name][1]);
  3472. }
  3473. }
  3474. }
  3475. }
  3476. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  3477. }
  3478. else
  3479. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  3480. }
  3481. /// <summary>
  3482. /// 导出项目
  3483. /// </summary>
  3484. /// <param name="sender"></param>
  3485. /// <param name="e"></param>
  3486. private void button1_Click(object sender, EventArgs e)
  3487. {
  3488. if (dataGridView2.Rows.Count == 0)
  3489. {
  3490. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  3491. return;
  3492. }
  3493. if (this.checkBox1.Checked)
  3494. this.btnSetUp.PerformClick();
  3495. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3496. {
  3497. PaintDotNet.Instrument.ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.DuctileIron.Text", this.analyzeSettingModel.savePath);
  3498. if (nodeItem == null) return;
  3499. //获取word书签与excel单元格的关系,以字典方式存储
  3500. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3501. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3502. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3503. {
  3504. foreach (mic_module_infos info in mic_module_infos)
  3505. {
  3506. tagInfos.Add(info.tag_name, info.cell_position);
  3507. }
  3508. }
  3509. //分析结果
  3510. List<List<string>> analysisContent = new List<List<string>>();
  3511. List<string> contentHead = new List<string>();
  3512. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  3513. contentHead.Add(PdnResources.GetString("Menu.view.text"));
  3514. if (IronType == 4 || IronType == 5)
  3515. {
  3516. contentHead.Add(PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)");
  3517. }
  3518. else
  3519. {
  3520. contentHead.Add(PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)");
  3521. }
  3522. contentHead.Add(PdnResources.GetString("Menu.Levelname.text"));
  3523. analysisContent.Add(contentHead);
  3524. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  3525. {
  3526. List<string> content = new List<string>();
  3527. content.Add(item.Cells[0].Value.ToString());
  3528. content.Add(item.Cells[1].Value.ToString());
  3529. content.Add(item.Cells[2].Value.ToString());
  3530. content.Add(item.Cells[3].Value.ToString());
  3531. analysisContent.Add(content);
  3532. }
  3533. analysisContent.Add(new List<string>() { "\r" });
  3534. foreach (DataGridViewRow item in this.dataGridView3.Rows)
  3535. {
  3536. List<string> content = new List<string>();
  3537. content.Add(item.Cells[0].Value.ToString());
  3538. content.Add(item.Cells[1].Value.ToString());
  3539. content.Add(item.Cells[2].Value.ToString());
  3540. content.Add(item.Cells[3].Value.ToString());
  3541. analysisContent.Add(content);
  3542. }
  3543. //图片
  3544. bitList = new List<Bitmap>();
  3545. if (this.showAll)
  3546. {
  3547. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  3548. {
  3549. bitList.Add(kv.Value[0]);
  3550. bitList.Add(kv.Value[1]);
  3551. }
  3552. }
  3553. else
  3554. {
  3555. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3556. {
  3557. foreach (ListViewItem item in this.listView2.SelectedItems)
  3558. {
  3559. if (bitDic.ContainsKey(item.Name))
  3560. {
  3561. bitList.Add(bitDic[item.Name][0]);
  3562. bitList.Add(bitDic[item.Name][1]);
  3563. }
  3564. }
  3565. }
  3566. }
  3567. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
  3568. //保存项目信息到数据库
  3569. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
  3570. }
  3571. else
  3572. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  3573. }
  3574. /// <summary>
  3575. /// 导出结果
  3576. /// </summary>
  3577. /// <param name="sender"></param>
  3578. /// <param name="e"></param>
  3579. private void button9_Click(object sender, EventArgs e)
  3580. {
  3581. if (this.dataGridView2.Rows.Count > 0)
  3582. {
  3583. SaveFileDialog exe = new SaveFileDialog();
  3584. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  3585. exe.FilterIndex = 0;
  3586. exe.RestoreDirectory = true;
  3587. //exe.CreatePrompt = true;
  3588. exe.Title = "Export Excel File";
  3589. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  3590. if (IronType == 1)
  3591. {
  3592. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.DuctileIron.Text")+"(GBT9441" + PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  3593. }
  3594. else if (IronType == 2)
  3595. {
  3596. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.VermiculateCastIron.Text")+"(GBT26656" + PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  3597. }
  3598. else if (IronType == 3)
  3599. {
  3600. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.VermiculateCastIron.Text")+"(JBT3829" + PdnResources.GetString("Menu.Quantityofcarbide.Text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  3601. }
  3602. else if (IronType == 4)
  3603. {
  3604. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.VermiculateCastIron.Text")+"(GBT26656" + PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  3605. }
  3606. else if (IronType == 5)
  3607. {
  3608. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.VermiculateCastIron.Text")+"(JBT3829" + PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  3609. }
  3610. DialogResult dr = exe.ShowDialog();
  3611. if (dr != DialogResult.OK)
  3612. return;
  3613. DataTable dtb = new DataTable();
  3614. dtb.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  3615. dtb.Columns.Add(PdnResources.GetString("Menu.view.text"));
  3616. if (IronType == 4 || IronType == 5)
  3617. {
  3618. dtb.Columns.Add(PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)");
  3619. }
  3620. else
  3621. {
  3622. dtb.Columns.Add(PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)");
  3623. }
  3624. dtb.Columns.Add(PdnResources.GetString("Menu.Levelname.text"));
  3625. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  3626. {
  3627. DataRow dataRow = dtb.NewRow();
  3628. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView2.Rows[i].Cells[0].Value;
  3629. dataRow[PdnResources.GetString("Menu.view.text")] = this.dataGridView2.Rows[i].Cells[1].Value;
  3630. if (IronType == 4 || IronType == 5)
  3631. {
  3632. dataRow[PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)"] = this.dataGridView2.Rows[i].Cells[2].Value;
  3633. }
  3634. else
  3635. {
  3636. dataRow[PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)"] = this.dataGridView2.Rows[i].Cells[2].Value;
  3637. }
  3638. dataRow[PdnResources.GetString("Menu.Levelname.text")] = this.dataGridView2.Rows[i].Cells[3].Value;
  3639. dtb.Rows.Add(dataRow);
  3640. }
  3641. for (int i = 0; i < this.dataGridView3.Rows.Count; i++)
  3642. {
  3643. DataRow dataRow = dtb.NewRow();
  3644. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView3.Rows[i].Cells[0].Value;
  3645. dataRow[PdnResources.GetString("Menu.view.text")] = this.dataGridView3.Rows[i].Cells[1].Value;
  3646. if (IronType == 4 || IronType == 5)
  3647. {
  3648. dataRow[PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text") + "(%)"] = this.dataGridView3.Rows[i].Cells[2].Value;
  3649. }
  3650. else
  3651. {
  3652. dataRow[PdnResources.GetString("Menu.Quantityofcarbide.Text") + "(%)"] = this.dataGridView3.Rows[i].Cells[2].Value;
  3653. }
  3654. dataRow[PdnResources.GetString("Menu.Levelname.text")] = this.dataGridView3.Rows[i].Cells[3].Value;
  3655. dtb.Rows.Add(dataRow);
  3656. }
  3657. //DataTable dtb1 = new DataTable();
  3658. //dtb1.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  3659. //dtb1.Columns.Add(PdnResources.GetString("Menu.view.text"));
  3660. //if (IronType == 4 || IronType == 5)
  3661. //{
  3662. // dtb1.Columns.Add(PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)");
  3663. //}
  3664. //else
  3665. //{
  3666. // dtb1.Columns.Add(PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)");
  3667. //}
  3668. //dtb1.Columns.Add(PdnResources.GetString("Menu.Levelname.text"));
  3669. //for (int i = 0; i < this.dataGridView3.Rows.Count; i++)
  3670. //{
  3671. // DataRow dataRow = dtb1.NewRow();
  3672. // dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView3.Rows[i].Cells[0].Value;
  3673. // dataRow[PdnResources.GetString("Menu.view.text")] = this.dataGridView3.Rows[i].Cells[1].Value;
  3674. // if (IronType == 4 || IronType == 5)
  3675. // {
  3676. // dataRow[PdnResources.GetString("Menu.Phosphoruseutecticnumber.Text")+"(%)"] = this.dataGridView3.Rows[i].Cells[2].Value;
  3677. // }
  3678. // else
  3679. // {
  3680. // dataRow[PdnResources.GetString("Menu.Quantityofcarbide.Text")+"(%)"] = this.dataGridView3.Rows[i].Cells[2].Value;
  3681. // }
  3682. // dataRow[PdnResources.GetString("Menu.Levelname.text")] = this.dataGridView3.Rows[i].Cells[3].Value;
  3683. // dtb1.Rows.Add(dataRow);
  3684. //}
  3685. List<DataTable> list = new List<DataTable>();
  3686. list.Add(dtb);
  3687. //list.Add(dtb1);
  3688. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  3689. }
  3690. else
  3691. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  3692. }
  3693. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  3694. {
  3695. if (this.showAll)
  3696. return;
  3697. RefreshDataGridView2();
  3698. }
  3699. /// <summary>
  3700. /// 全部显示
  3701. /// </summary>
  3702. /// <param name="sender"></param>
  3703. /// <param name="e"></param>
  3704. private void button6_Click(object sender, EventArgs e)
  3705. {
  3706. if (this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  3707. {
  3708. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  3709. this.showAll = true;
  3710. RefreshDataGridView2();
  3711. }
  3712. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  3713. {
  3714. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  3715. this.showAll = false;
  3716. RefreshDataGridView2();
  3717. }
  3718. }
  3719. /// <summary>
  3720. /// 删除
  3721. /// </summary>
  3722. /// <param name="sender"></param>
  3723. /// <param name="e"></param>
  3724. private void button7_Click(object sender, EventArgs e)
  3725. {
  3726. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  3727. {
  3728. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3729. if (dr == DialogResult.OK)
  3730. {
  3731. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  3732. {
  3733. string tableName = this.listView2.SelectedItems[i].Name;
  3734. foreach (DataTable dt in resultTableList)
  3735. {
  3736. if (dt.TableName.Equals(tableName))
  3737. {
  3738. resultTableList.Remove(dt);
  3739. break;
  3740. }
  3741. }
  3742. if (bitDic.ContainsKey(tableName))
  3743. bitDic.Remove(tableName);
  3744. }
  3745. foreach (ListViewItem item in this.listView2.Items)
  3746. {
  3747. if (item.Selected)
  3748. this.listView2.Items.Remove(item);
  3749. }
  3750. RefreshDataGridView2();
  3751. }
  3752. }
  3753. }
  3754. /// <summary>
  3755. /// 设置窗体缩放最小尺寸
  3756. /// </summary>
  3757. /// <param name="sender"></param>
  3758. /// <param name="e"></param>
  3759. private void SpheroidizationLevelDialog_ResizeEnd(object sender, EventArgs e)
  3760. {
  3761. if (this.Width <= 1179)
  3762. {
  3763. this.Width = 1179;
  3764. }
  3765. if (this.Height <= 945)
  3766. {
  3767. this.Height = 945;
  3768. }
  3769. }
  3770. #region 参数保存及提取
  3771. /// <summary>
  3772. /// 保存参数的key,value和type
  3773. /// </summary>
  3774. /// <param name="param_key"></param>
  3775. /// <param name="param_value"></param>
  3776. /// <param name="param_type"></param>
  3777. private void saveParamValue(string param_key, string param_value, int param_type)
  3778. {
  3779. bool foundItem = false;
  3780. if (!this.eachData.ContainsKey(GetImgKey()))
  3781. {
  3782. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  3783. analysisItem.menuId = this.menuId;
  3784. analysisItem.param_key = param_key;
  3785. analysisItem.param_type = param_type;
  3786. analysisItem.param_value = param_value;
  3787. analysisItem.setValue();
  3788. analysisItem.ListParam = new List<GrainSizeAnalysisModel>();
  3789. analysisItem.ListParam.Add(analysisItem);
  3790. this.eachData.Add(GetImgKey(), analysisItem);
  3791. }
  3792. foreach (var item in this.eachData[GetImgKey()].ListParam)
  3793. {
  3794. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  3795. {
  3796. item.param_value = param_value;
  3797. item.setValue();
  3798. foundItem = true;
  3799. break;
  3800. }
  3801. }
  3802. if (!foundItem)
  3803. {
  3804. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  3805. analysisItem.menuId = this.menuId;
  3806. analysisItem.param_key = param_key;
  3807. analysisItem.param_type = param_type;
  3808. analysisItem.param_value = param_value;
  3809. analysisItem.setValue();
  3810. this.eachData[GetImgKey()].ListParam.Add(analysisItem);
  3811. }
  3812. }
  3813. /// <summary>
  3814. /// 保存界面中的参数到model
  3815. /// </summary>
  3816. private void saveDialogParamValues()
  3817. {
  3818. saveParamValue(ParamKey_Report, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置
  3819. saveParamValue(ParamKey_Screen, checkBox3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//筛选
  3820. saveParamValue(ParamKey_ScreenMin, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最小值
  3821. saveParamValue(ParamKey_ScreenMax, numericUpDown5 != null ? numericUpDown5.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最大值
  3822. saveParamValue(ParamKey_Diameter, checkBox6.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//直径小于20um
  3823. saveParamValue(ParamKey_Colour, checkBox4.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//显示不同颜色
  3824. saveParamValue(ParamKey_AreaRatio, checkBox5.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//显示面积率
  3825. saveParamValue(ParamKey_AreaRatioRange, checkBox2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//显示面积率
  3826. saveParamValue(ParamKey_AreaRatioRangeMin, numericUpDown6 != null ? numericUpDown6.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积率区间最小值
  3827. saveParamValue(ParamKey_AreaRatioRangeMax, numericUpDown7 != null ? numericUpDown7.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积率区间最大值
  3828. saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//保留小数位数
  3829. saveParamValue(ParamKey_panelColour1_08, colour != null ? colour[ParamKey_panelColour1_08].ToArgb().ToString() : Color.Orange.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3830. saveParamValue(ParamKey_panelColour08_06, colour != null ? colour[ParamKey_panelColour08_06].ToArgb().ToString() : Color.Blue.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3831. saveParamValue(ParamKey_panelColour06_04, colour != null ? colour[ParamKey_panelColour06_04].ToArgb().ToString() : Color.Green.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3832. saveParamValue(ParamKey_panelColour04_02, colour != null ? colour[ParamKey_panelColour04_02].ToArgb().ToString() : Color.Pink.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3833. saveParamValue(ParamKey_panelColour02_01, colour != null ? colour[ParamKey_panelColour02_01].ToArgb().ToString() : Color.Violet.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3834. saveParamValue(ParamKey_panelColour01_0, colour != null ? colour[ParamKey_panelColour01_0].ToArgb().ToString() : Color.Yellow.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//不同区间颜色
  3835. saveParamValue(ParamKey_FontSize, colourFont != null ? colourFont.Keys.First() : "12", (int)PaintDotNet.Base.Dtryt.Interger);//字体大小
  3836. saveParamValue(ParamKey_FontColour, colour != null ? colourFont.Values.First().ToArgb().ToString() : Color.Black.ToArgb().ToString(), (int)PaintDotNet.Base.Dtryt.Color);//字体颜色
  3837. }
  3838. /// <summary>
  3839. /// 获取保存的参数
  3840. /// </summary>
  3841. private void GetListParamModel()
  3842. {
  3843. if (this.eachData.ContainsKey(GetImgKey()) && this.eachData[GetImgKey()] != null)
  3844. {
  3845. for (int i = 0; i < this.eachData[GetImgKey()].ListParam.Count; i++)
  3846. {
  3847. switch (this.eachData[GetImgKey()].ListParam[i].param_key)
  3848. {
  3849. case ParamKey_Report:
  3850. checkBox1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3851. break;
  3852. case ParamKey_Screen:
  3853. checkBox3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3854. break;
  3855. case ParamKey_ScreenMin:
  3856. areaMin = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  3857. break;
  3858. case ParamKey_ScreenMax:
  3859. areaMax = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  3860. break;
  3861. case ParamKey_Diameter:
  3862. checkBox6.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3863. break;
  3864. case ParamKey_Colour:
  3865. checkBox4.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3866. break;
  3867. case ParamKey_AreaRatio:
  3868. checkBox5.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3869. break;
  3870. case ParamKey_AreaRatioRange:
  3871. checkBox2.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  3872. break;
  3873. case ParamKey_AreaRatioRangeMin:
  3874. areaRatioRangeMin = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  3875. break;
  3876. case ParamKey_AreaRatioRangeMax:
  3877. areaRatioRangeMax = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  3878. break;
  3879. case ParamKey_DecimalPlace:
  3880. numericUpDown1.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  3881. break;
  3882. case ParamKey_panelColour1_08:
  3883. colour.Remove(ParamKey_panelColour1_08);
  3884. colour.Add(ParamKey_panelColour1_08, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3885. break;
  3886. case ParamKey_panelColour08_06:
  3887. colour.Remove(ParamKey_panelColour08_06);
  3888. colour.Add(ParamKey_panelColour08_06, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3889. break;
  3890. case ParamKey_panelColour06_04:
  3891. colour.Remove(ParamKey_panelColour06_04);
  3892. colour.Add(ParamKey_panelColour06_04, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3893. break;
  3894. case ParamKey_panelColour04_02:
  3895. colour.Remove(ParamKey_panelColour04_02);
  3896. colour.Add(ParamKey_panelColour04_02, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3897. break;
  3898. case ParamKey_panelColour02_01:
  3899. colour.Remove(ParamKey_panelColour02_01);
  3900. colour.Add(ParamKey_panelColour02_01, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3901. break;
  3902. case ParamKey_panelColour01_0:
  3903. colour.Remove(ParamKey_panelColour01_0);
  3904. colour.Add(ParamKey_panelColour01_0, Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value));
  3905. break;
  3906. case ParamKey_FontSize:
  3907. fontSize = this.eachData[GetImgKey()].ListParam[i].value.ToString();
  3908. break;
  3909. case ParamKey_FontColour:
  3910. fontColour = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value);
  3911. break;
  3912. }
  3913. }
  3914. colourFont.Clear();
  3915. colourFont.Add(fontSize, fontColour);
  3916. }
  3917. }
  3918. /// <summary>
  3919. /// 获取XML保存的参数
  3920. /// </summary>
  3921. private void GetXmlParameter()
  3922. {
  3923. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  3924. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  3925. for (int i = 0; i < listView1.Items.Count; i++)
  3926. {
  3927. if (this.eachData.ContainsKey(listView1.Items[i].Index.ToString()))
  3928. {
  3929. this.eachData[listView1.Items[i].Index.ToString()] = analysisModelXml.cloneListParamModel(this.menuId);
  3930. }
  3931. else
  3932. {
  3933. this.eachData.Add(listView1.Items[i].Index.ToString(), analysisModelXml.cloneListParamModel(this.menuId));
  3934. }
  3935. }
  3936. foreach (var item in this.eachData[GetImgKey()].ListParam)
  3937. item.setValue();
  3938. }
  3939. /// <summary>
  3940. /// 保存参数,防止没有图片
  3941. /// </summary>
  3942. private void NullKey()
  3943. {
  3944. GrainSizeAnalysisModel grainsizeanalysismodel = new GrainSizeAnalysisModel();
  3945. grainsizeanalysismodel.ListParam = new List<GrainSizeAnalysisModel>();
  3946. this.eachData.Add("null", grainsizeanalysismodel);
  3947. }
  3948. private string GetImgKey()
  3949. {
  3950. string key = this.listView1.FocusedItem != null ? this.listView1.FocusedItem.Index.ToString() : "null";
  3951. return key;
  3952. }
  3953. #endregion
  3954. private void button4_Click(object sender, EventArgs e)
  3955. {
  3956. if (this.listView1.FocusedItem == null)
  3957. {
  3958. return;
  3959. }
  3960. binaryClass.saveParams();
  3961. binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[int.Parse(GetImgKey())]);
  3962. saveDialogParamValues();
  3963. GrainSizeAnalysisModel data = new GrainSizeAnalysisModel();
  3964. if (eachData.ContainsKey(GetImgKey()))
  3965. {
  3966. data = eachData[GetImgKey()];
  3967. }
  3968. for (int i = 0; i < listView1.Items.Count; i++)
  3969. {
  3970. eachData[i.ToString()] = data.cloneListParamModel(this.menuId);
  3971. this.listView1.EnsureVisible(i);
  3972. this.listView1.Items[i].Focused = true;
  3973. this.listView1.Items[i].Selected = true;
  3974. }
  3975. }
  3976. private bool blSaveAll = false;
  3977. private void button3_Click(object sender, EventArgs e)
  3978. {
  3979. if (this.listView1.FocusedItem == null)
  3980. {
  3981. return;
  3982. }
  3983. if (eachData.Count - 1 != listView1.Items.Count)
  3984. {
  3985. MessageBox.Show("请先点击应用全部!");
  3986. return;
  3987. }
  3988. saveDialogParamValues();
  3989. int current = int.Parse(GetImgKey());
  3990. for (int i = 0; i < listView1.Items.Count; i++)
  3991. {
  3992. this.listView1.EnsureVisible(i);
  3993. this.listView1.Items[i].Focused = true;
  3994. this.listView1.Items[i].Selected = true;
  3995. this.button2.PerformClick();
  3996. blSaveAll = true;
  3997. }
  3998. this.listView1.EnsureVisible(current);
  3999. this.listView1.Items[current].Focused = true;
  4000. this.listView1.Items[current].Selected = true;
  4001. blSaveAll = false;
  4002. }
  4003. private void listView1_MouseDown(object sender, MouseEventArgs e)
  4004. {
  4005. if (this.listView1.FocusedItem != null)
  4006. saveDialogParamValues();
  4007. }
  4008. #region [脚本相关]
  4009. private void getValue(string key, object value)
  4010. {
  4011. switch (key)
  4012. {
  4013. case "parameter1":
  4014. checkBox3.Checked = Convert.ToBoolean(value);
  4015. break;
  4016. case "parameter2":
  4017. int min = Convert.ToInt32(value);
  4018. decimal minDec = Convert.ToDecimal(value);
  4019. if (bcBinaryChecked())
  4020. {
  4021. if (trackBar2.Minimum > min || trackBar2.Maximum < min)
  4022. {
  4023. trackBar2.Value = trackBar2.Minimum;
  4024. }
  4025. else
  4026. {
  4027. trackBar2.Value = min;
  4028. }
  4029. if (numericUpDown4.Minimum > min || numericUpDown4.Maximum < min)
  4030. {
  4031. numericUpDown4.Value = numericUpDown4.Minimum;
  4032. }
  4033. else
  4034. {
  4035. numericUpDown4.Value = minDec;
  4036. }
  4037. }
  4038. break;
  4039. case "parameter3":
  4040. int max = Convert.ToInt32(value);
  4041. decimal maxDec = Convert.ToDecimal(value);
  4042. if (bcBinaryChecked())
  4043. {
  4044. if (trackBar4.Minimum > max || trackBar4.Maximum < max)
  4045. {
  4046. trackBar4.Value = trackBar4.Maximum;
  4047. }
  4048. else
  4049. {
  4050. trackBar4.Value = max;
  4051. }
  4052. if (numericUpDown5.Minimum > max || numericUpDown5.Maximum < max)
  4053. {
  4054. numericUpDown5.Value = numericUpDown5.Maximum;
  4055. }
  4056. else
  4057. {
  4058. numericUpDown5.Value = maxDec;
  4059. }
  4060. }
  4061. break;
  4062. case "parameter4":
  4063. checkBox6.Checked = Convert.ToBoolean(value);
  4064. break;
  4065. case "parameter5":
  4066. checkBox4.Checked = Convert.ToBoolean(value);
  4067. break;
  4068. case "parameter6":
  4069. checkBox5.Checked = Convert.ToBoolean(value);
  4070. break;
  4071. case "parameter7":
  4072. fontSize = value.ToString();
  4073. colourFont.Clear();
  4074. colourFont.Add(fontSize, Color.Black);
  4075. break;
  4076. case "parameter8":
  4077. fontColour = Color.FromArgb((int)value);
  4078. if (colourFont.ContainsKey(fontSize))
  4079. {
  4080. colourFont[fontSize] = fontColour;
  4081. }
  4082. else {
  4083. colourFont.Add("10", fontColour);
  4084. }
  4085. this.documentWorkspace.Refresh();
  4086. break;
  4087. case "parameter9":
  4088. if (colour.ContainsKey("panelColour1_08")) {
  4089. colour["panelColour1_08"] = Color.FromArgb((int)value);
  4090. } else {
  4091. colour.Add("panelColour1_08", Color.FromArgb((int)value));
  4092. }
  4093. break;
  4094. case "parameter10":
  4095. if (colour.ContainsKey("panelColour08_06"))
  4096. {
  4097. colour["panelColour08_06"] = Color.FromArgb((int)value);
  4098. }
  4099. else
  4100. {
  4101. colour.Add("panelColour08_06", Color.FromArgb((int)value));
  4102. }
  4103. break;
  4104. case "parameter11":
  4105. if (colour.ContainsKey("panelColour06_04"))
  4106. {
  4107. colour["panelColour06_04"] = Color.FromArgb((int)value);
  4108. }
  4109. else
  4110. {
  4111. colour.Add("panelColour06_04", Color.FromArgb((int)value));
  4112. }
  4113. break;
  4114. case "parameter12":
  4115. if (colour.ContainsKey("panelColour04_02"))
  4116. {
  4117. colour["panelColour04_02"] = Color.FromArgb((int)value);
  4118. }
  4119. else
  4120. {
  4121. colour.Add("panelColour04_02", Color.FromArgb((int)value));
  4122. }
  4123. break;
  4124. case "parameter13":
  4125. if (colour.ContainsKey("panelColour02_01"))
  4126. {
  4127. colour["panelColour02_01"] = Color.FromArgb((int)value);
  4128. }
  4129. else
  4130. {
  4131. colour.Add("panelColour02_01", Color.FromArgb((int)value));
  4132. }
  4133. break;
  4134. case "parameter14":
  4135. if (colour.ContainsKey("panelColour01_0"))
  4136. {
  4137. colour["panelColour01_0"] = Color.FromArgb((int)value);
  4138. }
  4139. else
  4140. {
  4141. colour.Add("panelColour01_0", Color.FromArgb((int)value));
  4142. }
  4143. break;
  4144. case "parameter17":
  4145. checkBox2.Checked = Convert.ToBoolean(value);
  4146. break;
  4147. case "parameter15":
  4148. if (checkBox2.Checked)
  4149. {
  4150. int min2 = Convert.ToInt32(value);
  4151. decimal minDec2 = Convert.ToDecimal(value);
  4152. if (trackBar5.Minimum > min2 || trackBar5.Maximum < min2)
  4153. {
  4154. trackBar5.Value = trackBar5.Minimum;
  4155. }
  4156. else
  4157. {
  4158. trackBar5.Value = min2;
  4159. }
  4160. if (numericUpDown6.Minimum > minDec2 || numericUpDown6.Maximum < minDec2)
  4161. {
  4162. numericUpDown6.Value = numericUpDown6.Minimum;
  4163. }
  4164. else
  4165. {
  4166. numericUpDown6.Value = minDec2;
  4167. }
  4168. }
  4169. break;
  4170. case "parameter16":
  4171. if (checkBox2.Checked)
  4172. {
  4173. int min3 = Convert.ToInt32(value);
  4174. decimal minDec3 = Convert.ToDecimal(value);
  4175. if (trackBar6.Minimum > min3 || trackBar6.Maximum < min3)
  4176. {
  4177. trackBar6.Value = trackBar6.Minimum;
  4178. }
  4179. else
  4180. {
  4181. trackBar6.Value = min3;
  4182. }
  4183. if (numericUpDown7.Minimum > minDec3 || numericUpDown7.Maximum < minDec3)
  4184. {
  4185. numericUpDown7.Value = numericUpDown7.Minimum;
  4186. }
  4187. else
  4188. {
  4189. numericUpDown7.Value = minDec3;
  4190. }
  4191. }
  4192. break;
  4193. case "OpenWhileExportReport":
  4194. checkBox1.Checked = Convert.ToBoolean(value);
  4195. break;
  4196. case "CalculatorDecimalDigits":
  4197. numericUpDown1.Value = Convert.ToDecimal(value);
  4198. break;
  4199. case "ExportResults":
  4200. isExportResults = Convert.ToBoolean(value);
  4201. break;
  4202. case "ExportReports":
  4203. isExportReports = Convert.ToBoolean(value);
  4204. break;
  4205. case "ExportProjects":
  4206. isExportProjects = Convert.ToBoolean(value);
  4207. break;
  4208. }
  4209. }
  4210. private void startScriptAutomaticAction()
  4211. {
  4212. this.button4.PerformClick();
  4213. this.button3.PerformClick();
  4214. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  4215. this.showAll = true;
  4216. RefreshDataGridView2();
  4217. if (isExportResults)//导出结果
  4218. this.button9.PerformClick();
  4219. if (isExportReports)//生成报告
  4220. this.button8.PerformClick();
  4221. if (isExportProjects)//导出项目
  4222. this.button1.PerformClick();
  4223. this.appWorkspace.ScriptAutomatic = false;
  4224. this.Close();
  4225. }
  4226. #endregion
  4227. #region [脚本录制]
  4228. private void getScriptRecording()
  4229. {
  4230. string className = InvariantData.path_Action + ".Action" + menuId;
  4231. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  4232. List<Args> args = param.Lists;
  4233. foreach (var item in args)
  4234. {
  4235. item.value = setScriptRecording(item.key);
  4236. }
  4237. //找出二值相关参数 进行赋值
  4238. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  4239. foreach (var item in isNullList)
  4240. {
  4241. item.value = binaryClass.setScriptRecording(item.key);
  4242. }
  4243. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  4244. }
  4245. private object setScriptRecording(string key)
  4246. {
  4247. object value = null;
  4248. switch (key)
  4249. {
  4250. case "parameter1":
  4251. value = checkBox3.Checked;
  4252. break;
  4253. case "parameter2":
  4254. value = trackBar2.Value;
  4255. break;
  4256. case "parameter3":
  4257. value = trackBar4.Value;
  4258. break;
  4259. case "parameter4":
  4260. value = checkBox6.Checked;
  4261. break;
  4262. case "parameter5":
  4263. value = checkBox4.Checked;
  4264. break;
  4265. case "parameter6":
  4266. value = checkBox5.Checked;
  4267. break;
  4268. case "parameter7":
  4269. value = colourFont.First().Key;
  4270. break;
  4271. case "parameter8":
  4272. value = colourFont.First().Value.ToArgb();
  4273. break;
  4274. case "parameter9":
  4275. if (colour.ContainsKey("panelColour1_08"))
  4276. {
  4277. value = colour["panelColour1_08"].ToArgb();
  4278. }
  4279. else
  4280. {
  4281. value = Color.Orange.ToArgb();
  4282. }
  4283. break;
  4284. case "parameter10":
  4285. if (colour.ContainsKey("panelColour08_06"))
  4286. {
  4287. value = colour["panelColour08_06"].ToArgb();
  4288. }
  4289. else
  4290. {
  4291. value = Color.Blue.ToArgb();
  4292. }
  4293. break;
  4294. case "parameter11":
  4295. if (colour.ContainsKey("panelColour06_04"))
  4296. {
  4297. value = colour["panelColour06_04"].ToArgb();
  4298. }
  4299. else
  4300. {
  4301. value = Color.Green.ToArgb();
  4302. }
  4303. break;
  4304. case "parameter12":
  4305. if (colour.ContainsKey("panelColour04_02"))
  4306. {
  4307. value = colour["panelColour04_02"].ToArgb();
  4308. }
  4309. else
  4310. {
  4311. value = Color.Pink.ToArgb();
  4312. }
  4313. break;
  4314. case "parameter13":
  4315. if (colour.ContainsKey("panelColour02_01"))
  4316. {
  4317. value = colour["panelColour02_01"].ToArgb();
  4318. }
  4319. else
  4320. {
  4321. value = Color.Purple.ToArgb();
  4322. }
  4323. break;
  4324. case "parameter14":
  4325. if (colour.ContainsKey("panelColour01_0"))
  4326. {
  4327. value = colour["panelColour01_0"].ToArgb();
  4328. }
  4329. else
  4330. {
  4331. value = Color.Yellow.ToArgb();
  4332. }
  4333. break;
  4334. case "parameter17":
  4335. value = checkBox2.Checked;
  4336. break;
  4337. case "parameter15":
  4338. value = trackBar5.Value;
  4339. break;
  4340. case "parameter16":
  4341. value = trackBar6.Value;
  4342. break;
  4343. case "OpenWhileExportReport":
  4344. value = checkBox1.Checked;
  4345. break;
  4346. case "CalculatorDecimalDigits":
  4347. value = numericUpDown1.Value;
  4348. break;
  4349. case "ExportResults":
  4350. value = isExportResults;
  4351. break;
  4352. case "ExportReports":
  4353. value = isExportReports;
  4354. break;
  4355. case "ExportProjects":
  4356. value = isExportProjects;
  4357. break;
  4358. }
  4359. return value;
  4360. }
  4361. #endregion
  4362. }
  4363. }