SpheroidizationLevelDialog.cs 231 KB

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