PolyphaseDistanceDialog.cs 152 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525
  1. using OpenCvSharp;
  2. using PaintDotNet.Annotation;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Annotation.Label;
  5. using PaintDotNet.Annotation.PhysicalPhaseAction;
  6. using PaintDotNet.Base;
  7. using PaintDotNet.Base.Functionodel;
  8. using PaintDotNet.Base.CommTool;
  9. using PaintDotNet.Data.Param;
  10. using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Data;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows.Forms;
  21. using System.Xml;
  22. using static PaintDotNet.Base.SettingModel.LabelStyleModel;
  23. using PaintDotNet.CustomControl;
  24. using System.IO;
  25. using PaintDotNet.DbOpreate.DbBll;
  26. using PaintDotNet.DbOpreate.DbModel;
  27. using PaintDotNet.Instrument;
  28. using Metis.ParameterSet;
  29. namespace PaintDotNet.GeneralAnalysis
  30. {
  31. /// <summary>
  32. /// 物相间距
  33. /// </summary>
  34. internal class PolyphaseDistanceDialog : PdnBaseForm
  35. {
  36. #region 控件
  37. private System.Windows.Forms.GroupBox groupBox4;
  38. private System.Windows.Forms.ListView listView1;
  39. private System.Windows.Forms.GroupBox groupBox1;
  40. private System.Windows.Forms.Button button2;
  41. private System.Windows.Forms.CheckBox checkBox1;
  42. private System.Windows.Forms.Button button1;
  43. private System.Windows.Forms.GroupBox groupBox2;
  44. private System.Windows.Forms.GroupBox groupBox_review;
  45. private System.Windows.Forms.GroupBox groupBox5;
  46. private System.Windows.Forms.GroupBox groupBox6;
  47. private System.Windows.Forms.GroupBox groupBox7;
  48. private System.Windows.Forms.Label label1;
  49. private System.Windows.Forms.Button button4;
  50. private System.Windows.Forms.Button button3;
  51. private System.Windows.Forms.ImageList imageList1;
  52. private DataGridView dataGridView_results;
  53. private Button button_remove;
  54. private Button button_all;
  55. private Button button5;
  56. private GroupBox groupBox8;
  57. private GroupBox groupBox9;
  58. private GroupBox groupBox10;
  59. private GroupBox groupBox11;
  60. private CheckBox checkBox3;
  61. private Label label3;
  62. private CustomControl.TriangleTrackBar triangleTrackBar1;
  63. private Label label5;
  64. private NumericUpDown numericUpDown1;
  65. private Label label6;
  66. private Panel panel2;
  67. private RadioButton rb_2;
  68. private RadioButton rb_1;
  69. private Panel panel3;
  70. private Label label7;
  71. private RadioButton rb_4;
  72. private RadioButton rb_3;
  73. private Label label8;
  74. private Label label9;
  75. private NumericUpDown numericUpDown2;
  76. private NumericUpDown numericUpDown3;
  77. private Label lbl_line;
  78. private System.Data.SQLite.SQLiteCommand sqLiteCommand1;
  79. private CustomControl.TriangleTrackBar triangleTrackBar2;
  80. private Label label13;
  81. private CheckBox checkBox4;
  82. private CheckBox checkBox5;
  83. private CheckBox checkBox6;
  84. private NumericUpDown numericUpDown5;
  85. private NumericUpDown numericUpDown4;
  86. private Label label11;
  87. private Label label10;
  88. private Panel panel4;
  89. private RadioButton radioButton1;
  90. private RadioButton radioButton2;
  91. private Label lbl_kl_max;
  92. private Label lbl_kl_min;
  93. private int imgIndex = -1;
  94. //二值化集成1
  95. BinaryClass binaryClass;
  96. private int menuId;
  97. private string menuName;
  98. private BinaryControl bc;
  99. private Button button9;
  100. private CheckedListBox listBox_analysisResult;
  101. private DataGridViewTextBoxColumn Column5;
  102. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  103. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  104. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
  105. private Label label2;
  106. private GroupBox groupBox3;
  107. private IContainer components;
  108. private bool isCheck = false;
  109. private Mat original;
  110. #endregion
  111. #region InitializeComponent
  112. private void InitializeLanguageText()
  113. {
  114. //this.checkBox4.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  115. this.Text = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
  116. this.label8.Text = PdnResources.GetString("Menu.shape.text");
  117. this.label7.Text = PdnResources.GetString("Menu.style.text");
  118. this.rb_4.Text = PdnResources.GetString("Menu.Hollow.text");
  119. this.rb_3.Text = PdnResources.GetString("Menu.solid.text");
  120. this.rb_2.Text = PdnResources.GetString("Menu.Square.text");
  121. this.rb_1.Text = PdnResources.GetString("Menu.circular.Text");
  122. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  123. this.checkBox6.Text = PdnResources.GetString("Menu.displaysections.text");
  124. this.checkBox5.Text = PdnResources.GetString("Menu.displaygrid.text");
  125. this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
  126. this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  127. this.groupBox8.Text = PdnResources.GetString("Menu.Measuringlinesetting.text");
  128. this.label6.Text = PdnResources.GetString("Menu.color.text");
  129. this.label5.Text = PdnResources.GetString("Menu.Linewidth.text");
  130. this.groupBox9.Text = PdnResources.GetString("Menu.operation.text");
  131. this.radioButton2.Text = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Thenumberofsections.text");
  132. this.radioButton1.Text = PdnResources.GetString("Menu.Measuringline.text");
  133. this.groupBox10.Text = PdnResources.GetString("Menu.Interceptformatting.text");
  134. this.label11.Text = PdnResources.GetString("Menu.error.text");
  135. this.label10.Text = PdnResources.GetString("Menu.color.text");
  136. this.lbl_line.Text = PdnResources.GetString("Menu.Linewidth.text");
  137. this.label9.Text = PdnResources.GetString("Menu.size.text");
  138. this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  139. this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
  140. this.Column5.HeaderText = PdnResources.GetString("Menu.picture.Text");
  141. this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Averagespacing.text");
  142. this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.variance.text");
  143. this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.Numberofintercept.text");
  144. this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
  145. this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
  146. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  147. this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
  148. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  149. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  150. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  151. this.groupBox2.Text = PdnResources.GetString("Menu.Particlescreening.text");
  152. this.label13.Text = PdnResources.GetString("Menu.max.text");
  153. this.label3.Text = PdnResources.GetString("Menu.minimum.text");
  154. this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");
  155. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  156. this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
  157. this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  158. this.label2.Text = PdnResources.GetString("Menu.Decimal.text");
  159. }
  160. private void InitializeComponent()
  161. {
  162. this.components = new System.ComponentModel.Container();
  163. this.groupBox4 = new System.Windows.Forms.GroupBox();
  164. this.listView1 = new System.Windows.Forms.ListView();
  165. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  166. this.groupBox1 = new System.Windows.Forms.GroupBox();
  167. this.button5 = new System.Windows.Forms.Button();
  168. this.button2 = new System.Windows.Forms.Button();
  169. this.checkBox1 = new System.Windows.Forms.CheckBox();
  170. this.button1 = new System.Windows.Forms.Button();
  171. this.groupBox2 = new System.Windows.Forms.GroupBox();
  172. this.lbl_kl_max = new System.Windows.Forms.Label();
  173. this.lbl_kl_min = new System.Windows.Forms.Label();
  174. this.triangleTrackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
  175. this.label13 = new System.Windows.Forms.Label();
  176. this.label3 = new System.Windows.Forms.Label();
  177. this.triangleTrackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar();
  178. this.checkBox3 = new System.Windows.Forms.CheckBox();
  179. this.groupBox_review = new System.Windows.Forms.GroupBox();
  180. this.groupBox5 = new System.Windows.Forms.GroupBox();
  181. this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
  182. this.button_remove = new System.Windows.Forms.Button();
  183. this.button_all = new System.Windows.Forms.Button();
  184. this.groupBox6 = new System.Windows.Forms.GroupBox();
  185. this.dataGridView_results = new System.Windows.Forms.DataGridView();
  186. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  187. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  188. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  189. this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  190. this.groupBox7 = new System.Windows.Forms.GroupBox();
  191. this.label2 = new System.Windows.Forms.Label();
  192. this.button9 = new System.Windows.Forms.Button();
  193. this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
  194. this.label1 = new System.Windows.Forms.Label();
  195. this.button4 = new System.Windows.Forms.Button();
  196. this.button3 = new System.Windows.Forms.Button();
  197. this.groupBox8 = new System.Windows.Forms.GroupBox();
  198. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  199. this.label6 = new System.Windows.Forms.Label();
  200. this.panel2 = new System.Windows.Forms.Panel();
  201. this.label5 = new System.Windows.Forms.Label();
  202. this.groupBox9 = new System.Windows.Forms.GroupBox();
  203. this.radioButton2 = new System.Windows.Forms.RadioButton();
  204. this.radioButton1 = new System.Windows.Forms.RadioButton();
  205. this.groupBox10 = new System.Windows.Forms.GroupBox();
  206. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  207. this.label11 = new System.Windows.Forms.Label();
  208. this.label10 = new System.Windows.Forms.Label();
  209. this.panel4 = new System.Windows.Forms.Panel();
  210. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  211. this.lbl_line = new System.Windows.Forms.Label();
  212. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  213. this.label9 = new System.Windows.Forms.Label();
  214. this.label8 = new System.Windows.Forms.Label();
  215. this.panel3 = new System.Windows.Forms.Panel();
  216. this.label7 = new System.Windows.Forms.Label();
  217. this.rb_4 = new System.Windows.Forms.RadioButton();
  218. this.rb_3 = new System.Windows.Forms.RadioButton();
  219. this.rb_2 = new System.Windows.Forms.RadioButton();
  220. this.rb_1 = new System.Windows.Forms.RadioButton();
  221. this.groupBox11 = new System.Windows.Forms.GroupBox();
  222. this.checkBox6 = new System.Windows.Forms.CheckBox();
  223. this.checkBox5 = new System.Windows.Forms.CheckBox();
  224. this.checkBox4 = new System.Windows.Forms.CheckBox();
  225. this.sqLiteCommand1 = new System.Data.SQLite.SQLiteCommand();
  226. this.groupBox3 = new System.Windows.Forms.GroupBox();
  227. this.groupBox4.SuspendLayout();
  228. this.groupBox1.SuspendLayout();
  229. this.groupBox2.SuspendLayout();
  230. this.groupBox5.SuspendLayout();
  231. this.groupBox6.SuspendLayout();
  232. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
  233. this.groupBox7.SuspendLayout();
  234. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
  235. this.groupBox8.SuspendLayout();
  236. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  237. this.groupBox9.SuspendLayout();
  238. this.groupBox10.SuspendLayout();
  239. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  240. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  241. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  242. this.panel3.SuspendLayout();
  243. this.groupBox11.SuspendLayout();
  244. this.groupBox3.SuspendLayout();
  245. this.SuspendLayout();
  246. //
  247. // groupBox4
  248. //
  249. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  250. | System.Windows.Forms.AnchorStyles.Left)));
  251. this.groupBox4.Controls.Add(this.listView1);
  252. this.groupBox4.Location = new System.Drawing.Point(13, 72);
  253. this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
  254. this.groupBox4.Name = "groupBox4";
  255. this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
  256. this.groupBox4.Size = new System.Drawing.Size(158, 674);
  257. this.groupBox4.TabIndex = 9;
  258. this.groupBox4.TabStop = false;
  259. this.groupBox4.Text = "图像索引";
  260. //
  261. // listView1
  262. //
  263. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  264. | System.Windows.Forms.AnchorStyles.Left)
  265. | System.Windows.Forms.AnchorStyles.Right)));
  266. this.listView1.HideSelection = false;
  267. this.listView1.LargeImageList = this.imageList1;
  268. this.listView1.Location = new System.Drawing.Point(8, 26);
  269. this.listView1.Margin = new System.Windows.Forms.Padding(4);
  270. this.listView1.Name = "listView1";
  271. this.listView1.Size = new System.Drawing.Size(140, 640);
  272. this.listView1.TabIndex = 0;
  273. this.listView1.UseCompatibleStateImageBehavior = false;
  274. this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged);
  275. //
  276. // imageList1
  277. //
  278. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  279. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  280. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  281. //
  282. // groupBox1
  283. //
  284. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  285. | System.Windows.Forms.AnchorStyles.Right)));
  286. this.groupBox1.Controls.Add(this.button5);
  287. this.groupBox1.Controls.Add(this.button2);
  288. this.groupBox1.Controls.Add(this.checkBox1);
  289. this.groupBox1.Controls.Add(this.button1);
  290. this.groupBox1.Location = new System.Drawing.Point(20, 12);
  291. this.groupBox1.Name = "groupBox1";
  292. this.groupBox1.Size = new System.Drawing.Size(1160, 53);
  293. this.groupBox1.TabIndex = 10;
  294. this.groupBox1.TabStop = false;
  295. this.groupBox1.Text = "操作";
  296. //
  297. // button5
  298. //
  299. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  300. this.button5.Location = new System.Drawing.Point(971, 20);
  301. this.button5.Name = "button5";
  302. this.button5.Size = new System.Drawing.Size(75, 23);
  303. this.button5.TabIndex = 3;
  304. this.button5.Text = "关闭";
  305. this.button5.UseVisualStyleBackColor = true;
  306. this.button5.Click += new System.EventHandler(this.button5_Click);
  307. //
  308. // button2
  309. //
  310. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  311. this.button2.Location = new System.Drawing.Point(1070, 20);
  312. this.button2.Name = "button2";
  313. this.button2.Size = new System.Drawing.Size(75, 23);
  314. this.button2.TabIndex = 2;
  315. this.button2.Text = "保存结果";
  316. this.button2.UseVisualStyleBackColor = true;
  317. this.button2.Click += new System.EventHandler(this.button2_Click);
  318. //
  319. // checkBox1
  320. //
  321. this.checkBox1.AutoSize = true;
  322. this.checkBox1.Location = new System.Drawing.Point(98, 24);
  323. this.checkBox1.Name = "checkBox1";
  324. this.checkBox1.Size = new System.Drawing.Size(132, 16);
  325. this.checkBox1.TabIndex = 1;
  326. this.checkBox1.Text = "生成报告时打开设置";
  327. this.checkBox1.UseVisualStyleBackColor = true;
  328. //
  329. // button1
  330. //
  331. this.button1.Location = new System.Drawing.Point(6, 24);
  332. this.button1.Name = "button1";
  333. this.button1.Size = new System.Drawing.Size(75, 23);
  334. this.button1.TabIndex = 0;
  335. this.button1.Text = "设置";
  336. this.button1.UseVisualStyleBackColor = true;
  337. this.button1.Click += new System.EventHandler(this.button1_Click);
  338. //
  339. // groupBox2
  340. //
  341. this.groupBox2.Controls.Add(this.lbl_kl_max);
  342. this.groupBox2.Controls.Add(this.lbl_kl_min);
  343. this.groupBox2.Controls.Add(this.triangleTrackBar2);
  344. this.groupBox2.Controls.Add(this.label13);
  345. this.groupBox2.Controls.Add(this.label3);
  346. this.groupBox2.Controls.Add(this.triangleTrackBar1);
  347. this.groupBox2.Controls.Add(this.checkBox3);
  348. this.groupBox2.Location = new System.Drawing.Point(6, 20);
  349. this.groupBox2.Name = "groupBox2";
  350. this.groupBox2.Size = new System.Drawing.Size(360, 76);
  351. this.groupBox2.TabIndex = 11;
  352. this.groupBox2.TabStop = false;
  353. this.groupBox2.Text = "颗粒筛选";
  354. //
  355. // lbl_kl_max
  356. //
  357. this.lbl_kl_max.AutoSize = true;
  358. this.lbl_kl_max.Location = new System.Drawing.Point(302, 50);
  359. this.lbl_kl_max.Name = "lbl_kl_max";
  360. this.lbl_kl_max.Size = new System.Drawing.Size(11, 12);
  361. this.lbl_kl_max.TabIndex = 8;
  362. this.lbl_kl_max.Text = "0";
  363. //
  364. // lbl_kl_min
  365. //
  366. this.lbl_kl_min.AutoSize = true;
  367. this.lbl_kl_min.Location = new System.Drawing.Point(302, 21);
  368. this.lbl_kl_min.Name = "lbl_kl_min";
  369. this.lbl_kl_min.Size = new System.Drawing.Size(11, 12);
  370. this.lbl_kl_min.TabIndex = 7;
  371. this.lbl_kl_min.Text = "0";
  372. //
  373. // triangleTrackBar2
  374. //
  375. this.triangleTrackBar2.Location = new System.Drawing.Point(116, 44);
  376. this.triangleTrackBar2.Maximum = 10;
  377. this.triangleTrackBar2.Minimum = 0;
  378. this.triangleTrackBar2.Name = "triangleTrackBar2";
  379. this.triangleTrackBar2.Size = new System.Drawing.Size(177, 26);
  380. this.triangleTrackBar2.TabIndex = 6;
  381. this.triangleTrackBar2.Value = 0;
  382. this.triangleTrackBar2.TrackBarScroll += new System.EventHandler(this.triangleTrackBar2_TrackBarScroll);
  383. //
  384. // label13
  385. //
  386. this.label13.AutoSize = true;
  387. this.label13.Location = new System.Drawing.Point(77, 50);
  388. this.label13.Name = "label13";
  389. this.label13.Size = new System.Drawing.Size(29, 12);
  390. this.label13.TabIndex = 5;
  391. this.label13.Text = "最大";
  392. //
  393. // label3
  394. //
  395. this.label3.AutoSize = true;
  396. this.label3.Location = new System.Drawing.Point(77, 21);
  397. this.label3.Name = "label3";
  398. this.label3.Size = new System.Drawing.Size(29, 12);
  399. this.label3.TabIndex = 2;
  400. this.label3.Text = "最小";
  401. this.label3.Click += new System.EventHandler(this.label3_Click);
  402. //
  403. // triangleTrackBar1
  404. //
  405. this.triangleTrackBar1.Location = new System.Drawing.Point(116, 14);
  406. this.triangleTrackBar1.Maximum = 10;
  407. this.triangleTrackBar1.Minimum = 0;
  408. this.triangleTrackBar1.Name = "triangleTrackBar1";
  409. this.triangleTrackBar1.Size = new System.Drawing.Size(177, 26);
  410. this.triangleTrackBar1.TabIndex = 1;
  411. this.triangleTrackBar1.Value = 0;
  412. this.triangleTrackBar1.TrackBarScroll += new System.EventHandler(this.triangleTrackBar1_TrackBarScroll);
  413. //
  414. // checkBox3
  415. //
  416. this.checkBox3.AutoSize = true;
  417. this.checkBox3.Location = new System.Drawing.Point(18, 21);
  418. this.checkBox3.Name = "checkBox3";
  419. this.checkBox3.Size = new System.Drawing.Size(48, 16);
  420. this.checkBox3.TabIndex = 0;
  421. this.checkBox3.Text = "筛选";
  422. this.checkBox3.UseVisualStyleBackColor = true;
  423. this.checkBox3.Click += new System.EventHandler(this.checkBox3_BeforeCheckedChanged);
  424. //
  425. // groupBox_review
  426. //
  427. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  428. | System.Windows.Forms.AnchorStyles.Left)
  429. | System.Windows.Forms.AnchorStyles.Right)));
  430. this.groupBox_review.Location = new System.Drawing.Point(556, 72);
  431. this.groupBox_review.Name = "groupBox_review";
  432. this.groupBox_review.Size = new System.Drawing.Size(624, 674);
  433. this.groupBox_review.TabIndex = 12;
  434. this.groupBox_review.TabStop = false;
  435. this.groupBox_review.Text = "预览";
  436. //
  437. // groupBox5
  438. //
  439. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  440. this.groupBox5.Controls.Add(this.listBox_analysisResult);
  441. this.groupBox5.Controls.Add(this.button_remove);
  442. this.groupBox5.Controls.Add(this.button_all);
  443. this.groupBox5.Location = new System.Drawing.Point(13, 753);
  444. this.groupBox5.Name = "groupBox5";
  445. this.groupBox5.Size = new System.Drawing.Size(224, 156);
  446. this.groupBox5.TabIndex = 13;
  447. this.groupBox5.TabStop = false;
  448. //
  449. // listBox_analysisResult
  450. //
  451. this.listBox_analysisResult.CheckOnClick = true;
  452. this.listBox_analysisResult.FormattingEnabled = true;
  453. this.listBox_analysisResult.HorizontalScrollbar = true;
  454. this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
  455. this.listBox_analysisResult.Name = "listBox_analysisResult";
  456. this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
  457. this.listBox_analysisResult.TabIndex = 10;
  458. this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
  459. //
  460. // button_remove
  461. //
  462. this.button_remove.Location = new System.Drawing.Point(130, 24);
  463. this.button_remove.Name = "button_remove";
  464. this.button_remove.Size = new System.Drawing.Size(75, 23);
  465. this.button_remove.TabIndex = 8;
  466. this.button_remove.Text = "删除";
  467. this.button_remove.UseVisualStyleBackColor = true;
  468. this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
  469. //
  470. // button_all
  471. //
  472. this.button_all.Location = new System.Drawing.Point(14, 24);
  473. this.button_all.Name = "button_all";
  474. this.button_all.Size = new System.Drawing.Size(75, 23);
  475. this.button_all.TabIndex = 1;
  476. this.button_all.Text = "全部显示";
  477. this.button_all.UseVisualStyleBackColor = true;
  478. this.button_all.Click += new System.EventHandler(this.button_all_Click);
  479. //
  480. // groupBox6
  481. //
  482. this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  483. | System.Windows.Forms.AnchorStyles.Right)));
  484. this.groupBox6.Controls.Add(this.dataGridView_results);
  485. this.groupBox6.Location = new System.Drawing.Point(243, 753);
  486. this.groupBox6.Name = "groupBox6";
  487. this.groupBox6.Size = new System.Drawing.Size(721, 156);
  488. this.groupBox6.TabIndex = 14;
  489. this.groupBox6.TabStop = false;
  490. //
  491. // dataGridView_results
  492. //
  493. this.dataGridView_results.AllowUserToAddRows = false;
  494. this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  495. | System.Windows.Forms.AnchorStyles.Left)
  496. | System.Windows.Forms.AnchorStyles.Right)));
  497. this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
  498. this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  499. this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  500. this.Column5,
  501. this.dataGridViewTextBoxColumn1,
  502. this.dataGridViewTextBoxColumn2,
  503. this.dataGridViewTextBoxColumn3});
  504. this.dataGridView_results.Location = new System.Drawing.Point(6, 13);
  505. this.dataGridView_results.Name = "dataGridView_results";
  506. this.dataGridView_results.RowHeadersVisible = false;
  507. this.dataGridView_results.RowHeadersWidth = 51;
  508. this.dataGridView_results.RowTemplate.Height = 27;
  509. this.dataGridView_results.Size = new System.Drawing.Size(709, 139);
  510. this.dataGridView_results.TabIndex = 1;
  511. //
  512. // Column5
  513. //
  514. this.Column5.HeaderText = "Column5";
  515. this.Column5.MinimumWidth = 6;
  516. this.Column5.Name = "Column5";
  517. this.Column5.Width = 150;
  518. //
  519. // dataGridViewTextBoxColumn1
  520. //
  521. this.dataGridViewTextBoxColumn1.HeaderText = "dataGridViewTextBoxColumn1";
  522. this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
  523. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  524. this.dataGridViewTextBoxColumn1.Width = 160;
  525. //
  526. // dataGridViewTextBoxColumn2
  527. //
  528. this.dataGridViewTextBoxColumn2.HeaderText = "dataGridViewTextBoxColumn2";
  529. this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
  530. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  531. this.dataGridViewTextBoxColumn2.Width = 200;
  532. //
  533. // dataGridViewTextBoxColumn3
  534. //
  535. this.dataGridViewTextBoxColumn3.HeaderText = "dataGridViewTextBoxColumn3";
  536. this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
  537. this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
  538. this.dataGridViewTextBoxColumn3.Width = 200;
  539. //
  540. // groupBox7
  541. //
  542. this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  543. this.groupBox7.Controls.Add(this.label2);
  544. this.groupBox7.Controls.Add(this.button9);
  545. this.groupBox7.Controls.Add(this.numericUpDown5);
  546. this.groupBox7.Controls.Add(this.label1);
  547. this.groupBox7.Controls.Add(this.button4);
  548. this.groupBox7.Controls.Add(this.button3);
  549. this.groupBox7.Location = new System.Drawing.Point(970, 753);
  550. this.groupBox7.Name = "groupBox7";
  551. this.groupBox7.Size = new System.Drawing.Size(210, 156);
  552. this.groupBox7.TabIndex = 15;
  553. this.groupBox7.TabStop = false;
  554. //
  555. // label2
  556. //
  557. this.label2.AutoSize = true;
  558. this.label2.Location = new System.Drawing.Point(57, 126);
  559. this.label2.Name = "label2";
  560. this.label2.Size = new System.Drawing.Size(29, 12);
  561. this.label2.TabIndex = 8;
  562. this.label2.Text = "小数";
  563. //
  564. // button9
  565. //
  566. this.button9.Location = new System.Drawing.Point(59, 88);
  567. this.button9.Name = "button9";
  568. this.button9.Size = new System.Drawing.Size(107, 23);
  569. this.button9.TabIndex = 7;
  570. this.button9.Text = "项目工程";
  571. this.button9.UseVisualStyleBackColor = true;
  572. this.button9.Click += new System.EventHandler(this.button9_Click);
  573. //
  574. // numericUpDown5
  575. //
  576. this.numericUpDown5.Location = new System.Drawing.Point(92, 124);
  577. this.numericUpDown5.Maximum = new decimal(new int[] {
  578. 10,
  579. 0,
  580. 0,
  581. 0});
  582. this.numericUpDown5.Name = "numericUpDown5";
  583. this.numericUpDown5.Size = new System.Drawing.Size(74, 21);
  584. this.numericUpDown5.TabIndex = 5;
  585. this.numericUpDown5.Value = new decimal(new int[] {
  586. 2,
  587. 0,
  588. 0,
  589. 0});
  590. this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
  591. //
  592. // label1
  593. //
  594. this.label1.AutoSize = true;
  595. this.label1.Location = new System.Drawing.Point(57, 126);
  596. this.label1.Name = "label1";
  597. this.label1.Size = new System.Drawing.Size(0, 12);
  598. this.label1.TabIndex = 3;
  599. //
  600. // button4
  601. //
  602. this.button4.Location = new System.Drawing.Point(59, 54);
  603. this.button4.Name = "button4";
  604. this.button4.Size = new System.Drawing.Size(107, 23);
  605. this.button4.TabIndex = 1;
  606. this.button4.Text = "导出结果";
  607. this.button4.UseVisualStyleBackColor = true;
  608. this.button4.Click += new System.EventHandler(this.button4_Click);
  609. //
  610. // button3
  611. //
  612. this.button3.Location = new System.Drawing.Point(59, 20);
  613. this.button3.Name = "button3";
  614. this.button3.Size = new System.Drawing.Size(107, 23);
  615. this.button3.TabIndex = 0;
  616. this.button3.Text = "生成报告";
  617. this.button3.UseVisualStyleBackColor = true;
  618. this.button3.Click += new System.EventHandler(this.button3_Click);
  619. //
  620. // groupBox8
  621. //
  622. this.groupBox8.Controls.Add(this.numericUpDown1);
  623. this.groupBox8.Controls.Add(this.label6);
  624. this.groupBox8.Controls.Add(this.panel2);
  625. this.groupBox8.Controls.Add(this.label5);
  626. this.groupBox8.Location = new System.Drawing.Point(6, 102);
  627. this.groupBox8.Name = "groupBox8";
  628. this.groupBox8.Size = new System.Drawing.Size(360, 57);
  629. this.groupBox8.TabIndex = 18;
  630. this.groupBox8.TabStop = false;
  631. this.groupBox8.Text = "测量线设置";
  632. //
  633. // numericUpDown1
  634. //
  635. this.numericUpDown1.Location = new System.Drawing.Point(64, 18);
  636. this.numericUpDown1.Minimum = new decimal(new int[] {
  637. 1,
  638. 0,
  639. 0,
  640. 0});
  641. this.numericUpDown1.Name = "numericUpDown1";
  642. this.numericUpDown1.Size = new System.Drawing.Size(74, 21);
  643. this.numericUpDown1.TabIndex = 4;
  644. this.numericUpDown1.Value = new decimal(new int[] {
  645. 2,
  646. 0,
  647. 0,
  648. 0});
  649. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  650. //
  651. // label6
  652. //
  653. this.label6.AutoSize = true;
  654. this.label6.Location = new System.Drawing.Point(179, 20);
  655. this.label6.Name = "label6";
  656. this.label6.Size = new System.Drawing.Size(29, 12);
  657. this.label6.TabIndex = 3;
  658. this.label6.Text = "颜色";
  659. //
  660. // panel2
  661. //
  662. this.panel2.BackColor = System.Drawing.Color.Blue;
  663. this.panel2.Location = new System.Drawing.Point(214, 20);
  664. this.panel2.Name = "panel2";
  665. this.panel2.Size = new System.Drawing.Size(96, 19);
  666. this.panel2.TabIndex = 2;
  667. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  668. //
  669. // label5
  670. //
  671. this.label5.AutoSize = true;
  672. this.label5.Location = new System.Drawing.Point(10, 20);
  673. this.label5.Name = "label5";
  674. this.label5.Size = new System.Drawing.Size(29, 12);
  675. this.label5.TabIndex = 0;
  676. this.label5.Text = "线宽";
  677. //
  678. // groupBox9
  679. //
  680. this.groupBox9.Controls.Add(this.radioButton2);
  681. this.groupBox9.Controls.Add(this.radioButton1);
  682. this.groupBox9.Location = new System.Drawing.Point(6, 165);
  683. this.groupBox9.Name = "groupBox9";
  684. this.groupBox9.Size = new System.Drawing.Size(360, 50);
  685. this.groupBox9.TabIndex = 19;
  686. this.groupBox9.TabStop = false;
  687. this.groupBox9.Text = "操作";
  688. //
  689. // radioButton2
  690. //
  691. this.radioButton2.AutoSize = true;
  692. this.radioButton2.Location = new System.Drawing.Point(181, 20);
  693. this.radioButton2.Name = "radioButton2";
  694. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  695. this.radioButton2.TabIndex = 4;
  696. this.radioButton2.TabStop = true;
  697. this.radioButton2.Text = "截点";
  698. this.radioButton2.UseVisualStyleBackColor = true;
  699. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  700. //
  701. // radioButton1
  702. //
  703. this.radioButton1.AutoSize = true;
  704. this.radioButton1.Checked = true;
  705. this.radioButton1.Location = new System.Drawing.Point(65, 20);
  706. this.radioButton1.Name = "radioButton1";
  707. this.radioButton1.Size = new System.Drawing.Size(59, 16);
  708. this.radioButton1.TabIndex = 3;
  709. this.radioButton1.TabStop = true;
  710. this.radioButton1.Text = "测量线";
  711. this.radioButton1.UseVisualStyleBackColor = true;
  712. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  713. //
  714. // groupBox10
  715. //
  716. this.groupBox10.Controls.Add(this.numericUpDown4);
  717. this.groupBox10.Controls.Add(this.label11);
  718. this.groupBox10.Controls.Add(this.label10);
  719. this.groupBox10.Controls.Add(this.panel4);
  720. this.groupBox10.Controls.Add(this.numericUpDown3);
  721. this.groupBox10.Controls.Add(this.lbl_line);
  722. this.groupBox10.Controls.Add(this.numericUpDown2);
  723. this.groupBox10.Controls.Add(this.label9);
  724. this.groupBox10.Controls.Add(this.label8);
  725. this.groupBox10.Controls.Add(this.panel3);
  726. this.groupBox10.Controls.Add(this.rb_2);
  727. this.groupBox10.Controls.Add(this.rb_1);
  728. this.groupBox10.Location = new System.Drawing.Point(6, 221);
  729. this.groupBox10.Name = "groupBox10";
  730. this.groupBox10.Size = new System.Drawing.Size(360, 102);
  731. this.groupBox10.TabIndex = 20;
  732. this.groupBox10.TabStop = false;
  733. this.groupBox10.Text = "截点格式设置";
  734. //
  735. // numericUpDown4
  736. //
  737. this.numericUpDown4.Location = new System.Drawing.Point(212, 72);
  738. this.numericUpDown4.Maximum = new decimal(new int[] {
  739. 10000,
  740. 0,
  741. 0,
  742. 0});
  743. this.numericUpDown4.Minimum = new decimal(new int[] {
  744. 1,
  745. 0,
  746. 0,
  747. 0});
  748. this.numericUpDown4.Name = "numericUpDown4";
  749. this.numericUpDown4.Size = new System.Drawing.Size(74, 21);
  750. this.numericUpDown4.TabIndex = 24;
  751. this.numericUpDown4.Value = new decimal(new int[] {
  752. 30,
  753. 0,
  754. 0,
  755. 0});
  756. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  757. //
  758. // label11
  759. //
  760. this.label11.AutoSize = true;
  761. this.label11.Location = new System.Drawing.Point(179, 75);
  762. this.label11.Name = "label11";
  763. this.label11.Size = new System.Drawing.Size(29, 12);
  764. this.label11.TabIndex = 23;
  765. this.label11.Text = "误差";
  766. //
  767. // label10
  768. //
  769. this.label10.AutoSize = true;
  770. this.label10.Location = new System.Drawing.Point(179, 51);
  771. this.label10.Name = "label10";
  772. this.label10.Size = new System.Drawing.Size(29, 12);
  773. this.label10.TabIndex = 22;
  774. this.label10.Text = "颜色";
  775. //
  776. // panel4
  777. //
  778. this.panel4.BackColor = System.Drawing.Color.Yellow;
  779. this.panel4.Location = new System.Drawing.Point(212, 48);
  780. this.panel4.Name = "panel4";
  781. this.panel4.Size = new System.Drawing.Size(100, 19);
  782. this.panel4.TabIndex = 21;
  783. this.panel4.Click += new System.EventHandler(this.panel4_Click);
  784. //
  785. // numericUpDown3
  786. //
  787. this.numericUpDown3.Location = new System.Drawing.Point(65, 72);
  788. this.numericUpDown3.Minimum = new decimal(new int[] {
  789. 1,
  790. 0,
  791. 0,
  792. 0});
  793. this.numericUpDown3.Name = "numericUpDown3";
  794. this.numericUpDown3.Size = new System.Drawing.Size(74, 21);
  795. this.numericUpDown3.TabIndex = 14;
  796. this.numericUpDown3.Value = new decimal(new int[] {
  797. 1,
  798. 0,
  799. 0,
  800. 0});
  801. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  802. //
  803. // lbl_line
  804. //
  805. this.lbl_line.AutoSize = true;
  806. this.lbl_line.Location = new System.Drawing.Point(16, 75);
  807. this.lbl_line.Name = "lbl_line";
  808. this.lbl_line.Size = new System.Drawing.Size(29, 12);
  809. this.lbl_line.TabIndex = 13;
  810. this.lbl_line.Text = "线宽";
  811. //
  812. // numericUpDown2
  813. //
  814. this.numericUpDown2.Location = new System.Drawing.Point(64, 46);
  815. this.numericUpDown2.Name = "numericUpDown2";
  816. this.numericUpDown2.Size = new System.Drawing.Size(74, 21);
  817. this.numericUpDown2.TabIndex = 10;
  818. this.numericUpDown2.Value = new decimal(new int[] {
  819. 20,
  820. 0,
  821. 0,
  822. 0});
  823. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  824. //
  825. // label9
  826. //
  827. this.label9.AutoSize = true;
  828. this.label9.Location = new System.Drawing.Point(16, 51);
  829. this.label9.Name = "label9";
  830. this.label9.Size = new System.Drawing.Size(29, 12);
  831. this.label9.TabIndex = 9;
  832. this.label9.Text = "大小";
  833. //
  834. // label8
  835. //
  836. this.label8.AutoSize = true;
  837. this.label8.Location = new System.Drawing.Point(16, 24);
  838. this.label8.Name = "label8";
  839. this.label8.Size = new System.Drawing.Size(29, 12);
  840. this.label8.TabIndex = 8;
  841. this.label8.Text = "形状";
  842. //
  843. // panel3
  844. //
  845. this.panel3.Controls.Add(this.label7);
  846. this.panel3.Controls.Add(this.rb_4);
  847. this.panel3.Controls.Add(this.rb_3);
  848. this.panel3.Location = new System.Drawing.Point(178, 11);
  849. this.panel3.Name = "panel3";
  850. this.panel3.Size = new System.Drawing.Size(176, 34);
  851. this.panel3.TabIndex = 5;
  852. //
  853. // label7
  854. //
  855. this.label7.AutoSize = true;
  856. this.label7.Location = new System.Drawing.Point(12, 11);
  857. this.label7.Name = "label7";
  858. this.label7.Size = new System.Drawing.Size(29, 12);
  859. this.label7.TabIndex = 7;
  860. this.label7.Text = "样式";
  861. //
  862. // rb_4
  863. //
  864. this.rb_4.AutoSize = true;
  865. this.rb_4.Checked = true;
  866. this.rb_4.Location = new System.Drawing.Point(100, 9);
  867. this.rb_4.Name = "rb_4";
  868. this.rb_4.Size = new System.Drawing.Size(47, 16);
  869. this.rb_4.TabIndex = 6;
  870. this.rb_4.TabStop = true;
  871. this.rb_4.Text = "空心";
  872. this.rb_4.UseVisualStyleBackColor = true;
  873. this.rb_4.CheckedChanged += new System.EventHandler(this.rb_4_CheckedChanged);
  874. //
  875. // rb_3
  876. //
  877. this.rb_3.AutoSize = true;
  878. this.rb_3.Location = new System.Drawing.Point(47, 9);
  879. this.rb_3.Name = "rb_3";
  880. this.rb_3.Size = new System.Drawing.Size(47, 16);
  881. this.rb_3.TabIndex = 5;
  882. this.rb_3.Text = "实心";
  883. this.rb_3.UseVisualStyleBackColor = true;
  884. this.rb_3.CheckedChanged += new System.EventHandler(this.rb_3_CheckedChanged);
  885. //
  886. // rb_2
  887. //
  888. this.rb_2.AutoSize = true;
  889. this.rb_2.Location = new System.Drawing.Point(116, 20);
  890. this.rb_2.Name = "rb_2";
  891. this.rb_2.Size = new System.Drawing.Size(47, 16);
  892. this.rb_2.TabIndex = 1;
  893. this.rb_2.Text = "方形";
  894. this.rb_2.UseVisualStyleBackColor = true;
  895. this.rb_2.CheckedChanged += new System.EventHandler(this.rb_2_CheckedChanged);
  896. //
  897. // rb_1
  898. //
  899. this.rb_1.AutoSize = true;
  900. this.rb_1.Checked = true;
  901. this.rb_1.Location = new System.Drawing.Point(65, 20);
  902. this.rb_1.Name = "rb_1";
  903. this.rb_1.Size = new System.Drawing.Size(47, 16);
  904. this.rb_1.TabIndex = 0;
  905. this.rb_1.TabStop = true;
  906. this.rb_1.Text = "圆形";
  907. this.rb_1.UseVisualStyleBackColor = true;
  908. this.rb_1.CheckedChanged += new System.EventHandler(this.rb_1_CheckedChanged);
  909. //
  910. // groupBox11
  911. //
  912. this.groupBox11.Controls.Add(this.checkBox6);
  913. this.groupBox11.Controls.Add(this.checkBox5);
  914. this.groupBox11.Controls.Add(this.checkBox4);
  915. this.groupBox11.Location = new System.Drawing.Point(6, 329);
  916. this.groupBox11.Name = "groupBox11";
  917. this.groupBox11.Size = new System.Drawing.Size(360, 47);
  918. this.groupBox11.TabIndex = 21;
  919. this.groupBox11.TabStop = false;
  920. //
  921. // checkBox6
  922. //
  923. this.checkBox6.AutoSize = true;
  924. this.checkBox6.Checked = true;
  925. this.checkBox6.CheckState = System.Windows.Forms.CheckState.Checked;
  926. this.checkBox6.Location = new System.Drawing.Point(245, 20);
  927. this.checkBox6.Name = "checkBox6";
  928. this.checkBox6.Size = new System.Drawing.Size(72, 16);
  929. this.checkBox6.TabIndex = 2;
  930. this.checkBox6.Text = "显示截点";
  931. this.checkBox6.UseVisualStyleBackColor = true;
  932. this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
  933. //
  934. // checkBox5
  935. //
  936. this.checkBox5.AutoSize = true;
  937. this.checkBox5.Checked = true;
  938. this.checkBox5.CheckState = System.Windows.Forms.CheckState.Checked;
  939. this.checkBox5.Location = new System.Drawing.Point(134, 20);
  940. this.checkBox5.Name = "checkBox5";
  941. this.checkBox5.Size = new System.Drawing.Size(72, 16);
  942. this.checkBox5.TabIndex = 1;
  943. this.checkBox5.Text = "显示网格";
  944. this.checkBox5.UseVisualStyleBackColor = true;
  945. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  946. //
  947. // checkBox4
  948. //
  949. this.checkBox4.AutoSize = true;
  950. this.checkBox4.Checked = true;
  951. this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
  952. this.checkBox4.Location = new System.Drawing.Point(12, 20);
  953. this.checkBox4.Name = "checkBox4";
  954. this.checkBox4.Size = new System.Drawing.Size(96, 16);
  955. this.checkBox4.TabIndex = 0;
  956. this.checkBox4.Text = "显示二值数据";
  957. this.checkBox4.UseVisualStyleBackColor = true;
  958. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  959. //
  960. // sqLiteCommand1
  961. //
  962. this.sqLiteCommand1.CommandText = null;
  963. //
  964. // groupBox3
  965. //
  966. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  967. | System.Windows.Forms.AnchorStyles.Left)));
  968. this.groupBox3.Controls.Add(this.groupBox2);
  969. this.groupBox3.Controls.Add(this.groupBox8);
  970. this.groupBox3.Controls.Add(this.groupBox9);
  971. this.groupBox3.Controls.Add(this.groupBox10);
  972. this.groupBox3.Controls.Add(this.groupBox11);
  973. this.groupBox3.Location = new System.Drawing.Point(178, 365);
  974. this.groupBox3.Name = "groupBox3";
  975. this.groupBox3.Size = new System.Drawing.Size(372, 381);
  976. this.groupBox3.TabIndex = 22;
  977. this.groupBox3.TabStop = false;
  978. //
  979. // PolyphaseDistanceDialog
  980. //
  981. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  982. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  983. this.ClientSize = new System.Drawing.Size(1192, 921);
  984. this.Controls.Add(this.groupBox3);
  985. this.Controls.Add(this.groupBox5);
  986. this.Controls.Add(this.groupBox7);
  987. this.Controls.Add(this.groupBox6);
  988. this.Controls.Add(this.groupBox_review);
  989. this.Controls.Add(this.groupBox1);
  990. this.Controls.Add(this.groupBox4);
  991. this.Name = "PolyphaseDistanceDialog";
  992. this.Shown += new System.EventHandler(this.showImg);
  993. this.Resize += new System.EventHandler(this.PolyphaseDistanceDialog_Resize);
  994. this.Controls.SetChildIndex(this.groupBox4, 0);
  995. this.Controls.SetChildIndex(this.groupBox1, 0);
  996. this.Controls.SetChildIndex(this.groupBox_review, 0);
  997. this.Controls.SetChildIndex(this.groupBox6, 0);
  998. this.Controls.SetChildIndex(this.groupBox7, 0);
  999. this.Controls.SetChildIndex(this.groupBox5, 0);
  1000. this.Controls.SetChildIndex(this.groupBox3, 0);
  1001. this.groupBox4.ResumeLayout(false);
  1002. this.groupBox1.ResumeLayout(false);
  1003. this.groupBox1.PerformLayout();
  1004. this.groupBox2.ResumeLayout(false);
  1005. this.groupBox2.PerformLayout();
  1006. this.groupBox5.ResumeLayout(false);
  1007. this.groupBox6.ResumeLayout(false);
  1008. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
  1009. this.groupBox7.ResumeLayout(false);
  1010. this.groupBox7.PerformLayout();
  1011. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
  1012. this.groupBox8.ResumeLayout(false);
  1013. this.groupBox8.PerformLayout();
  1014. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  1015. this.groupBox9.ResumeLayout(false);
  1016. this.groupBox9.PerformLayout();
  1017. this.groupBox10.ResumeLayout(false);
  1018. this.groupBox10.PerformLayout();
  1019. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  1020. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  1021. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  1022. this.panel3.ResumeLayout(false);
  1023. this.panel3.PerformLayout();
  1024. this.groupBox11.ResumeLayout(false);
  1025. this.groupBox11.PerformLayout();
  1026. this.groupBox3.ResumeLayout(false);
  1027. this.ResumeLayout(false);
  1028. }
  1029. private void InitializeComponent2() {
  1030. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  1031. //
  1032. // bc
  1033. //
  1034. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  1035. this.bc.BinaryChecked = false;
  1036. this.bc.BinaryStyle = 1;
  1037. this.bc.Location = new System.Drawing.Point(178, 72);
  1038. this.bc.Name = "bc";
  1039. this.bc.OriginChecked = false;
  1040. this.bc.scope1End = 0D;
  1041. this.bc.scope1Start = 0D;
  1042. this.bc.scope2End = 0D;
  1043. this.bc.scope2Start = 0D;
  1044. this.bc.scope3End = 0D;
  1045. this.bc.scope3Start = 0D;
  1046. this.bc.Size = new System.Drawing.Size(360, 292);
  1047. this.bc.TabIndex = 3;
  1048. //
  1049. this.Controls.Add(this.bc);
  1050. this.Controls.SetChildIndex(this.bc, 0);
  1051. }
  1052. #endregion
  1053. private CommonControlButtons commonControlButtons;
  1054. /// <summary>
  1055. /// 主空间
  1056. /// </summary>
  1057. private AppWorkspace appWorkspace;
  1058. /// <summary>
  1059. /// 图像面板
  1060. /// </summary>
  1061. private DocumentWorkspaceWindow documentWorkspace;
  1062. /// <summary>
  1063. /// 选中图片的bitmap
  1064. /// </summary>
  1065. private Bitmap bitmap;
  1066. /// <summary>
  1067. /// 处理程序
  1068. /// </summary>
  1069. private ParamObject action = new Data.Action.Action1010();
  1070. int decnum = 2;
  1071. DrawAnalysisModel lineStyleModel = new DrawAnalysisModel();
  1072. DrawAnalysisModel pointStyleModel = new DrawAnalysisModel();
  1073. private ColorsForm colorsFormGrid;
  1074. private ColorsForm lineColorsFormGrid;
  1075. private ColorsForm PointcolorsFormGrid;
  1076. List<PolyphaseDistanceResult> allResults = new List<PolyphaseDistanceResult>();
  1077. private Dictionary<string, List<List<string>>> intermediateDataList = new Dictionary<string, List<List<string>>>();
  1078. //0 画线 1 画截点
  1079. private int drawaction = 0;
  1080. List<PolyphaseDistanceLineResult> lineResults = new List<PolyphaseDistanceLineResult>();
  1081. List<DrawObject> drawObjects = new List<DrawObject>();
  1082. List<DrawObject> rmObjects = new List<DrawObject>();
  1083. private int offsetHalfW = 0;
  1084. private int offsetHalfH = 0;
  1085. private int m_tolerance = 30;
  1086. private int tolerance = 2;
  1087. //0 画线 1 删除
  1088. private int lineAction = 0;
  1089. private decimal maxArea = 0;
  1090. private System.Drawing.Point lineStartPos = new System.Drawing.Point();
  1091. private DrawMulLineA activeLine = null;
  1092. private PhaseModel activePhaseModel = null;
  1093. //private List<Bitmap> bitList = new List<Bitmap>();
  1094. private List<Bitmap> bitList = new List<Bitmap>();
  1095. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  1096. private int is_all = 0;
  1097. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  1098. private int selectPicture = -1;
  1099. private Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel>();
  1100. private string selectedImg = string.Empty;
  1101. /// <summary>
  1102. /// 是否脚本运行
  1103. /// </summary>
  1104. private Boolean initScriptValues = false;
  1105. public PolyphaseDistanceDialog()
  1106. {
  1107. InitializeComponent();
  1108. }
  1109. #region 公共按钮
  1110. private void InitCommonButtonEvent()
  1111. {
  1112. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1113. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1114. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1115. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1116. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1117. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1118. }
  1119. private void zoomInButton_Click(object sender, EventArgs e)
  1120. {
  1121. if(this.bitmap!=null)
  1122. this.documentWorkspace.ZoomIn();
  1123. }
  1124. private void zoomOutButton_Click(object sender, EventArgs e)
  1125. {
  1126. if (this.bitmap != null)
  1127. this.documentWorkspace.ZoomOut();
  1128. }
  1129. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1130. {
  1131. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1132. }
  1133. private void actualSizeButton_Click(object sender, EventArgs e)
  1134. {
  1135. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1136. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1137. }
  1138. private void pointerButton_Click(object sender, EventArgs e)
  1139. {
  1140. documentWorkspace.panel.MouseMove += Panel_MouseMove;
  1141. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1142. }
  1143. private void mobileModeButton_Click(object sender, EventArgs e)
  1144. {
  1145. documentWorkspace.panel.MouseMove -= Panel_MouseMove;
  1146. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1147. }
  1148. #endregion
  1149. public PolyphaseDistanceDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  1150. {
  1151. this.menuId = menuItem.MenuId;
  1152. this.menuName = menuItem.Text;
  1153. binaryClass = new BinaryClass(menuId);
  1154. InitializeComponent();
  1155. InitializeComponent2();
  1156. InitializeLanguageText();
  1157. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  1158. this.colorsFormGrid = new ColorsForm();
  1159. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1160. this.lineColorsFormGrid = new ColorsForm();
  1161. this.lineColorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1162. this.PointcolorsFormGrid = new ColorsForm();
  1163. this.PointcolorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1164. this.appWorkspace = appWorkspace;
  1165. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  1166. this.documentWorkspace.Dock = DockStyle.Fill;
  1167. this.documentWorkspace.HookMouseEvents();
  1168. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1169. this.documentWorkspace.Visible = false;
  1170. this.groupBox_review.Controls.Add(documentWorkspace);
  1171. this.commonControlButtons = new CommonControlButtons();
  1172. this.commonControlButtons.Dock = DockStyle.Top;
  1173. this.commonControlButtons.Height = 30;
  1174. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1175. this.groupBox_review.Controls.Add(commonControlButtons);
  1176. documentWorkspace.panel.MouseDown += Panel_MouseDown;
  1177. documentWorkspace.panel.MouseUp += Panel_MouseUp;
  1178. documentWorkspace.panel.Paint += Panel_Paint;
  1179. documentWorkspace.panel.MouseMove += Panel_MouseMove;
  1180. InitPicList();
  1181. SetAnalyzeModelFromXml("Template.Manager.item2.PolyphaseDistance");
  1182. SetStyle(ControlStyles.UserPaint, true);
  1183. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  1184. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
  1185. UpdateStyle();
  1186. InitCommonButtonEvent();
  1187. //二值化集成2
  1188. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  1189. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text") }
  1190. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  1191. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1192. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  1193. }
  1194. /// <summary>
  1195. /// 获取上次操作参数
  1196. /// </summary>
  1197. private void getLastData()
  1198. {
  1199. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1200. if (!System.IO.File.Exists(filePath))
  1201. {
  1202. generalAnalysisModel = new GeneralAnalysisModel();
  1203. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1204. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1205. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1206. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1207. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1208. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1209. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1210. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1211. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1212. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1213. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1214. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1215. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1216. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1217. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1218. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1219. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1220. }
  1221. else
  1222. {
  1223. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1224. if (generalAnalysisModel.PolyphaseDistanceModels == null)
  1225. {
  1226. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1227. }
  1228. if (generalAnalysisModel.PolyphaseDistanceModels.hasUsed)
  1229. {
  1230. checkBox3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter1;
  1231. if (generalAnalysisModel.PolyphaseDistanceModels.parameter2 <= triangleTrackBar1.Maximum)
  1232. {
  1233. triangleTrackBar1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter2;
  1234. lbl_kl_min.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter2.ToString();
  1235. }
  1236. if (generalAnalysisModel.PolyphaseDistanceModels.parameter3 <= triangleTrackBar2.Maximum)
  1237. {
  1238. triangleTrackBar2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter3;
  1239. lbl_kl_max.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter3.ToString();
  1240. }
  1241. if (checkBox3.Checked)
  1242. {
  1243. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1244. maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  1245. triangleTrackBar1.Maximum = (int)maxArea;
  1246. triangleTrackBar2.Maximum = (int)maxArea;
  1247. triangleTrackBar2_TrackBarScroll(null, null);
  1248. }
  1249. numericUpDown1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter4;
  1250. panel2.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter5);
  1251. radioButton1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? true : false;
  1252. radioButton2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? false : true;
  1253. rb_1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? true : false;
  1254. rb_2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? false : true;
  1255. rb_3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? true : false;
  1256. rb_4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? false : true;
  1257. numericUpDown2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter9;
  1258. panel4.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter10);
  1259. numericUpDown3.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter11;
  1260. numericUpDown4.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter12;
  1261. checkBox4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter13;
  1262. checkBox5.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter14;
  1263. checkBox6.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter15;
  1264. numericUpDown5.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter16;
  1265. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  1266. checkBox1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter17;
  1267. for (int i = 0; i < listView1.Items.Count; i++)
  1268. {
  1269. if (everyImgData.ContainsKey(listView1.Items[i].Name))
  1270. {
  1271. everyImgData[listView1.Items[i].Name] = generalAnalysisModel.PolyphaseDistanceModels;
  1272. }
  1273. else
  1274. {
  1275. everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.PolyphaseDistanceModels);
  1276. }
  1277. }
  1278. }
  1279. }
  1280. }
  1281. /// <summary>
  1282. /// 保存上次操作参数
  1283. /// </summary>
  1284. private void saveLastData(object sender, EventArgs e)
  1285. {
  1286. #region [开启脚本录制]
  1287. if (appWorkspace.startScriptRecording)
  1288. {
  1289. getScriptRecording();
  1290. }
  1291. #endregion
  1292. binaryClass.saveParams();
  1293. if (generalAnalysisModel.PolyphaseDistanceModels == null)
  1294. {
  1295. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1296. }
  1297. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = true;
  1298. generalAnalysisModel.PolyphaseDistanceModels.parameter1 = checkBox3.Checked;
  1299. generalAnalysisModel.PolyphaseDistanceModels.parameter2 = triangleTrackBar1.Value;
  1300. generalAnalysisModel.PolyphaseDistanceModels.parameter3 = triangleTrackBar2.Value;
  1301. generalAnalysisModel.PolyphaseDistanceModels.parameter4 = (int)numericUpDown1.Value;
  1302. generalAnalysisModel.PolyphaseDistanceModels.parameter5 = panel2.BackColor.ToArgb();
  1303. generalAnalysisModel.PolyphaseDistanceModels.parameter17 = checkBox1.Checked;
  1304. if (radioButton1.Checked) {
  1305. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 1;
  1306. } else if (radioButton2.Checked) {
  1307. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 2;
  1308. }else {
  1309. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 3;
  1310. }
  1311. if (rb_1.Checked)
  1312. {
  1313. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 1;
  1314. }
  1315. else if (rb_2.Checked)
  1316. {
  1317. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 2;
  1318. }
  1319. else
  1320. {
  1321. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 3;
  1322. }
  1323. if (rb_3.Checked)
  1324. {
  1325. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 1;
  1326. }
  1327. else if (rb_4.Checked)
  1328. {
  1329. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 2;
  1330. }
  1331. else
  1332. {
  1333. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 3;
  1334. }
  1335. generalAnalysisModel.PolyphaseDistanceModels.parameter9 = (int)numericUpDown2.Value;
  1336. generalAnalysisModel.PolyphaseDistanceModels.parameter10 = panel4.BackColor.ToArgb();
  1337. generalAnalysisModel.PolyphaseDistanceModels.parameter11 = (int)numericUpDown3.Value;
  1338. generalAnalysisModel.PolyphaseDistanceModels.parameter12 = (int)numericUpDown4.Value;
  1339. generalAnalysisModel.PolyphaseDistanceModels.parameter13 = checkBox4.Checked;
  1340. generalAnalysisModel.PolyphaseDistanceModels.parameter14 = checkBox5.Checked;
  1341. generalAnalysisModel.PolyphaseDistanceModels.parameter15 = checkBox6.Checked;
  1342. generalAnalysisModel.PolyphaseDistanceModels.parameter16 = (int)numericUpDown5.Value;
  1343. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1344. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1345. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1346. }
  1347. #region [二值化相关方法]
  1348. /// <summary>
  1349. /// 添加参数改变的监听
  1350. /// </summary>
  1351. /// <param name="sender"></param>
  1352. /// <param name="e"></param>
  1353. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1354. {
  1355. this.binaryClass.loadParams();
  1356. }
  1357. private bool bcBinaryChecked()
  1358. {
  1359. return bc != null && bc.BinaryChecked;
  1360. }
  1361. private bool bcOriginChecked()
  1362. {
  1363. return bc != null && bc.OriginChecked;
  1364. }
  1365. /// <summary>
  1366. /// 显示原图/原图+二值图
  1367. /// </summary>
  1368. /// <param name="sender"></param>
  1369. /// <param name="e"></param>
  1370. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1371. {
  1372. if (!bcOriginChecked())
  1373. {
  1374. if (bcBinaryChecked())
  1375. {
  1376. if (checkBox4.Checked) {
  1377. this.documentWorkspace.PhaseModels[0].choise = true;
  1378. }
  1379. else
  1380. {
  1381. this.documentWorkspace.PhaseModels[0].choise = false;
  1382. }
  1383. }
  1384. }
  1385. else
  1386. {
  1387. this.documentWorkspace.PhaseModels[0].choise = false;
  1388. }
  1389. this.documentWorkspace.Refresh();
  1390. }
  1391. /// <summary>
  1392. /// 参数改变时,重新处理图像
  1393. /// </summary>
  1394. /// <param name="sender"></param>
  1395. /// <param name="e"></param>
  1396. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1397. {
  1398. if (!bcOriginChecked())
  1399. {
  1400. if (bcBinaryChecked())
  1401. {
  1402. if (checkBox4.Checked)
  1403. {
  1404. this.documentWorkspace.PhaseModels[0].choise = true;
  1405. }
  1406. else {
  1407. this.documentWorkspace.PhaseModels[0].choise = false;
  1408. }
  1409. }
  1410. else
  1411. {
  1412. this.documentWorkspace.PhaseModels[0].choise = false;
  1413. }
  1414. this.drawObjects.RemoveAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
  1415. if (!bcBinaryChecked())
  1416. {
  1417. this.rmObjects = this.drawObjects.FindAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
  1418. }
  1419. else {
  1420. this.drawObjects.AddRange(this.rmObjects);
  1421. this.rmObjects.Clear();
  1422. UpdateLine();
  1423. if (checkBox3.Checked)
  1424. {
  1425. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  1426. }
  1427. }
  1428. }
  1429. this.documentWorkspace.Refresh();
  1430. }
  1431. #endregion
  1432. private void showImg(object sender, EventArgs e) {
  1433. listView1.Focus();
  1434. if (this.imgIndex != -1)
  1435. {
  1436. //滚动到指定的行位置
  1437. this.listView1.EnsureVisible(this.imgIndex);
  1438. this.selectPicture = this.imgIndex;
  1439. this.listView1.Items[imgIndex].Focused = true;
  1440. this.listView1.Items[imgIndex].Selected = true;
  1441. }
  1442. binaryClass.RefreshHistogramControl1Values();
  1443. //如果是脚本执行,将参数带入
  1444. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  1445. {
  1446. this.initScriptValues = true;//ScriptAutomatic
  1447. //Boolean initScriptValues = true;
  1448. ////在这里反射出对应功能的参数类
  1449. string className = InvariantData.path_Action + ".Action" + menuId;
  1450. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1451. foreach (Args arg in param.Lists)
  1452. {
  1453. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  1454. if (param1.value != null)
  1455. arg.Value = param1.value;
  1456. getValue(arg.key, arg.Value);
  1457. }
  1458. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1459. }
  1460. else
  1461. {//读取上次关闭窗口时保存的参数
  1462. getLastData();
  1463. }
  1464. }
  1465. private void Init()
  1466. {
  1467. this.drawObjects.Clear();
  1468. this.lineResults.Clear();
  1469. //this.documentWorkspace.phaseModels.Clear();
  1470. //this.documentWorkspace.GraphicsList.Clear();
  1471. }
  1472. private void Panel_MouseMove(object sender, MouseEventArgs e)
  1473. {
  1474. System.Drawing.Point pointscroll = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1475. if (e.Button == MouseButtons.Left)
  1476. {
  1477. if (drawaction == 0)
  1478. {
  1479. if (activeLine != null)
  1480. {
  1481. if (activeLine.pointArray.Count == 1)
  1482. activeLine.pointArray.Add(pointscroll);
  1483. else
  1484. activeLine.pointArray[1] = pointscroll;
  1485. }
  1486. }
  1487. this.documentWorkspace.Refresh();
  1488. }
  1489. }
  1490. private void Panel_Paint(object sender, PaintEventArgs e)
  1491. {
  1492. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1493. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1494. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1495. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
  1496. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
  1497. e.Graphics.TranslateTransform(x, y);
  1498. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1499. if (drawObjects != null)
  1500. {
  1501. foreach (DrawObject drobj in drawObjects)
  1502. {
  1503. drobj.Draw(e.Graphics);
  1504. }
  1505. }
  1506. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1507. e.Graphics.TranslateTransform(-x, -y);
  1508. }
  1509. private void UpdateLine()
  1510. {
  1511. if (listView1.Items.Count == 0 || listView1.SelectedItems == null) {
  1512. return;
  1513. }
  1514. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1515. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  1516. if (mat.Channels() <= 3)
  1517. {
  1518. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  1519. }
  1520. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  1521. foreach (var line in lines)
  1522. {
  1523. if (line == null || line.GetPoints().Count < 2) {
  1524. continue;
  1525. }
  1526. PointF a = line.GetPoints()[0];
  1527. PointF b = line.GetPoints()[1];
  1528. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  1529. int linkCount = 0;
  1530. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
  1531. var ind = lineResults.IndexOf(lineResult);
  1532. if (lineResult == null) {
  1533. continue;
  1534. }
  1535. foreach (int pointid in lineResult.PointIDs.Keys)
  1536. {
  1537. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1538. if (dr != null)
  1539. {
  1540. this.drawObjects.Remove(dr);
  1541. }
  1542. }
  1543. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1544. for (int i = 0; i < linePoints.Count; i++)
  1545. {
  1546. System.Drawing.Point ploc = linePoints[i];
  1547. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
  1548. {
  1549. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  1550. if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
  1551. {
  1552. linkCount++;
  1553. if (linkCount == 1)
  1554. {
  1555. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  1556. if (pointStyleModel.DrawType == 0)
  1557. {
  1558. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1559. circleA.ISurfaceBox = documentWorkspace;
  1560. lineResult.PointIDs.Add(circleA.ID, ploc);
  1561. this.drawObjects.Add(circleA);
  1562. }
  1563. else
  1564. {
  1565. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1566. squareA.ISurfaceBox = documentWorkspace;
  1567. lineResult.PointIDs.Add(squareA.ID, ploc);
  1568. this.drawObjects.Add(squareA);
  1569. }
  1570. }
  1571. else if ((linkCount % m_tolerance) == 0)
  1572. {
  1573. if (pointStyleModel.DrawType == 0)
  1574. {
  1575. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1576. circleA.ISurfaceBox = documentWorkspace;
  1577. lineResult.PointIDs.Add(circleA.ID, ploc);
  1578. this.drawObjects.Add(circleA);
  1579. }
  1580. else
  1581. {
  1582. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1583. squareA.ISurfaceBox = documentWorkspace;
  1584. lineResult.PointIDs.Add(squareA.ID, ploc);
  1585. this.drawObjects.Add(squareA);
  1586. }
  1587. }
  1588. }
  1589. else
  1590. {
  1591. linkCount = 0;
  1592. }
  1593. }
  1594. }
  1595. lineResults[ind] = lineResult;
  1596. }
  1597. }
  1598. private void UpdateStyle()
  1599. {
  1600. lineStyleModel.lineColor = panel2.BackColor.ToArgb();
  1601. lineStyleModel.lineWidth = (int)numericUpDown1.Value;
  1602. pointStyleModel.lineWidth = (int)numericUpDown3.Value;
  1603. pointStyleModel.size = (int)numericUpDown2.Value;
  1604. if (checkBox6.Checked)
  1605. {
  1606. pointStyleModel.fillColor = panel4.BackColor.ToArgb();
  1607. pointStyleModel.lineColor = panel4.BackColor.ToArgb();
  1608. }
  1609. else {
  1610. pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  1611. pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  1612. }
  1613. m_tolerance = (int)numericUpDown4.Value;
  1614. if (rb_3.Checked)
  1615. {
  1616. pointStyleModel.fillType = 1;
  1617. }
  1618. else if (rb_4.Checked)
  1619. {
  1620. pointStyleModel.fillType = 0;
  1621. }
  1622. if (rb_1.Checked)
  1623. {
  1624. pointStyleModel.DrawType = 0;
  1625. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1626. foreach (DrawObject lineObj in lines)
  1627. {
  1628. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  1629. Hashtable newPoints = new Hashtable();
  1630. if (lineResult == null) {
  1631. continue;
  1632. }
  1633. foreach (int pointid in lineResult.PointIDs.Keys)
  1634. {
  1635. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1636. if (dr != null)
  1637. {
  1638. this.drawObjects.Remove(dr);
  1639. }
  1640. System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
  1641. //lineResult.PointIDs.Remove(pointid);
  1642. DrawCircleA squareA = new DrawCircleA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
  1643. squareA.ISurfaceBox = documentWorkspace;
  1644. newPoints.Add(squareA.ID, linePoint);
  1645. this.drawObjects.Add(squareA);
  1646. }
  1647. lineResult.PointIDs = newPoints;
  1648. }
  1649. }
  1650. else if (rb_2.Checked)
  1651. {
  1652. pointStyleModel.DrawType = 1;
  1653. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1654. foreach (DrawObject lineObj in lines)
  1655. {
  1656. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  1657. if (lineResult == null) {
  1658. continue;
  1659. }
  1660. Hashtable newPoints = new Hashtable();
  1661. foreach (int pointid in lineResult.PointIDs.Keys)
  1662. {
  1663. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1664. if (dr != null)
  1665. {
  1666. this.drawObjects.Remove(dr);
  1667. }
  1668. System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
  1669. //lineResult.PointIDs.Remove(pointid);
  1670. DrawSquareA squareA = new DrawSquareA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
  1671. squareA.ISurfaceBox = documentWorkspace;
  1672. newPoints.Add(squareA.ID, linePoint);
  1673. this.drawObjects.Add(squareA);
  1674. }
  1675. lineResult.PointIDs = newPoints;
  1676. //drawObjects[i].drawToolType = DrawToolType.DrawCircleA;
  1677. //if (pointStyleModel.DrawType == 0)
  1678. //{
  1679. // DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1680. // circleA.ISurfaceBox = documentWorkspace;
  1681. // lineResult.PointIDs.Add(circleA.ID, linePoint);
  1682. // this.drawObjects.Add(circleA);
  1683. //}
  1684. //else
  1685. //{
  1686. }
  1687. }
  1688. decnum = (int)numericUpDown5.Value;
  1689. this.documentWorkspace.Refresh();
  1690. }
  1691. private DrawObject getDrawObjectsByLocation(PointF point, DrawToolType drawToolType)
  1692. {
  1693. foreach (DrawObject dr in drawObjects)
  1694. {
  1695. if (dr.drawToolType == drawToolType)
  1696. {
  1697. if (dr.drawToolType == DrawToolType.DrawMulLineA)
  1698. {
  1699. //判断线
  1700. if (dr.GetPoints().Count > 1)
  1701. {
  1702. PointF a = dr.GetPoints()[0];
  1703. PointF b = dr.GetPoints()[1];
  1704. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1705. for (int i = 0; i < linePoints.Count; i++)
  1706. {
  1707. if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), linePoints[i], tolerance))
  1708. {
  1709. return dr;
  1710. }
  1711. }
  1712. }
  1713. }
  1714. if (dr.drawToolType == drawToolType)
  1715. {
  1716. System.Drawing.Point pointLocation = new System.Drawing.Point((int)dr.GetPoints()[0].X, (int)dr.GetPoints()[0].Y);
  1717. if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), pointLocation, tolerance))
  1718. {
  1719. return dr;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. return null;
  1725. }
  1726. private bool ComparePoint(System.Drawing.Point source, System.Drawing.Point target, int tolerance)
  1727. {
  1728. if ((source.X >= (target.X - tolerance)) && (source.X <= (target.X + tolerance)) && (source.Y >= (target.Y - tolerance)) && (source.Y <= (target.Y + tolerance)))
  1729. {
  1730. return true;
  1731. }
  1732. else
  1733. {
  1734. return false;
  1735. }
  1736. }
  1737. private void Panel_MouseDown(object sender, MouseEventArgs e)
  1738. {
  1739. if (documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  1740. {
  1741. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
  1742. }
  1743. if (e.Button == MouseButtons.Left)
  1744. {
  1745. System.Drawing.Point loc = documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1746. DrawObject line = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawMulLineA);
  1747. //首先判断是否在线上
  1748. if (line != null)
  1749. {
  1750. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
  1751. //List<System.Drawing.Point> activeLinePoints = (List<System.Drawing.Point>)linesPoints[line.ID];
  1752. if (drawaction == 1)
  1753. {
  1754. DrawObject circleObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawCircleA);
  1755. DrawObject squareObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawSquareA);
  1756. if (circleObject == null && squareObject == null)
  1757. {
  1758. //碰撞检测,如未检测到对象则新增。
  1759. if (line.GetPoints().Count >= 2)
  1760. {
  1761. PointF a = line.GetPoints()[0];
  1762. PointF b = line.GetPoints()[1];
  1763. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1764. System.Drawing.Point linePoint = linePoints.Find(u => ComparePoint(u, loc, tolerance));
  1765. if (linePoint != null)
  1766. {
  1767. if (pointStyleModel.DrawType == 0)
  1768. {
  1769. DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1770. circleA.ISurfaceBox = documentWorkspace;
  1771. lineResult.PointIDs.Add(circleA.ID, linePoint);
  1772. this.drawObjects.Add(circleA);
  1773. }
  1774. else
  1775. {
  1776. DrawSquareA squareA = new DrawSquareA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1777. squareA.ISurfaceBox = documentWorkspace;
  1778. lineResult.PointIDs.Add(squareA.ID, linePoint);
  1779. this.drawObjects.Add(squareA);
  1780. }
  1781. //activeLinePoints.Add(linePoint);
  1782. }
  1783. }
  1784. }
  1785. else
  1786. {
  1787. if (e.Clicks > 1)
  1788. {
  1789. //如果存在截点,则删除截点
  1790. if (circleObject != null)
  1791. {
  1792. this.drawObjects.Remove(circleObject);
  1793. if (lineResult != null)
  1794. {
  1795. lineResult.PointIDs.Remove(circleObject.ID);
  1796. }
  1797. }
  1798. if (squareObject != null)
  1799. {
  1800. this.drawObjects.Remove(squareObject);
  1801. if (lineResult != null)
  1802. {
  1803. lineResult.PointIDs.Remove(squareObject.ID);
  1804. }
  1805. }
  1806. }
  1807. }
  1808. }
  1809. else
  1810. {
  1811. if (e.Clicks > 1)
  1812. {
  1813. //画线模式,发现线,则删除
  1814. if (lineResult != null)
  1815. {
  1816. foreach (int pointid in lineResult.PointIDs.Keys)
  1817. {
  1818. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1819. if (dr != null)
  1820. {
  1821. this.drawObjects.Remove(dr);
  1822. }
  1823. }
  1824. this.drawObjects.Remove(line);
  1825. lineResults.RemoveAll(u => u.LineID == line.ID);
  1826. activeLine = null;
  1827. }
  1828. }
  1829. lineAction = 1;
  1830. }
  1831. }
  1832. else
  1833. {
  1834. lineStartPos = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1835. this.documentWorkspace.AnalysisStyleModel = lineStyleModel;
  1836. activeLine = new DrawMulLineA(this.documentWorkspace, lineStartPos.X, lineStartPos.Y);
  1837. this.drawObjects.Add(activeLine);
  1838. lineAction = 0;
  1839. }
  1840. documentWorkspace.Refresh();
  1841. }
  1842. }
  1843. int XiangSu = 1;
  1844. /// <summary>
  1845. /// Bresenham画线算法,给出两个点a,b
  1846. /// </summary>
  1847. /// PS:这里XiangSu是光栅的最小距离,因为我是在高分辨率的窗口中模拟低分辨率效果,
  1848. /// 所以用这个XiangSu来控制模拟的光栅最小单元格的边的大小,实际运用中XiangSu=1
  1849. /// <param name="a"></param>
  1850. /// <param name="b"></param>
  1851. List<System.Drawing.Point> Bresenhamline(System.Drawing.PointF a, System.Drawing.PointF b)
  1852. {
  1853. List<System.Drawing.Point> tempP = new List<System.Drawing.Point>();
  1854. int x, y, dx, dy, s1, s2, p, temp, interchange, i;
  1855. x = (int)a.X;
  1856. y = (int)a.Y;
  1857. dx = Math.Abs((int)b.X - (int)a.X);
  1858. dy = Math.Abs((int)b.Y - (int)a.Y);
  1859. if (b.X > a.X)
  1860. s1 = XiangSu;
  1861. else
  1862. s1 = -XiangSu;
  1863. if (b.Y > a.Y)
  1864. s2 = XiangSu;
  1865. else
  1866. s2 = -XiangSu;
  1867. if (dy > dx)
  1868. {
  1869. temp = dx;
  1870. dx = dy;
  1871. dy = temp;
  1872. interchange = 1;
  1873. }
  1874. else
  1875. interchange = 0;
  1876. p = 2 * dy - dx;
  1877. for (i = 1; i <= dx; i += XiangSu)
  1878. {
  1879. System.Drawing.Point tempp = new System.Drawing.Point(x, y);
  1880. tempp.X = x;
  1881. tempp.Y = y;
  1882. tempP.Add(tempp);
  1883. //Vram[x + y * 600] = true;//把该片内存置为边界标记
  1884. if (p >= 0)
  1885. {
  1886. if (interchange == 0)
  1887. y = y + s2;
  1888. else
  1889. x = x + s1;
  1890. p = p - 2 * dx;
  1891. }
  1892. if (interchange == 0)
  1893. x = x + s1;
  1894. else
  1895. y = y + s2;
  1896. p = p + 2 * dy;
  1897. }
  1898. return tempP;
  1899. }
  1900. private void Panel_MouseUp(object sender, MouseEventArgs e)
  1901. {
  1902. //画线
  1903. if (drawaction == 0)
  1904. {
  1905. if (e.Button == MouseButtons.Left)
  1906. {
  1907. if (lineAction == 0)
  1908. {
  1909. if (activeLine != null && activeLine.GetPoints().Count > 1)
  1910. {
  1911. PointF a = activeLine.GetPoints()[0];
  1912. PointF b = activeLine.GetPoints()[1];
  1913. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  1914. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  1915. if (mat.Channels() <= 3) {
  1916. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  1917. }
  1918. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  1919. int linkCount = 0;
  1920. PolyphaseDistanceLineResult lineResult = new PolyphaseDistanceLineResult();
  1921. lineResult.LineID = activeLine.ID;
  1922. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1923. for (int i = 0; i < linePoints.Count; i++)
  1924. {
  1925. System.Drawing.Point ploc = linePoints[i];
  1926. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X>=0 && ploc.Y>=0)
  1927. {
  1928. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  1929. if (targetPoint[0] == color.B && targetPoint[1] == color.G &&
  1930. targetPoint[2] == color.R && targetPoint[3] == 255)
  1931. {
  1932. linkCount++;
  1933. if (linkCount == 1)
  1934. {
  1935. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  1936. if (pointStyleModel.DrawType == 0)
  1937. {
  1938. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1939. circleA.ISurfaceBox = documentWorkspace;
  1940. lineResult.PointIDs.Add(circleA.ID, ploc);
  1941. this.drawObjects.Add(circleA);
  1942. }
  1943. else
  1944. {
  1945. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1946. squareA.ISurfaceBox = documentWorkspace;
  1947. lineResult.PointIDs.Add(squareA.ID, ploc);
  1948. this.drawObjects.Add(squareA);
  1949. }
  1950. }
  1951. else if ((linkCount % m_tolerance) == 0)
  1952. {
  1953. if (pointStyleModel.DrawType == 0)
  1954. {
  1955. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1956. circleA.ISurfaceBox = documentWorkspace;
  1957. lineResult.PointIDs.Add(circleA.ID, ploc);
  1958. this.drawObjects.Add(circleA);
  1959. }
  1960. else
  1961. {
  1962. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1963. squareA.ISurfaceBox = documentWorkspace;
  1964. lineResult.PointIDs.Add(squareA.ID, ploc);
  1965. this.drawObjects.Add(squareA);
  1966. }
  1967. }
  1968. }
  1969. else
  1970. {
  1971. linkCount = 0;
  1972. }
  1973. }
  1974. }
  1975. lineResults.Add(lineResult);
  1976. }
  1977. }
  1978. }
  1979. }
  1980. documentWorkspace.Refresh();
  1981. }
  1982. /// <summary>
  1983. /// 初始化图片列表数据
  1984. /// </summary>
  1985. //public void InitPicList()
  1986. //{
  1987. // //初始化图片列表
  1988. // for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1989. // {
  1990. // this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1991. // this.listView1.Items.Add("", i);
  1992. // this.listView1.Items[i].ImageIndex = i;
  1993. // this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1994. // this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1995. // }
  1996. //}
  1997. public void InitPicList()
  1998. {
  1999. //初始化图片列表
  2000. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  2001. {
  2002. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);
  2003. this.listView1.Items.Add("", i);
  2004. this.listView1.Items[i].ImageIndex = i;
  2005. String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  2006. if (listView1.Items.Find(imageName, false).Count() > 0)
  2007. {
  2008. if (imageName.Split('.').Count() > 1)
  2009. {
  2010. imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
  2011. }
  2012. }
  2013. this.listView1.Items[i].Text = imageName;
  2014. this.listView1.Items[i].Name = imageName;
  2015. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  2016. {
  2017. this.imgIndex = i;
  2018. }
  2019. }
  2020. }
  2021. /// <summary>
  2022. /// ListView图片选择改变事件
  2023. /// </summary>
  2024. /// <param name="sender"></param>
  2025. /// <param name="e"></param>
  2026. private void ListViewSelectedIndexChanged(object sender, EventArgs e)
  2027. {
  2028. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  2029. {
  2030. Init();
  2031. if (!string.IsNullOrEmpty(selectedImg)) {
  2032. #region [保存参数]
  2033. var model = new GeneralAnalysisModel.PolyphaseDistanceModel();
  2034. model.parameter1 = checkBox3.Checked;
  2035. model.parameter2 = triangleTrackBar1.Value;
  2036. model.parameter3 = triangleTrackBar2.Value;
  2037. model.parameter4 = (int)numericUpDown1.Value;
  2038. model.parameter5 = panel2.BackColor.ToArgb();
  2039. model.parameter17 = checkBox1.Checked;
  2040. if (radioButton1.Checked)
  2041. {
  2042. model.parameter6 = 1;
  2043. }
  2044. else if (radioButton2.Checked)
  2045. {
  2046. model.parameter6 = 2;
  2047. }
  2048. else
  2049. {
  2050. model.parameter6 = 3;
  2051. }
  2052. if (rb_1.Checked)
  2053. {
  2054. model.parameter7 = 1;
  2055. }
  2056. else if (rb_2.Checked)
  2057. {
  2058. model.parameter7 = 2;
  2059. }
  2060. else
  2061. {
  2062. model.parameter7 = 3;
  2063. }
  2064. if (rb_3.Checked)
  2065. {
  2066. model.parameter8 = 1;
  2067. }
  2068. else if (rb_4.Checked)
  2069. {
  2070. model.parameter8 = 2;
  2071. }
  2072. else
  2073. {
  2074. model.parameter8 = 3;
  2075. }
  2076. model.parameter9 = (int)numericUpDown2.Value;
  2077. model.parameter10 = panel4.BackColor.ToArgb();
  2078. model.parameter11 = (int)numericUpDown3.Value;
  2079. model.parameter12 = (int)numericUpDown4.Value;
  2080. model.parameter13 = checkBox4.Checked;
  2081. model.parameter14 = checkBox5.Checked;
  2082. model.parameter15 = checkBox6.Checked;
  2083. model.parameter16 = (int)numericUpDown5.Value;
  2084. if (everyImgData.ContainsKey(selectedImg))
  2085. {
  2086. everyImgData[selectedImg] = model;
  2087. }
  2088. else {
  2089. everyImgData.Add(selectedImg, model);
  2090. }
  2091. #endregion
  2092. }
  2093. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  2094. Document document = Document.FromImage(bitmap);
  2095. this.documentWorkspace.Document = document;
  2096. this.documentWorkspace.Visible = true;
  2097. if (selectPicture != -1) {
  2098. this.binaryClass.saveMat(this.imageList1.Images.Keys[selectPicture]);
  2099. }
  2100. selectPicture = this.listView1.FocusedItem.Index;
  2101. binaryClass.listView1_SelectedIndexChanged(this.bitmap, this.imageList1.Images.Keys[selectPicture]);
  2102. if (this.documentWorkspace.phaseModels.Count > 0)
  2103. {
  2104. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2105. maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  2106. triangleTrackBar1.Maximum = (int)maxArea;
  2107. triangleTrackBar2.Maximum = (int)maxArea;
  2108. }
  2109. else {
  2110. triangleTrackBar1.Maximum = 10000;
  2111. triangleTrackBar2.Maximum = 10000;
  2112. }
  2113. if (this.isCheck) {
  2114. checkBox3_BeforeCheckedChanged(sender, e);
  2115. triangleTrackBar2.Value = triangleTrackBar2.Maximum;
  2116. lbl_kl_max.Text = triangleTrackBar2.Maximum.ToString();
  2117. }
  2118. #region [设置参数]
  2119. this.selectedImg = this.listView1.FocusedItem.Name;
  2120. if (everyImgData.ContainsKey(this.selectedImg)) {
  2121. var thisModel = everyImgData[this.selectedImg];
  2122. checkBox3.Checked = thisModel.parameter1;
  2123. if (thisModel.parameter2 <= triangleTrackBar1.Maximum)
  2124. {
  2125. triangleTrackBar1.Value = thisModel.parameter2;
  2126. }
  2127. else {
  2128. triangleTrackBar1.Value = 0;
  2129. }
  2130. if (thisModel.parameter3 <= triangleTrackBar2.Maximum)
  2131. {
  2132. triangleTrackBar2.Value = thisModel.parameter3;
  2133. }
  2134. else
  2135. {
  2136. triangleTrackBar2.Value = 0;
  2137. }
  2138. lbl_kl_min.Text = thisModel.parameter2.ToString();
  2139. lbl_kl_max.Text = thisModel.parameter3.ToString();
  2140. numericUpDown1.Value = thisModel.parameter4;
  2141. panel2.BackColor = Color.FromArgb(thisModel.parameter5);
  2142. radioButton1.Checked = thisModel.parameter6 == 1 ? true : false;
  2143. radioButton2.Checked = thisModel.parameter6 == 1 ? false : true;
  2144. rb_1.Checked = thisModel.parameter7 == 1 ? true : false;
  2145. rb_2.Checked = thisModel.parameter7 == 1 ? false : true;
  2146. rb_3.Checked = thisModel.parameter8 == 1 ? true : false;
  2147. rb_4.Checked = thisModel.parameter8 == 1 ? false : true;
  2148. numericUpDown2.Value = thisModel.parameter9;
  2149. panel4.BackColor = Color.FromArgb(thisModel.parameter10);
  2150. numericUpDown3.Value = thisModel.parameter11;
  2151. numericUpDown4.Value = thisModel.parameter12;
  2152. checkBox4.Checked = thisModel.parameter13;
  2153. checkBox5.Checked = thisModel.parameter14;
  2154. checkBox6.Checked = thisModel.parameter15;
  2155. numericUpDown5.Value = thisModel.parameter16;
  2156. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  2157. checkBox1.Checked = thisModel.parameter17;
  2158. }
  2159. #endregion
  2160. if (this.documentWorkspace.phaseModels.Count > 0)
  2161. {
  2162. if (this.documentWorkspace.phaseModels[0].mat != null)
  2163. {
  2164. original = this.documentWorkspace.phaseModels[0].mat.Clone();
  2165. }
  2166. }
  2167. }
  2168. }
  2169. private void button2_Click(object sender, EventArgs e)
  2170. {
  2171. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2172. if ( this.appWorkspace.DocumentWorkspaces.Length == 0)
  2173. {
  2174. MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
  2175. return;
  2176. }
  2177. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2178. if (listView1.SelectedItems.Count == 0)
  2179. {
  2180. MessageBox.Show(PdnResources.GetString("Menu.seselecttheimagethatyouwanttoan.Text") + "!");
  2181. return;
  2182. }
  2183. if (lineResults.Count==0)
  2184. {
  2185. MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text")+"!");
  2186. return;
  2187. }
  2188. String tag = listView1.FocusedItem.Text;
  2189. List<Bitmap> tempBit = new List<Bitmap>();
  2190. double avgDistince = 0f;
  2191. double distinceSum = 0f;
  2192. //计算间距
  2193. int distinceCount = 0;
  2194. int pointCount = 0;
  2195. List<List<string>> dataList = new List<List<string>>();
  2196. List<string> titleList = new List<string>();
  2197. titleList.Add(PdnResources.GetString("Menu.Thetotallength.Text"));
  2198. titleList.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
  2199. titleList.Add(PdnResources.GetString("Menu.Theaveragelengthof.Text"));
  2200. dataList.Add(titleList);
  2201. for (int i = 0; i < lineResults.Count; i++)
  2202. {
  2203. pointCount += lineResults[i].PointIDs.Count;
  2204. System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
  2205. lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
  2206. pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
  2207. for (int j = 0; j < pointArray.Count() - 1; j++)
  2208. {
  2209. double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10);
  2210. distinceSum += distince * pxPerUnit;
  2211. distinceCount++;
  2212. }
  2213. List<string> newList = new List<string>();
  2214. if (distinceSum != 0)
  2215. {
  2216. newList.Add(distinceSum.ToString());
  2217. newList.Add(pointArray.Count().ToString());
  2218. newList.Add(Math.Round(distinceSum / (pointArray.Count() / 2), 2).ToString());
  2219. dataList.Add(newList);
  2220. }
  2221. }
  2222. if (intermediateDataList.ContainsKey(listView1.FocusedItem.Text.ToString()))
  2223. {
  2224. intermediateDataList[listView1.FocusedItem.Text.ToString()] = dataList;
  2225. }
  2226. else
  2227. {
  2228. intermediateDataList.Add(listView1.FocusedItem.Text.ToString(), dataList);
  2229. }
  2230. if (distinceCount > 0)
  2231. {
  2232. avgDistince = distinceSum / distinceCount;
  2233. }
  2234. //计算方差
  2235. double dfSum = 0f;
  2236. double fc = 0f;
  2237. int fcCount = 0;
  2238. for (int i = 0; i < lineResults.Count; i++)
  2239. {
  2240. System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
  2241. lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
  2242. pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
  2243. for (int j = 0; j < pointArray.Count() - 1; j++)
  2244. {
  2245. double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10) * pxPerUnit;
  2246. double df = Math.Pow((distince - avgDistince), 2);
  2247. dfSum += df;
  2248. fcCount++;
  2249. }
  2250. }
  2251. if (fcCount > 0)
  2252. {
  2253. fc = dfSum / fcCount;
  2254. }
  2255. PolyphaseDistanceResult result = new PolyphaseDistanceResult(listView1.FocusedItem.Text.ToString(), avgDistince, fc, pointCount);
  2256. if (listView1.SelectedItems.Count > 0)
  2257. {
  2258. List<PolyphaseDistanceResult> editResults = allResults.FindAll(item => item.GraphName.Equals(listView1.FocusedItem.Text));
  2259. if (editResults.Count == 0)
  2260. {
  2261. listBox_analysisResult.Items.Add(this.listView1.FocusedItem.Text);
  2262. allResults.Add(result);
  2263. listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1,true);
  2264. dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
  2265. }
  2266. else
  2267. {
  2268. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  2269. if (dr != DialogResult.OK)
  2270. {
  2271. return;
  2272. }
  2273. int index = allResults.FindIndex(item => item.GraphName.Equals(listView1.FocusedItem.Text));
  2274. allResults[index] = result;
  2275. List<string> list = new List<string>();
  2276. foreach (var s in this.listBox_analysisResult.Items)
  2277. {
  2278. list.Add(s.ToString());
  2279. }
  2280. this.listBox_analysisResult.Items.Clear();
  2281. foreach (var s in list)
  2282. {
  2283. this.listBox_analysisResult.Items.Add(s);
  2284. }
  2285. var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
  2286. this.dataGridView_results.Rows.Clear();
  2287. listBox_analysisResult.SetItemChecked(thisindex, true);
  2288. dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
  2289. }
  2290. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  2291. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  2292. originalBit.Tag = pantographRatio;
  2293. tempBit.Add(originalBit);
  2294. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2295. newBit.Tag = pantographRatio;
  2296. Graphics graphics = Graphics.FromImage(newBit);
  2297. Draw(graphics);
  2298. tempBit.Add(newBit);
  2299. if (bitDic.ContainsKey(tag))
  2300. {
  2301. bitDic[tag].Clear();
  2302. bitDic[tag] = tempBit;
  2303. }
  2304. else
  2305. {
  2306. bitDic.Add(tag, tempBit);
  2307. }
  2308. }
  2309. else
  2310. {
  2311. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  2312. }
  2313. }
  2314. private void Draw(Graphics graphics)
  2315. {
  2316. if (this.documentWorkspace.phaseModels.Count > 0)
  2317. {
  2318. foreach (PhaseModel model in this.documentWorkspace.phaseModels)
  2319. {
  2320. if (model.choise && model.mat != null)
  2321. {
  2322. Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
  2323. graphics.DrawImage(map, 0, 0, map.Width, map.Height);
  2324. }
  2325. }
  2326. if (drawObjects != null)
  2327. {
  2328. foreach (DrawObject drobj in drawObjects)
  2329. {
  2330. drobj.Draw(graphics);
  2331. }
  2332. }
  2333. }
  2334. }
  2335. private void button8_Click(object sender, EventArgs e)
  2336. {
  2337. drawaction = 1;
  2338. }
  2339. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  2340. {
  2341. UpdateStyle();
  2342. }
  2343. private void rb_1_CheckedChanged(object sender, EventArgs e)
  2344. {
  2345. if (rb_1.Checked)
  2346. {
  2347. UpdateStyle();
  2348. }
  2349. }
  2350. private void rb_2_CheckedChanged(object sender, EventArgs e)
  2351. {
  2352. if (rb_2.Checked)
  2353. {
  2354. UpdateStyle();
  2355. }
  2356. }
  2357. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  2358. {
  2359. UpdateStyle();
  2360. }
  2361. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  2362. {
  2363. UpdateStyle();
  2364. }
  2365. private void rb_3_CheckedChanged(object sender, EventArgs e)
  2366. {
  2367. if (rb_3.Checked)
  2368. {
  2369. UpdateStyle();
  2370. }
  2371. }
  2372. private void rb_4_CheckedChanged(object sender, EventArgs e)
  2373. {
  2374. if (rb_4.Checked)
  2375. {
  2376. UpdateStyle();
  2377. }
  2378. }
  2379. private void panel2_Click(object sender, EventArgs e)
  2380. {
  2381. this.lineColorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  2382. this.lineColorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
  2383. this.lineColorsFormGrid.ShowDialog();
  2384. }
  2385. private void lineColorChanged(object sender, EventArgs e)
  2386. {
  2387. Color color = this.lineColorsFormGrid.UserPrimaryColor.ToColor();
  2388. //更改背景色,触发事件
  2389. this.panel2.BackColor = color;
  2390. //改变配置文件里面的相颜色
  2391. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2392. //关闭色板
  2393. UpdateStyle();
  2394. this.lineColorsFormGrid.Close();
  2395. }
  2396. private void panel4_Click(object sender, EventArgs e)
  2397. {
  2398. this.PointcolorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
  2399. this.PointcolorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.PointColorChanged));
  2400. this.PointcolorsFormGrid.ShowDialog();
  2401. }
  2402. private void PointColorChanged(object sender, EventArgs e)
  2403. {
  2404. Color color = this.PointcolorsFormGrid.UserPrimaryColor.ToColor();
  2405. //更改背景色,触发事件
  2406. this.panel4.BackColor = color;
  2407. //改变配置文件里面的相颜色
  2408. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2409. //关闭色板
  2410. UpdateStyle();
  2411. this.PointcolorsFormGrid.Close();
  2412. }
  2413. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  2414. {
  2415. if (checkBox6.Checked)
  2416. {
  2417. pointStyleModel.fillColor = panel4.BackColor.ToArgb();
  2418. pointStyleModel.lineColor = panel4.BackColor.ToArgb();
  2419. }
  2420. else
  2421. {
  2422. pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2423. pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2424. }
  2425. documentWorkspace.Refresh();
  2426. }
  2427. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  2428. {
  2429. if (checkBox5.Checked)
  2430. {
  2431. lineStyleModel.lineColor = panel2.BackColor.ToArgb();
  2432. }
  2433. else
  2434. {
  2435. lineStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2436. }
  2437. documentWorkspace.Refresh();
  2438. }
  2439. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  2440. {
  2441. if (checkBox4.Checked)
  2442. {
  2443. if (documentWorkspace.phaseModels.Count > 0)
  2444. {
  2445. documentWorkspace.phaseModels[0].choise = true;
  2446. }
  2447. }
  2448. else
  2449. {
  2450. if (documentWorkspace.phaseModels.Count > 0)
  2451. {
  2452. documentWorkspace.phaseModels[0].choise = false;
  2453. }
  2454. }
  2455. documentWorkspace.Refresh();
  2456. }
  2457. private void tb_2_Load(object sender, EventArgs e)
  2458. {
  2459. }
  2460. private void triangleTrackBar2_TrackBarScroll(object sender, EventArgs e)
  2461. {
  2462. //Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
  2463. if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  2464. {
  2465. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text")+"!");
  2466. return;
  2467. }
  2468. this.documentWorkspace.phaseModels[0].mat = original.Clone();
  2469. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat.Clone());
  2470. lbl_kl_max.Text = triangleTrackBar2.Value.ToString();
  2471. redrawForTolerance();
  2472. this.documentWorkspace.Refresh();
  2473. }
  2474. private void triangleTrackBar1_TrackBarScroll(object sender, EventArgs e)
  2475. {
  2476. if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  2477. {
  2478. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text")+"!");
  2479. return;
  2480. }
  2481. this.documentWorkspace.phaseModels[0].mat = original.Clone();
  2482. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  2483. lbl_kl_min.Text = triangleTrackBar1.Value.ToString();
  2484. redrawForTolerance();
  2485. this.documentWorkspace.Refresh();
  2486. }
  2487. private decimal getMaxArea(Mat pMat)
  2488. {
  2489. if (pMat == null) {
  2490. return 10000;
  2491. }
  2492. double maxArea = 0;
  2493. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2494. HierarchyIndex[] hierarchy;
  2495. OpenCvSharp.Point[][] contours;
  2496. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2497. for (int i = 0; i < contours.Count(); i++)
  2498. {
  2499. double area = Cv2.ContourArea(contours[i]);
  2500. if (area > maxArea)
  2501. {
  2502. maxArea = area;
  2503. }
  2504. }
  2505. return (decimal)maxArea;
  2506. }
  2507. private void checkBox3_BeforeCheckedChanged(object sender, EventArgs e) {
  2508. if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
  2509. {
  2510. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text")+"!");
  2511. this.checkBox3.Checked = false;
  2512. return;
  2513. }
  2514. checkBox3_CheckedChanged(sender,e);
  2515. }
  2516. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  2517. {
  2518. if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0) {
  2519. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text")+"!");
  2520. return;
  2521. }
  2522. this.isCheck = checkBox3.Checked;
  2523. if (checkBox3.Checked)
  2524. {
  2525. if (this.documentWorkspace.phaseModels.Count > 0 && bcBinaryChecked())
  2526. {
  2527. //double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2528. //maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  2529. //triangleTrackBar1.Maximum = (int)maxArea;
  2530. //triangleTrackBar2.Maximum = (int)maxArea;
  2531. }else
  2532. {
  2533. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text")+"!");
  2534. return;
  2535. }
  2536. }
  2537. else
  2538. {
  2539. triangleTrackBar1.Value = 0;
  2540. triangleTrackBar2.Value = 0;
  2541. lbl_kl_max.Text = "0";
  2542. lbl_kl_min.Text = "0";
  2543. //binaryClass.applyButtonImpl();
  2544. this.documentWorkspace.Refresh();
  2545. }
  2546. }
  2547. private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
  2548. {
  2549. if (!checkBox3.Checked)
  2550. {
  2551. return;
  2552. }
  2553. List<OpenCvSharp.Point[]> selectContours = new List<OpenCvSharp.Point[]>();
  2554. List<OpenCvSharp.Point[]> unSelectContours = new List<OpenCvSharp.Point[]>();
  2555. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2556. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2557. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2558. HierarchyIndex[] hierarchy;
  2559. OpenCvSharp.Point[][] contours;
  2560. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2561. for (int i = 0; i < contours.Length; i++)
  2562. {
  2563. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)) - contours[i].Length / 2.0) * pxPerUnit * pxPerUnit;
  2564. if (area < 0) {
  2565. area = 0;
  2566. }
  2567. if (area >= (double)areaMin && area <= (double)areaMax)
  2568. {
  2569. selectContours.Add(contours[i]);
  2570. }
  2571. else
  2572. {
  2573. unSelectContours.Add(contours[i]);
  2574. }
  2575. }
  2576. Cv2.DrawContours(documentWorkspace.phaseModels[0].mat, selectContours, -1, new Scalar(this.documentWorkspace.phaseModels[0].color), Cv2.FILLED);
  2577. documentWorkspace.Refresh();
  2578. }
  2579. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2580. {
  2581. m_tolerance = (int)numericUpDown4.Value;
  2582. redrawForTolerance();
  2583. this.documentWorkspace.Refresh();
  2584. }
  2585. private void redrawForTolerance()
  2586. {
  2587. if (drawaction==0)
  2588. {
  2589. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  2590. foreach (DrawObject lineObj in lines)
  2591. {
  2592. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  2593. if (lineResult != null)
  2594. {
  2595. //删除原有点
  2596. foreach (int pointid in lineResult.PointIDs.Keys)
  2597. {
  2598. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  2599. if (dr != null)
  2600. {
  2601. this.drawObjects.Remove(dr);
  2602. }
  2603. }
  2604. lineResult.PointIDs.Clear();
  2605. //画新点
  2606. if (lineObj != null && lineObj.GetPoints().Count > 1)
  2607. {
  2608. PointF a = lineObj.GetPoints()[0];
  2609. PointF b = lineObj.GetPoints()[1];
  2610. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  2611. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  2612. if (mat.Channels() <= 3)
  2613. {
  2614. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  2615. }
  2616. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  2617. int linkCount = 0;
  2618. lineResult.LineID = lineObj.ID;
  2619. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  2620. for (int i = 0; i < linePoints.Count; i++)
  2621. {
  2622. System.Drawing.Point ploc = linePoints[i];
  2623. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
  2624. {
  2625. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  2626. if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
  2627. {
  2628. linkCount++;
  2629. if (linkCount == 1)
  2630. {
  2631. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  2632. if (pointStyleModel.DrawType == 0)
  2633. {
  2634. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2635. circleA.ISurfaceBox = documentWorkspace;
  2636. lineResult.PointIDs.Add(circleA.ID, ploc);
  2637. this.drawObjects.Add(circleA);
  2638. }
  2639. else
  2640. {
  2641. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2642. squareA.ISurfaceBox = documentWorkspace;
  2643. lineResult.PointIDs.Add(squareA.ID, ploc);
  2644. this.drawObjects.Add(squareA);
  2645. }
  2646. }
  2647. else if ((linkCount % m_tolerance) == 0)
  2648. {
  2649. if (pointStyleModel.DrawType == 0)
  2650. {
  2651. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2652. circleA.ISurfaceBox = documentWorkspace;
  2653. lineResult.PointIDs.Add(circleA.ID, ploc);
  2654. this.drawObjects.Add(circleA);
  2655. }
  2656. else
  2657. {
  2658. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2659. squareA.ISurfaceBox = documentWorkspace;
  2660. lineResult.PointIDs.Add(squareA.ID, ploc);
  2661. this.drawObjects.Add(squareA);
  2662. }
  2663. }
  2664. }
  2665. else
  2666. {
  2667. linkCount = 0;
  2668. }
  2669. }
  2670. }//end for
  2671. }//end if
  2672. }//end if
  2673. }// end foreach
  2674. }//end for if
  2675. }
  2676. private void button_all_Click(object sender, EventArgs e)
  2677. {
  2678. dataGridView_results.Rows.Clear();
  2679. if (this.is_all % 2 == 0)
  2680. {
  2681. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  2682. {
  2683. listBox_analysisResult.SetItemChecked(i, false);
  2684. }
  2685. }
  2686. else {
  2687. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  2688. {
  2689. listBox_analysisResult.SetItemChecked(i, true);
  2690. }
  2691. for (int i = 0; i < allResults.Count; i++)
  2692. {
  2693. PolyphaseDistanceResult editResult = allResults[i];
  2694. dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count);
  2695. }
  2696. }
  2697. this.is_all += 1;
  2698. }
  2699. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  2700. {
  2701. dataGridView_results.Rows.Clear();
  2702. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  2703. {
  2704. foreach (var s in listBox_analysisResult.CheckedItems)
  2705. {
  2706. List<PolyphaseDistanceResult> editResults = allResults.FindAll(u => u.GraphName == s.ToString());
  2707. for (int i = 0; i < editResults.Count; i++)
  2708. {
  2709. PolyphaseDistanceResult editResult = editResults[i];
  2710. dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count, AnalysisTools.GetDecNum(editResult.medianAvr, decnum));
  2711. }
  2712. }
  2713. }
  2714. }
  2715. private void button_remove_Click(object sender, EventArgs e)
  2716. {
  2717. var removeList = new List<string>();
  2718. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  2719. {
  2720. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text")+"?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  2721. if (dr == DialogResult.OK)
  2722. {
  2723. foreach (var s in listBox_analysisResult.CheckedItems)
  2724. {
  2725. for (int i = 0; i < dataGridView_results.Rows.Count; i++)
  2726. {
  2727. if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
  2728. {
  2729. dataGridView_results.Rows.RemoveAt(i);
  2730. }
  2731. }
  2732. allResults.RemoveAll(u => u.GraphName == s.ToString());
  2733. removeList.Add(s.ToString());
  2734. }
  2735. foreach (var m in removeList)
  2736. {
  2737. listBox_analysisResult.Items.Remove(m);
  2738. }
  2739. }
  2740. }
  2741. else
  2742. {
  2743. MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text")+"!");
  2744. }
  2745. }
  2746. private void numericUpDown5_ValueChanged(object sender, EventArgs e)
  2747. {
  2748. decnum = (int)numericUpDown5.Value;
  2749. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2750. {
  2751. PolyphaseDistanceResult result = allResults.Find(u => u.GraphName == dataGridView_results.Rows[i].Cells[0].Value);
  2752. if (result != null)
  2753. {
  2754. dataGridView_results.Rows[i].Cells[1].Value = AnalysisTools.GetDecNum(result.AvgDistince, decnum);
  2755. dataGridView_results.Rows[i].Cells[2].Value = AnalysisTools.GetDecNum(result.Fc, decnum);
  2756. }
  2757. }
  2758. }
  2759. private void button5_Click(object sender, EventArgs e)
  2760. {
  2761. this.Close();
  2762. }
  2763. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  2764. {
  2765. if (radioButton1.Checked)
  2766. {
  2767. drawaction = 0;
  2768. }
  2769. }
  2770. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  2771. {
  2772. if (radioButton2.Checked)
  2773. {
  2774. drawaction = 1;
  2775. }
  2776. }
  2777. private void tb_1_Load(object sender, EventArgs e)
  2778. {
  2779. }
  2780. private void label3_Click(object sender, EventArgs e)
  2781. {
  2782. }
  2783. private void button4_Click(object sender, EventArgs e)
  2784. {
  2785. if (this.dataGridView_results.Rows.Count > 0)
  2786. {
  2787. SaveFileDialog exe = new SaveFileDialog();
  2788. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  2789. exe.FilterIndex = 0;
  2790. exe.RestoreDirectory = true;
  2791. exe.Title = "Export Excel File";
  2792. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  2793. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text")+ PdnResources.GetString("Menu.Analysisresult.text");
  2794. DialogResult dr = exe.ShowDialog();
  2795. if (dr == DialogResult.OK)
  2796. {
  2797. DataTable dtb = new DataTable();
  2798. foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
  2799. {
  2800. dtb.Columns.Add(c.HeaderText);
  2801. }
  2802. for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
  2803. {
  2804. DataRow dataRow = dtb.NewRow();
  2805. for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
  2806. {
  2807. dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
  2808. }
  2809. dtb.Rows.Add(dataRow);
  2810. }
  2811. List<DataTable> list = new List<DataTable>();
  2812. list.Add(dtb);
  2813. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  2814. }
  2815. }
  2816. else
  2817. {
  2818. MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
  2819. }
  2820. }
  2821. private void button1_Click(object sender, EventArgs e)
  2822. {
  2823. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
  2824. if (recombinationRateSetDialog.hasModule)
  2825. {
  2826. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  2827. recombinationRateSetDialog.ShowDialog();
  2828. }
  2829. else
  2830. {
  2831. recombinationRateSetDialog = null;
  2832. }
  2833. }
  2834. private void button3_Click(object sender, EventArgs e)
  2835. {
  2836. if (checkBox1.Checked)
  2837. {
  2838. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
  2839. if (recombinationRateSetDialog.hasModule)
  2840. {
  2841. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  2842. recombinationRateSetDialog.ShowDialog();
  2843. }
  2844. else
  2845. {
  2846. recombinationRateSetDialog = null;
  2847. }
  2848. }
  2849. bitList.Clear();
  2850. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2851. {
  2852. //获取word书签与excel单元格的关系,以字典方式存储
  2853. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2854. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2855. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2856. {
  2857. foreach (mic_module_infos info in mic_module_infos)
  2858. {
  2859. tagInfos.Add(info.tag_name, info.cell_position);
  2860. }
  2861. }
  2862. List<List<string>> analysisContent = new List<List<string>>();
  2863. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2864. {
  2865. List<string> content1 = new List<string>();
  2866. if (i == 0)
  2867. {
  2868. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  2869. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  2870. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  2871. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  2872. analysisContent.Add(content1);
  2873. }
  2874. content1 = new List<string>();
  2875. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  2876. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  2877. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  2878. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  2879. analysisContent.Add(content1);
  2880. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  2881. if (bitDic.ContainsKey(tag))
  2882. {
  2883. bitList.Add(bitDic[tag][0]);
  2884. bitList.Add(bitDic[tag][1]);
  2885. }
  2886. }
  2887. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  2888. }
  2889. else
  2890. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2891. }
  2892. private void button9_Click(object sender, EventArgs e)
  2893. {
  2894. if (this.dataGridView_results.Rows.Count == 0)
  2895. {
  2896. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  2897. return;
  2898. }
  2899. if (this.analyzeSettingModel == null)
  2900. {
  2901. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  2902. return;
  2903. }
  2904. //获取项目工程内的文件夹路径
  2905. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.PhaseSpacing.Text", this.analyzeSettingModel.savePath);
  2906. if (item != null)
  2907. {
  2908. //向文件夹内保存图片和报告
  2909. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2910. {
  2911. //获取word书签与excel单元格的关系,以字典方式存储
  2912. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2913. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2914. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2915. {
  2916. foreach (mic_module_infos info in mic_module_infos)
  2917. {
  2918. tagInfos.Add(info.tag_name, info.cell_position);
  2919. }
  2920. }
  2921. List<List<string>> analysisContent = new List<List<string>>();
  2922. List<List<string>> inclusionList = new List<List<string>>();
  2923. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2924. List<Bitmap> bitImgList = new List<Bitmap>();
  2925. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2926. {
  2927. List<string> content1 = new List<string>();
  2928. if (i == 0)
  2929. {
  2930. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  2931. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  2932. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  2933. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  2934. analysisContent.Add(content1);
  2935. }
  2936. content1 = new List<string>();
  2937. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  2938. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  2939. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  2940. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  2941. analysisContent.Add(content1);
  2942. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  2943. if (intermediateDataList.ContainsKey(tag))
  2944. {
  2945. ExportProjectModel exportProjectModel = new ExportProjectModel();
  2946. exportProjectModel.dataList = intermediateDataList[tag];
  2947. exportProjectModel.picName = tag;
  2948. exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
  2949. exportModel.Add(exportProjectModel);
  2950. }
  2951. if (bitDic.ContainsKey(tag))
  2952. {
  2953. bitImgList.Add(bitDic[tag][0]);
  2954. bitImgList.Add(bitDic[tag][1]);
  2955. }
  2956. }
  2957. try
  2958. {
  2959. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
  2960. }
  2961. catch (Exception ex)
  2962. {
  2963. MessageBox.Show(ex.Message);
  2964. }
  2965. }
  2966. else
  2967. {
  2968. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2969. return;
  2970. }
  2971. //保存项目信息到数据库
  2972. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2973. }
  2974. }
  2975. private void PolyphaseDistanceDialog_Resize(object sender, EventArgs e)
  2976. {
  2977. if (dataGridView_results != null)
  2978. {
  2979. AutoSizeColumn(dataGridView_results, 10);
  2980. }
  2981. }
  2982. private void getValue(string key, Object value)
  2983. {
  2984. switch (key)
  2985. {
  2986. case "parameter11":
  2987. numericUpDown1.Value = Convert.ToDecimal(value);
  2988. break;
  2989. case "parameter12":
  2990. panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
  2991. break;
  2992. case "parameter13":
  2993. radioButton1.Checked = (int)value == 1 ? true : false;
  2994. radioButton2.Checked = (int)value == 1 ? false : true;
  2995. break;
  2996. case "parameter14":
  2997. rb_1.Checked = (int)value == 1 ? true : false;
  2998. rb_2.Checked = (int)value == 1 ? false : true;
  2999. break;
  3000. case "parameter15":
  3001. rb_3.Checked = (int)value == 1 ? true : false;
  3002. rb_4.Checked = (int)value == 1 ? false : true;
  3003. break;
  3004. case "parameter16":
  3005. numericUpDown2.Value = Convert.ToDecimal(value);
  3006. break;
  3007. case "parameter17":
  3008. numericUpDown3.Value = Convert.ToDecimal(value);
  3009. break;
  3010. case "parameter18":
  3011. numericUpDown4.Value = Convert.ToDecimal(value);
  3012. break;
  3013. case "parameter19":
  3014. checkBox4.Checked = Convert.ToBoolean(value);
  3015. break;
  3016. case "parameter20":
  3017. checkBox5.Checked = Convert.ToBoolean(value);
  3018. break;
  3019. case "parameter21":
  3020. checkBox6.Checked = Convert.ToBoolean(value);
  3021. break;
  3022. case "parameter22":
  3023. panel4.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3024. break;
  3025. case "OpenWhileExportReport":
  3026. checkBox1.Checked = Convert.ToBoolean(value);
  3027. break;
  3028. case "CalculatorDecimalDigits":
  3029. numericUpDown5.Value = Convert.ToDecimal(value);
  3030. break;
  3031. }
  3032. }
  3033. #region [脚本录制]
  3034. private void getScriptRecording()
  3035. {
  3036. string className = InvariantData.path_Action + ".Action" + menuId;
  3037. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3038. List<Args> args = param.Lists;
  3039. foreach (var item in args)
  3040. {
  3041. item.value = setScriptRecording(item.key);
  3042. }
  3043. //找出二值相关参数 进行赋值
  3044. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  3045. foreach (var item in isNullList)
  3046. {
  3047. item.value = binaryClass.setScriptRecording(item.key);
  3048. }
  3049. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3050. }
  3051. private object setScriptRecording(string key)
  3052. {
  3053. object value = null;
  3054. switch (key)
  3055. {
  3056. case "parameter11":
  3057. value = numericUpDown1.Value;
  3058. break;
  3059. case "parameter12":
  3060. value = panel2.BackColor.ToArgb();
  3061. break;
  3062. case "parameter13":
  3063. value = radioButton1.Checked ? 1 : 2;
  3064. break;
  3065. case "parameter14":
  3066. value = rb_1.Checked ? 1 : 2;
  3067. break;
  3068. case "parameter15":
  3069. value = rb_3.Checked ? 1 : 2;
  3070. break;
  3071. case "parameter16":
  3072. value = numericUpDown2.Value;
  3073. break;
  3074. case "parameter17":
  3075. value = numericUpDown3.Value;
  3076. break;
  3077. case "parameter18":
  3078. value = numericUpDown4.Value;
  3079. break;
  3080. case "parameter19":
  3081. value = checkBox4.Checked;
  3082. break;
  3083. case "parameter20":
  3084. value = checkBox5.Checked;
  3085. break;
  3086. case "parameter21":
  3087. value = checkBox6.Checked;
  3088. break;
  3089. case "parameter22":
  3090. value = panel4.BackColor.ToArgb();
  3091. break;
  3092. case "OpenWhileExportReport":
  3093. value = checkBox1.Checked;
  3094. break;
  3095. case "CalculatorDecimalDigits":
  3096. value = numericUpDown5.Value;
  3097. break;
  3098. case "ExportResults":
  3099. value = false;
  3100. break;
  3101. case "ExportReports":
  3102. value = false;
  3103. break;
  3104. case "ExportProjects":
  3105. value = false;
  3106. break;
  3107. }
  3108. return value;
  3109. }
  3110. #endregion
  3111. }
  3112. }