PolyphaseDistanceDialog.cs 152 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558
  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. {
  1031. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  1032. //
  1033. // bc
  1034. //
  1035. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  1036. this.bc.BinaryChecked = false;
  1037. this.bc.BinaryStyle = 1;
  1038. this.bc.Location = new System.Drawing.Point(178, 72);
  1039. this.bc.Name = "bc";
  1040. this.bc.OriginChecked = false;
  1041. this.bc.scope1End = 0D;
  1042. this.bc.scope1Start = 0D;
  1043. this.bc.scope2End = 0D;
  1044. this.bc.scope2Start = 0D;
  1045. this.bc.scope3End = 0D;
  1046. this.bc.scope3Start = 0D;
  1047. this.bc.Size = new System.Drawing.Size(360, 292);
  1048. this.bc.TabIndex = 3;
  1049. //
  1050. this.Controls.Add(this.bc);
  1051. this.Controls.SetChildIndex(this.bc, 0);
  1052. }
  1053. #endregion
  1054. private CommonControlButtons commonControlButtons;
  1055. /// <summary>
  1056. /// 主空间
  1057. /// </summary>
  1058. private AppWorkspace appWorkspace;
  1059. /// <summary>
  1060. /// 图像面板
  1061. /// </summary>
  1062. private DocumentWorkspaceWindow documentWorkspace;
  1063. /// <summary>
  1064. /// 选中图片的mat
  1065. /// </summary>
  1066. private Mat imageMat;
  1067. /// <summary>
  1068. /// 处理程序
  1069. /// </summary>
  1070. private ParamObject action = new Data.Action.Action1010();
  1071. int decnum = 2;
  1072. DrawAnalysisModel lineStyleModel = new DrawAnalysisModel();
  1073. DrawAnalysisModel pointStyleModel = new DrawAnalysisModel();
  1074. private ColorsForm colorsFormGrid;
  1075. private ColorsForm lineColorsFormGrid;
  1076. private ColorsForm PointcolorsFormGrid;
  1077. List<PolyphaseDistanceResult> allResults = new List<PolyphaseDistanceResult>();
  1078. private Dictionary<string, List<List<string>>> intermediateDataList = new Dictionary<string, List<List<string>>>();
  1079. //0 画线 1 画截点
  1080. private int drawaction = 0;
  1081. List<PolyphaseDistanceLineResult> lineResults = new List<PolyphaseDistanceLineResult>();
  1082. List<DrawObject> drawObjects = new List<DrawObject>();
  1083. List<DrawObject> rmObjects = new List<DrawObject>();
  1084. private int offsetHalfW = 0;
  1085. private int offsetHalfH = 0;
  1086. private int m_tolerance = 30;
  1087. private int tolerance = 2;
  1088. //0 画线 1 删除
  1089. private int lineAction = 0;
  1090. private decimal maxArea = 0;
  1091. private System.Drawing.Point lineStartPos = new System.Drawing.Point();
  1092. private DrawMulLineA activeLine = null;
  1093. private PhaseModel activePhaseModel = null;
  1094. //private List<Bitmap> bitList = new List<Bitmap>();
  1095. private List<Bitmap> bitList = new List<Bitmap>();
  1096. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  1097. private int is_all = 0;
  1098. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  1099. private int selectPicture = -1;
  1100. private Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel>();
  1101. private string selectedImg = string.Empty;
  1102. /// <summary>
  1103. /// 是否脚本运行
  1104. /// </summary>
  1105. private Boolean initScriptValues = false;
  1106. public PolyphaseDistanceDialog()
  1107. {
  1108. InitializeComponent();
  1109. }
  1110. #region 公共按钮
  1111. private void InitCommonButtonEvent()
  1112. {
  1113. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1114. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1115. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1116. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1117. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1118. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1119. }
  1120. private void zoomInButton_Click(object sender, EventArgs e)
  1121. {
  1122. if (this.imageMat != null)
  1123. this.documentWorkspace.ZoomIn();
  1124. }
  1125. private void zoomOutButton_Click(object sender, EventArgs e)
  1126. {
  1127. if (this.imageMat != null)
  1128. this.documentWorkspace.ZoomOut();
  1129. }
  1130. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1131. {
  1132. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1133. }
  1134. private void actualSizeButton_Click(object sender, EventArgs e)
  1135. {
  1136. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1137. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1138. }
  1139. private void pointerButton_Click(object sender, EventArgs e)
  1140. {
  1141. documentWorkspace.panel.MouseMove += Panel_MouseMove;
  1142. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1143. }
  1144. private void mobileModeButton_Click(object sender, EventArgs e)
  1145. {
  1146. documentWorkspace.panel.MouseMove -= Panel_MouseMove;
  1147. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1148. }
  1149. #endregion
  1150. public PolyphaseDistanceDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  1151. {
  1152. this.menuId = menuItem.MenuId;
  1153. this.menuName = menuItem.Text;
  1154. binaryClass = new BinaryClass(menuId);
  1155. InitializeComponent();
  1156. InitializeComponent2();
  1157. InitializeLanguageText();
  1158. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  1159. this.colorsFormGrid = new ColorsForm();
  1160. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1161. this.lineColorsFormGrid = new ColorsForm();
  1162. this.lineColorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1163. this.PointcolorsFormGrid = new ColorsForm();
  1164. this.PointcolorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  1165. this.appWorkspace = appWorkspace;
  1166. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  1167. this.documentWorkspace.Dock = DockStyle.Fill;
  1168. this.documentWorkspace.HookMouseEvents();
  1169. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1170. this.documentWorkspace.Visible = false;
  1171. documentWorkspace.ActiveTool = DrawToolType.NullTool;
  1172. documentWorkspace.GraphicsList.UnselectAll();
  1173. this.groupBox_review.Controls.Add(documentWorkspace);
  1174. this.commonControlButtons = new CommonControlButtons();
  1175. this.commonControlButtons.Dock = DockStyle.Top;
  1176. this.commonControlButtons.Height = 30;
  1177. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1178. this.groupBox_review.Controls.Add(commonControlButtons);
  1179. documentWorkspace.panel.MouseDown += Panel_MouseDown;
  1180. documentWorkspace.panel.MouseUp += Panel_MouseUp;
  1181. documentWorkspace.panel.Paint += Panel_Paint;
  1182. documentWorkspace.panel.MouseMove += Panel_MouseMove;
  1183. InitPicList();
  1184. SetAnalyzeModelFromXml("Template.Manager.item2.PolyphaseDistance");
  1185. SetStyle(ControlStyles.UserPaint, true);
  1186. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  1187. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
  1188. UpdateStyle();
  1189. InitCommonButtonEvent();
  1190. //二值化集成2
  1191. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  1192. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text") }
  1193. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  1194. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  1195. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  1196. }
  1197. /// <summary>
  1198. /// 获取上次操作参数
  1199. /// </summary>
  1200. private void getLastData()
  1201. {
  1202. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1203. if (!System.IO.File.Exists(filePath))
  1204. {
  1205. generalAnalysisModel = new GeneralAnalysisModel();
  1206. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  1207. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  1208. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  1209. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  1210. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1211. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  1212. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  1213. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  1214. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  1215. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  1216. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  1217. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  1218. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  1219. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  1220. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1221. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  1222. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  1223. }
  1224. else
  1225. {
  1226. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  1227. if (generalAnalysisModel.PolyphaseDistanceModels == null)
  1228. {
  1229. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1230. }
  1231. if (generalAnalysisModel.PolyphaseDistanceModels.hasUsed)
  1232. {
  1233. checkBox3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter1;
  1234. if (generalAnalysisModel.PolyphaseDistanceModels.parameter2 <= triangleTrackBar1.Maximum)
  1235. {
  1236. triangleTrackBar1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter2;
  1237. lbl_kl_min.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter2.ToString();
  1238. }
  1239. if (generalAnalysisModel.PolyphaseDistanceModels.parameter3 <= triangleTrackBar2.Maximum)
  1240. {
  1241. triangleTrackBar2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter3;
  1242. lbl_kl_max.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter3.ToString();
  1243. }
  1244. if (checkBox3.Checked)
  1245. {
  1246. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1247. maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  1248. triangleTrackBar1.Maximum = (int)maxArea;
  1249. triangleTrackBar2.Maximum = (int)maxArea;
  1250. triangleTrackBar2_TrackBarScroll(null, null);
  1251. }
  1252. numericUpDown1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter4;
  1253. panel2.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter5);
  1254. radioButton1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? true : false;
  1255. radioButton2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? false : true;
  1256. rb_1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? true : false;
  1257. rb_2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? false : true;
  1258. rb_3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? true : false;
  1259. rb_4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? false : true;
  1260. numericUpDown2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter9;
  1261. panel4.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter10);
  1262. numericUpDown3.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter11;
  1263. numericUpDown4.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter12;
  1264. checkBox4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter13;
  1265. checkBox5.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter14;
  1266. checkBox6.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter15;
  1267. numericUpDown5.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter16;
  1268. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  1269. checkBox1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter17;
  1270. for (int i = 0; i < listView1.Items.Count; i++)
  1271. {
  1272. if (everyImgData.ContainsKey(listView1.Items[i].Name))
  1273. {
  1274. everyImgData[listView1.Items[i].Name] = generalAnalysisModel.PolyphaseDistanceModels;
  1275. }
  1276. else
  1277. {
  1278. everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.PolyphaseDistanceModels);
  1279. }
  1280. }
  1281. }
  1282. }
  1283. }
  1284. /// <summary>
  1285. /// 保存上次操作参数
  1286. /// </summary>
  1287. private void saveLastData(object sender, EventArgs e)
  1288. {
  1289. #region [开启脚本录制]
  1290. if (appWorkspace.startScriptRecording)
  1291. {
  1292. getScriptRecording();
  1293. }
  1294. #endregion
  1295. binaryClass.saveParams();
  1296. if (generalAnalysisModel.PolyphaseDistanceModels == null)
  1297. {
  1298. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  1299. }
  1300. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = true;
  1301. generalAnalysisModel.PolyphaseDistanceModels.parameter1 = checkBox3.Checked;
  1302. generalAnalysisModel.PolyphaseDistanceModels.parameter2 = triangleTrackBar1.Value;
  1303. generalAnalysisModel.PolyphaseDistanceModels.parameter3 = triangleTrackBar2.Value;
  1304. generalAnalysisModel.PolyphaseDistanceModels.parameter4 = (int)numericUpDown1.Value;
  1305. generalAnalysisModel.PolyphaseDistanceModels.parameter5 = panel2.BackColor.ToArgb();
  1306. generalAnalysisModel.PolyphaseDistanceModels.parameter17 = checkBox1.Checked;
  1307. if (radioButton1.Checked)
  1308. {
  1309. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 1;
  1310. }
  1311. else if (radioButton2.Checked)
  1312. {
  1313. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 2;
  1314. }
  1315. else
  1316. {
  1317. generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 3;
  1318. }
  1319. if (rb_1.Checked)
  1320. {
  1321. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 1;
  1322. }
  1323. else if (rb_2.Checked)
  1324. {
  1325. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 2;
  1326. }
  1327. else
  1328. {
  1329. generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 3;
  1330. }
  1331. if (rb_3.Checked)
  1332. {
  1333. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 1;
  1334. }
  1335. else if (rb_4.Checked)
  1336. {
  1337. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 2;
  1338. }
  1339. else
  1340. {
  1341. generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 3;
  1342. }
  1343. generalAnalysisModel.PolyphaseDistanceModels.parameter9 = (int)numericUpDown2.Value;
  1344. generalAnalysisModel.PolyphaseDistanceModels.parameter10 = panel4.BackColor.ToArgb();
  1345. generalAnalysisModel.PolyphaseDistanceModels.parameter11 = (int)numericUpDown3.Value;
  1346. generalAnalysisModel.PolyphaseDistanceModels.parameter12 = (int)numericUpDown4.Value;
  1347. generalAnalysisModel.PolyphaseDistanceModels.parameter13 = checkBox4.Checked;
  1348. generalAnalysisModel.PolyphaseDistanceModels.parameter14 = checkBox5.Checked;
  1349. generalAnalysisModel.PolyphaseDistanceModels.parameter15 = checkBox6.Checked;
  1350. generalAnalysisModel.PolyphaseDistanceModels.parameter16 = (int)numericUpDown5.Value;
  1351. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  1352. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  1353. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  1354. }
  1355. #region [二值化相关方法]
  1356. /// <summary>
  1357. /// 添加参数改变的监听
  1358. /// </summary>
  1359. /// <param name="sender"></param>
  1360. /// <param name="e"></param>
  1361. private void GrainSizeDialog_Load(object sender, EventArgs e)
  1362. {
  1363. this.binaryClass.loadParams();
  1364. }
  1365. private bool bcBinaryChecked()
  1366. {
  1367. return bc != null && bc.BinaryChecked;
  1368. }
  1369. private bool bcOriginChecked()
  1370. {
  1371. return bc != null && bc.OriginChecked;
  1372. }
  1373. /// <summary>
  1374. /// 显示原图/原图+二值图
  1375. /// </summary>
  1376. /// <param name="sender"></param>
  1377. /// <param name="e"></param>
  1378. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1379. {
  1380. if (!bcOriginChecked())
  1381. {
  1382. if (bcBinaryChecked())
  1383. {
  1384. if (checkBox4.Checked)
  1385. {
  1386. this.documentWorkspace.PhaseModels[0].choise = true;
  1387. }
  1388. else
  1389. {
  1390. this.documentWorkspace.PhaseModels[0].choise = false;
  1391. }
  1392. }
  1393. }
  1394. else
  1395. {
  1396. this.documentWorkspace.PhaseModels[0].choise = false;
  1397. }
  1398. this.documentWorkspace.Refresh();
  1399. }
  1400. /// <summary>
  1401. /// 参数改变时,重新处理图像
  1402. /// </summary>
  1403. /// <param name="sender"></param>
  1404. /// <param name="e"></param>
  1405. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1406. {
  1407. if (!bcOriginChecked())
  1408. {
  1409. if (bcBinaryChecked())
  1410. {
  1411. if (checkBox4.Checked)
  1412. {
  1413. this.documentWorkspace.PhaseModels[0].choise = true;
  1414. }
  1415. else
  1416. {
  1417. this.documentWorkspace.PhaseModels[0].choise = false;
  1418. }
  1419. }
  1420. else
  1421. {
  1422. this.documentWorkspace.PhaseModels[0].choise = false;
  1423. }
  1424. this.drawObjects.RemoveAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
  1425. if (!bcBinaryChecked())
  1426. {
  1427. this.rmObjects = this.drawObjects.FindAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
  1428. }
  1429. else
  1430. {
  1431. this.drawObjects.AddRange(this.rmObjects);
  1432. this.rmObjects.Clear();
  1433. UpdateLine();
  1434. if (checkBox3.Checked)
  1435. {
  1436. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  1437. }
  1438. }
  1439. }
  1440. this.documentWorkspace.Refresh();
  1441. }
  1442. #endregion
  1443. private void showImg(object sender, EventArgs e)
  1444. {
  1445. listView1.Focus();
  1446. if (this.imgIndex != -1)
  1447. {
  1448. //滚动到指定的行位置
  1449. this.listView1.EnsureVisible(this.imgIndex);
  1450. this.selectPicture = this.imgIndex;
  1451. this.listView1.Items[imgIndex].Focused = true;
  1452. this.listView1.Items[imgIndex].Selected = true;
  1453. }
  1454. binaryClass.RefreshHistogramControl1Values();
  1455. //如果是脚本执行,将参数带入
  1456. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  1457. {
  1458. this.initScriptValues = true;//ScriptAutomatic
  1459. //Boolean initScriptValues = true;
  1460. ////在这里反射出对应功能的参数类
  1461. string className = InvariantData.path_Action + ".Action" + menuId;
  1462. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1463. foreach (Args arg in param.Lists)
  1464. {
  1465. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  1466. if (param1.value != null)
  1467. arg.Value = param1.value;
  1468. getValue(arg.key, arg.Value);
  1469. }
  1470. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  1471. }
  1472. else
  1473. {//读取上次关闭窗口时保存的参数
  1474. getLastData();
  1475. }
  1476. }
  1477. private void Init()
  1478. {
  1479. this.drawObjects.Clear();
  1480. this.lineResults.Clear();
  1481. //this.documentWorkspace.phaseModels.Clear();
  1482. //this.documentWorkspace.GraphicsList.Clear();
  1483. }
  1484. private void Panel_MouseMove(object sender, MouseEventArgs e)
  1485. {
  1486. System.Drawing.Point pointscroll = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1487. if (e.Button == MouseButtons.Left&& documentWorkspace.ActiveTool == DrawToolType.NullTool)
  1488. {
  1489. if (drawaction == 0)
  1490. {
  1491. if (activeLine != null)
  1492. {
  1493. if (activeLine.pointArray.Count == 1)
  1494. activeLine.pointArray.Add(pointscroll);
  1495. else
  1496. activeLine.pointArray[1] = pointscroll;
  1497. }
  1498. }
  1499. this.documentWorkspace.Refresh();
  1500. }
  1501. }
  1502. private void Panel_Paint(object sender, PaintEventArgs e)
  1503. {
  1504. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1505. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1506. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1507. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
  1508. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
  1509. e.Graphics.TranslateTransform(x, y);
  1510. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1511. if (drawObjects != null)
  1512. {
  1513. foreach (DrawObject drobj in drawObjects)
  1514. {
  1515. drobj.Draw(e.Graphics);
  1516. }
  1517. }
  1518. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1519. e.Graphics.TranslateTransform(-x, -y);
  1520. }
  1521. private void UpdateLine()
  1522. {
  1523. if (listView1.Items.Count == 0 || listView1.SelectedItems == null)
  1524. {
  1525. return;
  1526. }
  1527. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1528. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  1529. if (mat.Channels() <= 3)
  1530. {
  1531. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  1532. }
  1533. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  1534. foreach (var line in lines)
  1535. {
  1536. if (line == null || line.GetPoints().Count < 2)
  1537. {
  1538. continue;
  1539. }
  1540. PointF a = line.GetPoints()[0];
  1541. PointF b = line.GetPoints()[1];
  1542. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  1543. int linkCount = 0;
  1544. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
  1545. var ind = lineResults.IndexOf(lineResult);
  1546. if (lineResult == null)
  1547. {
  1548. continue;
  1549. }
  1550. foreach (int pointid in lineResult.PointIDs.Keys)
  1551. {
  1552. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1553. if (dr != null)
  1554. {
  1555. this.drawObjects.Remove(dr);
  1556. }
  1557. }
  1558. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1559. for (int i = 0; i < linePoints.Count; i++)
  1560. {
  1561. System.Drawing.Point ploc = linePoints[i];
  1562. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
  1563. {
  1564. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  1565. if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
  1566. {
  1567. linkCount++;
  1568. if (linkCount == 1)
  1569. {
  1570. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  1571. if (pointStyleModel.DrawType == 0)
  1572. {
  1573. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1574. circleA.ISurfaceBox = documentWorkspace;
  1575. lineResult.PointIDs.Add(circleA.ID, ploc);
  1576. this.drawObjects.Add(circleA);
  1577. }
  1578. else
  1579. {
  1580. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1581. squareA.ISurfaceBox = documentWorkspace;
  1582. lineResult.PointIDs.Add(squareA.ID, ploc);
  1583. this.drawObjects.Add(squareA);
  1584. }
  1585. }
  1586. else if ((linkCount % m_tolerance) == 0)
  1587. {
  1588. if (pointStyleModel.DrawType == 0)
  1589. {
  1590. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1591. circleA.ISurfaceBox = documentWorkspace;
  1592. lineResult.PointIDs.Add(circleA.ID, ploc);
  1593. this.drawObjects.Add(circleA);
  1594. }
  1595. else
  1596. {
  1597. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1598. squareA.ISurfaceBox = documentWorkspace;
  1599. lineResult.PointIDs.Add(squareA.ID, ploc);
  1600. this.drawObjects.Add(squareA);
  1601. }
  1602. }
  1603. }
  1604. else
  1605. {
  1606. linkCount = 0;
  1607. }
  1608. }
  1609. }
  1610. lineResults[ind] = lineResult;
  1611. }
  1612. }
  1613. private void UpdateStyle()
  1614. {
  1615. lineStyleModel.lineColor = panel2.BackColor.ToArgb();
  1616. lineStyleModel.lineWidth = (int)numericUpDown1.Value;
  1617. pointStyleModel.lineWidth = (int)numericUpDown3.Value;
  1618. pointStyleModel.size = (int)numericUpDown2.Value;
  1619. if (checkBox6.Checked)
  1620. {
  1621. pointStyleModel.fillColor = panel4.BackColor.ToArgb();
  1622. pointStyleModel.lineColor = panel4.BackColor.ToArgb();
  1623. }
  1624. else
  1625. {
  1626. pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  1627. pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  1628. }
  1629. m_tolerance = (int)numericUpDown4.Value;
  1630. if (rb_3.Checked)
  1631. {
  1632. pointStyleModel.fillType = 1;
  1633. }
  1634. else if (rb_4.Checked)
  1635. {
  1636. pointStyleModel.fillType = 0;
  1637. }
  1638. if (rb_1.Checked)
  1639. {
  1640. pointStyleModel.DrawType = 0;
  1641. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1642. foreach (DrawObject lineObj in lines)
  1643. {
  1644. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  1645. Hashtable newPoints = new Hashtable();
  1646. if (lineResult == null)
  1647. {
  1648. continue;
  1649. }
  1650. foreach (int pointid in lineResult.PointIDs.Keys)
  1651. {
  1652. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1653. if (dr != null)
  1654. {
  1655. this.drawObjects.Remove(dr);
  1656. }
  1657. System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
  1658. //lineResult.PointIDs.Remove(pointid);
  1659. DrawCircleA squareA = new DrawCircleA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
  1660. squareA.ISurfaceBox = documentWorkspace;
  1661. newPoints.Add(squareA.ID, linePoint);
  1662. this.drawObjects.Add(squareA);
  1663. }
  1664. lineResult.PointIDs = newPoints;
  1665. }
  1666. }
  1667. else if (rb_2.Checked)
  1668. {
  1669. pointStyleModel.DrawType = 1;
  1670. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  1671. foreach (DrawObject lineObj in lines)
  1672. {
  1673. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  1674. if (lineResult == null)
  1675. {
  1676. continue;
  1677. }
  1678. Hashtable newPoints = new Hashtable();
  1679. foreach (int pointid in lineResult.PointIDs.Keys)
  1680. {
  1681. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1682. if (dr != null)
  1683. {
  1684. this.drawObjects.Remove(dr);
  1685. }
  1686. System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
  1687. //lineResult.PointIDs.Remove(pointid);
  1688. DrawSquareA squareA = new DrawSquareA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
  1689. squareA.ISurfaceBox = documentWorkspace;
  1690. newPoints.Add(squareA.ID, linePoint);
  1691. this.drawObjects.Add(squareA);
  1692. }
  1693. lineResult.PointIDs = newPoints;
  1694. //drawObjects[i].drawToolType = DrawToolType.DrawCircleA;
  1695. //if (pointStyleModel.DrawType == 0)
  1696. //{
  1697. // DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1698. // circleA.ISurfaceBox = documentWorkspace;
  1699. // lineResult.PointIDs.Add(circleA.ID, linePoint);
  1700. // this.drawObjects.Add(circleA);
  1701. //}
  1702. //else
  1703. //{
  1704. }
  1705. }
  1706. decnum = (int)numericUpDown5.Value;
  1707. this.documentWorkspace.Refresh();
  1708. }
  1709. private DrawObject getDrawObjectsByLocation(PointF point, DrawToolType drawToolType)
  1710. {
  1711. foreach (DrawObject dr in drawObjects)
  1712. {
  1713. if (dr.drawToolType == drawToolType)
  1714. {
  1715. if (dr.drawToolType == DrawToolType.DrawMulLineA)
  1716. {
  1717. //判断线
  1718. if (dr.GetPoints().Count > 1)
  1719. {
  1720. PointF a = dr.GetPoints()[0];
  1721. PointF b = dr.GetPoints()[1];
  1722. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1723. for (int i = 0; i < linePoints.Count; i++)
  1724. {
  1725. if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), linePoints[i], tolerance))
  1726. {
  1727. return dr;
  1728. }
  1729. }
  1730. }
  1731. }
  1732. if (dr.drawToolType == drawToolType)
  1733. {
  1734. System.Drawing.Point pointLocation = new System.Drawing.Point((int)dr.GetPoints()[0].X, (int)dr.GetPoints()[0].Y);
  1735. if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), pointLocation, tolerance))
  1736. {
  1737. return dr;
  1738. }
  1739. }
  1740. }
  1741. }
  1742. return null;
  1743. }
  1744. private bool ComparePoint(System.Drawing.Point source, System.Drawing.Point target, int tolerance)
  1745. {
  1746. if ((source.X >= (target.X - tolerance)) && (source.X <= (target.X + tolerance)) && (source.Y >= (target.Y - tolerance)) && (source.Y <= (target.Y + tolerance)))
  1747. {
  1748. return true;
  1749. }
  1750. else
  1751. {
  1752. return false;
  1753. }
  1754. }
  1755. private void Panel_MouseDown(object sender, MouseEventArgs e)
  1756. {
  1757. if (documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  1758. {
  1759. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
  1760. }
  1761. if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
  1762. {
  1763. System.Drawing.Point loc = documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1764. DrawObject line = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawMulLineA);
  1765. //首先判断是否在线上
  1766. if (line != null)
  1767. {
  1768. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
  1769. //List<System.Drawing.Point> activeLinePoints = (List<System.Drawing.Point>)linesPoints[line.ID];
  1770. if (drawaction == 1)
  1771. {
  1772. DrawObject circleObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawCircleA);
  1773. DrawObject squareObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawSquareA);
  1774. if (circleObject == null && squareObject == null)
  1775. {
  1776. //碰撞检测,如未检测到对象则新增。
  1777. if (line.GetPoints().Count >= 2)
  1778. {
  1779. PointF a = line.GetPoints()[0];
  1780. PointF b = line.GetPoints()[1];
  1781. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1782. System.Drawing.Point linePoint = linePoints.Find(u => ComparePoint(u, loc, tolerance));
  1783. if (linePoint != null)
  1784. {
  1785. if (pointStyleModel.DrawType == 0)
  1786. {
  1787. DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1788. circleA.ISurfaceBox = documentWorkspace;
  1789. lineResult.PointIDs.Add(circleA.ID, linePoint);
  1790. this.drawObjects.Add(circleA);
  1791. }
  1792. else
  1793. {
  1794. DrawSquareA squareA = new DrawSquareA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
  1795. squareA.ISurfaceBox = documentWorkspace;
  1796. lineResult.PointIDs.Add(squareA.ID, linePoint);
  1797. this.drawObjects.Add(squareA);
  1798. }
  1799. //activeLinePoints.Add(linePoint);
  1800. }
  1801. }
  1802. }
  1803. else
  1804. {
  1805. if (e.Clicks > 1)
  1806. {
  1807. //如果存在截点,则删除截点
  1808. if (circleObject != null)
  1809. {
  1810. this.drawObjects.Remove(circleObject);
  1811. if (lineResult != null)
  1812. {
  1813. lineResult.PointIDs.Remove(circleObject.ID);
  1814. }
  1815. }
  1816. if (squareObject != null)
  1817. {
  1818. this.drawObjects.Remove(squareObject);
  1819. if (lineResult != null)
  1820. {
  1821. lineResult.PointIDs.Remove(squareObject.ID);
  1822. }
  1823. }
  1824. }
  1825. }
  1826. }
  1827. else
  1828. {
  1829. if (e.Clicks > 1)
  1830. {
  1831. //画线模式,发现线,则删除
  1832. if (lineResult != null)
  1833. {
  1834. foreach (int pointid in lineResult.PointIDs.Keys)
  1835. {
  1836. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  1837. if (dr != null)
  1838. {
  1839. this.drawObjects.Remove(dr);
  1840. }
  1841. }
  1842. this.drawObjects.Remove(line);
  1843. lineResults.RemoveAll(u => u.LineID == line.ID);
  1844. activeLine = null;
  1845. }
  1846. }
  1847. lineAction = 1;
  1848. }
  1849. }
  1850. else
  1851. {
  1852. lineStartPos = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
  1853. this.documentWorkspace.AnalysisStyleModel = lineStyleModel;
  1854. activeLine = new DrawMulLineA(this.documentWorkspace, lineStartPos.X, lineStartPos.Y);
  1855. this.drawObjects.Add(activeLine);
  1856. lineAction = 0;
  1857. }
  1858. documentWorkspace.Refresh();
  1859. }
  1860. }
  1861. int XiangSu = 1;
  1862. /// <summary>
  1863. /// Bresenham画线算法,给出两个点a,b
  1864. /// </summary>
  1865. /// PS:这里XiangSu是光栅的最小距离,因为我是在高分辨率的窗口中模拟低分辨率效果,
  1866. /// 所以用这个XiangSu来控制模拟的光栅最小单元格的边的大小,实际运用中XiangSu=1
  1867. /// <param name="a"></param>
  1868. /// <param name="b"></param>
  1869. List<System.Drawing.Point> Bresenhamline(System.Drawing.PointF a, System.Drawing.PointF b)
  1870. {
  1871. List<System.Drawing.Point> tempP = new List<System.Drawing.Point>();
  1872. int x, y, dx, dy, s1, s2, p, temp, interchange, i;
  1873. x = (int)a.X;
  1874. y = (int)a.Y;
  1875. dx = Math.Abs((int)b.X - (int)a.X);
  1876. dy = Math.Abs((int)b.Y - (int)a.Y);
  1877. if (b.X > a.X)
  1878. s1 = XiangSu;
  1879. else
  1880. s1 = -XiangSu;
  1881. if (b.Y > a.Y)
  1882. s2 = XiangSu;
  1883. else
  1884. s2 = -XiangSu;
  1885. if (dy > dx)
  1886. {
  1887. temp = dx;
  1888. dx = dy;
  1889. dy = temp;
  1890. interchange = 1;
  1891. }
  1892. else
  1893. interchange = 0;
  1894. p = 2 * dy - dx;
  1895. for (i = 1; i <= dx; i += XiangSu)
  1896. {
  1897. System.Drawing.Point tempp = new System.Drawing.Point(x, y);
  1898. tempp.X = x;
  1899. tempp.Y = y;
  1900. tempP.Add(tempp);
  1901. //Vram[x + y * 600] = true;//把该片内存置为边界标记
  1902. if (p >= 0)
  1903. {
  1904. if (interchange == 0)
  1905. y = y + s2;
  1906. else
  1907. x = x + s1;
  1908. p = p - 2 * dx;
  1909. }
  1910. if (interchange == 0)
  1911. x = x + s1;
  1912. else
  1913. y = y + s2;
  1914. p = p + 2 * dy;
  1915. }
  1916. return tempP;
  1917. }
  1918. private void Panel_MouseUp(object sender, MouseEventArgs e)
  1919. {
  1920. //画线
  1921. if (drawaction == 0)
  1922. {
  1923. if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
  1924. {
  1925. if (lineAction == 0)
  1926. {
  1927. if (activeLine != null && activeLine.GetPoints().Count > 1)
  1928. {
  1929. PointF a = activeLine.GetPoints()[0];
  1930. PointF b = activeLine.GetPoints()[1];
  1931. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  1932. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  1933. if (mat.Channels() <= 3)
  1934. {
  1935. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  1936. }
  1937. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  1938. int linkCount = 0;
  1939. PolyphaseDistanceLineResult lineResult = new PolyphaseDistanceLineResult();
  1940. lineResult.LineID = activeLine.ID;
  1941. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  1942. for (int i = 0; i < linePoints.Count; i++)
  1943. {
  1944. System.Drawing.Point ploc = linePoints[i];
  1945. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
  1946. {
  1947. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  1948. if (targetPoint[0] == color.B && targetPoint[1] == color.G &&
  1949. targetPoint[2] == color.R && targetPoint[3] == 255)
  1950. {
  1951. linkCount++;
  1952. if (linkCount == 1)
  1953. {
  1954. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  1955. if (pointStyleModel.DrawType == 0)
  1956. {
  1957. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1958. circleA.ISurfaceBox = documentWorkspace;
  1959. lineResult.PointIDs.Add(circleA.ID, ploc);
  1960. this.drawObjects.Add(circleA);
  1961. }
  1962. else
  1963. {
  1964. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1965. squareA.ISurfaceBox = documentWorkspace;
  1966. lineResult.PointIDs.Add(squareA.ID, ploc);
  1967. this.drawObjects.Add(squareA);
  1968. }
  1969. }
  1970. else if ((linkCount % m_tolerance) == 0)
  1971. {
  1972. if (pointStyleModel.DrawType == 0)
  1973. {
  1974. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1975. circleA.ISurfaceBox = documentWorkspace;
  1976. lineResult.PointIDs.Add(circleA.ID, ploc);
  1977. this.drawObjects.Add(circleA);
  1978. }
  1979. else
  1980. {
  1981. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  1982. squareA.ISurfaceBox = documentWorkspace;
  1983. lineResult.PointIDs.Add(squareA.ID, ploc);
  1984. this.drawObjects.Add(squareA);
  1985. }
  1986. }
  1987. }
  1988. else
  1989. {
  1990. linkCount = 0;
  1991. }
  1992. }
  1993. }
  1994. lineResults.Add(lineResult);
  1995. }
  1996. }
  1997. }
  1998. }
  1999. documentWorkspace.ActiveTool = DrawToolType.NullTool;
  2000. documentWorkspace.Cursor = Cursors.Default;
  2001. documentWorkspace.GraphicsList.UnselectAll();
  2002. documentWorkspace.Refresh();
  2003. }
  2004. /// <summary>
  2005. /// 初始化图片列表数据
  2006. /// </summary>
  2007. //public void InitPicList()
  2008. //{
  2009. // //初始化图片列表
  2010. // for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  2011. // {
  2012. // this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  2013. // this.listView1.Items.Add("", i);
  2014. // this.listView1.Items[i].ImageIndex = i;
  2015. // this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  2016. // this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  2017. // }
  2018. //}
  2019. public void InitPicList()
  2020. {
  2021. //初始化图片列表
  2022. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  2023. {
  2024. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);
  2025. this.listView1.Items.Add("", i);
  2026. this.listView1.Items[i].ImageIndex = i;
  2027. String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  2028. if (listView1.Items.Find(imageName, false).Count() > 0)
  2029. {
  2030. if (imageName.Split('.').Count() > 1)
  2031. {
  2032. imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
  2033. }
  2034. }
  2035. this.listView1.Items[i].Text = imageName;
  2036. this.listView1.Items[i].Name = imageName;
  2037. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  2038. {
  2039. this.imgIndex = i;
  2040. }
  2041. }
  2042. }
  2043. /// <summary>
  2044. /// ListView图片选择改变事件
  2045. /// </summary>
  2046. /// <param name="sender"></param>
  2047. /// <param name="e"></param>
  2048. private void ListViewSelectedIndexChanged(object sender, EventArgs e)
  2049. {
  2050. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  2051. {
  2052. Init();
  2053. if (!string.IsNullOrEmpty(selectedImg))
  2054. {
  2055. #region [保存参数]
  2056. var model = new GeneralAnalysisModel.PolyphaseDistanceModel();
  2057. model.parameter1 = checkBox3.Checked;
  2058. model.parameter2 = triangleTrackBar1.Value;
  2059. model.parameter3 = triangleTrackBar2.Value;
  2060. model.parameter4 = (int)numericUpDown1.Value;
  2061. model.parameter5 = panel2.BackColor.ToArgb();
  2062. model.parameter17 = checkBox1.Checked;
  2063. if (radioButton1.Checked)
  2064. {
  2065. model.parameter6 = 1;
  2066. }
  2067. else if (radioButton2.Checked)
  2068. {
  2069. model.parameter6 = 2;
  2070. }
  2071. else
  2072. {
  2073. model.parameter6 = 3;
  2074. }
  2075. if (rb_1.Checked)
  2076. {
  2077. model.parameter7 = 1;
  2078. }
  2079. else if (rb_2.Checked)
  2080. {
  2081. model.parameter7 = 2;
  2082. }
  2083. else
  2084. {
  2085. model.parameter7 = 3;
  2086. }
  2087. if (rb_3.Checked)
  2088. {
  2089. model.parameter8 = 1;
  2090. }
  2091. else if (rb_4.Checked)
  2092. {
  2093. model.parameter8 = 2;
  2094. }
  2095. else
  2096. {
  2097. model.parameter8 = 3;
  2098. }
  2099. model.parameter9 = (int)numericUpDown2.Value;
  2100. model.parameter10 = panel4.BackColor.ToArgb();
  2101. model.parameter11 = (int)numericUpDown3.Value;
  2102. model.parameter12 = (int)numericUpDown4.Value;
  2103. model.parameter13 = checkBox4.Checked;
  2104. model.parameter14 = checkBox5.Checked;
  2105. model.parameter15 = checkBox6.Checked;
  2106. model.parameter16 = (int)numericUpDown5.Value;
  2107. if (everyImgData.ContainsKey(selectedImg))
  2108. {
  2109. everyImgData[selectedImg] = model;
  2110. }
  2111. else
  2112. {
  2113. everyImgData.Add(selectedImg, model);
  2114. }
  2115. #endregion
  2116. }
  2117. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  2118. Document document = Document.FromImageMat(imageMat.Clone());
  2119. this.documentWorkspace.Document = document;
  2120. this.documentWorkspace.Visible = true;
  2121. if (selectPicture != -1)
  2122. {
  2123. this.binaryClass.saveMat(this.imageList1.Images.Keys[selectPicture]);
  2124. }
  2125. selectPicture = this.listView1.FocusedItem.Index;
  2126. binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), this.imageList1.Images.Keys[selectPicture]);
  2127. if (this.documentWorkspace.phaseModels.Count > 0)
  2128. {
  2129. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2130. maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  2131. triangleTrackBar1.Maximum = (int)maxArea;
  2132. triangleTrackBar2.Maximum = (int)maxArea;
  2133. }
  2134. else
  2135. {
  2136. triangleTrackBar1.Maximum = 10000;
  2137. triangleTrackBar2.Maximum = 10000;
  2138. }
  2139. if (this.isCheck)
  2140. {
  2141. checkBox3_BeforeCheckedChanged(sender, e);
  2142. triangleTrackBar2.Value = triangleTrackBar2.Maximum;
  2143. lbl_kl_max.Text = triangleTrackBar2.Maximum.ToString();
  2144. }
  2145. #region [设置参数]
  2146. this.selectedImg = this.listView1.FocusedItem.Name;
  2147. if (everyImgData.ContainsKey(this.selectedImg))
  2148. {
  2149. var thisModel = everyImgData[this.selectedImg];
  2150. checkBox3.Checked = thisModel.parameter1;
  2151. if (thisModel.parameter2 <= triangleTrackBar1.Maximum)
  2152. {
  2153. triangleTrackBar1.Value = thisModel.parameter2;
  2154. }
  2155. else
  2156. {
  2157. triangleTrackBar1.Value = 0;
  2158. }
  2159. if (thisModel.parameter3 <= triangleTrackBar2.Maximum)
  2160. {
  2161. triangleTrackBar2.Value = thisModel.parameter3;
  2162. }
  2163. else
  2164. {
  2165. triangleTrackBar2.Value = 0;
  2166. }
  2167. lbl_kl_min.Text = thisModel.parameter2.ToString();
  2168. lbl_kl_max.Text = thisModel.parameter3.ToString();
  2169. numericUpDown1.Value = thisModel.parameter4;
  2170. panel2.BackColor = Color.FromArgb(thisModel.parameter5);
  2171. radioButton1.Checked = thisModel.parameter6 == 1 ? true : false;
  2172. radioButton2.Checked = thisModel.parameter6 == 1 ? false : true;
  2173. rb_1.Checked = thisModel.parameter7 == 1 ? true : false;
  2174. rb_2.Checked = thisModel.parameter7 == 1 ? false : true;
  2175. rb_3.Checked = thisModel.parameter8 == 1 ? true : false;
  2176. rb_4.Checked = thisModel.parameter8 == 1 ? false : true;
  2177. numericUpDown2.Value = thisModel.parameter9;
  2178. panel4.BackColor = Color.FromArgb(thisModel.parameter10);
  2179. numericUpDown3.Value = thisModel.parameter11;
  2180. numericUpDown4.Value = thisModel.parameter12;
  2181. checkBox4.Checked = thisModel.parameter13;
  2182. checkBox5.Checked = thisModel.parameter14;
  2183. checkBox6.Checked = thisModel.parameter15;
  2184. numericUpDown5.Value = thisModel.parameter16;
  2185. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  2186. checkBox1.Checked = thisModel.parameter17;
  2187. }
  2188. #endregion
  2189. if (this.documentWorkspace.phaseModels.Count > 0)
  2190. {
  2191. if (this.documentWorkspace.phaseModels[0].mat != null)
  2192. {
  2193. original = this.documentWorkspace.phaseModels[0].mat.Clone();
  2194. }
  2195. }
  2196. }
  2197. }
  2198. private void button2_Click(object sender, EventArgs e)
  2199. {
  2200. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2201. if (this.appWorkspace.DocumentWorkspaces.Length == 0)
  2202. {
  2203. MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
  2204. return;
  2205. }
  2206. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2207. if (listView1.SelectedItems.Count == 0)
  2208. {
  2209. MessageBox.Show(PdnResources.GetString("Menu.seselecttheimagethatyouwanttoan.Text") + "!");
  2210. return;
  2211. }
  2212. if (lineResults.Count == 0)
  2213. {
  2214. MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
  2215. return;
  2216. }
  2217. String tag = listView1.FocusedItem.Text;
  2218. List<Bitmap> tempBit = new List<Bitmap>();
  2219. double avgDistince = 0f;
  2220. double distinceSum = 0f;
  2221. //计算间距
  2222. int distinceCount = 0;
  2223. int pointCount = 0;
  2224. List<List<string>> dataList = new List<List<string>>();
  2225. List<string> titleList = new List<string>();
  2226. titleList.Add(PdnResources.GetString("Menu.Thetotallength.Text"));
  2227. titleList.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
  2228. titleList.Add(PdnResources.GetString("Menu.Theaveragelengthof.Text"));
  2229. dataList.Add(titleList);
  2230. for (int i = 0; i < lineResults.Count; i++)
  2231. {
  2232. pointCount += lineResults[i].PointIDs.Count;
  2233. System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
  2234. lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
  2235. pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
  2236. for (int j = 0; j < pointArray.Count() - 1; j++)
  2237. {
  2238. double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10);
  2239. distinceSum += distince * pxPerUnit;
  2240. distinceCount++;
  2241. }
  2242. List<string> newList = new List<string>();
  2243. if (distinceSum != 0)
  2244. {
  2245. newList.Add(distinceSum.ToString());
  2246. newList.Add(pointArray.Count().ToString());
  2247. newList.Add(Math.Round(distinceSum / (pointArray.Count() / 2), 2).ToString());
  2248. dataList.Add(newList);
  2249. }
  2250. }
  2251. if (intermediateDataList.ContainsKey(listView1.FocusedItem.Text.ToString()))
  2252. {
  2253. intermediateDataList[listView1.FocusedItem.Text.ToString()] = dataList;
  2254. }
  2255. else
  2256. {
  2257. intermediateDataList.Add(listView1.FocusedItem.Text.ToString(), dataList);
  2258. }
  2259. if (distinceCount > 0)
  2260. {
  2261. avgDistince = distinceSum / distinceCount;
  2262. }
  2263. //计算方差
  2264. double dfSum = 0f;
  2265. double fc = 0f;
  2266. int fcCount = 0;
  2267. for (int i = 0; i < lineResults.Count; i++)
  2268. {
  2269. System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
  2270. lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
  2271. pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
  2272. for (int j = 0; j < pointArray.Count() - 1; j++)
  2273. {
  2274. double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10) * pxPerUnit;
  2275. double df = Math.Pow((distince - avgDistince), 2);
  2276. dfSum += df;
  2277. fcCount++;
  2278. }
  2279. }
  2280. if (fcCount > 0)
  2281. {
  2282. fc = dfSum / fcCount;
  2283. }
  2284. PolyphaseDistanceResult result = new PolyphaseDistanceResult(listView1.FocusedItem.Text.ToString(), avgDistince, fc, pointCount);
  2285. if (listView1.SelectedItems.Count > 0)
  2286. {
  2287. List<PolyphaseDistanceResult> editResults = allResults.FindAll(item => item.GraphName.Equals(listView1.FocusedItem.Text));
  2288. if (editResults.Count == 0)
  2289. {
  2290. listBox_analysisResult.Items.Add(this.listView1.FocusedItem.Text);
  2291. allResults.Add(result);
  2292. listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
  2293. dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
  2294. }
  2295. else
  2296. {
  2297. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  2298. if (dr != DialogResult.OK)
  2299. {
  2300. return;
  2301. }
  2302. int index = allResults.FindIndex(item => item.GraphName.Equals(listView1.FocusedItem.Text));
  2303. allResults[index] = result;
  2304. List<string> list = new List<string>();
  2305. foreach (var s in this.listBox_analysisResult.Items)
  2306. {
  2307. list.Add(s.ToString());
  2308. }
  2309. this.listBox_analysisResult.Items.Clear();
  2310. foreach (var s in list)
  2311. {
  2312. this.listBox_analysisResult.Items.Add(s);
  2313. }
  2314. var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
  2315. this.dataGridView_results.Rows.Clear();
  2316. listBox_analysisResult.SetItemChecked(thisindex, true);
  2317. dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
  2318. }
  2319. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  2320. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  2321. originalBit.Tag = pantographRatio;
  2322. tempBit.Add(originalBit);
  2323. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2324. newBit.Tag = pantographRatio;
  2325. Graphics graphics = Graphics.FromImage(newBit);
  2326. Draw(graphics);
  2327. tempBit.Add(newBit);
  2328. if (bitDic.ContainsKey(tag))
  2329. {
  2330. bitDic[tag].Clear();
  2331. bitDic[tag] = tempBit;
  2332. }
  2333. else
  2334. {
  2335. bitDic.Add(tag, tempBit);
  2336. }
  2337. }
  2338. else
  2339. {
  2340. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  2341. }
  2342. }
  2343. private void Draw(Graphics graphics)
  2344. {
  2345. if (this.documentWorkspace.phaseModels.Count > 0)
  2346. {
  2347. foreach (PhaseModel model in this.documentWorkspace.phaseModels)
  2348. {
  2349. if (model.choise && model.mat != null)
  2350. {
  2351. Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
  2352. graphics.DrawImage(map, 0, 0, map.Width, map.Height);
  2353. }
  2354. }
  2355. if (drawObjects != null)
  2356. {
  2357. foreach (DrawObject drobj in drawObjects)
  2358. {
  2359. drobj.Draw(graphics);
  2360. }
  2361. }
  2362. }
  2363. }
  2364. private void button8_Click(object sender, EventArgs e)
  2365. {
  2366. drawaction = 1;
  2367. }
  2368. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  2369. {
  2370. UpdateStyle();
  2371. }
  2372. private void rb_1_CheckedChanged(object sender, EventArgs e)
  2373. {
  2374. if (rb_1.Checked)
  2375. {
  2376. UpdateStyle();
  2377. }
  2378. }
  2379. private void rb_2_CheckedChanged(object sender, EventArgs e)
  2380. {
  2381. if (rb_2.Checked)
  2382. {
  2383. UpdateStyle();
  2384. }
  2385. }
  2386. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  2387. {
  2388. UpdateStyle();
  2389. }
  2390. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  2391. {
  2392. UpdateStyle();
  2393. }
  2394. private void rb_3_CheckedChanged(object sender, EventArgs e)
  2395. {
  2396. if (rb_3.Checked)
  2397. {
  2398. UpdateStyle();
  2399. }
  2400. }
  2401. private void rb_4_CheckedChanged(object sender, EventArgs e)
  2402. {
  2403. if (rb_4.Checked)
  2404. {
  2405. UpdateStyle();
  2406. }
  2407. }
  2408. private void panel2_Click(object sender, EventArgs e)
  2409. {
  2410. this.lineColorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  2411. this.lineColorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
  2412. this.lineColorsFormGrid.ShowDialog();
  2413. }
  2414. private void lineColorChanged(object sender, EventArgs e)
  2415. {
  2416. Color color = this.lineColorsFormGrid.UserPrimaryColor.ToColor();
  2417. //更改背景色,触发事件
  2418. this.panel2.BackColor = color;
  2419. //改变配置文件里面的相颜色
  2420. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2421. //关闭色板
  2422. UpdateStyle();
  2423. this.lineColorsFormGrid.Close();
  2424. }
  2425. private void panel4_Click(object sender, EventArgs e)
  2426. {
  2427. this.PointcolorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
  2428. this.PointcolorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.PointColorChanged));
  2429. this.PointcolorsFormGrid.ShowDialog();
  2430. }
  2431. private void PointColorChanged(object sender, EventArgs e)
  2432. {
  2433. Color color = this.PointcolorsFormGrid.UserPrimaryColor.ToColor();
  2434. //更改背景色,触发事件
  2435. this.panel4.BackColor = color;
  2436. //改变配置文件里面的相颜色
  2437. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2438. //关闭色板
  2439. UpdateStyle();
  2440. this.PointcolorsFormGrid.Close();
  2441. }
  2442. private void checkBox6_CheckedChanged(object sender, EventArgs e)
  2443. {
  2444. if (checkBox6.Checked)
  2445. {
  2446. pointStyleModel.fillColor = panel4.BackColor.ToArgb();
  2447. pointStyleModel.lineColor = panel4.BackColor.ToArgb();
  2448. }
  2449. else
  2450. {
  2451. pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2452. pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2453. }
  2454. documentWorkspace.Refresh();
  2455. }
  2456. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  2457. {
  2458. if (checkBox5.Checked)
  2459. {
  2460. lineStyleModel.lineColor = panel2.BackColor.ToArgb();
  2461. }
  2462. else
  2463. {
  2464. lineStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
  2465. }
  2466. documentWorkspace.Refresh();
  2467. }
  2468. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  2469. {
  2470. if (checkBox4.Checked)
  2471. {
  2472. if (documentWorkspace.phaseModels.Count > 0)
  2473. {
  2474. documentWorkspace.phaseModels[0].choise = true;
  2475. }
  2476. }
  2477. else
  2478. {
  2479. if (documentWorkspace.phaseModels.Count > 0)
  2480. {
  2481. documentWorkspace.phaseModels[0].choise = false;
  2482. }
  2483. }
  2484. documentWorkspace.Refresh();
  2485. }
  2486. private void tb_2_Load(object sender, EventArgs e)
  2487. {
  2488. }
  2489. private void triangleTrackBar2_TrackBarScroll(object sender, EventArgs e)
  2490. {
  2491. //Mat mat = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
  2492. if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  2493. {
  2494. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
  2495. return;
  2496. }
  2497. this.documentWorkspace.phaseModels[0].mat = original.Clone();
  2498. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat.Clone());
  2499. lbl_kl_max.Text = triangleTrackBar2.Value.ToString();
  2500. redrawForTolerance();
  2501. this.documentWorkspace.Refresh();
  2502. }
  2503. private void triangleTrackBar1_TrackBarScroll(object sender, EventArgs e)
  2504. {
  2505. if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
  2506. {
  2507. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
  2508. return;
  2509. }
  2510. this.documentWorkspace.phaseModels[0].mat = original.Clone();
  2511. GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
  2512. lbl_kl_min.Text = triangleTrackBar1.Value.ToString();
  2513. redrawForTolerance();
  2514. this.documentWorkspace.Refresh();
  2515. }
  2516. private decimal getMaxArea(Mat pMat)
  2517. {
  2518. if (pMat == null)
  2519. {
  2520. return 10000;
  2521. }
  2522. double maxArea = 0;
  2523. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2524. HierarchyIndex[] hierarchy;
  2525. OpenCvSharp.Point[][] contours;
  2526. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2527. for (int i = 0; i < contours.Count(); i++)
  2528. {
  2529. double area = Cv2.ContourArea(contours[i]);
  2530. if (area > maxArea)
  2531. {
  2532. maxArea = area;
  2533. }
  2534. }
  2535. return (decimal)maxArea;
  2536. }
  2537. private void checkBox3_BeforeCheckedChanged(object sender, EventArgs e)
  2538. {
  2539. if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
  2540. {
  2541. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
  2542. this.checkBox3.Checked = false;
  2543. return;
  2544. }
  2545. checkBox3_CheckedChanged(sender, e);
  2546. }
  2547. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  2548. {
  2549. if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
  2550. {
  2551. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
  2552. return;
  2553. }
  2554. this.isCheck = checkBox3.Checked;
  2555. if (checkBox3.Checked)
  2556. {
  2557. if (this.documentWorkspace.phaseModels.Count > 0 && bcBinaryChecked())
  2558. {
  2559. //double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2560. //maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
  2561. //triangleTrackBar1.Maximum = (int)maxArea;
  2562. //triangleTrackBar2.Maximum = (int)maxArea;
  2563. }
  2564. else
  2565. {
  2566. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
  2567. return;
  2568. }
  2569. }
  2570. else
  2571. {
  2572. triangleTrackBar1.Value = 0;
  2573. triangleTrackBar2.Value = 0;
  2574. lbl_kl_max.Text = "0";
  2575. lbl_kl_min.Text = "0";
  2576. //binaryClass.applyButtonImpl();
  2577. this.documentWorkspace.Refresh();
  2578. }
  2579. }
  2580. private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
  2581. {
  2582. if (!checkBox3.Checked)
  2583. {
  2584. return;
  2585. }
  2586. List<OpenCvSharp.Point[]> selectContours = new List<OpenCvSharp.Point[]>();
  2587. List<OpenCvSharp.Point[]> unSelectContours = new List<OpenCvSharp.Point[]>();
  2588. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2589. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2590. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2591. HierarchyIndex[] hierarchy;
  2592. OpenCvSharp.Point[][] contours;
  2593. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2594. for (int i = 0; i < contours.Length; i++)
  2595. {
  2596. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)) - contours[i].Length / 2.0) * pxPerUnit * pxPerUnit;
  2597. if (area < 0)
  2598. {
  2599. area = 0;
  2600. }
  2601. if (area >= (double)areaMin && area <= (double)areaMax)
  2602. {
  2603. selectContours.Add(contours[i]);
  2604. }
  2605. else
  2606. {
  2607. unSelectContours.Add(contours[i]);
  2608. }
  2609. }
  2610. Cv2.DrawContours(documentWorkspace.phaseModels[0].mat, selectContours, -1, new Scalar(this.documentWorkspace.phaseModels[0].color), Cv2.FILLED);
  2611. documentWorkspace.Refresh();
  2612. }
  2613. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2614. {
  2615. m_tolerance = (int)numericUpDown4.Value;
  2616. redrawForTolerance();
  2617. this.documentWorkspace.Refresh();
  2618. }
  2619. private void redrawForTolerance()
  2620. {
  2621. if (drawaction == 0)
  2622. {
  2623. List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
  2624. foreach (DrawObject lineObj in lines)
  2625. {
  2626. PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
  2627. if (lineResult != null)
  2628. {
  2629. //删除原有点
  2630. foreach (int pointid in lineResult.PointIDs.Keys)
  2631. {
  2632. DrawObject dr = drawObjects.Find(u => u.ID == pointid);
  2633. if (dr != null)
  2634. {
  2635. this.drawObjects.Remove(dr);
  2636. }
  2637. }
  2638. lineResult.PointIDs.Clear();
  2639. //画新点
  2640. if (lineObj != null && lineObj.GetPoints().Count > 1)
  2641. {
  2642. PointF a = lineObj.GetPoints()[0];
  2643. PointF b = lineObj.GetPoints()[1];
  2644. List<System.Drawing.Point> points = new List<System.Drawing.Point>();
  2645. Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
  2646. if (mat.Channels() <= 3)
  2647. {
  2648. mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
  2649. }
  2650. Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
  2651. int linkCount = 0;
  2652. lineResult.LineID = lineObj.ID;
  2653. List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
  2654. for (int i = 0; i < linePoints.Count; i++)
  2655. {
  2656. System.Drawing.Point ploc = linePoints[i];
  2657. if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
  2658. {
  2659. Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
  2660. if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
  2661. {
  2662. linkCount++;
  2663. if (linkCount == 1)
  2664. {
  2665. points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
  2666. if (pointStyleModel.DrawType == 0)
  2667. {
  2668. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2669. circleA.ISurfaceBox = documentWorkspace;
  2670. lineResult.PointIDs.Add(circleA.ID, ploc);
  2671. this.drawObjects.Add(circleA);
  2672. }
  2673. else
  2674. {
  2675. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2676. squareA.ISurfaceBox = documentWorkspace;
  2677. lineResult.PointIDs.Add(squareA.ID, ploc);
  2678. this.drawObjects.Add(squareA);
  2679. }
  2680. }
  2681. else if ((linkCount % m_tolerance) == 0)
  2682. {
  2683. if (pointStyleModel.DrawType == 0)
  2684. {
  2685. DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2686. circleA.ISurfaceBox = documentWorkspace;
  2687. lineResult.PointIDs.Add(circleA.ID, ploc);
  2688. this.drawObjects.Add(circleA);
  2689. }
  2690. else
  2691. {
  2692. DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
  2693. squareA.ISurfaceBox = documentWorkspace;
  2694. lineResult.PointIDs.Add(squareA.ID, ploc);
  2695. this.drawObjects.Add(squareA);
  2696. }
  2697. }
  2698. }
  2699. else
  2700. {
  2701. linkCount = 0;
  2702. }
  2703. }
  2704. }//end for
  2705. }//end if
  2706. }//end if
  2707. }// end foreach
  2708. }//end for if
  2709. }
  2710. private void button_all_Click(object sender, EventArgs e)
  2711. {
  2712. dataGridView_results.Rows.Clear();
  2713. if (this.is_all % 2 == 0)
  2714. {
  2715. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  2716. {
  2717. listBox_analysisResult.SetItemChecked(i, false);
  2718. }
  2719. }
  2720. else
  2721. {
  2722. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  2723. {
  2724. listBox_analysisResult.SetItemChecked(i, true);
  2725. }
  2726. for (int i = 0; i < allResults.Count; i++)
  2727. {
  2728. PolyphaseDistanceResult editResult = allResults[i];
  2729. dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count);
  2730. }
  2731. }
  2732. this.is_all += 1;
  2733. }
  2734. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  2735. {
  2736. dataGridView_results.Rows.Clear();
  2737. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  2738. {
  2739. foreach (var s in listBox_analysisResult.CheckedItems)
  2740. {
  2741. List<PolyphaseDistanceResult> editResults = allResults.FindAll(u => u.GraphName == s.ToString());
  2742. for (int i = 0; i < editResults.Count; i++)
  2743. {
  2744. PolyphaseDistanceResult editResult = editResults[i];
  2745. dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count, AnalysisTools.GetDecNum(editResult.medianAvr, decnum));
  2746. }
  2747. }
  2748. }
  2749. }
  2750. private void button_remove_Click(object sender, EventArgs e)
  2751. {
  2752. var removeList = new List<string>();
  2753. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  2754. {
  2755. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  2756. if (dr == DialogResult.OK)
  2757. {
  2758. foreach (var s in listBox_analysisResult.CheckedItems)
  2759. {
  2760. for (int i = 0; i < dataGridView_results.Rows.Count; i++)
  2761. {
  2762. if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
  2763. {
  2764. dataGridView_results.Rows.RemoveAt(i);
  2765. }
  2766. }
  2767. allResults.RemoveAll(u => u.GraphName == s.ToString());
  2768. removeList.Add(s.ToString());
  2769. }
  2770. foreach (var m in removeList)
  2771. {
  2772. listBox_analysisResult.Items.Remove(m);
  2773. }
  2774. }
  2775. }
  2776. else
  2777. {
  2778. MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!");
  2779. }
  2780. }
  2781. private void numericUpDown5_ValueChanged(object sender, EventArgs e)
  2782. {
  2783. decnum = (int)numericUpDown5.Value;
  2784. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2785. {
  2786. PolyphaseDistanceResult result = allResults.Find(u => u.GraphName == dataGridView_results.Rows[i].Cells[0].Value);
  2787. if (result != null)
  2788. {
  2789. dataGridView_results.Rows[i].Cells[1].Value = AnalysisTools.GetDecNum(result.AvgDistince, decnum);
  2790. dataGridView_results.Rows[i].Cells[2].Value = AnalysisTools.GetDecNum(result.Fc, decnum);
  2791. }
  2792. }
  2793. }
  2794. private void button5_Click(object sender, EventArgs e)
  2795. {
  2796. this.Close();
  2797. }
  2798. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  2799. {
  2800. if (radioButton1.Checked)
  2801. {
  2802. drawaction = 0;
  2803. }
  2804. }
  2805. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  2806. {
  2807. if (radioButton2.Checked)
  2808. {
  2809. drawaction = 1;
  2810. }
  2811. }
  2812. private void tb_1_Load(object sender, EventArgs e)
  2813. {
  2814. }
  2815. private void label3_Click(object sender, EventArgs e)
  2816. {
  2817. }
  2818. private void button4_Click(object sender, EventArgs e)
  2819. {
  2820. if (this.dataGridView_results.Rows.Count > 0)
  2821. {
  2822. SaveFileDialog exe = new SaveFileDialog();
  2823. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  2824. exe.FilterIndex = 0;
  2825. exe.RestoreDirectory = true;
  2826. exe.Title = "Export Excel File";
  2827. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  2828. exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text") + PdnResources.GetString("Menu.Analysisresult.text");
  2829. DialogResult dr = exe.ShowDialog();
  2830. if (dr == DialogResult.OK)
  2831. {
  2832. DataTable dtb = new DataTable();
  2833. foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
  2834. {
  2835. dtb.Columns.Add(c.HeaderText);
  2836. }
  2837. for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
  2838. {
  2839. DataRow dataRow = dtb.NewRow();
  2840. for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
  2841. {
  2842. dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
  2843. }
  2844. dtb.Rows.Add(dataRow);
  2845. }
  2846. List<DataTable> list = new List<DataTable>();
  2847. list.Add(dtb);
  2848. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  2849. }
  2850. }
  2851. else
  2852. {
  2853. MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
  2854. }
  2855. }
  2856. private void button1_Click(object sender, EventArgs e)
  2857. {
  2858. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
  2859. if (recombinationRateSetDialog.hasModule)
  2860. {
  2861. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  2862. recombinationRateSetDialog.ShowDialog();
  2863. }
  2864. else
  2865. {
  2866. recombinationRateSetDialog = null;
  2867. }
  2868. }
  2869. private void button3_Click(object sender, EventArgs e)
  2870. {
  2871. if (checkBox1.Checked)
  2872. {
  2873. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
  2874. if (recombinationRateSetDialog.hasModule)
  2875. {
  2876. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  2877. recombinationRateSetDialog.ShowDialog();
  2878. }
  2879. else
  2880. {
  2881. recombinationRateSetDialog = null;
  2882. }
  2883. }
  2884. bitList.Clear();
  2885. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2886. {
  2887. //获取word书签与excel单元格的关系,以字典方式存储
  2888. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2889. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2890. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2891. {
  2892. foreach (mic_module_infos info in mic_module_infos)
  2893. {
  2894. tagInfos.Add(info.tag_name, info.cell_position);
  2895. }
  2896. }
  2897. List<List<string>> analysisContent = new List<List<string>>();
  2898. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2899. {
  2900. List<string> content1 = new List<string>();
  2901. if (i == 0)
  2902. {
  2903. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  2904. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  2905. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  2906. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  2907. analysisContent.Add(content1);
  2908. }
  2909. content1 = new List<string>();
  2910. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  2911. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  2912. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  2913. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  2914. analysisContent.Add(content1);
  2915. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  2916. if (bitDic.ContainsKey(tag))
  2917. {
  2918. bitList.Add(bitDic[tag][0]);
  2919. bitList.Add(bitDic[tag][1]);
  2920. }
  2921. }
  2922. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  2923. }
  2924. else
  2925. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2926. }
  2927. private void button9_Click(object sender, EventArgs e)
  2928. {
  2929. if (this.dataGridView_results.Rows.Count == 0)
  2930. {
  2931. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  2932. return;
  2933. }
  2934. if (this.analyzeSettingModel == null)
  2935. {
  2936. MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  2937. return;
  2938. }
  2939. //获取项目工程内的文件夹路径
  2940. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.PhaseSpacing.Text", this.analyzeSettingModel.savePath);
  2941. if (item != null)
  2942. {
  2943. //向文件夹内保存图片和报告
  2944. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2945. {
  2946. //获取word书签与excel单元格的关系,以字典方式存储
  2947. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2948. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2949. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2950. {
  2951. foreach (mic_module_infos info in mic_module_infos)
  2952. {
  2953. tagInfos.Add(info.tag_name, info.cell_position);
  2954. }
  2955. }
  2956. List<List<string>> analysisContent = new List<List<string>>();
  2957. List<List<string>> inclusionList = new List<List<string>>();
  2958. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2959. List<Bitmap> bitImgList = new List<Bitmap>();
  2960. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  2961. {
  2962. List<string> content1 = new List<string>();
  2963. if (i == 0)
  2964. {
  2965. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  2966. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  2967. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  2968. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  2969. analysisContent.Add(content1);
  2970. }
  2971. content1 = new List<string>();
  2972. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  2973. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  2974. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  2975. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  2976. analysisContent.Add(content1);
  2977. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  2978. if (intermediateDataList.ContainsKey(tag))
  2979. {
  2980. ExportProjectModel exportProjectModel = new ExportProjectModel();
  2981. exportProjectModel.dataList = intermediateDataList[tag];
  2982. exportProjectModel.picName = tag;
  2983. exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
  2984. exportModel.Add(exportProjectModel);
  2985. }
  2986. if (bitDic.ContainsKey(tag))
  2987. {
  2988. bitImgList.Add(bitDic[tag][0]);
  2989. bitImgList.Add(bitDic[tag][1]);
  2990. }
  2991. }
  2992. try
  2993. {
  2994. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
  2995. }
  2996. catch (Exception ex)
  2997. {
  2998. MessageBox.Show(ex.Message);
  2999. }
  3000. }
  3001. else
  3002. {
  3003. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3004. return;
  3005. }
  3006. //保存项目信息到数据库
  3007. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  3008. }
  3009. }
  3010. private void PolyphaseDistanceDialog_Resize(object sender, EventArgs e)
  3011. {
  3012. if (dataGridView_results != null)
  3013. {
  3014. AutoSizeColumn(dataGridView_results, 10);
  3015. }
  3016. }
  3017. private void getValue(string key, Object value)
  3018. {
  3019. switch (key)
  3020. {
  3021. case "parameter11":
  3022. numericUpDown1.Value = Convert.ToDecimal(value);
  3023. break;
  3024. case "parameter12":
  3025. panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3026. break;
  3027. case "parameter13":
  3028. radioButton1.Checked = (int)value == 1 ? true : false;
  3029. radioButton2.Checked = (int)value == 1 ? false : true;
  3030. break;
  3031. case "parameter14":
  3032. rb_1.Checked = (int)value == 1 ? true : false;
  3033. rb_2.Checked = (int)value == 1 ? false : true;
  3034. break;
  3035. case "parameter15":
  3036. rb_3.Checked = (int)value == 1 ? true : false;
  3037. rb_4.Checked = (int)value == 1 ? false : true;
  3038. break;
  3039. case "parameter16":
  3040. numericUpDown2.Value = Convert.ToDecimal(value);
  3041. break;
  3042. case "parameter17":
  3043. numericUpDown3.Value = Convert.ToDecimal(value);
  3044. break;
  3045. case "parameter18":
  3046. numericUpDown4.Value = Convert.ToDecimal(value);
  3047. break;
  3048. case "parameter19":
  3049. checkBox4.Checked = Convert.ToBoolean(value);
  3050. break;
  3051. case "parameter20":
  3052. checkBox5.Checked = Convert.ToBoolean(value);
  3053. break;
  3054. case "parameter21":
  3055. checkBox6.Checked = Convert.ToBoolean(value);
  3056. break;
  3057. case "parameter22":
  3058. panel4.BackColor = Color.FromArgb(Convert.ToInt32(value));
  3059. break;
  3060. case "OpenWhileExportReport":
  3061. checkBox1.Checked = Convert.ToBoolean(value);
  3062. break;
  3063. case "CalculatorDecimalDigits":
  3064. numericUpDown5.Value = Convert.ToDecimal(value);
  3065. break;
  3066. }
  3067. }
  3068. #region [脚本录制]
  3069. private void getScriptRecording()
  3070. {
  3071. string className = InvariantData.path_Action + ".Action" + menuId;
  3072. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3073. List<Args> args = param.Lists;
  3074. foreach (var item in args)
  3075. {
  3076. item.value = setScriptRecording(item.key);
  3077. }
  3078. //找出二值相关参数 进行赋值
  3079. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  3080. foreach (var item in isNullList)
  3081. {
  3082. item.value = binaryClass.setScriptRecording(item.key);
  3083. }
  3084. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3085. }
  3086. private object setScriptRecording(string key)
  3087. {
  3088. object value = null;
  3089. switch (key)
  3090. {
  3091. case "parameter11":
  3092. value = numericUpDown1.Value;
  3093. break;
  3094. case "parameter12":
  3095. value = panel2.BackColor.ToArgb();
  3096. break;
  3097. case "parameter13":
  3098. value = radioButton1.Checked ? 1 : 2;
  3099. break;
  3100. case "parameter14":
  3101. value = rb_1.Checked ? 1 : 2;
  3102. break;
  3103. case "parameter15":
  3104. value = rb_3.Checked ? 1 : 2;
  3105. break;
  3106. case "parameter16":
  3107. value = numericUpDown2.Value;
  3108. break;
  3109. case "parameter17":
  3110. value = numericUpDown3.Value;
  3111. break;
  3112. case "parameter18":
  3113. value = numericUpDown4.Value;
  3114. break;
  3115. case "parameter19":
  3116. value = checkBox4.Checked;
  3117. break;
  3118. case "parameter20":
  3119. value = checkBox5.Checked;
  3120. break;
  3121. case "parameter21":
  3122. value = checkBox6.Checked;
  3123. break;
  3124. case "parameter22":
  3125. value = panel4.BackColor.ToArgb();
  3126. break;
  3127. case "OpenWhileExportReport":
  3128. value = checkBox1.Checked;
  3129. break;
  3130. case "CalculatorDecimalDigits":
  3131. value = numericUpDown5.Value;
  3132. break;
  3133. case "ExportResults":
  3134. value = false;
  3135. break;
  3136. case "ExportReports":
  3137. value = false;
  3138. break;
  3139. case "ExportProjects":
  3140. value = false;
  3141. break;
  3142. }
  3143. return value;
  3144. }
  3145. #endregion
  3146. }
  3147. }