SpheroidizationNumberDialog.cs 177 KB

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