SpheroidizationGraphiteSize.cs 223 KB

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