TwoPhaseScaleDialog.cs 172 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.Functionodel;
  3. using PaintDotNet.CustomControl;
  4. using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Windows.Forms;
  12. using PaintDotNet.DbOpreate.DbBll;
  13. using PaintDotNet.DbOpreate.DbModel;
  14. using Point = OpenCvSharp.Point;
  15. using PaintDotNet.Base.CommTool;
  16. using PaintDotNet.Instrument;
  17. using PaintDotNet.Annotation.Enum;
  18. using Metis.ParameterSet;
  19. using System.IO;
  20. using PaintDotNet.Data.Param;
  21. using PaintDotNet.Base;
  22. namespace PaintDotNet.GeneralAnalysis
  23. {
  24. /// <summary>
  25. /// 两相比例
  26. /// </summary>
  27. internal class TwoPhaseScaleDialog : PdnBaseForm
  28. {
  29. #region 控件
  30. private System.Windows.Forms.GroupBox groupBox4;
  31. private System.Windows.Forms.ListView listView1;
  32. private System.Windows.Forms.GroupBox groupBox1;
  33. private System.Windows.Forms.Button button2;
  34. private System.Windows.Forms.CheckBox checkBox1;
  35. private System.Windows.Forms.Button button1;
  36. private System.Windows.Forms.GroupBox groupBox_review;
  37. private System.Windows.Forms.GroupBox groupBox5;
  38. private System.Windows.Forms.GroupBox groupBox6;
  39. private System.Windows.Forms.GroupBox groupBox7;
  40. private System.Windows.Forms.Label label1;
  41. private System.Windows.Forms.Button button4;
  42. private System.Windows.Forms.Button button3;
  43. private System.Windows.Forms.ImageList imageList1;
  44. private DataGridView dataGridView_results;
  45. private Button button_remove;
  46. private Button button_all;
  47. private Button button5;
  48. private GroupBox groupBox8;
  49. private Label label6;
  50. private Label label5;
  51. private Label label7;
  52. private Label label8;
  53. private TextBox txt_UnSelectArea;
  54. private TextBox txt_UnSelectCount;
  55. private TextBox txt_SelectCountPersent;
  56. private TextBox txt_SelectArea;
  57. private TextBox txt_SelectCount;
  58. private Label label9;
  59. private TextBox txt_UnSelectCountPersent;
  60. private Label label10;
  61. private IContainer components;
  62. private Label label13;
  63. private TextBox txt_UnSelectContent;
  64. private TextBox txt_SelectContent;
  65. private Label label12;
  66. private Label label11;
  67. private Label label14;
  68. private TextBox txt_UnSelectCountFromAll;
  69. private TextBox txt_SelectContentFromAll;
  70. private Label label15;
  71. private Label label16;
  72. private TextBox txt_UnSelectDivSelectCount;
  73. private TextBox txt_SelectCountDivUnSelect;
  74. private ColorsForm oneColorsForm;
  75. private ColorsForm twoColorsForm;
  76. private NumericUpDown numericUpDown3;
  77. #endregion
  78. private CommonControlButtons commonControlButtons;
  79. /// <summary>
  80. /// 主空间
  81. /// </summary>
  82. private AppWorkspace appWorkspace;
  83. /// <summary>
  84. /// 选中图片的mat
  85. /// </summary>
  86. private Mat imageMat;
  87. /// <summary>
  88. /// 选择物相index
  89. /// </summary>
  90. int selectIndex = 0;
  91. /// <summary>
  92. /// 当前选择的图片index
  93. /// </summary>
  94. int selectImageIndex = 0;
  95. int decnum = 2;
  96. /// <summary>
  97. /// 分析类型 0 面积 1 面积比 2 长宽比 4 最大卡规直径
  98. /// </summary>
  99. int workType = 0;
  100. TwoPhaseScaleResult selectResults = new TwoPhaseScaleResult();
  101. TwoPhaseScaleResult unSelectResults = new TwoPhaseScaleResult();
  102. PhaseModel onePhase = new PhaseModel();
  103. private DocumentWorkspaceWindow documentWorkspace;
  104. private List<TwoPhaseScaleExportResult> finalResults = new List<TwoPhaseScaleExportResult>();
  105. private List<Bitmap> bitList = new List<Bitmap>();
  106. private Button button9;
  107. private CheckedListBox listBox_analysisResult;
  108. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  109. private Label label2;
  110. private Label label3;
  111. private Label label4;
  112. private NumericUpDown numericUpDown1;
  113. private NumericUpDown numericUpDown2;
  114. private ComboBox comboBox1;
  115. private Label label17;
  116. private Label label18;
  117. private TriangleTrackBar trackBar2;
  118. private TriangleTrackBar trackBar1;
  119. private Label label19;
  120. private Label label20;
  121. private Panel panel1;
  122. private Panel panel2;
  123. private GroupBox groupBox2;
  124. private Label label21;
  125. private int is_all = 0;
  126. private int menuId;
  127. private string menuName;
  128. /// <summary>
  129. /// 是否脚本运行
  130. /// </summary>
  131. private Boolean initScriptValues = false;
  132. private List<Point[]> points = new List<Point[]>();
  133. /// <summary>
  134. /// 当前选择的搜索选项
  135. /// </summary>
  136. int selectSearchIndex = 0;
  137. private DataGridViewTextBoxColumn Column12;
  138. private DataGridViewTextBoxColumn Column1;
  139. private DataGridViewTextBoxColumn Column2;
  140. private DataGridViewTextBoxColumn Column3;
  141. private DataGridViewTextBoxColumn Column4;
  142. private DataGridViewTextBoxColumn Column5;
  143. private DataGridViewTextBoxColumn Column6;
  144. private DataGridViewTextBoxColumn Column7;
  145. private DataGridViewTextBoxColumn Column8;
  146. private DataGridViewTextBoxColumn Column9;
  147. private DataGridViewTextBoxColumn Column10;
  148. private DataGridViewTextBoxColumn Column11;
  149. private DataGridViewTextBoxColumn Column13;
  150. private int imgIndex = -1;
  151. private ComboBox comboBox2;
  152. private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
  153. private string selectedImg = string.Empty;
  154. private Dictionary<string, GeneralAnalysisModel.TwoPhaseScaleModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.TwoPhaseScaleModel>();
  155. public TwoPhaseScaleDialog()
  156. {
  157. InitializeComponent();
  158. }
  159. private void showImg(object sender, EventArgs e)
  160. {
  161. listView1.Focus();
  162. //滚动到指定的行位置
  163. if (this.imgIndex != -1)
  164. {
  165. this.listView1.EnsureVisible(this.imgIndex);
  166. this.listView1.Items[imgIndex].Focused = true;
  167. this.listView1.Items[imgIndex].Selected = true;
  168. //如果是脚本执行,将参数带入
  169. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  170. {
  171. this.initScriptValues = true;//ScriptAutomatic
  172. //Boolean initScriptValues = true;
  173. ////在这里反射出对应功能的参数类
  174. string className = InvariantData.path_Action + ".Action" + menuId;
  175. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  176. foreach (Args arg in param.Lists)
  177. {
  178. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  179. if (param1.value != null)
  180. arg.Value = param1.value;
  181. getValue(arg.key, arg.Value);
  182. }
  183. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  184. }
  185. else
  186. {//读取上次关闭窗口时保存的参数
  187. getLastData();
  188. }
  189. }
  190. }
  191. /// <summary>
  192. /// 获取上次操作参数
  193. /// </summary>
  194. private void getLastData()
  195. {
  196. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  197. if (!System.IO.File.Exists(filePath))
  198. {
  199. generalAnalysisModel = new GeneralAnalysisModel();
  200. generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
  201. generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
  202. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  203. generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
  204. generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
  205. generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
  206. generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
  207. generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
  208. generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
  209. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
  210. generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
  211. generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
  212. generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
  213. generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
  214. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  215. Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
  216. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
  217. }
  218. else
  219. {
  220. generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
  221. if (generalAnalysisModel.TwoPhaseScaleModels == null) {
  222. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  223. }
  224. if (generalAnalysisModel.TwoPhaseScaleModels.hasUsed)
  225. {
  226. if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
  227. {
  228. if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter1))
  229. {
  230. comboBox1.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter1;
  231. }
  232. if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter2))
  233. {
  234. comboBox2.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter2;
  235. }
  236. if (numericUpDown1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || numericUpDown1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3)
  237. {
  238. numericUpDown1.Value = 0;
  239. }
  240. else {
  241. numericUpDown1.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter3;
  242. }
  243. if (numericUpDown2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || numericUpDown2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4)
  244. {
  245. numericUpDown2.Value = 0;
  246. }
  247. else
  248. {
  249. numericUpDown2.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter4;
  250. }
  251. if (trackBar1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || trackBar1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3)
  252. {
  253. trackBar1.Value = 0;
  254. }
  255. else
  256. {
  257. trackBar1.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter3;
  258. }
  259. if (trackBar2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || trackBar2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4)
  260. {
  261. trackBar2.Value = 0;
  262. }
  263. else
  264. {
  265. trackBar2.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter4;
  266. }
  267. panel1.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter5 == 0 ? Color.Red: Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter5);
  268. panel2.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter6 == 0 ? Color.Yellow:Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter6);
  269. }
  270. numericUpDown3.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter7;
  271. checkBox1.Checked = generalAnalysisModel.TwoPhaseScaleModels.parameter8;
  272. if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1)
  273. {
  274. GetAreaBetweenMinToMax(generalAnalysisModel.TwoPhaseScaleModels.parameter3, generalAnalysisModel.TwoPhaseScaleModels.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat);
  275. }
  276. for (int i = 0; i < listView1.Items.Count; i++)
  277. {
  278. if (everyImgData.ContainsKey(listView1.Items[i].Name))
  279. {
  280. everyImgData[listView1.Items[i].Name] = generalAnalysisModel.TwoPhaseScaleModels;
  281. }
  282. else
  283. {
  284. everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.TwoPhaseScaleModels);
  285. }
  286. }
  287. }
  288. }
  289. }
  290. /// <summary>
  291. /// 保存上次操作参数
  292. /// </summary>
  293. private void saveLastData(object sender, EventArgs e)
  294. {
  295. #region [开启脚本录制]
  296. if (appWorkspace.startScriptRecording)
  297. {
  298. getScriptRecording();
  299. }
  300. #endregion
  301. if (generalAnalysisModel.TwoPhaseScaleModels == null)
  302. {
  303. generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
  304. }
  305. generalAnalysisModel.TwoPhaseScaleModels.hasUsed = true;
  306. if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
  307. {
  308. if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
  309. {
  310. if (comboBox1.SelectedIndex != -1)
  311. {
  312. generalAnalysisModel.TwoPhaseScaleModels.parameter1 = comboBox1.SelectedItem.ToString();
  313. }
  314. if (comboBox2.SelectedIndex != -1)
  315. {
  316. generalAnalysisModel.TwoPhaseScaleModels.parameter2 = comboBox2.SelectedItem.ToString();
  317. }
  318. }
  319. generalAnalysisModel.TwoPhaseScaleModels.parameter3 = numericUpDown1.Value;
  320. generalAnalysisModel.TwoPhaseScaleModels.parameter4 = numericUpDown2.Value;
  321. generalAnalysisModel.TwoPhaseScaleModels.parameter5 = panel1.BackColor.ToArgb();
  322. generalAnalysisModel.TwoPhaseScaleModels.parameter6 = panel2.BackColor.ToArgb();
  323. }
  324. generalAnalysisModel.TwoPhaseScaleModels.parameter7 = (int)numericUpDown3.Value;
  325. generalAnalysisModel.TwoPhaseScaleModels.parameter8 = checkBox1.Checked;
  326. string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
  327. string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
  328. FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
  329. }
  330. /// <summary>
  331. /// 初始化图片列表数据
  332. /// </summary>
  333. public void InitPicList()
  334. {
  335. //初始化图片列表
  336. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  337. {
  338. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  339. this.listView1.Items.Add("", i);
  340. this.listView1.Items[i].ImageIndex = i;
  341. String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  342. if (listView1.Items.Find(imageName, false).Count() > 0)
  343. {
  344. if (imageName.Split('.').Count() > 1)
  345. {
  346. imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
  347. }
  348. }
  349. this.listView1.Items[i].Text = imageName;
  350. this.listView1.Items[i].Name = imageName;
  351. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  352. {
  353. this.imgIndex = i;
  354. }
  355. }
  356. }
  357. public TwoPhaseScaleDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  358. {
  359. InitializeComponent();
  360. InitializeLanguageText();
  361. this.appWorkspace = appWorkspace;
  362. this.menuId = menuItem.MenuId;
  363. this.menuName = menuItem.Text;
  364. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  365. this.documentWorkspace.Dock = DockStyle.Fill;
  366. this.documentWorkspace.HookMouseEvents();
  367. this.documentWorkspace.AuxiliaryLineEnabled = false;
  368. this.documentWorkspace.Visible = false;
  369. oneColorsForm = new ColorsForm();
  370. this.oneColorsForm.StartPosition = FormStartPosition.CenterScreen;
  371. twoColorsForm = new ColorsForm();
  372. this.twoColorsForm.StartPosition = FormStartPosition.CenterParent;
  373. this.groupBox_review.Controls.Add(documentWorkspace);
  374. this.commonControlButtons = new CommonControlButtons();
  375. this.commonControlButtons.Dock = DockStyle.Top;
  376. this.commonControlButtons.Height = 30;
  377. this.commonControlButtons.HideZoomToWindowAndActualSize();
  378. this.groupBox_review.Controls.Add(commonControlButtons);
  379. InitPicList();
  380. SetAnalyzeModelFromXml("Template.Manager.item2.TwoPhaseScale");
  381. this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
  382. SetStyle(ControlStyles.UserPaint, true);
  383. SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
  384. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
  385. InitCommonButtonEvent();
  386. this.Shown += showImg;
  387. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
  388. }
  389. private void InitCommonButtonEvent()
  390. {
  391. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  392. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  393. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  394. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  395. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  396. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  397. }
  398. private void zoomInButton_Click(object sender, EventArgs e)
  399. {
  400. if (this.imageMat != null)
  401. this.documentWorkspace.ZoomIn();
  402. }
  403. private void zoomOutButton_Click(object sender, EventArgs e)
  404. {
  405. if (this.imageMat != null)
  406. this.documentWorkspace.ZoomOut();
  407. }
  408. private void zoomToWindowButton_Click(object sender, EventArgs e)
  409. {
  410. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  411. }
  412. private void actualSizeButton_Click(object sender, EventArgs e)
  413. {
  414. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  415. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  416. }
  417. private void pointerButton_Click(object sender, EventArgs e)
  418. {
  419. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  420. }
  421. private void mobileModeButton_Click(object sender, EventArgs e)
  422. {
  423. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  424. }
  425. private void Init()
  426. {
  427. //this.trackBar1.Value = 0;
  428. //this.trackBar2.Value = 0;
  429. //this.numericUpDown1.Value = 0;
  430. //this.numericUpDown2.Value = 0;
  431. selectResults = new TwoPhaseScaleResult();
  432. unSelectResults = new TwoPhaseScaleResult();
  433. //InitUI();
  434. }
  435. /// <summary>
  436. /// ListView图片选择改变事件
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void ListViewSelectedIndexChanged(object sender, EventArgs e)
  441. {
  442. if (listView1.SelectedItems.Count == 1)
  443. {
  444. if (this.listView1.SelectedItems.Count > 0 && this.listView1.FocusedItem != null)
  445. {
  446. if (!string.IsNullOrEmpty(this.selectedImg))
  447. {
  448. #region [保存参数]
  449. var model = new GeneralAnalysisModel.TwoPhaseScaleModel();
  450. if (comboBox1.SelectedIndex != -1)
  451. {
  452. model.parameter1 = comboBox1.SelectedItem.ToString();
  453. }
  454. if (comboBox2.SelectedIndex != -1)
  455. {
  456. model.parameter2 = comboBox2.SelectedItem.ToString();
  457. }
  458. model.parameter3 = (int)numericUpDown1.Value;
  459. model.parameter4 = (int)numericUpDown2.Value;
  460. model.parameter5 = panel1.BackColor.ToArgb();
  461. model.parameter6 = panel2.BackColor.ToArgb();
  462. if (everyImgData.ContainsKey(this.selectedImg))
  463. {
  464. everyImgData[this.selectedImg] = model;
  465. }
  466. else
  467. {
  468. everyImgData.Add(this.selectedImg, model);
  469. }
  470. #endregion
  471. }
  472. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  473. Document document = Document.FromImageMat(imageMat.Clone());
  474. this.documentWorkspace.Document = document;
  475. this.documentWorkspace.Visible = true;
  476. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
  477. this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].PhaseModelsForCopy;
  478. if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count == 0)
  479. {
  480. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.enophasesavailableforanalysi.text"));
  481. //return;
  482. }
  483. comboBox1.Items.Clear();
  484. comboBox1.Text = "";
  485. comboBox1.SelectedIndex = -1;
  486. comboBox2.SelectedIndex = -1;
  487. onePhase.mat = null;
  488. documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
  489. for (int i = 0; i < this.documentWorkspace.phaseModels.Count; i++)
  490. {
  491. comboBox1.Items.Add(this.documentWorkspace.phaseModels[i].name);
  492. }
  493. #region [设置参数]
  494. this.selectedImg = this.listView1.FocusedItem.Name;
  495. if (everyImgData.ContainsKey(selectedImg))
  496. {
  497. var model = everyImgData[selectedImg];
  498. if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
  499. {
  500. if (!string.IsNullOrEmpty(model.parameter1))
  501. {
  502. comboBox1.SelectedItem = model.parameter1;
  503. comboBox1_SelectedIndexChanged(sender, e);
  504. }
  505. if (!string.IsNullOrEmpty(model.parameter2))
  506. {
  507. comboBox2.SelectedItem = model.parameter2;
  508. }
  509. //numericUpDown1.Value = model.parameter3;
  510. //numericUpDown2.Value = model.parameter4;
  511. //trackBar1.Value = (int)model.parameter3;
  512. //trackBar2.Value = (int)model.parameter4;
  513. if (numericUpDown1.Minimum > model.parameter3 || numericUpDown1.Maximum < model.parameter3)
  514. {
  515. numericUpDown1.Value = 0;
  516. }
  517. else
  518. {
  519. numericUpDown1.Value = model.parameter3;
  520. }
  521. if (numericUpDown2.Minimum > model.parameter4 || numericUpDown2.Maximum < model.parameter4)
  522. {
  523. numericUpDown2.Value = 0;
  524. }
  525. else
  526. {
  527. numericUpDown2.Value = model.parameter4;
  528. }
  529. if (trackBar1.Minimum > model.parameter3 || trackBar1.Maximum < model.parameter3)
  530. {
  531. trackBar1.Value = 0;
  532. }
  533. else
  534. {
  535. trackBar1.Value = (int)model.parameter3;
  536. }
  537. if (trackBar2.Minimum > model.parameter4 || trackBar2.Maximum < model.parameter4)
  538. {
  539. trackBar2.Value = 0;
  540. }
  541. else
  542. {
  543. trackBar2.Value = (int)model.parameter4;
  544. }
  545. panel1.BackColor = model.parameter5 == 0 ? Color.Red : Color.FromArgb(model.parameter5);
  546. panel2.BackColor = model.parameter5 == 0 ? Color.Yellow : Color.FromArgb(model.parameter6);
  547. }
  548. numericUpDown3.Value = model.parameter7;
  549. checkBox1.Checked = model.parameter8;
  550. if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1)
  551. {
  552. GetAreaBetweenMinToMax(model.parameter3, model.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat);
  553. }
  554. UpdateUI();
  555. }
  556. else {
  557. InitUI();
  558. }
  559. #endregion
  560. Init();
  561. }
  562. }
  563. }
  564. private void UpdateUI()
  565. {
  566. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  567. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  568. this.txt_SelectCount.Text = selectResults.Count.ToString();
  569. this.txt_SelectArea.Text = (AnalysisTools.GetDecNum(selectResults.Area, decnum)).ToString();
  570. this.txt_SelectCountPersent.Text = AnalysisTools.GetDecNum(selectResults.CountPercent, decnum) + " %";
  571. this.txt_SelectContent.Text = AnalysisTools.GetDecNum(selectResults.Content, decnum) + " %";
  572. this.txt_SelectContentFromAll.Text = AnalysisTools.GetDecNum(selectResults.ContentFromAll, decnum) + " %";
  573. this.txt_SelectCountDivUnSelect.Text = AnalysisTools.GetDecNum(selectResults.CountScaleU, decnum) + " %";
  574. this.txt_UnSelectCount.Text = unSelectResults.Count.ToString();
  575. this.txt_UnSelectArea.Text = (AnalysisTools.GetDecNum(unSelectResults.Area, decnum)).ToString();
  576. this.txt_UnSelectCountPersent.Text = AnalysisTools.GetDecNum(unSelectResults.CountPercent, decnum) + " %";
  577. this.txt_UnSelectCountFromAll.Text = AnalysisTools.GetDecNum(unSelectResults.ContentFromAll, decnum) + " %";
  578. this.txt_UnSelectContent.Text = AnalysisTools.GetDecNum(unSelectResults.Content, decnum) + " %";
  579. this.txt_UnSelectDivSelectCount.Text = AnalysisTools.GetDecNum(unSelectResults.CountScaleU, decnum) + " %";
  580. }
  581. private void InitUI()
  582. {
  583. this.txt_SelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
  584. this.txt_SelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text");
  585. this.txt_SelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text");
  586. this.txt_SelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text");
  587. this.txt_SelectContentFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text");
  588. this.txt_SelectCountDivUnSelect.Text = PdnResources.GetString("Menu.Nottochoose.text");
  589. this.txt_UnSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
  590. this.txt_UnSelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text");
  591. this.txt_UnSelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text");
  592. this.txt_UnSelectCountFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text");
  593. this.txt_UnSelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text");
  594. this.txt_UnSelectDivSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
  595. }
  596. private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
  597. {
  598. if (onePhase.mat == null)
  599. {
  600. System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Nooperationalphasefound.text"));
  601. return;
  602. }
  603. List<Point[]> oneContours = new List<Point[]>();
  604. List<Point[]> twoContours = new List<Point[]>();
  605. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  606. HierarchyIndex[] hierarchy;
  607. OpenCvSharp.Point[][] contours;
  608. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  609. int amount = contours.Length;
  610. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  611. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  612. #region [获取总面积]
  613. int allArea = 0;
  614. if (this.documentWorkspace.GraphicsList.IsExsitView())
  615. {
  616. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  617. {
  618. switch (this.documentWorkspace.GraphicsList[i].drawToolType)
  619. {
  620. case DrawToolType.ViewOval:
  621. allArea = (int)(Math.PI * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
  622. break;
  623. case DrawToolType.ViewCircle:
  624. allArea = (int)(Math.PI * (this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height * 0.25));
  625. break;
  626. case DrawToolType.ViewRectangle:
  627. allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
  628. break;
  629. case DrawToolType.ViewTriangle:
  630. allArea = (int)(0.5 * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
  631. break;
  632. case DrawToolType.ViewSquare:
  633. allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
  634. break;
  635. case DrawToolType.ViewRectangleEx:
  636. case DrawToolType.ViewPolygon:
  637. case DrawToolType.ViewTriangleEx:
  638. for (int k = 0; k < this.documentWorkspace.GraphicsList[i].Rectangle.Height; k++)
  639. {
  640. for (int j = 0; j < this.documentWorkspace.GraphicsList[i].Rectangle.Width; j++)
  641. {
  642. allArea += 1;
  643. }
  644. }
  645. break;
  646. }
  647. }
  648. }
  649. else
  650. {
  651. allArea = (int)(mat.Height * mat.Width);
  652. }
  653. allArea = (int)(allArea * pxPerUnit * pxPerUnit);
  654. #endregion
  655. int selectCount = 0;
  656. double areaAmount = 0;
  657. double selectAreaAmount = 0;
  658. List<Int32> areaList = new List<int>();
  659. selectResults = new TwoPhaseScaleResult();
  660. unSelectResults = new TwoPhaseScaleResult();
  661. switch (workType)
  662. {
  663. case 1://面积过滤
  664. for (int i = 0; i < contours.Length; i++)
  665. {
  666. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  667. areaAmount += area;
  668. if ((decimal)area >= areaMin && (decimal)area <= areaMax)
  669. {
  670. selectCount++;
  671. selectAreaAmount += area;
  672. oneContours.Add(contours[i]);
  673. }
  674. else
  675. {
  676. twoContours.Add(contours[i]);
  677. }
  678. }
  679. break;
  680. case 2://面积比
  681. Point2f center;
  682. for (int i = 0; i < contours.Length; i++)
  683. {
  684. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  685. float radius;
  686. Cv2.MinEnclosingCircle(contours[i], out center, out radius);
  687. double areaPercent = area / (Math.PI * radius * radius);
  688. area = (int)(area * pxPerUnit * pxPerUnit);
  689. areaAmount += area;
  690. if (areaPercent >= Convert.ToSingle(areaMin) && areaPercent <= Convert.ToSingle(areaMax))
  691. {
  692. selectCount++;
  693. selectAreaAmount += area;
  694. oneContours.Add(contours[i]);
  695. }
  696. else
  697. {
  698. twoContours.Add(contours[i]);
  699. }
  700. }
  701. break;
  702. case 3: //周长
  703. for (int i = 0; i < contours.Length; i++)
  704. {
  705. int p = (int)(contours[i].Length * pxPerUnit);
  706. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  707. areaAmount += area;
  708. if (p >= Convert.ToSingle(areaMin) && p <= Convert.ToSingle(areaMax))
  709. {
  710. selectCount++;
  711. selectAreaAmount += area;
  712. oneContours.Add(contours[i]);
  713. }
  714. else
  715. {
  716. twoContours.Add(contours[i]);
  717. }
  718. }
  719. break;
  720. case 4: // 长轴
  721. for (int i = 0; i < contours.Length; i++)
  722. {
  723. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  724. double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit;
  725. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  726. areaAmount += area;
  727. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  728. {
  729. selectCount++;
  730. selectAreaAmount += area;
  731. oneContours.Add(contours[i]);
  732. }
  733. else
  734. {
  735. twoContours.Add(contours[i]);
  736. }
  737. }
  738. break;
  739. case 5: // 短轴
  740. for (int i = 0; i < contours.Length; i++)
  741. {
  742. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  743. double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit;
  744. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  745. areaAmount += area;
  746. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  747. {
  748. selectCount++;
  749. selectAreaAmount += area;
  750. oneContours.Add(contours[i]);
  751. }
  752. else
  753. {
  754. twoContours.Add(contours[i]);
  755. }
  756. }
  757. break;
  758. case 6: // 倾斜角度
  759. for (int i = 0; i < contours.Length; i++)
  760. {
  761. if (contours[i].Count() < 5)
  762. {
  763. continue;
  764. }
  765. RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]);
  766. float width = ellipsemege.Angle;
  767. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  768. areaAmount += area;
  769. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  770. {
  771. selectCount++;
  772. selectAreaAmount += area;
  773. oneContours.Add(contours[i]);
  774. }
  775. else
  776. {
  777. twoContours.Add(contours[i]);
  778. }
  779. }
  780. break;
  781. case 7: // 高度
  782. for (int i = 0; i < contours.Length; i++)
  783. {
  784. Rect ellipsemege = Cv2.BoundingRect(contours[i]);
  785. double width = ellipsemege.Size.Height * pxPerUnit;
  786. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  787. areaAmount += area;
  788. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  789. {
  790. selectCount++;
  791. selectAreaAmount += area;
  792. oneContours.Add(contours[i]);
  793. }
  794. else
  795. {
  796. twoContours.Add(contours[i]);
  797. }
  798. }
  799. break;
  800. case 8:// 宽度
  801. for (int i = 0; i < contours.Length; i++)
  802. {
  803. Rect ellipsemege = Cv2.BoundingRect(contours[i]);
  804. double width = ellipsemege.Size.Width * pxPerUnit;
  805. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  806. areaAmount += area;
  807. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  808. {
  809. selectCount++;
  810. selectAreaAmount += area;
  811. oneContours.Add(contours[i]);
  812. }
  813. else
  814. {
  815. twoContours.Add(contours[i]);
  816. }
  817. }
  818. break;
  819. case 9://长宽比
  820. for (int i = 0; i < contours.Length; i++)
  821. {
  822. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  823. areaAmount += area;
  824. Rect rect = Cv2.BoundingRect(contours[i]);
  825. decimal ckb = (decimal)(rect.Width / rect.Height);
  826. if (ckb >= areaMin && ckb <= areaMax)
  827. {
  828. selectCount++;
  829. selectAreaAmount += area;
  830. oneContours.Add(contours[i]);
  831. }
  832. else
  833. {
  834. twoContours.Add(contours[i]);
  835. }
  836. }
  837. break;
  838. case 10: // 长径
  839. for (int i = 0; i < contours.Length; i++)
  840. {
  841. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  842. double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit;
  843. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  844. areaAmount += area;
  845. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  846. {
  847. selectCount++;
  848. selectAreaAmount += area;
  849. oneContours.Add(contours[i]);
  850. }
  851. else
  852. {
  853. twoContours.Add(contours[i]);
  854. }
  855. }
  856. break;
  857. case 11: // 短径
  858. for (int i = 0; i < contours.Length; i++)
  859. {
  860. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  861. double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit;
  862. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  863. areaAmount += area;
  864. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  865. {
  866. selectCount++;
  867. selectAreaAmount += area;
  868. oneContours.Add(contours[i]);
  869. }
  870. else
  871. {
  872. twoContours.Add(contours[i]);
  873. }
  874. }
  875. break;
  876. case 12: // 外接圆直径
  877. Point2f point;
  878. for (int i = 0; i < contours.Length; i++)
  879. {
  880. float radius;
  881. Cv2.MinEnclosingCircle(contours[i], out point, out radius);
  882. double width = radius * 2 * pxPerUnit;
  883. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  884. areaAmount += area;
  885. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  886. {
  887. selectCount++;
  888. selectAreaAmount += area;
  889. oneContours.Add(contours[i]);
  890. }
  891. else
  892. {
  893. twoContours.Add(contours[i]);
  894. }
  895. }
  896. break;
  897. case 13: // 球化率
  898. Point2f pointF;
  899. for (int i = 0; i < contours.Length; i++)
  900. {
  901. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  902. areaAmount += area;
  903. float radius;
  904. Cv2.MinEnclosingCircle(contours[i], out pointF, out radius);
  905. double width = (area / (Math.PI * radius * radius));
  906. area = (Cv2.ContourArea(contours[i]) * pxPerUnit * pxPerUnit);
  907. areaAmount += area;
  908. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  909. {
  910. selectCount++;
  911. selectAreaAmount += area;
  912. oneContours.Add(contours[i]);
  913. }
  914. else
  915. {
  916. twoContours.Add(contours[i]);
  917. }
  918. }
  919. break;
  920. case 14: // 等积圆直径
  921. for (int i = 0; i < contours.Length; i++)
  922. {
  923. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  924. areaAmount += area;
  925. var width = (Math.Sqrt(area / Math.PI) * 2);
  926. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  927. {
  928. selectCount++;
  929. selectAreaAmount += area;
  930. oneContours.Add(contours[i]);
  931. }
  932. else
  933. {
  934. twoContours.Add(contours[i]);
  935. }
  936. }
  937. break;
  938. case 15://最大卡规直径
  939. for (int i = 0; i < contours.Length; i++)
  940. {
  941. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  942. areaAmount += area;
  943. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  944. decimal diam = (decimal)(vs.Max() * pxPerUnit);
  945. if (diam >= areaMin && diam <= areaMax)
  946. {
  947. selectCount++;
  948. selectAreaAmount += area;
  949. oneContours.Add(contours[i]);
  950. }
  951. else
  952. {
  953. twoContours.Add(contours[i]);
  954. }
  955. }
  956. break;
  957. case 16://最小卡规直径
  958. for (int i = 0; i < contours.Length; i++)
  959. {
  960. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  961. areaAmount += area;
  962. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  963. decimal diam = (decimal)(vs.Min() * pxPerUnit);
  964. if (diam >= areaMin && diam <= areaMax)
  965. {
  966. selectCount++;
  967. selectAreaAmount += area;
  968. oneContours.Add(contours[i]);
  969. }
  970. else
  971. {
  972. twoContours.Add(contours[i]);
  973. }
  974. }
  975. break;
  976. case 17://平均卡规直径
  977. for (int i = 0; i < contours.Length; i++)
  978. {
  979. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
  980. areaAmount += area;
  981. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  982. decimal diam = (decimal)(vs.Average() * pxPerUnit);
  983. if (diam >= areaMin && diam <= areaMax)
  984. {
  985. selectCount++;
  986. selectAreaAmount += area;
  987. oneContours.Add(contours[i]);
  988. }
  989. else
  990. {
  991. twoContours.Add(contours[i]);
  992. }
  993. }
  994. break;
  995. case 18: // 纤维长度
  996. for (int i = 0; i < contours.Length; i++)
  997. {
  998. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  999. var width = ((contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4) * pxPerUnit;
  1000. area = (int)(area * pxPerUnit * pxPerUnit);
  1001. areaAmount += area;
  1002. if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
  1003. {
  1004. selectCount++;
  1005. selectAreaAmount += area;
  1006. oneContours.Add(contours[i]);
  1007. }
  1008. else
  1009. {
  1010. twoContours.Add(contours[i]);
  1011. }
  1012. }
  1013. break;
  1014. }
  1015. Cv2.DrawContours(onePhase.mat, oneContours, -1, new Scalar(panel1.BackColor.B, panel1.BackColor.G, panel1.BackColor.R, 255), Cv2.FILLED);
  1016. Cv2.DrawContours(onePhase.mat, twoContours, -1, new Scalar(panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255), Cv2.FILLED);
  1017. documentWorkspace.Refresh();
  1018. if (areaMax == 0)
  1019. {
  1020. selectResults.Count = 0;
  1021. }
  1022. else
  1023. {
  1024. selectResults.Count = selectCount;
  1025. }
  1026. unSelectResults.Count = (contours.Length - selectCount);
  1027. selectResults.Area = selectAreaAmount;
  1028. unSelectResults.Area = areaAmount - selectAreaAmount;
  1029. if (unSelectResults.Area < 0)
  1030. {
  1031. unSelectResults.Area = 0;
  1032. }
  1033. if (contours.Length > 0)
  1034. {
  1035. selectResults.CountPercent = ((Single)selectCount / contours.Length) * 100;
  1036. }
  1037. else
  1038. {
  1039. selectResults.CountPercent = 0;
  1040. }
  1041. if (contours.Length > 0)
  1042. {
  1043. unSelectResults.CountPercent = ((Single)unSelectResults.Count / contours.Length) * 100;
  1044. }
  1045. else
  1046. {
  1047. unSelectResults.CountPercent = 0;
  1048. }
  1049. if (allArea > 0)
  1050. {
  1051. selectResults.Content = ((Single)selectAreaAmount / allArea) * 100;
  1052. }
  1053. else
  1054. {
  1055. selectResults.Content = 0;
  1056. }
  1057. if (allArea > 0)
  1058. {
  1059. unSelectResults.Content = ((Single)unSelectResults.Area / allArea) * 100;
  1060. }
  1061. else
  1062. {
  1063. unSelectResults.Content = 0;
  1064. }
  1065. if (contours.Length > 0)
  1066. {
  1067. selectResults.ContentFromAll = (float)(((Single)selectAreaAmount / areaAmount) * 100);
  1068. }
  1069. else
  1070. {
  1071. selectResults.ContentFromAll = 0;
  1072. }
  1073. if (contours.Length > 0)
  1074. {
  1075. unSelectResults.ContentFromAll = (float)((Single)unSelectResults.Area / areaAmount) * 100;
  1076. }
  1077. else
  1078. {
  1079. unSelectResults.ContentFromAll = 0;
  1080. }
  1081. if ((contours.Length - selectCount) > 0)
  1082. {
  1083. selectResults.CountScaleU = ((Single)selectCount / (contours.Length - selectCount)) * 100;
  1084. }
  1085. else
  1086. {
  1087. selectResults.CountScaleU = 0;
  1088. }
  1089. if (unSelectResults.Area > 0)
  1090. {
  1091. unSelectResults.CountScaleU = (float)((Single)selectAreaAmount / unSelectResults.Area) * 100;
  1092. }
  1093. else
  1094. {
  1095. unSelectResults.CountScaleU = 0;
  1096. }
  1097. UpdateUI();
  1098. }
  1099. private void InitializeLanguageText()
  1100. {
  1101. this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  1102. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  1103. this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
  1104. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  1105. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  1106. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  1107. this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Phasesetting.text");
  1108. this.label20.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle2color.text");
  1109. this.label19.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle1color.text");
  1110. this.label18.Text = PdnResources.GetString("Menu.max.text");
  1111. this.label17.Text = PdnResources.GetString("Menu.minimum.text");
  1112. this.label4.Text = PdnResources.GetString("Menu.max.text");
  1113. this.label3.Text = PdnResources.GetString("Menu.minimum.text");
  1114. this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Selectphase.text");
  1115. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  1116. this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
  1117. this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  1118. this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
  1119. this.Column12.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text");
  1120. this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
  1121. this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
  1122. this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
  1123. this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  1124. this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
  1125. this.label16.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Lparticle1/parea).text");
  1126. this.label15.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Kparticleumber).text");
  1127. this.label14.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Jparticle2rticle2)content.text");
  1128. this.label13.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Iparticle1/(ontent.text");
  1129. this.label12.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.thecontentofHparticle2.text");
  1130. this.label11.Text = PdnResources.GetString("Menu.Gparticle1content.text");
  1131. this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofFparticles2%.text");
  1132. this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofEparticles1%.text");
  1133. this.label8.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofDparticle2.text");
  1134. this.label7.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.ColumnAicles2.text");
  1135. this.label6.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofCparticle1.text");
  1136. this.label5.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofAparticles1.text");
  1137. this.Text = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text");
  1138. this.label21.Text = PdnResources.GetString("Menu.Binaryoperation.Removedebris.filtermethod.text");
  1139. }
  1140. #region InitializeComponent
  1141. private void InitializeComponent()
  1142. {
  1143. this.components = new System.ComponentModel.Container();
  1144. this.groupBox4 = new System.Windows.Forms.GroupBox();
  1145. this.listView1 = new System.Windows.Forms.ListView();
  1146. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  1147. this.groupBox1 = new System.Windows.Forms.GroupBox();
  1148. this.button5 = new System.Windows.Forms.Button();
  1149. this.button2 = new System.Windows.Forms.Button();
  1150. this.checkBox1 = new System.Windows.Forms.CheckBox();
  1151. this.button1 = new System.Windows.Forms.Button();
  1152. this.groupBox_review = new System.Windows.Forms.GroupBox();
  1153. this.groupBox5 = new System.Windows.Forms.GroupBox();
  1154. this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
  1155. this.button_remove = new System.Windows.Forms.Button();
  1156. this.button_all = new System.Windows.Forms.Button();
  1157. this.groupBox6 = new System.Windows.Forms.GroupBox();
  1158. this.dataGridView_results = new System.Windows.Forms.DataGridView();
  1159. this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1160. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1161. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1162. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1163. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1164. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1165. this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1166. this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1167. this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1168. this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1169. this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1170. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1171. this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1172. this.groupBox7 = new System.Windows.Forms.GroupBox();
  1173. this.button9 = new System.Windows.Forms.Button();
  1174. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  1175. this.label1 = new System.Windows.Forms.Label();
  1176. this.button4 = new System.Windows.Forms.Button();
  1177. this.button3 = new System.Windows.Forms.Button();
  1178. this.groupBox8 = new System.Windows.Forms.GroupBox();
  1179. this.txt_UnSelectDivSelectCount = new System.Windows.Forms.TextBox();
  1180. this.txt_SelectCountDivUnSelect = new System.Windows.Forms.TextBox();
  1181. this.label16 = new System.Windows.Forms.Label();
  1182. this.label15 = new System.Windows.Forms.Label();
  1183. this.txt_UnSelectCountFromAll = new System.Windows.Forms.TextBox();
  1184. this.txt_SelectContentFromAll = new System.Windows.Forms.TextBox();
  1185. this.label14 = new System.Windows.Forms.Label();
  1186. this.label13 = new System.Windows.Forms.Label();
  1187. this.txt_UnSelectContent = new System.Windows.Forms.TextBox();
  1188. this.txt_SelectContent = new System.Windows.Forms.TextBox();
  1189. this.label12 = new System.Windows.Forms.Label();
  1190. this.label11 = new System.Windows.Forms.Label();
  1191. this.txt_UnSelectCountPersent = new System.Windows.Forms.TextBox();
  1192. this.label10 = new System.Windows.Forms.Label();
  1193. this.txt_UnSelectArea = new System.Windows.Forms.TextBox();
  1194. this.txt_UnSelectCount = new System.Windows.Forms.TextBox();
  1195. this.txt_SelectCountPersent = new System.Windows.Forms.TextBox();
  1196. this.txt_SelectArea = new System.Windows.Forms.TextBox();
  1197. this.txt_SelectCount = new System.Windows.Forms.TextBox();
  1198. this.label9 = new System.Windows.Forms.Label();
  1199. this.label8 = new System.Windows.Forms.Label();
  1200. this.label7 = new System.Windows.Forms.Label();
  1201. this.label6 = new System.Windows.Forms.Label();
  1202. this.label5 = new System.Windows.Forms.Label();
  1203. this.label2 = new System.Windows.Forms.Label();
  1204. this.label3 = new System.Windows.Forms.Label();
  1205. this.label4 = new System.Windows.Forms.Label();
  1206. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  1207. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  1208. this.comboBox1 = new System.Windows.Forms.ComboBox();
  1209. this.label17 = new System.Windows.Forms.Label();
  1210. this.label18 = new System.Windows.Forms.Label();
  1211. this.trackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
  1212. this.trackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar();
  1213. this.label19 = new System.Windows.Forms.Label();
  1214. this.label20 = new System.Windows.Forms.Label();
  1215. this.panel1 = new System.Windows.Forms.Panel();
  1216. this.panel2 = new System.Windows.Forms.Panel();
  1217. this.comboBox2 = new System.Windows.Forms.ComboBox();
  1218. this.groupBox2 = new System.Windows.Forms.GroupBox();
  1219. this.label21 = new System.Windows.Forms.Label();
  1220. this.groupBox4.SuspendLayout();
  1221. this.groupBox1.SuspendLayout();
  1222. this.groupBox5.SuspendLayout();
  1223. this.groupBox6.SuspendLayout();
  1224. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
  1225. this.groupBox7.SuspendLayout();
  1226. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  1227. this.groupBox8.SuspendLayout();
  1228. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  1229. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  1230. this.groupBox2.SuspendLayout();
  1231. this.SuspendLayout();
  1232. //
  1233. // groupBox4
  1234. //
  1235. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1236. | System.Windows.Forms.AnchorStyles.Left)));
  1237. this.groupBox4.Controls.Add(this.listView1);
  1238. this.groupBox4.Location = new System.Drawing.Point(13, 72);
  1239. this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
  1240. this.groupBox4.Name = "groupBox4";
  1241. this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
  1242. this.groupBox4.Size = new System.Drawing.Size(158, 483);
  1243. this.groupBox4.TabIndex = 9;
  1244. this.groupBox4.TabStop = false;
  1245. this.groupBox4.Text = "图像索引";
  1246. //
  1247. // listView1
  1248. //
  1249. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1250. | System.Windows.Forms.AnchorStyles.Left)
  1251. | System.Windows.Forms.AnchorStyles.Right)));
  1252. this.listView1.HideSelection = false;
  1253. this.listView1.LargeImageList = this.imageList1;
  1254. this.listView1.Location = new System.Drawing.Point(8, 26);
  1255. this.listView1.Margin = new System.Windows.Forms.Padding(4);
  1256. this.listView1.MultiSelect = false;
  1257. this.listView1.Name = "listView1";
  1258. this.listView1.Size = new System.Drawing.Size(140, 449);
  1259. this.listView1.TabIndex = 0;
  1260. this.listView1.UseCompatibleStateImageBehavior = false;
  1261. //
  1262. // imageList1
  1263. //
  1264. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  1265. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  1266. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  1267. //
  1268. // groupBox1
  1269. //
  1270. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1271. | System.Windows.Forms.AnchorStyles.Right)));
  1272. this.groupBox1.Controls.Add(this.button5);
  1273. this.groupBox1.Controls.Add(this.button2);
  1274. this.groupBox1.Controls.Add(this.checkBox1);
  1275. this.groupBox1.Controls.Add(this.button1);
  1276. this.groupBox1.Location = new System.Drawing.Point(20, 12);
  1277. this.groupBox1.Name = "groupBox1";
  1278. this.groupBox1.Size = new System.Drawing.Size(1145, 53);
  1279. this.groupBox1.TabIndex = 10;
  1280. this.groupBox1.TabStop = false;
  1281. this.groupBox1.Text = "操作";
  1282. //
  1283. // button5
  1284. //
  1285. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1286. this.button5.Location = new System.Drawing.Point(972, 21);
  1287. this.button5.Name = "button5";
  1288. this.button5.Size = new System.Drawing.Size(75, 23);
  1289. this.button5.TabIndex = 3;
  1290. this.button5.Text = "关闭";
  1291. this.button5.UseVisualStyleBackColor = true;
  1292. this.button5.Click += new System.EventHandler(this.button5_Click);
  1293. //
  1294. // button2
  1295. //
  1296. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1297. this.button2.Location = new System.Drawing.Point(1053, 21);
  1298. this.button2.Name = "button2";
  1299. this.button2.Size = new System.Drawing.Size(75, 23);
  1300. this.button2.TabIndex = 2;
  1301. this.button2.Text = "保存结果";
  1302. this.button2.UseVisualStyleBackColor = true;
  1303. this.button2.Click += new System.EventHandler(this.button2_Click);
  1304. //
  1305. // checkBox1
  1306. //
  1307. this.checkBox1.AutoSize = true;
  1308. this.checkBox1.Location = new System.Drawing.Point(98, 24);
  1309. this.checkBox1.Name = "checkBox1";
  1310. this.checkBox1.Size = new System.Drawing.Size(132, 16);
  1311. this.checkBox1.TabIndex = 1;
  1312. this.checkBox1.Text = "生成报告时打开设置";
  1313. this.checkBox1.UseVisualStyleBackColor = true;
  1314. //
  1315. // button1
  1316. //
  1317. this.button1.Location = new System.Drawing.Point(6, 24);
  1318. this.button1.Name = "button1";
  1319. this.button1.Size = new System.Drawing.Size(75, 23);
  1320. this.button1.TabIndex = 0;
  1321. this.button1.Text = "设置";
  1322. this.button1.UseVisualStyleBackColor = true;
  1323. this.button1.Click += new System.EventHandler(this.button1_Click);
  1324. //
  1325. // groupBox_review
  1326. //
  1327. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1328. | System.Windows.Forms.AnchorStyles.Left)
  1329. | System.Windows.Forms.AnchorStyles.Right)));
  1330. this.groupBox_review.Location = new System.Drawing.Point(590, 72);
  1331. this.groupBox_review.Name = "groupBox_review";
  1332. this.groupBox_review.Size = new System.Drawing.Size(575, 483);
  1333. this.groupBox_review.TabIndex = 12;
  1334. this.groupBox_review.TabStop = false;
  1335. this.groupBox_review.Text = "预览";
  1336. //
  1337. // groupBox5
  1338. //
  1339. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  1340. this.groupBox5.Controls.Add(this.listBox_analysisResult);
  1341. this.groupBox5.Controls.Add(this.button_remove);
  1342. this.groupBox5.Controls.Add(this.button_all);
  1343. this.groupBox5.Location = new System.Drawing.Point(13, 567);
  1344. this.groupBox5.Name = "groupBox5";
  1345. this.groupBox5.Size = new System.Drawing.Size(224, 165);
  1346. this.groupBox5.TabIndex = 13;
  1347. this.groupBox5.TabStop = false;
  1348. this.groupBox5.Text = "分析结果";
  1349. //
  1350. // listBox_analysisResult
  1351. //
  1352. this.listBox_analysisResult.CheckOnClick = true;
  1353. this.listBox_analysisResult.FormattingEnabled = true;
  1354. this.listBox_analysisResult.HorizontalScrollbar = true;
  1355. this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
  1356. this.listBox_analysisResult.Name = "listBox_analysisResult";
  1357. this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
  1358. this.listBox_analysisResult.TabIndex = 10;
  1359. this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
  1360. //
  1361. // button_remove
  1362. //
  1363. this.button_remove.Location = new System.Drawing.Point(130, 24);
  1364. this.button_remove.Name = "button_remove";
  1365. this.button_remove.Size = new System.Drawing.Size(75, 23);
  1366. this.button_remove.TabIndex = 8;
  1367. this.button_remove.Text = "删除";
  1368. this.button_remove.UseVisualStyleBackColor = true;
  1369. this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
  1370. //
  1371. // button_all
  1372. //
  1373. this.button_all.Location = new System.Drawing.Point(14, 24);
  1374. this.button_all.Name = "button_all";
  1375. this.button_all.Size = new System.Drawing.Size(75, 23);
  1376. this.button_all.TabIndex = 1;
  1377. this.button_all.Text = "全部显示";
  1378. this.button_all.UseVisualStyleBackColor = true;
  1379. this.button_all.Click += new System.EventHandler(this.button_all_Click);
  1380. //
  1381. // groupBox6
  1382. //
  1383. this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  1384. | System.Windows.Forms.AnchorStyles.Right)));
  1385. this.groupBox6.Controls.Add(this.dataGridView_results);
  1386. this.groupBox6.Location = new System.Drawing.Point(257, 562);
  1387. this.groupBox6.Name = "groupBox6";
  1388. this.groupBox6.Size = new System.Drawing.Size(678, 165);
  1389. this.groupBox6.TabIndex = 14;
  1390. this.groupBox6.TabStop = false;
  1391. //
  1392. // dataGridView_results
  1393. //
  1394. this.dataGridView_results.AllowUserToAddRows = false;
  1395. this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1396. | System.Windows.Forms.AnchorStyles.Right)));
  1397. this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
  1398. this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  1399. this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  1400. this.Column12,
  1401. this.Column1,
  1402. this.Column2,
  1403. this.Column3,
  1404. this.Column4,
  1405. this.Column5,
  1406. this.Column6,
  1407. this.Column7,
  1408. this.Column8,
  1409. this.Column9,
  1410. this.Column10,
  1411. this.Column11,
  1412. this.Column13});
  1413. this.dataGridView_results.Location = new System.Drawing.Point(16, 29);
  1414. this.dataGridView_results.Name = "dataGridView_results";
  1415. this.dataGridView_results.RowHeadersVisible = false;
  1416. this.dataGridView_results.RowHeadersWidth = 51;
  1417. this.dataGridView_results.RowTemplate.Height = 27;
  1418. this.dataGridView_results.Size = new System.Drawing.Size(645, 130);
  1419. this.dataGridView_results.TabIndex = 1;
  1420. //
  1421. // Column12
  1422. //
  1423. this.Column12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1424. this.Column12.HeaderText = "Column12";
  1425. this.Column12.Name = "Column12";
  1426. //
  1427. // Column1
  1428. //
  1429. this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1430. this.Column1.HeaderText = "A";
  1431. this.Column1.MinimumWidth = 49;
  1432. this.Column1.Name = "Column1";
  1433. //
  1434. // Column2
  1435. //
  1436. this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1437. this.Column2.HeaderText = "B";
  1438. this.Column2.MinimumWidth = 50;
  1439. this.Column2.Name = "Column2";
  1440. //
  1441. // Column3
  1442. //
  1443. this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1444. this.Column3.HeaderText = "C";
  1445. this.Column3.MinimumWidth = 49;
  1446. this.Column3.Name = "Column3";
  1447. //
  1448. // Column4
  1449. //
  1450. this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1451. this.Column4.HeaderText = "D";
  1452. this.Column4.MinimumWidth = 50;
  1453. this.Column4.Name = "Column4";
  1454. //
  1455. // Column5
  1456. //
  1457. this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1458. this.Column5.HeaderText = "E";
  1459. this.Column5.MinimumWidth = 49;
  1460. this.Column5.Name = "Column5";
  1461. //
  1462. // Column6
  1463. //
  1464. this.Column6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1465. this.Column6.HeaderText = "F";
  1466. this.Column6.MinimumWidth = 50;
  1467. this.Column6.Name = "Column6";
  1468. //
  1469. // Column7
  1470. //
  1471. this.Column7.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1472. this.Column7.HeaderText = "G";
  1473. this.Column7.MinimumWidth = 49;
  1474. this.Column7.Name = "Column7";
  1475. //
  1476. // Column8
  1477. //
  1478. this.Column8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1479. this.Column8.HeaderText = "H";
  1480. this.Column8.MinimumWidth = 50;
  1481. this.Column8.Name = "Column8";
  1482. //
  1483. // Column9
  1484. //
  1485. this.Column9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1486. this.Column9.HeaderText = "I";
  1487. this.Column9.MinimumWidth = 49;
  1488. this.Column9.Name = "Column9";
  1489. //
  1490. // Column10
  1491. //
  1492. this.Column10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1493. this.Column10.HeaderText = "J";
  1494. this.Column10.MinimumWidth = 50;
  1495. this.Column10.Name = "Column10";
  1496. //
  1497. // Column11
  1498. //
  1499. this.Column11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1500. this.Column11.HeaderText = "K";
  1501. this.Column11.MinimumWidth = 49;
  1502. this.Column11.Name = "Column11";
  1503. //
  1504. // Column13
  1505. //
  1506. this.Column13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  1507. this.Column13.HeaderText = "L";
  1508. this.Column13.MinimumWidth = 50;
  1509. this.Column13.Name = "Column13";
  1510. //
  1511. // groupBox7
  1512. //
  1513. this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  1514. this.groupBox7.Controls.Add(this.button9);
  1515. this.groupBox7.Controls.Add(this.numericUpDown3);
  1516. this.groupBox7.Controls.Add(this.label1);
  1517. this.groupBox7.Controls.Add(this.button4);
  1518. this.groupBox7.Controls.Add(this.button3);
  1519. this.groupBox7.Location = new System.Drawing.Point(941, 562);
  1520. this.groupBox7.Name = "groupBox7";
  1521. this.groupBox7.Size = new System.Drawing.Size(224, 165);
  1522. this.groupBox7.TabIndex = 15;
  1523. this.groupBox7.TabStop = false;
  1524. //
  1525. // button9
  1526. //
  1527. this.button9.Location = new System.Drawing.Point(54, 88);
  1528. this.button9.Name = "button9";
  1529. this.button9.Size = new System.Drawing.Size(117, 23);
  1530. this.button9.TabIndex = 10;
  1531. this.button9.Text = "项目工程";
  1532. this.button9.UseVisualStyleBackColor = true;
  1533. this.button9.Click += new System.EventHandler(this.button9_Click);
  1534. //
  1535. // numericUpDown3
  1536. //
  1537. this.numericUpDown3.Location = new System.Drawing.Point(87, 124);
  1538. this.numericUpDown3.Maximum = new decimal(new int[] {
  1539. 10,
  1540. 0,
  1541. 0,
  1542. 0});
  1543. this.numericUpDown3.Name = "numericUpDown3";
  1544. this.numericUpDown3.Size = new System.Drawing.Size(84, 21);
  1545. this.numericUpDown3.TabIndex = 4;
  1546. this.numericUpDown3.Value = new decimal(new int[] {
  1547. 2,
  1548. 0,
  1549. 0,
  1550. 0});
  1551. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  1552. //
  1553. // label1
  1554. //
  1555. this.label1.AutoSize = true;
  1556. this.label1.Location = new System.Drawing.Point(52, 126);
  1557. this.label1.Name = "label1";
  1558. this.label1.Size = new System.Drawing.Size(0, 12);
  1559. this.label1.TabIndex = 3;
  1560. //
  1561. // button4
  1562. //
  1563. this.button4.Location = new System.Drawing.Point(54, 54);
  1564. this.button4.Name = "button4";
  1565. this.button4.Size = new System.Drawing.Size(117, 23);
  1566. this.button4.TabIndex = 1;
  1567. this.button4.Text = "导出结果";
  1568. this.button4.UseVisualStyleBackColor = true;
  1569. this.button4.Click += new System.EventHandler(this.button4_Click);
  1570. //
  1571. // button3
  1572. //
  1573. this.button3.Location = new System.Drawing.Point(54, 20);
  1574. this.button3.Name = "button3";
  1575. this.button3.Size = new System.Drawing.Size(117, 23);
  1576. this.button3.TabIndex = 0;
  1577. this.button3.Text = "生成报告";
  1578. this.button3.UseVisualStyleBackColor = true;
  1579. this.button3.Click += new System.EventHandler(this.button3_Click);
  1580. //
  1581. // groupBox8
  1582. //
  1583. this.groupBox8.Controls.Add(this.txt_UnSelectDivSelectCount);
  1584. this.groupBox8.Controls.Add(this.txt_SelectCountDivUnSelect);
  1585. this.groupBox8.Controls.Add(this.label16);
  1586. this.groupBox8.Controls.Add(this.label15);
  1587. this.groupBox8.Controls.Add(this.txt_UnSelectCountFromAll);
  1588. this.groupBox8.Controls.Add(this.txt_SelectContentFromAll);
  1589. this.groupBox8.Controls.Add(this.label14);
  1590. this.groupBox8.Controls.Add(this.label13);
  1591. this.groupBox8.Controls.Add(this.txt_UnSelectContent);
  1592. this.groupBox8.Controls.Add(this.txt_SelectContent);
  1593. this.groupBox8.Controls.Add(this.label12);
  1594. this.groupBox8.Controls.Add(this.label11);
  1595. this.groupBox8.Controls.Add(this.txt_UnSelectCountPersent);
  1596. this.groupBox8.Controls.Add(this.label10);
  1597. this.groupBox8.Controls.Add(this.txt_UnSelectArea);
  1598. this.groupBox8.Controls.Add(this.txt_UnSelectCount);
  1599. this.groupBox8.Controls.Add(this.txt_SelectCountPersent);
  1600. this.groupBox8.Controls.Add(this.txt_SelectArea);
  1601. this.groupBox8.Controls.Add(this.txt_SelectCount);
  1602. this.groupBox8.Controls.Add(this.label9);
  1603. this.groupBox8.Controls.Add(this.label8);
  1604. this.groupBox8.Controls.Add(this.label7);
  1605. this.groupBox8.Controls.Add(this.label6);
  1606. this.groupBox8.Controls.Add(this.label5);
  1607. this.groupBox8.Enabled = false;
  1608. this.groupBox8.Location = new System.Drawing.Point(178, 313);
  1609. this.groupBox8.Name = "groupBox8";
  1610. this.groupBox8.Size = new System.Drawing.Size(400, 243);
  1611. this.groupBox8.TabIndex = 17;
  1612. this.groupBox8.TabStop = false;
  1613. this.groupBox8.Text = "分析结果";
  1614. //
  1615. // txt_UnSelectDivSelectCount
  1616. //
  1617. this.txt_UnSelectDivSelectCount.Location = new System.Drawing.Point(179, 216);
  1618. this.txt_UnSelectDivSelectCount.Name = "txt_UnSelectDivSelectCount";
  1619. this.txt_UnSelectDivSelectCount.Size = new System.Drawing.Size(66, 21);
  1620. this.txt_UnSelectDivSelectCount.TabIndex = 23;
  1621. //
  1622. // txt_SelectCountDivUnSelect
  1623. //
  1624. this.txt_SelectCountDivUnSelect.Location = new System.Drawing.Point(179, 192);
  1625. this.txt_SelectCountDivUnSelect.Name = "txt_SelectCountDivUnSelect";
  1626. this.txt_SelectCountDivUnSelect.Size = new System.Drawing.Size(66, 21);
  1627. this.txt_SelectCountDivUnSelect.TabIndex = 22;
  1628. //
  1629. // label16
  1630. //
  1631. this.label16.AutoSize = true;
  1632. this.label16.Location = new System.Drawing.Point(19, 219);
  1633. this.label16.Name = "label16";
  1634. this.label16.Size = new System.Drawing.Size(113, 12);
  1635. this.label16.TabIndex = 21;
  1636. this.label16.Text = "L颗粒1/颗粒2(面积)";
  1637. //
  1638. // label15
  1639. //
  1640. this.label15.AutoSize = true;
  1641. this.label15.Location = new System.Drawing.Point(19, 195);
  1642. this.label15.Name = "label15";
  1643. this.label15.Size = new System.Drawing.Size(113, 12);
  1644. this.label15.TabIndex = 20;
  1645. this.label15.Text = "K颗粒1/颗粒2(个数)";
  1646. //
  1647. // txt_UnSelectCountFromAll
  1648. //
  1649. this.txt_UnSelectCountFromAll.Location = new System.Drawing.Point(179, 165);
  1650. this.txt_UnSelectCountFromAll.Name = "txt_UnSelectCountFromAll";
  1651. this.txt_UnSelectCountFromAll.Size = new System.Drawing.Size(66, 21);
  1652. this.txt_UnSelectCountFromAll.TabIndex = 19;
  1653. //
  1654. // txt_SelectContentFromAll
  1655. //
  1656. this.txt_SelectContentFromAll.Location = new System.Drawing.Point(179, 141);
  1657. this.txt_SelectContentFromAll.Name = "txt_SelectContentFromAll";
  1658. this.txt_SelectContentFromAll.Size = new System.Drawing.Size(66, 21);
  1659. this.txt_SelectContentFromAll.TabIndex = 18;
  1660. //
  1661. // label14
  1662. //
  1663. this.label14.AutoSize = true;
  1664. this.label14.Location = new System.Drawing.Point(19, 168);
  1665. this.label14.Name = "label14";
  1666. this.label14.Size = new System.Drawing.Size(155, 12);
  1667. this.label14.TabIndex = 17;
  1668. this.label14.Text = "J颗粒2/(颗粒1+颗粒2)含量%";
  1669. //
  1670. // label13
  1671. //
  1672. this.label13.AutoSize = true;
  1673. this.label13.Location = new System.Drawing.Point(19, 144);
  1674. this.label13.Name = "label13";
  1675. this.label13.Size = new System.Drawing.Size(155, 12);
  1676. this.label13.TabIndex = 16;
  1677. this.label13.Text = "I颗粒1/(颗粒1+颗粒2)含量%";
  1678. //
  1679. // txt_UnSelectContent
  1680. //
  1681. this.txt_UnSelectContent.Location = new System.Drawing.Point(251, 114);
  1682. this.txt_UnSelectContent.Name = "txt_UnSelectContent";
  1683. this.txt_UnSelectContent.Size = new System.Drawing.Size(66, 21);
  1684. this.txt_UnSelectContent.TabIndex = 15;
  1685. //
  1686. // txt_SelectContent
  1687. //
  1688. this.txt_SelectContent.Location = new System.Drawing.Point(95, 114);
  1689. this.txt_SelectContent.Name = "txt_SelectContent";
  1690. this.txt_SelectContent.Size = new System.Drawing.Size(66, 21);
  1691. this.txt_SelectContent.TabIndex = 14;
  1692. //
  1693. // label12
  1694. //
  1695. this.label12.AutoSize = true;
  1696. this.label12.Location = new System.Drawing.Point(180, 114);
  1697. this.label12.Name = "label12";
  1698. this.label12.Size = new System.Drawing.Size(71, 12);
  1699. this.label12.TabIndex = 13;
  1700. this.label12.Text = "H颗粒2含量%";
  1701. //
  1702. // label11
  1703. //
  1704. this.label11.AutoSize = true;
  1705. this.label11.Location = new System.Drawing.Point(19, 114);
  1706. this.label11.Name = "label11";
  1707. this.label11.Size = new System.Drawing.Size(71, 12);
  1708. this.label11.TabIndex = 12;
  1709. this.label11.Text = "G颗粒1含量%";
  1710. //
  1711. // txt_UnSelectCountPersent
  1712. //
  1713. this.txt_UnSelectCountPersent.Location = new System.Drawing.Point(251, 83);
  1714. this.txt_UnSelectCountPersent.Name = "txt_UnSelectCountPersent";
  1715. this.txt_UnSelectCountPersent.Size = new System.Drawing.Size(66, 21);
  1716. this.txt_UnSelectCountPersent.TabIndex = 11;
  1717. //
  1718. // label10
  1719. //
  1720. this.label10.AutoSize = true;
  1721. this.label10.Location = new System.Drawing.Point(180, 85);
  1722. this.label10.Name = "label10";
  1723. this.label10.Size = new System.Drawing.Size(71, 12);
  1724. this.label10.TabIndex = 10;
  1725. this.label10.Text = "F颗粒2个数%";
  1726. //
  1727. // txt_UnSelectArea
  1728. //
  1729. this.txt_UnSelectArea.Location = new System.Drawing.Point(251, 56);
  1730. this.txt_UnSelectArea.Name = "txt_UnSelectArea";
  1731. this.txt_UnSelectArea.Size = new System.Drawing.Size(66, 21);
  1732. this.txt_UnSelectArea.TabIndex = 9;
  1733. //
  1734. // txt_UnSelectCount
  1735. //
  1736. this.txt_UnSelectCount.Location = new System.Drawing.Point(251, 31);
  1737. this.txt_UnSelectCount.Name = "txt_UnSelectCount";
  1738. this.txt_UnSelectCount.Size = new System.Drawing.Size(66, 21);
  1739. this.txt_UnSelectCount.TabIndex = 8;
  1740. //
  1741. // txt_SelectCountPersent
  1742. //
  1743. this.txt_SelectCountPersent.Location = new System.Drawing.Point(95, 82);
  1744. this.txt_SelectCountPersent.Name = "txt_SelectCountPersent";
  1745. this.txt_SelectCountPersent.Size = new System.Drawing.Size(66, 21);
  1746. this.txt_SelectCountPersent.TabIndex = 7;
  1747. //
  1748. // txt_SelectArea
  1749. //
  1750. this.txt_SelectArea.Location = new System.Drawing.Point(95, 56);
  1751. this.txt_SelectArea.Name = "txt_SelectArea";
  1752. this.txt_SelectArea.Size = new System.Drawing.Size(66, 21);
  1753. this.txt_SelectArea.TabIndex = 6;
  1754. //
  1755. // txt_SelectCount
  1756. //
  1757. this.txt_SelectCount.Location = new System.Drawing.Point(95, 31);
  1758. this.txt_SelectCount.Name = "txt_SelectCount";
  1759. this.txt_SelectCount.Size = new System.Drawing.Size(66, 21);
  1760. this.txt_SelectCount.TabIndex = 5;
  1761. //
  1762. // label9
  1763. //
  1764. this.label9.AutoSize = true;
  1765. this.label9.Location = new System.Drawing.Point(19, 82);
  1766. this.label9.Name = "label9";
  1767. this.label9.Size = new System.Drawing.Size(71, 12);
  1768. this.label9.TabIndex = 4;
  1769. this.label9.Text = "E颗粒1个数%";
  1770. //
  1771. // label8
  1772. //
  1773. this.label8.AutoSize = true;
  1774. this.label8.Location = new System.Drawing.Point(180, 59);
  1775. this.label8.Name = "label8";
  1776. this.label8.Size = new System.Drawing.Size(65, 12);
  1777. this.label8.TabIndex = 3;
  1778. this.label8.Text = "D颗粒2面积";
  1779. //
  1780. // label7
  1781. //
  1782. this.label7.AutoSize = true;
  1783. this.label7.Location = new System.Drawing.Point(180, 34);
  1784. this.label7.Name = "label7";
  1785. this.label7.Size = new System.Drawing.Size(65, 12);
  1786. this.label7.TabIndex = 2;
  1787. this.label7.Text = "B颗粒2个数";
  1788. //
  1789. // label6
  1790. //
  1791. this.label6.AutoSize = true;
  1792. this.label6.Location = new System.Drawing.Point(19, 59);
  1793. this.label6.Name = "label6";
  1794. this.label6.Size = new System.Drawing.Size(65, 12);
  1795. this.label6.TabIndex = 1;
  1796. this.label6.Text = "C颗粒1面积";
  1797. //
  1798. // label5
  1799. //
  1800. this.label5.AutoSize = true;
  1801. this.label5.Location = new System.Drawing.Point(19, 34);
  1802. this.label5.Name = "label5";
  1803. this.label5.Size = new System.Drawing.Size(65, 12);
  1804. this.label5.TabIndex = 0;
  1805. this.label5.Text = "A颗粒1个数";
  1806. //
  1807. // label2
  1808. //
  1809. this.label2.AutoSize = true;
  1810. this.label2.Location = new System.Drawing.Point(17, 26);
  1811. this.label2.Name = "label2";
  1812. this.label2.Size = new System.Drawing.Size(53, 12);
  1813. this.label2.TabIndex = 0;
  1814. this.label2.Text = "选择物相";
  1815. //
  1816. // label3
  1817. //
  1818. this.label3.AutoSize = true;
  1819. this.label3.Location = new System.Drawing.Point(19, 91);
  1820. this.label3.Name = "label3";
  1821. this.label3.Size = new System.Drawing.Size(29, 12);
  1822. this.label3.TabIndex = 5;
  1823. this.label3.Text = "最小";
  1824. //
  1825. // label4
  1826. //
  1827. this.label4.AutoSize = true;
  1828. this.label4.Location = new System.Drawing.Point(164, 91);
  1829. this.label4.Name = "label4";
  1830. this.label4.Size = new System.Drawing.Size(29, 12);
  1831. this.label4.TabIndex = 6;
  1832. this.label4.Text = "最大";
  1833. //
  1834. // numericUpDown1
  1835. //
  1836. this.numericUpDown1.Location = new System.Drawing.Point(54, 89);
  1837. this.numericUpDown1.Maximum = new decimal(new int[] {
  1838. 1000000,
  1839. 0,
  1840. 0,
  1841. 0});
  1842. this.numericUpDown1.Name = "numericUpDown1";
  1843. this.numericUpDown1.Size = new System.Drawing.Size(60, 21);
  1844. this.numericUpDown1.TabIndex = 7;
  1845. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  1846. this.numericUpDown1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown1_KeyUp);
  1847. //
  1848. // numericUpDown2
  1849. //
  1850. this.numericUpDown2.Location = new System.Drawing.Point(199, 89);
  1851. this.numericUpDown2.Maximum = new decimal(new int[] {
  1852. 1000000,
  1853. 0,
  1854. 0,
  1855. 0});
  1856. this.numericUpDown2.Name = "numericUpDown2";
  1857. this.numericUpDown2.Size = new System.Drawing.Size(60, 21);
  1858. this.numericUpDown2.TabIndex = 8;
  1859. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  1860. this.numericUpDown2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown2_KeyUp);
  1861. //
  1862. // comboBox1
  1863. //
  1864. this.comboBox1.FormattingEnabled = true;
  1865. this.comboBox1.Location = new System.Drawing.Point(95, 23);
  1866. this.comboBox1.Name = "comboBox1";
  1867. this.comboBox1.Size = new System.Drawing.Size(141, 20);
  1868. this.comboBox1.TabIndex = 9;
  1869. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  1870. //
  1871. // label17
  1872. //
  1873. this.label17.AutoSize = true;
  1874. this.label17.Location = new System.Drawing.Point(19, 121);
  1875. this.label17.Name = "label17";
  1876. this.label17.Size = new System.Drawing.Size(29, 12);
  1877. this.label17.TabIndex = 12;
  1878. this.label17.Text = "最小";
  1879. //
  1880. // label18
  1881. //
  1882. this.label18.AutoSize = true;
  1883. this.label18.Location = new System.Drawing.Point(19, 150);
  1884. this.label18.Name = "label18";
  1885. this.label18.Size = new System.Drawing.Size(29, 12);
  1886. this.label18.TabIndex = 13;
  1887. this.label18.Text = "最大";
  1888. //
  1889. // trackBar2
  1890. //
  1891. this.trackBar2.Location = new System.Drawing.Point(59, 150);
  1892. this.trackBar2.Maximum = 10000;
  1893. this.trackBar2.Minimum = 0;
  1894. this.trackBar2.Name = "trackBar2";
  1895. this.trackBar2.Size = new System.Drawing.Size(341, 26);
  1896. this.trackBar2.TabIndex = 14;
  1897. this.trackBar2.Value = 0;
  1898. this.trackBar2.TrackBarScroll += new System.EventHandler(this.trackBar2_TrackBarScroll);
  1899. //
  1900. // trackBar1
  1901. //
  1902. this.trackBar1.Location = new System.Drawing.Point(59, 116);
  1903. this.trackBar1.Maximum = 10000;
  1904. this.trackBar1.Minimum = 0;
  1905. this.trackBar1.Name = "trackBar1";
  1906. this.trackBar1.Size = new System.Drawing.Size(341, 26);
  1907. this.trackBar1.TabIndex = 18;
  1908. this.trackBar1.Value = 0;
  1909. this.trackBar1.TrackBarScroll += new System.EventHandler(this.trackBar1_TrackBarScroll);
  1910. //
  1911. // label19
  1912. //
  1913. this.label19.AutoSize = true;
  1914. this.label19.Location = new System.Drawing.Point(21, 194);
  1915. this.label19.Name = "label19";
  1916. this.label19.Size = new System.Drawing.Size(59, 12);
  1917. this.label19.TabIndex = 19;
  1918. this.label19.Text = "颗粒1颜色";
  1919. //
  1920. // label20
  1921. //
  1922. this.label20.AutoSize = true;
  1923. this.label20.Location = new System.Drawing.Point(193, 194);
  1924. this.label20.Name = "label20";
  1925. this.label20.Size = new System.Drawing.Size(59, 12);
  1926. this.label20.TabIndex = 20;
  1927. this.label20.Text = "颗粒2颜色";
  1928. //
  1929. // panel1
  1930. //
  1931. this.panel1.BackColor = System.Drawing.Color.Red;
  1932. this.panel1.Location = new System.Drawing.Point(87, 190);
  1933. this.panel1.Name = "panel1";
  1934. this.panel1.Size = new System.Drawing.Size(93, 23);
  1935. this.panel1.TabIndex = 21;
  1936. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  1937. //
  1938. // panel2
  1939. //
  1940. this.panel2.BackColor = System.Drawing.Color.Yellow;
  1941. this.panel2.Location = new System.Drawing.Point(258, 190);
  1942. this.panel2.Name = "panel2";
  1943. this.panel2.Size = new System.Drawing.Size(93, 23);
  1944. this.panel2.TabIndex = 22;
  1945. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  1946. //
  1947. // comboBox2
  1948. //
  1949. this.comboBox2.FormattingEnabled = true;
  1950. this.comboBox2.Items.AddRange(new object[] {
  1951. "面积",
  1952. "面积比",
  1953. "周长",
  1954. "短轴",
  1955. "长轴",
  1956. "倾斜角度",
  1957. "高度",
  1958. "宽度",
  1959. "宽高比",
  1960. "长径",
  1961. "短径",
  1962. "外接圆直径",
  1963. "球化率",
  1964. "等积圆直径",
  1965. "最大卡规直径",
  1966. "最小卡规直径",
  1967. "平均卡规直径",
  1968. "纤维长度"});
  1969. this.comboBox2.Location = new System.Drawing.Point(95, 60);
  1970. this.comboBox2.Name = "comboBox2";
  1971. this.comboBox2.Size = new System.Drawing.Size(141, 20);
  1972. this.comboBox2.TabIndex = 23;
  1973. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  1974. //
  1975. // groupBox2
  1976. //
  1977. this.groupBox2.Controls.Add(this.label21);
  1978. this.groupBox2.Controls.Add(this.comboBox2);
  1979. this.groupBox2.Controls.Add(this.panel2);
  1980. this.groupBox2.Controls.Add(this.panel1);
  1981. this.groupBox2.Controls.Add(this.label20);
  1982. this.groupBox2.Controls.Add(this.label19);
  1983. this.groupBox2.Controls.Add(this.trackBar1);
  1984. this.groupBox2.Controls.Add(this.trackBar2);
  1985. this.groupBox2.Controls.Add(this.label18);
  1986. this.groupBox2.Controls.Add(this.label17);
  1987. this.groupBox2.Controls.Add(this.comboBox1);
  1988. this.groupBox2.Controls.Add(this.numericUpDown2);
  1989. this.groupBox2.Controls.Add(this.numericUpDown1);
  1990. this.groupBox2.Controls.Add(this.label4);
  1991. this.groupBox2.Controls.Add(this.label3);
  1992. this.groupBox2.Controls.Add(this.label2);
  1993. this.groupBox2.Location = new System.Drawing.Point(178, 72);
  1994. this.groupBox2.Name = "groupBox2";
  1995. this.groupBox2.Size = new System.Drawing.Size(406, 235);
  1996. this.groupBox2.TabIndex = 11;
  1997. this.groupBox2.TabStop = false;
  1998. this.groupBox2.Text = "物相设置";
  1999. //
  2000. // label21
  2001. //
  2002. this.label21.AutoSize = true;
  2003. this.label21.Location = new System.Drawing.Point(19, 63);
  2004. this.label21.Name = "label21";
  2005. this.label21.Size = new System.Drawing.Size(53, 12);
  2006. this.label21.TabIndex = 24;
  2007. this.label21.Text = "筛选条件";
  2008. //
  2009. // TwoPhaseScaleDialog
  2010. //
  2011. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  2012. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  2013. this.ClientSize = new System.Drawing.Size(1177, 744);
  2014. this.Controls.Add(this.groupBox8);
  2015. this.Controls.Add(this.groupBox7);
  2016. this.Controls.Add(this.groupBox6);
  2017. this.Controls.Add(this.groupBox5);
  2018. this.Controls.Add(this.groupBox_review);
  2019. this.Controls.Add(this.groupBox2);
  2020. this.Controls.Add(this.groupBox1);
  2021. this.Controls.Add(this.groupBox4);
  2022. this.Name = "TwoPhaseScaleDialog";
  2023. this.Text = "两相比例";
  2024. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TwoPhaseScaleDialog_FormClosing);
  2025. this.Load += new System.EventHandler(this.TwoPhaseScaleDialog_Load);
  2026. this.Controls.SetChildIndex(this.groupBox4, 0);
  2027. this.Controls.SetChildIndex(this.groupBox1, 0);
  2028. this.Controls.SetChildIndex(this.groupBox2, 0);
  2029. this.Controls.SetChildIndex(this.groupBox_review, 0);
  2030. this.Controls.SetChildIndex(this.groupBox5, 0);
  2031. this.Controls.SetChildIndex(this.groupBox6, 0);
  2032. this.Controls.SetChildIndex(this.groupBox7, 0);
  2033. this.Controls.SetChildIndex(this.groupBox8, 0);
  2034. this.groupBox4.ResumeLayout(false);
  2035. this.groupBox1.ResumeLayout(false);
  2036. this.groupBox1.PerformLayout();
  2037. this.groupBox5.ResumeLayout(false);
  2038. this.groupBox6.ResumeLayout(false);
  2039. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
  2040. this.groupBox7.ResumeLayout(false);
  2041. this.groupBox7.PerformLayout();
  2042. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  2043. this.groupBox8.ResumeLayout(false);
  2044. this.groupBox8.PerformLayout();
  2045. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  2046. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  2047. this.groupBox2.ResumeLayout(false);
  2048. this.groupBox2.PerformLayout();
  2049. this.ResumeLayout(false);
  2050. }
  2051. #endregion
  2052. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  2053. {
  2054. if (this.documentWorkspace.phaseModels.Count == 0)
  2055. {
  2056. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2057. return;
  2058. }
  2059. if (workType == 2 || workType == 9 || workType == 13)
  2060. {
  2061. trackBar1.Value = (int)(numericUpDown1.Value * 100);
  2062. }
  2063. else
  2064. {
  2065. trackBar1.Value = (int)numericUpDown1.Value;
  2066. }
  2067. GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
  2068. }
  2069. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  2070. {
  2071. if (this.documentWorkspace.phaseModels.Count == 0)
  2072. {
  2073. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2074. return;
  2075. }
  2076. if (workType == 2 || workType == 9 || workType == 13)
  2077. {
  2078. trackBar2.Value = (int)(numericUpDown2.Value * 100);
  2079. }
  2080. else
  2081. {
  2082. trackBar2.Value = (int)(numericUpDown2.Value);
  2083. }
  2084. GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
  2085. }
  2086. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  2087. {
  2088. selectIndex = comboBox1.SelectedIndex;
  2089. Mat oldMat = documentWorkspace.phaseModels[selectIndex].mat;
  2090. onePhase.name = "one";
  2091. onePhase.mat = new Mat(new OpenCvSharp.Size(oldMat.Cols, oldMat.Rows), MatType.CV_8UC4, new Scalar(0, 0, 0, 255));
  2092. onePhase.color = panel1.BackColor.ToArgb();
  2093. onePhase.choise = true;
  2094. oldMat.CopyTo(onePhase.mat);
  2095. PhaseModel oneP = documentWorkspace.phaseModels.Find(u => u.name == "one");
  2096. if (oneP == null)
  2097. {
  2098. documentWorkspace.phaseModels.Add(onePhase);
  2099. }
  2100. else
  2101. {
  2102. oneP = onePhase;
  2103. }
  2104. this.trackBar1.Value = 0;
  2105. this.trackBar2.Value = 0;
  2106. this.numericUpDown1.Value = 0;
  2107. this.numericUpDown2.Value = 0;
  2108. }
  2109. private void trackBar2_TrackBarScroll(object sender, EventArgs e)
  2110. {
  2111. if (workType == 2 || workType == 9 || workType == 13)
  2112. {
  2113. numericUpDown2.Value = (decimal)trackBar2.Value / 100;
  2114. }
  2115. else
  2116. {
  2117. numericUpDown2.Value = trackBar2.Value;
  2118. }
  2119. }
  2120. private void trackBar1_TrackBarScroll(object sender, EventArgs e)
  2121. {
  2122. if (workType == 2 || workType == 9 || workType == 13)
  2123. {
  2124. numericUpDown1.Value = (decimal)trackBar1.Value / 100;
  2125. }
  2126. else
  2127. {
  2128. numericUpDown1.Value = trackBar1.Value;
  2129. }
  2130. }
  2131. private void panel1_Click(object sender, EventArgs e)
  2132. {
  2133. if (this.documentWorkspace.phaseModels.Count == 0)
  2134. {
  2135. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2136. return;
  2137. }
  2138. this.oneColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  2139. this.oneColorsForm.setSaveBtn_Click(new System.EventHandler(this.oneColorsChanged));
  2140. this.oneColorsForm.ShowDialog();
  2141. }
  2142. private void panel2_Click(object sender, EventArgs e)
  2143. {
  2144. if (this.documentWorkspace.phaseModels.Count == 0)
  2145. {
  2146. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2147. return;
  2148. }
  2149. this.twoColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  2150. this.twoColorsForm.setSaveBtn_Click(new System.EventHandler(this.twoColorsChanged));
  2151. this.twoColorsForm.ShowDialog();
  2152. }
  2153. private void twoColorsChanged(object sender, EventArgs e)
  2154. {
  2155. Color color = this.twoColorsForm.UserPrimaryColor.ToColor();
  2156. //更改背景色,触发事件
  2157. this.panel2.BackColor = color;
  2158. //改变配置文件里面的相颜色
  2159. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2160. //关闭色板
  2161. GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
  2162. //this.documentWorkspace.Refresh();
  2163. this.twoColorsForm.Close();
  2164. }
  2165. private void oneColorsChanged(object sender, EventArgs e)
  2166. {
  2167. Color color = this.oneColorsForm.UserPrimaryColor.ToColor();
  2168. //更改背景色,触发事件
  2169. this.panel1.BackColor = color;
  2170. //改变配置文件里面的相颜色
  2171. //this.binaryExtractionModel.PhaseColor = color.ToArgb();
  2172. //关闭色板
  2173. GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
  2174. //this.documentWorkspace.Refresh();
  2175. this.oneColorsForm.Close();
  2176. }
  2177. #region [筛选条件]
  2178. /// <summary>
  2179. /// 面积
  2180. /// </summary>
  2181. private void rb1_CheckedChanged()
  2182. {
  2183. if (this.documentWorkspace.phaseModels.Count == 0)
  2184. {
  2185. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2186. return;
  2187. }
  2188. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2189. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2190. decimal maxArea = (decimal)Math.Ceiling((getMaxArea(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit * pxPerUnit));
  2191. trackBar1.Maximum = (int)((double)maxArea);
  2192. trackBar2.Maximum = (int)((double)maxArea);
  2193. numericUpDown1.DecimalPlaces = 0;
  2194. numericUpDown1.Increment = 1;
  2195. numericUpDown2.DecimalPlaces = 0;
  2196. numericUpDown2.Increment = 1;
  2197. numericUpDown1.Maximum = maxArea;
  2198. numericUpDown2.Maximum = maxArea;
  2199. numericUpDown1.Value = 0;
  2200. numericUpDown2.Value = 0;
  2201. trackBar1.Value = 0;
  2202. trackBar2.Value = 0;
  2203. InitUI();
  2204. selectResults = new TwoPhaseScaleResult();
  2205. unSelectResults = new TwoPhaseScaleResult();
  2206. workType = 1;
  2207. }
  2208. /// <summary>
  2209. /// 面积比
  2210. /// </summary>
  2211. private void rb2_CheckedChanged()
  2212. {
  2213. if (this.documentWorkspace.phaseModels.Count == 0)
  2214. {
  2215. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2216. return;
  2217. }
  2218. trackBar1.Maximum = 100;
  2219. trackBar2.Maximum = 100;
  2220. numericUpDown1.DecimalPlaces = 2;
  2221. numericUpDown1.Increment = 0.01M;
  2222. numericUpDown2.DecimalPlaces = 2;
  2223. numericUpDown2.Increment = 0.01M;
  2224. numericUpDown1.Maximum = 1;
  2225. numericUpDown2.Maximum = 1;
  2226. numericUpDown1.Value = 0;
  2227. numericUpDown2.Value = 0;
  2228. trackBar1.Value = 0;
  2229. trackBar2.Value = 0;
  2230. InitUI();
  2231. workType = 2;
  2232. }
  2233. /// <summary>
  2234. /// 最大卡规直径
  2235. /// </summary>
  2236. private void rb4_CheckedChanged()
  2237. {
  2238. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2239. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2240. if (this.documentWorkspace.phaseModels.Count == 0)
  2241. {
  2242. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2243. return;
  2244. }
  2245. decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit);
  2246. trackBar1.Maximum = (int)maxLength;
  2247. trackBar2.Maximum = (int)maxLength;
  2248. numericUpDown1.DecimalPlaces = 0;
  2249. numericUpDown1.Increment = 1;
  2250. numericUpDown2.DecimalPlaces = 0;
  2251. numericUpDown2.Increment = 1;
  2252. numericUpDown1.Maximum = maxLength;
  2253. numericUpDown2.Maximum = maxLength;
  2254. numericUpDown1.Value = 0;
  2255. numericUpDown2.Value = 0;
  2256. trackBar1.Value = 0;
  2257. trackBar2.Value = 0;
  2258. InitUI();
  2259. workType = 15;
  2260. }
  2261. /// <summary>
  2262. /// 长宽比
  2263. /// </summary>
  2264. private void rb3_CheckedChanged()
  2265. {
  2266. if (this.documentWorkspace.phaseModels.Count == 0)
  2267. {
  2268. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2269. return;
  2270. }
  2271. decimal maxLength = 0;
  2272. try
  2273. {
  2274. maxLength = (decimal)Math.Ceiling(getAspectRatio(this.documentWorkspace.phaseModels[selectIndex].mat));
  2275. }
  2276. catch (Exception)
  2277. {
  2278. }
  2279. trackBar1.Maximum = (int)(maxLength * 100);
  2280. trackBar2.Maximum = (int)(maxLength * 100);
  2281. numericUpDown1.DecimalPlaces = 2;
  2282. numericUpDown1.Increment = 0.01M;
  2283. numericUpDown2.DecimalPlaces = 2;
  2284. numericUpDown2.Increment = 0.01M;
  2285. numericUpDown1.Maximum = maxLength;
  2286. numericUpDown2.Maximum = maxLength;
  2287. numericUpDown1.Value = 0;
  2288. numericUpDown2.Value = 0;
  2289. trackBar1.Value = 0;
  2290. trackBar2.Value = 0;
  2291. InitUI();
  2292. workType = 9;
  2293. }
  2294. /// <summary>
  2295. /// 最小卡规直径
  2296. /// </summary>
  2297. /// <param name="sender"></param>
  2298. /// <param name="e"></param>
  2299. private void minimumCaliperDiameter()
  2300. {
  2301. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2302. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2303. if (this.documentWorkspace.phaseModels.Count == 0)
  2304. {
  2305. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2306. return;
  2307. }
  2308. decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit);
  2309. trackBar1.Maximum = (int)maxLength;
  2310. trackBar2.Maximum = (int)maxLength;
  2311. numericUpDown1.DecimalPlaces = 0;
  2312. numericUpDown1.Increment = 1;
  2313. numericUpDown2.DecimalPlaces = 0;
  2314. numericUpDown2.Increment = 1;
  2315. numericUpDown1.Maximum = maxLength;
  2316. numericUpDown2.Maximum = maxLength;
  2317. numericUpDown1.Value = 0;
  2318. numericUpDown2.Value = 0;
  2319. trackBar1.Value = 0;
  2320. trackBar2.Value = 0;
  2321. InitUI();
  2322. workType = 16;
  2323. }
  2324. /// <summary>
  2325. /// 平均卡规直径
  2326. /// </summary>
  2327. private void averageCaliperDiameter()
  2328. {
  2329. if (this.documentWorkspace.phaseModels.Count == 0)
  2330. {
  2331. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2332. return;
  2333. }
  2334. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2335. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2336. decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 3) * pxPerUnit);
  2337. trackBar1.Maximum = (int)maxLength;
  2338. trackBar2.Maximum = (int)maxLength;
  2339. numericUpDown1.DecimalPlaces = 0;
  2340. numericUpDown1.Increment = 1;
  2341. numericUpDown2.DecimalPlaces = 0;
  2342. numericUpDown2.Increment = 1;
  2343. numericUpDown1.Maximum = maxLength;
  2344. numericUpDown2.Maximum = maxLength;
  2345. numericUpDown1.Value = 0;
  2346. numericUpDown2.Value = 0;
  2347. trackBar1.Value = 0;
  2348. trackBar2.Value = 0;
  2349. InitUI();
  2350. workType = 17;
  2351. }
  2352. /// <summary>
  2353. /// 长轴
  2354. /// </summary>
  2355. private void longAxis(int type)
  2356. {
  2357. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2358. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2359. if (this.documentWorkspace.phaseModels.Count == 0)
  2360. {
  2361. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2362. return;
  2363. }
  2364. double maxLength = Math.Ceiling(getLongAxis(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit);
  2365. trackBar1.Maximum = (int)maxLength;
  2366. trackBar2.Maximum = (int)maxLength;
  2367. numericUpDown1.DecimalPlaces = 0;
  2368. numericUpDown1.Increment = 1;
  2369. numericUpDown2.DecimalPlaces = 0;
  2370. numericUpDown2.Increment = 1;
  2371. numericUpDown1.Maximum = (decimal)maxLength;
  2372. numericUpDown2.Maximum = (decimal)maxLength;
  2373. numericUpDown1.Value = 0;
  2374. numericUpDown2.Value = 0;
  2375. trackBar1.Value = 0;
  2376. trackBar2.Value = 0;
  2377. InitUI();
  2378. workType = type == 1 ? 4 : 5;
  2379. }
  2380. /// <summary>
  2381. /// 周长
  2382. /// </summary>
  2383. private void perimeter()
  2384. {
  2385. if (this.documentWorkspace.phaseModels.Count == 0)
  2386. {
  2387. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2388. return;
  2389. }
  2390. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2391. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2392. decimal maxLength = (decimal)Math.Ceiling(getMaxPerimeter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
  2393. trackBar1.Maximum = (int)maxLength;
  2394. trackBar2.Maximum = (int)maxLength;
  2395. numericUpDown1.DecimalPlaces = 0;
  2396. numericUpDown1.Increment = 1;
  2397. numericUpDown2.DecimalPlaces = 0;
  2398. numericUpDown2.Increment = 1;
  2399. numericUpDown1.Maximum = maxLength;
  2400. numericUpDown2.Maximum = maxLength;
  2401. numericUpDown1.Value = 0;
  2402. numericUpDown2.Value = 0;
  2403. trackBar1.Value = 0;
  2404. trackBar2.Value = 0;
  2405. InitUI();
  2406. workType = 3;
  2407. }
  2408. /// <summary>
  2409. /// 倾斜角度
  2410. /// </summary>
  2411. private void slope()
  2412. {
  2413. if (this.documentWorkspace.phaseModels.Count == 0)
  2414. {
  2415. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2416. return;
  2417. }
  2418. decimal maxLength = (decimal)getMaxSlope(this.documentWorkspace.phaseModels[selectIndex].mat);
  2419. trackBar1.Maximum = (int)maxLength;
  2420. trackBar2.Maximum = (int)maxLength;
  2421. numericUpDown1.DecimalPlaces = 0;
  2422. numericUpDown1.Increment = 1;
  2423. numericUpDown2.DecimalPlaces = 0;
  2424. numericUpDown2.Increment = 1;
  2425. numericUpDown1.Maximum = maxLength;
  2426. numericUpDown2.Maximum = maxLength;
  2427. numericUpDown1.Value = 0;
  2428. numericUpDown2.Value = 0;
  2429. trackBar1.Value = 0;
  2430. trackBar2.Value = 0;
  2431. InitUI();
  2432. workType = 6;
  2433. }
  2434. /// <summary>
  2435. /// 高度
  2436. /// </summary>
  2437. private void particulatesHeight()
  2438. {
  2439. if (this.documentWorkspace.phaseModels.Count == 0)
  2440. {
  2441. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2442. return;
  2443. }
  2444. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2445. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2446. decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit);
  2447. trackBar1.Maximum = (int)maxLength;
  2448. trackBar2.Maximum = (int)maxLength;
  2449. numericUpDown1.DecimalPlaces = 0;
  2450. numericUpDown1.Increment = 1;
  2451. numericUpDown2.DecimalPlaces = 0;
  2452. numericUpDown2.Increment = 1;
  2453. numericUpDown1.Maximum = maxLength;
  2454. numericUpDown2.Maximum = maxLength;
  2455. numericUpDown1.Value = 0;
  2456. numericUpDown2.Value = 0;
  2457. trackBar1.Value = 0;
  2458. trackBar2.Value = 0;
  2459. InitUI();
  2460. workType = 7;
  2461. }
  2462. /// <summary>
  2463. /// 宽度
  2464. /// </summary>
  2465. private void particulatesWidth()
  2466. {
  2467. if (this.documentWorkspace.phaseModels.Count == 0)
  2468. {
  2469. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2470. return;
  2471. }
  2472. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2473. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2474. decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit);
  2475. trackBar1.Maximum = (int)maxLength;
  2476. trackBar2.Maximum = (int)maxLength;
  2477. numericUpDown1.DecimalPlaces = 0;
  2478. numericUpDown1.Increment = 1;
  2479. numericUpDown2.DecimalPlaces = 0;
  2480. numericUpDown2.Increment = 1;
  2481. numericUpDown1.Maximum = maxLength;
  2482. numericUpDown2.Maximum = maxLength;
  2483. numericUpDown1.Value = 0;
  2484. numericUpDown2.Value = 0;
  2485. trackBar1.Value = 0;
  2486. trackBar2.Value = 0;
  2487. InitUI();
  2488. workType = 8;
  2489. }
  2490. /// <summary>
  2491. /// 长径或者短径
  2492. /// </summary>
  2493. private void trail(int type)
  2494. {
  2495. if (this.documentWorkspace.phaseModels.Count == 0)
  2496. {
  2497. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2498. return;
  2499. }
  2500. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2501. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2502. decimal maxLength = (decimal)Math.Ceiling(getTrail(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit);
  2503. trackBar1.Maximum = (int)maxLength;
  2504. trackBar2.Maximum = (int)maxLength;
  2505. numericUpDown1.DecimalPlaces = 0;
  2506. numericUpDown1.Increment = 1;
  2507. numericUpDown2.DecimalPlaces = 0;
  2508. numericUpDown2.Increment = 1;
  2509. numericUpDown1.Maximum = maxLength;
  2510. numericUpDown2.Maximum = maxLength;
  2511. numericUpDown1.Value = 0;
  2512. numericUpDown2.Value = 0;
  2513. trackBar1.Value = 0;
  2514. trackBar2.Value = 0;
  2515. InitUI();
  2516. workType = type == 1 ? 10 : 11;
  2517. }
  2518. /// <summary>
  2519. /// 外接圆直径
  2520. /// </summary>
  2521. private void circumscribedCircleDiameter()
  2522. {
  2523. if (this.documentWorkspace.phaseModels.Count == 0)
  2524. {
  2525. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2526. return;
  2527. }
  2528. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2529. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2530. decimal maxLength = (decimal)Math.Ceiling(getCircumscribedCircleDiameter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
  2531. trackBar1.Maximum = (int)maxLength;
  2532. trackBar2.Maximum = (int)maxLength;
  2533. numericUpDown1.DecimalPlaces = 0;
  2534. numericUpDown1.Increment = 1;
  2535. numericUpDown2.DecimalPlaces = 0;
  2536. numericUpDown2.Increment = 1;
  2537. numericUpDown1.Maximum = maxLength;
  2538. numericUpDown2.Maximum = maxLength;
  2539. numericUpDown1.Value = 0;
  2540. numericUpDown2.Value = 0;
  2541. trackBar1.Value = 0;
  2542. trackBar2.Value = 0;
  2543. InitUI();
  2544. workType = 12;
  2545. }
  2546. /// <summary>
  2547. /// 球化率
  2548. /// </summary>
  2549. private void spheroidizationRate()
  2550. {
  2551. if (this.documentWorkspace.phaseModels.Count == 0)
  2552. {
  2553. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2554. return;
  2555. }
  2556. trackBar1.Maximum = 100;
  2557. trackBar2.Maximum = 100;
  2558. numericUpDown1.DecimalPlaces = 2;
  2559. numericUpDown1.Increment = 0.01M;
  2560. numericUpDown2.DecimalPlaces = 2;
  2561. numericUpDown2.Increment = 0.01M;
  2562. numericUpDown1.Maximum = 1;
  2563. numericUpDown2.Maximum = 1;
  2564. numericUpDown1.Value = 0;
  2565. numericUpDown2.Value = 0;
  2566. trackBar1.Value = 0;
  2567. trackBar2.Value = 0;
  2568. InitUI();
  2569. workType = 13;
  2570. }
  2571. /// <summary>
  2572. /// 等积圆直径
  2573. /// </summary>
  2574. private void equalAreaCircle()
  2575. {
  2576. if (this.documentWorkspace.phaseModels.Count == 0)
  2577. {
  2578. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2579. return;
  2580. }
  2581. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2582. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2583. decimal maxLength = Math.Ceiling((decimal)(getEqualAreaCircle(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit));
  2584. trackBar1.Maximum = (int)maxLength;
  2585. trackBar2.Maximum = (int)maxLength;
  2586. numericUpDown1.DecimalPlaces = 0;
  2587. numericUpDown1.Increment = 1;
  2588. numericUpDown2.DecimalPlaces = 0;
  2589. numericUpDown2.Increment = 1;
  2590. numericUpDown1.Maximum = maxLength;
  2591. numericUpDown2.Maximum = maxLength;
  2592. numericUpDown1.Value = 0;
  2593. numericUpDown2.Value = 0;
  2594. trackBar1.Value = 0;
  2595. trackBar2.Value = 0;
  2596. InitUI();
  2597. workType = 14;
  2598. }
  2599. /// <summary>
  2600. /// 纤维长度
  2601. /// </summary>
  2602. private void fiberLength()
  2603. {
  2604. if (this.documentWorkspace.phaseModels.Count == 0)
  2605. {
  2606. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
  2607. return;
  2608. }
  2609. //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
  2610. double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2611. decimal maxLength = (decimal)Math.Ceiling(getFiberLength(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
  2612. trackBar1.Maximum = (int)maxLength;
  2613. trackBar2.Maximum = (int)maxLength;
  2614. numericUpDown1.DecimalPlaces = 0;
  2615. numericUpDown1.Increment = 1;
  2616. numericUpDown2.DecimalPlaces = 0;
  2617. numericUpDown2.Increment = 1;
  2618. numericUpDown1.Maximum = maxLength;
  2619. numericUpDown2.Maximum = maxLength;
  2620. numericUpDown1.Value = 0;
  2621. numericUpDown2.Value = 0;
  2622. trackBar1.Value = 0;
  2623. trackBar2.Value = 0;
  2624. InitUI();
  2625. workType = 18;
  2626. }
  2627. #endregion
  2628. #region [基础方法]
  2629. /// <summary>
  2630. /// 获取最大面积
  2631. /// </summary>
  2632. /// <param name="pMat"></param>
  2633. /// <returns></returns>
  2634. private double getMaxArea(Mat pMat)
  2635. {
  2636. double maxArea = 0;
  2637. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2638. HierarchyIndex[] hierarchy;
  2639. OpenCvSharp.Point[][] contours;
  2640. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2641. for (int i = 0; i < contours.Count(); i++)
  2642. {
  2643. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  2644. if (area > maxArea)
  2645. {
  2646. maxArea = area;
  2647. }
  2648. }
  2649. return Math.Ceiling(maxArea);
  2650. }
  2651. /// <summary>
  2652. /// 获取轮廓的最大卡规直径
  2653. /// </summary>
  2654. /// <param name="pMat"></param>
  2655. /// <returns></returns>
  2656. private double getContoursMaxLength(Mat pMat, int type)
  2657. {
  2658. double maxLength = 0;
  2659. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2660. HierarchyIndex[] hierarchy;
  2661. OpenCvSharp.Point[][] contours;
  2662. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2663. if (type == 2)
  2664. {
  2665. for (int i = 0; i < contours.Count(); i++)
  2666. {
  2667. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  2668. int width = vs.Max();
  2669. if (width > maxLength)
  2670. {
  2671. maxLength = width;
  2672. }
  2673. }
  2674. }
  2675. else if (type == 1)
  2676. {
  2677. for (int i = 0; i < contours.Count(); i++)
  2678. {
  2679. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  2680. int width = vs.Min();
  2681. if (width > maxLength)
  2682. {
  2683. maxLength = width;
  2684. }
  2685. }
  2686. }
  2687. else
  2688. {
  2689. for (int i = 0; i < contours.Count(); i++)
  2690. {
  2691. List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
  2692. var width = Math.Ceiling(vs.Average());
  2693. if (width > maxLength)
  2694. {
  2695. maxLength = width;
  2696. }
  2697. }
  2698. }
  2699. return Math.Ceiling(maxLength);
  2700. }
  2701. /// <summary>
  2702. /// 获取轮廓的周长
  2703. /// </summary>
  2704. /// <param name="pMat"></param>
  2705. /// <returns></returns>
  2706. private double getMaxPerimeter(Mat pMat)
  2707. {
  2708. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2709. HierarchyIndex[] hierarchy;
  2710. OpenCvSharp.Point[][] contours;
  2711. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2712. return contours.Max(m => m.Length); ;
  2713. }
  2714. /// <summary>
  2715. /// 获取轮廓长轴或者短轴
  2716. /// </summary>
  2717. /// <param name="pMat"></param>
  2718. /// <returns></returns>
  2719. private double getLongAxis(Mat pMat, int type)
  2720. {
  2721. double maxLength = 0;
  2722. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2723. HierarchyIndex[] hierarchy;
  2724. OpenCvSharp.Point[][] contours;
  2725. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2726. for (int i = 0; i < contours.Count(); i++)
  2727. {
  2728. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  2729. float width = 0;
  2730. if (type == 1)
  2731. {
  2732. width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height;
  2733. }
  2734. else
  2735. {
  2736. width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height;
  2737. }
  2738. if (width > maxLength)
  2739. {
  2740. maxLength = width;
  2741. }
  2742. }
  2743. return Math.Ceiling(maxLength);
  2744. }
  2745. /// <summary>
  2746. /// 获取轮廓倾斜角度
  2747. /// </summary>
  2748. /// <param name="pMat"></param>
  2749. /// <returns></returns>
  2750. private double getMaxSlope(Mat pMat)
  2751. {
  2752. double maxLength = 0;
  2753. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2754. HierarchyIndex[] hierarchy;
  2755. OpenCvSharp.Point[][] contours;
  2756. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2757. for (int i = 0; i < contours.Count(); i++)
  2758. {
  2759. if (contours[i].Count() < 5)
  2760. {
  2761. continue;
  2762. }
  2763. RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]);
  2764. float width = ellipsemege.Angle;
  2765. if (width > maxLength)
  2766. {
  2767. maxLength = width;
  2768. }
  2769. }
  2770. return Math.Ceiling(maxLength);
  2771. }
  2772. /// <summary>
  2773. /// 获取轮廓高度或者宽度
  2774. /// </summary>
  2775. /// <param name="pMat"></param>
  2776. /// <returns></returns>
  2777. private double getHeightOrWidth(Mat pMat, int type)
  2778. {
  2779. double maxLength = 0;
  2780. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2781. HierarchyIndex[] hierarchy;
  2782. OpenCvSharp.Point[][] contours;
  2783. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2784. for (int i = 0; i < contours.Count(); i++)
  2785. {
  2786. Rect ellipsemege = Cv2.BoundingRect(contours[i]);
  2787. float width = type == 1 ? ellipsemege.Size.Height : ellipsemege.Size.Width;
  2788. if (width > maxLength)
  2789. {
  2790. maxLength = width;
  2791. }
  2792. }
  2793. return Math.Ceiling(maxLength);
  2794. }
  2795. /// <summary>
  2796. /// 获取轮廓长径或者短径
  2797. /// </summary>
  2798. /// <param name="pMat"></param>
  2799. /// <returns></returns>
  2800. private double getTrail(Mat pMat, int type)
  2801. {
  2802. double maxLength = 0;
  2803. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2804. HierarchyIndex[] hierarchy;
  2805. OpenCvSharp.Point[][] contours;
  2806. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2807. for (int i = 0; i < contours.Count(); i++)
  2808. {
  2809. RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
  2810. double width;
  2811. if (type == 1)
  2812. {
  2813. width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5;
  2814. }
  2815. else
  2816. {
  2817. width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5;
  2818. }
  2819. if (width > maxLength)
  2820. {
  2821. maxLength = width;
  2822. }
  2823. }
  2824. return Math.Ceiling(maxLength);
  2825. }
  2826. /// <summary>
  2827. /// 外接圆直径
  2828. /// </summary>
  2829. /// <param name="pMat"></param>
  2830. /// <returns></returns>
  2831. private double getCircumscribedCircleDiameter(Mat pMat)
  2832. {
  2833. double maxLength = 0;
  2834. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2835. HierarchyIndex[] hierarchy;
  2836. OpenCvSharp.Point[][] contours;
  2837. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2838. Point2f point;
  2839. for (int i = 0; i < contours.Count(); i++)
  2840. {
  2841. float radius;
  2842. Cv2.MinEnclosingCircle(contours[i], out point, out radius);
  2843. double width = radius * 2;
  2844. if (width > maxLength)
  2845. {
  2846. maxLength = width;
  2847. }
  2848. }
  2849. return Math.Ceiling(maxLength);
  2850. }
  2851. /// <summary>
  2852. /// 等积圆直径
  2853. /// </summary>
  2854. /// <param name="pMat"></param>
  2855. /// <returns></returns>
  2856. private double getEqualAreaCircle(Mat pMat)
  2857. {
  2858. double maxLength = 0;
  2859. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2860. HierarchyIndex[] hierarchy;
  2861. OpenCvSharp.Point[][] contours;
  2862. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2863. for (int i = 0; i < contours.Count(); i++)
  2864. {
  2865. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  2866. double width = Math.Sqrt(area / Math.PI) * 2;
  2867. if (width > maxLength)
  2868. {
  2869. maxLength = width;
  2870. }
  2871. }
  2872. return Math.Ceiling(maxLength);
  2873. }
  2874. /// <summary>
  2875. /// 纤维长度
  2876. /// </summary>
  2877. /// <param name="pMat"></param>
  2878. /// <returns></returns>
  2879. private double getFiberLength(Mat pMat)
  2880. {
  2881. double maxLength = 0;
  2882. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2883. HierarchyIndex[] hierarchy;
  2884. OpenCvSharp.Point[][] contours;
  2885. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2886. for (int i = 0; i < contours.Count(); i++)
  2887. {
  2888. double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
  2889. double width = (contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4;
  2890. if (width > maxLength)
  2891. {
  2892. maxLength = width;
  2893. }
  2894. }
  2895. return Math.Ceiling(maxLength);
  2896. }
  2897. /// <summary>
  2898. /// 长宽比
  2899. /// </summary>
  2900. /// <returns></returns>
  2901. private double getAspectRatio(Mat pMat)
  2902. {
  2903. double maxLength = 0;
  2904. Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
  2905. HierarchyIndex[] hierarchy;
  2906. OpenCvSharp.Point[][] contours;
  2907. Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
  2908. for (int i = 0; i < contours.Count(); i++)
  2909. {
  2910. Rect area = Cv2.BoundingRect(contours[i]);
  2911. double width = (double)area.Width / (double)area.Height;
  2912. if (width > maxLength)
  2913. {
  2914. maxLength = width;
  2915. }
  2916. }
  2917. return Math.Ceiling(maxLength);
  2918. }
  2919. #endregion
  2920. private void button2_Click(object sender, EventArgs e)
  2921. {
  2922. if (listView1.SelectedItems.Count == 0)
  2923. {
  2924. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  2925. return;
  2926. }
  2927. if (comboBox1.SelectedIndex == -1)
  2928. {
  2929. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Selectthephaseyouwanttoanalyze.text") + "!");
  2930. comboBox1.Focus();
  2931. return;
  2932. }
  2933. String tag = listView1.FocusedItem.Text;
  2934. List<Bitmap> tempBit = new List<Bitmap>();
  2935. if (finalResults.FindAll(u => u.GraphName == listView1.FocusedItem.Text).Count == 0)
  2936. {
  2937. TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults);
  2938. finalResults.Add(activeResult);
  2939. listBox_analysisResult.Items.Add(listView1.FocusedItem.Text);
  2940. listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
  2941. dataGridView_results.Rows.Add(activeResult.GraphName,
  2942. activeResult.selectResult.Count.ToString(),
  2943. activeResult.unSelectResult.Count.ToString(),
  2944. AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(),
  2945. AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(),
  2946. AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum),
  2947. AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum),
  2948. AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum),
  2949. AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum),
  2950. AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum),
  2951. AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum),
  2952. AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum),
  2953. AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum));
  2954. }
  2955. else
  2956. {
  2957. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  2958. if (dr != DialogResult.OK)
  2959. {
  2960. return;
  2961. }
  2962. finalResults.RemoveAll(u => u.GraphName == listView1.FocusedItem.Text);
  2963. TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults);
  2964. finalResults.Add(activeResult);
  2965. List<string> list = new List<string>();
  2966. foreach (var s in this.listBox_analysisResult.Items)
  2967. {
  2968. list.Add(s.ToString());
  2969. }
  2970. this.listBox_analysisResult.Items.Clear();
  2971. foreach (var s in list)
  2972. {
  2973. this.listBox_analysisResult.Items.Add(s);
  2974. }
  2975. var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
  2976. this.dataGridView_results.Rows.Clear();
  2977. listBox_analysisResult.SetItemChecked(thisindex, true);
  2978. dataGridView_results.Rows.Add(activeResult.GraphName,
  2979. activeResult.selectResult.Count.ToString(),
  2980. activeResult.unSelectResult.Count.ToString(),
  2981. AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(),
  2982. AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(),
  2983. AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum),
  2984. AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum),
  2985. AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum),
  2986. AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum),
  2987. AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum),
  2988. AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum),
  2989. AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum),
  2990. AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum));
  2991. }
  2992. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  2993. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  2994. originalBit.Tag = pantographRatio;
  2995. tempBit.Add(originalBit);
  2996. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  2997. Graphics graphics = Graphics.FromImage(newBit);
  2998. Draw(graphics);
  2999. newBit.Tag = pantographRatio;
  3000. tempBit.Add(newBit);
  3001. if (bitDic.ContainsKey(tag))
  3002. {
  3003. bitDic[tag].Clear();
  3004. bitDic[tag] = tempBit;
  3005. }
  3006. else
  3007. {
  3008. bitDic.Add(tag, tempBit);
  3009. }
  3010. }
  3011. private void Draw(Graphics graphics)
  3012. {
  3013. if (this.documentWorkspace.phaseModels.Count > 0)
  3014. {
  3015. foreach (PhaseModel model in this.documentWorkspace.phaseModels)
  3016. {
  3017. if (model.choise && model.mat != null)
  3018. {
  3019. Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
  3020. graphics.DrawImage(map, 0, 0, map.Width, map.Height);
  3021. }
  3022. }
  3023. }
  3024. }
  3025. private void button_all_Click(object sender, EventArgs e)
  3026. {
  3027. dataGridView_results.Rows.Clear();
  3028. if (this.is_all % 2 == 0)
  3029. {
  3030. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  3031. {
  3032. listBox_analysisResult.SetItemChecked(i, false);
  3033. }
  3034. }
  3035. else
  3036. {
  3037. for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
  3038. {
  3039. listBox_analysisResult.SetItemChecked(i, true);
  3040. }
  3041. for (int i = 0; i < finalResults.Count; i++)
  3042. {
  3043. dataGridView_results.Rows.Add(finalResults[i].GraphName,
  3044. finalResults[i].selectResult.Count.ToString(),
  3045. finalResults[i].unSelectResult.Count.ToString(),
  3046. AnalysisTools.GetDecNum(finalResults[i].selectResult.Area, decnum),
  3047. AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Area, decnum),
  3048. AnalysisTools.GetDecNum(finalResults[i].selectResult.CountPercent, decnum),
  3049. AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountPercent, decnum),
  3050. AnalysisTools.GetDecNum(finalResults[i].selectResult.Content, decnum),
  3051. AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Count, decnum),
  3052. AnalysisTools.GetDecNum(finalResults[i].selectResult.ContentFromAll, decnum),
  3053. AnalysisTools.GetDecNum(finalResults[i].unSelectResult.ContentFromAll, decnum),
  3054. AnalysisTools.GetDecNum(finalResults[i].selectResult.CountScaleU, decnum),
  3055. AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountScaleU, decnum));
  3056. }
  3057. }
  3058. this.is_all += 1;
  3059. }
  3060. private void button_remove_Click(object sender, EventArgs e)
  3061. {
  3062. var removeList = new List<string>();
  3063. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  3064. {
  3065. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3066. if (dr == DialogResult.OK)
  3067. {
  3068. foreach (var s in listBox_analysisResult.CheckedItems)
  3069. {
  3070. for (int i = 0; i < dataGridView_results.Rows.Count; i++)
  3071. {
  3072. if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
  3073. {
  3074. dataGridView_results.Rows.RemoveAt(i);
  3075. }
  3076. }
  3077. finalResults.RemoveAll(u => u.GraphName == s.ToString());
  3078. removeList.Add(s.ToString());
  3079. }
  3080. foreach (var m in removeList)
  3081. {
  3082. listBox_analysisResult.Items.Remove(m);
  3083. }
  3084. }
  3085. }
  3086. else
  3087. {
  3088. MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!");
  3089. }
  3090. }
  3091. private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
  3092. {
  3093. dataGridView_results.Rows.Clear();
  3094. if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
  3095. {
  3096. foreach (var s in listBox_analysisResult.CheckedItems)
  3097. {
  3098. List<TwoPhaseScaleExportResult> selectItems = finalResults.FindAll(u => u.GraphName == s.ToString());
  3099. for (int i = 0; i < selectItems.Count; i++)
  3100. {
  3101. dataGridView_results.Rows.Add(selectItems[i].GraphName,
  3102. selectItems[i].selectResult.Count.ToString(),
  3103. selectItems[i].unSelectResult.Count.ToString(),
  3104. AnalysisTools.GetDecNum(selectItems[i].selectResult.Area, decnum).ToString(),
  3105. AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Area, decnum).ToString(),
  3106. AnalysisTools.GetDecNum(selectItems[i].selectResult.CountPercent, decnum),
  3107. AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountPercent, decnum),
  3108. AnalysisTools.GetDecNum(selectItems[i].selectResult.Content, decnum),
  3109. AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Content, decnum),
  3110. AnalysisTools.GetDecNum(selectItems[i].selectResult.ContentFromAll, decnum),
  3111. AnalysisTools.GetDecNum(selectItems[i].unSelectResult.ContentFromAll, decnum),
  3112. AnalysisTools.GetDecNum(selectItems[i].selectResult.CountScaleU, decnum),
  3113. AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountScaleU, decnum));
  3114. }
  3115. }
  3116. }
  3117. }
  3118. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  3119. {
  3120. decnum = (int)numericUpDown3.Value;
  3121. for (int i = 0; i < dataGridView_results.Rows.Count; i++)
  3122. {
  3123. TwoPhaseScaleExportResult result = this.finalResults.Find(u => u.GraphName.Equals(dataGridView_results.Rows[i].Cells[0].Value.ToString()));
  3124. if (result != null)
  3125. {
  3126. dataGridView_results.Rows[i].Cells[3].Value = AnalysisTools.GetDecNum(result.selectResult.Area, decnum);
  3127. dataGridView_results.Rows[i].Cells[4].Value = AnalysisTools.GetDecNum(result.unSelectResult.Area, decnum);
  3128. dataGridView_results.Rows[i].Cells[5].Value = AnalysisTools.GetDecNum(result.selectResult.CountPercent, decnum);
  3129. dataGridView_results.Rows[i].Cells[6].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountPercent, decnum);
  3130. dataGridView_results.Rows[i].Cells[7].Value = AnalysisTools.GetDecNum(result.selectResult.Content, decnum);
  3131. dataGridView_results.Rows[i].Cells[8].Value = AnalysisTools.GetDecNum(result.unSelectResult.Content, decnum);
  3132. dataGridView_results.Rows[i].Cells[9].Value = AnalysisTools.GetDecNum(result.selectResult.ContentFromAll, decnum);
  3133. dataGridView_results.Rows[i].Cells[10].Value = AnalysisTools.GetDecNum(result.unSelectResult.ContentFromAll, decnum);
  3134. dataGridView_results.Rows[i].Cells[11].Value = AnalysisTools.GetDecNum(result.selectResult.CountScaleU, decnum);
  3135. dataGridView_results.Rows[i].Cells[12].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountScaleU, decnum);
  3136. }
  3137. }
  3138. }
  3139. private void button5_Click(object sender, EventArgs e)
  3140. {
  3141. this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
  3142. this.Close();
  3143. }
  3144. private void button4_Click(object sender, EventArgs e)
  3145. {
  3146. if (this.dataGridView_results.Rows.Count > 0)
  3147. {
  3148. SaveFileDialog exe = new SaveFileDialog();
  3149. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  3150. exe.FilterIndex = 0;
  3151. exe.RestoreDirectory = true;
  3152. exe.Title = "Export Excel File";
  3153. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  3154. exe.FileName = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
  3155. DialogResult dr = exe.ShowDialog();
  3156. if (dr == DialogResult.OK)
  3157. {
  3158. DataTable dtb = new DataTable();
  3159. foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
  3160. {
  3161. dtb.Columns.Add(c.HeaderText);
  3162. }
  3163. for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
  3164. {
  3165. DataRow dataRow = dtb.NewRow();
  3166. for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
  3167. {
  3168. dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
  3169. }
  3170. dtb.Rows.Add(dataRow);
  3171. }
  3172. List<DataTable> list = new List<DataTable>();
  3173. list.Add(dtb);
  3174. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  3175. }
  3176. }
  3177. else
  3178. {
  3179. System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
  3180. }
  3181. }
  3182. private void button1_Click(object sender, EventArgs e)
  3183. {
  3184. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale");
  3185. if (recombinationRateSetDialog.hasModule)
  3186. {
  3187. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  3188. recombinationRateSetDialog.ShowDialog();
  3189. }
  3190. else
  3191. {
  3192. recombinationRateSetDialog = null;
  3193. }
  3194. }
  3195. private void button3_Click(object sender, EventArgs e)
  3196. {
  3197. bitList.Clear();
  3198. if (checkBox1.Checked)
  3199. {
  3200. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale");
  3201. if (recombinationRateSetDialog.hasModule)
  3202. {
  3203. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  3204. recombinationRateSetDialog.ShowDialog();
  3205. }
  3206. else
  3207. {
  3208. recombinationRateSetDialog = null;
  3209. }
  3210. }
  3211. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3212. {
  3213. //获取word书签与excel单元格的关系,以字典方式存储
  3214. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3215. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3216. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3217. {
  3218. foreach (mic_module_infos info in mic_module_infos)
  3219. {
  3220. tagInfos.Add(info.tag_name, info.cell_position);
  3221. }
  3222. }
  3223. List<List<string>> analysisContent = new List<List<string>>();
  3224. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  3225. {
  3226. List<string> content1 = new List<string>();
  3227. if (i == 0)
  3228. {
  3229. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  3230. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  3231. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  3232. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  3233. content1.Add(this.dataGridView_results.Columns[4].HeaderText);
  3234. content1.Add(this.dataGridView_results.Columns[5].HeaderText);
  3235. content1.Add(this.dataGridView_results.Columns[6].HeaderText);
  3236. content1.Add(this.dataGridView_results.Columns[7].HeaderText);
  3237. content1.Add(this.dataGridView_results.Columns[8].HeaderText);
  3238. content1.Add(this.dataGridView_results.Columns[9].HeaderText);
  3239. content1.Add(this.dataGridView_results.Columns[10].HeaderText);
  3240. content1.Add(this.dataGridView_results.Columns[11].HeaderText);
  3241. content1.Add(this.dataGridView_results.Columns[12].HeaderText);
  3242. analysisContent.Add(content1);
  3243. }
  3244. content1 = new List<string>();
  3245. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  3246. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  3247. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  3248. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  3249. content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
  3250. content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString());
  3251. content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString());
  3252. content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString());
  3253. content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString());
  3254. content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString());
  3255. content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString());
  3256. content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString());
  3257. content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString());
  3258. analysisContent.Add(content1);
  3259. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  3260. if (bitDic.ContainsKey(tag))
  3261. {
  3262. bitList.Add(bitDic[tag][0]);
  3263. bitList.Add(bitDic[tag][1]);
  3264. }
  3265. }
  3266. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  3267. }
  3268. else
  3269. System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3270. }
  3271. private void numericUpDown1_KeyUp(object sender, KeyEventArgs e)
  3272. {
  3273. numericUpDown1.Value = numericUpDown1.Value;
  3274. }
  3275. private void numericUpDown2_KeyUp(object sender, KeyEventArgs e)
  3276. {
  3277. numericUpDown2.Value = numericUpDown2.Value;
  3278. }
  3279. private void TwoPhaseScaleDialog_Load(object sender, EventArgs e)
  3280. {
  3281. }
  3282. private void TwoPhaseScaleDialog_FormClosing(object sender, FormClosingEventArgs e)
  3283. {
  3284. this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
  3285. }
  3286. private void button9_Click(object sender, EventArgs e)
  3287. {
  3288. if (this.dataGridView_results.Rows.Count == 0)
  3289. {
  3290. System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  3291. return;
  3292. }
  3293. if (this.analyzeSettingModel == null)
  3294. {
  3295. System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
  3296. return;
  3297. }
  3298. //获取项目工程内的文件夹路径
  3299. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.TwoComparisonCases.Text", this.analyzeSettingModel.savePath);
  3300. if (item != null)
  3301. {
  3302. //向文件夹内保存图片和报告
  3303. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  3304. {
  3305. //获取word书签与excel单元格的关系,以字典方式存储
  3306. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  3307. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  3308. if (mic_module_infos != null && mic_module_infos.Count > 0)
  3309. {
  3310. foreach (mic_module_infos info in mic_module_infos)
  3311. {
  3312. tagInfos.Add(info.tag_name, info.cell_position);
  3313. }
  3314. }
  3315. List<List<string>> analysisContent = new List<List<string>>();
  3316. List<List<string>> inclusionList = new List<List<string>>();
  3317. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  3318. List<Bitmap> bitImgList = new List<Bitmap>();
  3319. List<string> titleContent = new List<string>();
  3320. for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
  3321. {
  3322. List<string> content1 = new List<string>();
  3323. if (i == 0)
  3324. {
  3325. content1.Add(this.dataGridView_results.Columns[0].HeaderText);
  3326. content1.Add(this.dataGridView_results.Columns[1].HeaderText);
  3327. content1.Add(this.dataGridView_results.Columns[2].HeaderText);
  3328. content1.Add(this.dataGridView_results.Columns[3].HeaderText);
  3329. content1.Add(this.dataGridView_results.Columns[4].HeaderText);
  3330. content1.Add(this.dataGridView_results.Columns[5].HeaderText);
  3331. content1.Add(this.dataGridView_results.Columns[6].HeaderText);
  3332. content1.Add(this.dataGridView_results.Columns[7].HeaderText);
  3333. content1.Add(this.dataGridView_results.Columns[8].HeaderText);
  3334. content1.Add(this.dataGridView_results.Columns[9].HeaderText);
  3335. content1.Add(this.dataGridView_results.Columns[10].HeaderText);
  3336. content1.Add(this.dataGridView_results.Columns[11].HeaderText);
  3337. content1.Add(this.dataGridView_results.Columns[12].HeaderText);
  3338. analysisContent.Add(content1);
  3339. titleContent.AddRange(content1);
  3340. }
  3341. content1 = new List<string>();
  3342. content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
  3343. content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
  3344. content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
  3345. content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
  3346. content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
  3347. content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString());
  3348. content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString());
  3349. content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString());
  3350. content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString());
  3351. content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString());
  3352. content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString());
  3353. content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString());
  3354. content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString());
  3355. analysisContent.Add(content1);
  3356. string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
  3357. var export = exportModel.Where(m => m.picName == tag).FirstOrDefault();
  3358. if (export == null)
  3359. {
  3360. ExportProjectModel exportProjectModel = new ExportProjectModel();
  3361. exportProjectModel.dataList = new List<List<string>>();
  3362. exportProjectModel.dataList.Add(titleContent);
  3363. exportProjectModel.dataList.Add(content1);
  3364. exportProjectModel.picName = tag;
  3365. exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text");
  3366. exportModel.Add(exportProjectModel);
  3367. }
  3368. else
  3369. {
  3370. exportModel[exportModel.IndexOf(export)].dataList.Add(content1);
  3371. }
  3372. if (bitDic.ContainsKey(tag))
  3373. {
  3374. bitImgList.Add(bitDic[tag][0]);
  3375. bitImgList.Add(bitDic[tag][1]);
  3376. }
  3377. }
  3378. try
  3379. {
  3380. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
  3381. }
  3382. catch (Exception ex)
  3383. {
  3384. System.Windows.MessageBox.Show(ex.Message);
  3385. }
  3386. }
  3387. else
  3388. {
  3389. System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  3390. return;
  3391. }
  3392. //保存项目信息到数据库
  3393. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  3394. }
  3395. }
  3396. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  3397. {
  3398. if (this.comboBox2.SelectedIndex == -1)
  3399. {
  3400. return;
  3401. }
  3402. switch (this.comboBox2.SelectedItem.ToString())
  3403. {
  3404. case "面积":
  3405. this.selectSearchIndex = 1;
  3406. this.rb1_CheckedChanged();
  3407. break;
  3408. case "面积比":
  3409. this.selectSearchIndex = 2;
  3410. this.rb2_CheckedChanged();
  3411. break;
  3412. case "周长":
  3413. this.selectSearchIndex = 3;
  3414. this.perimeter();
  3415. break;
  3416. case "长轴":
  3417. this.selectSearchIndex = 4;
  3418. this.longAxis(1);
  3419. break;
  3420. case "短轴":
  3421. this.selectSearchIndex = 5;
  3422. this.longAxis(2);
  3423. break;
  3424. case "倾斜角度":
  3425. this.selectSearchIndex = 6;
  3426. this.slope();
  3427. break;
  3428. case "高度":
  3429. this.selectSearchIndex = 7;
  3430. this.particulatesHeight();
  3431. break;
  3432. case "宽度":
  3433. this.selectSearchIndex = 8;
  3434. this.particulatesWidth();
  3435. break;
  3436. case "宽高比":
  3437. this.selectSearchIndex = 9;
  3438. this.rb3_CheckedChanged();
  3439. break;
  3440. case "长径":
  3441. this.selectSearchIndex = 10;
  3442. this.trail(1);
  3443. break;
  3444. case "短径":
  3445. this.selectSearchIndex = 11;
  3446. this.trail(2);
  3447. break;
  3448. case "外接圆直径":
  3449. this.selectSearchIndex = 12;
  3450. this.circumscribedCircleDiameter();
  3451. break;
  3452. case "球化率":
  3453. this.selectSearchIndex = 13;
  3454. this.spheroidizationRate();
  3455. break;
  3456. case "等积圆直径":
  3457. this.selectSearchIndex = 14;
  3458. this.equalAreaCircle();
  3459. break;
  3460. case "最大卡规直径":
  3461. this.selectSearchIndex = 15;
  3462. this.rb4_CheckedChanged();
  3463. break;
  3464. case "最小卡规直径":
  3465. this.selectSearchIndex = 16;
  3466. this.minimumCaliperDiameter();
  3467. break;
  3468. case "平均卡规直径":
  3469. this.selectSearchIndex = 17;
  3470. this.averageCaliperDiameter();
  3471. break;
  3472. case "纤维长度":
  3473. this.selectSearchIndex = 18;
  3474. this.fiberLength();
  3475. break;
  3476. }
  3477. }
  3478. /// <summary>
  3479. /// 应用全部
  3480. /// </summary>
  3481. /// <param name="sender"></param>
  3482. /// <param name="e"></param>
  3483. private void button7_Click(object sender, EventArgs e)
  3484. {
  3485. //if (this.listView1.FocusedItem == null)
  3486. //{
  3487. // return;
  3488. //}
  3489. //for (int i = 0; i < listView1.Items.Count; i++)
  3490. //{
  3491. // this.listView1.EnsureVisible(i);
  3492. // this.listView1.Items[i].Focused = true;
  3493. // this.listView1.Items[i].Selected = true;
  3494. //}
  3495. }
  3496. /// <summary>
  3497. /// 保存全部
  3498. /// </summary>
  3499. /// <param name="sender"></param>
  3500. /// <param name="e"></param>
  3501. private void button6_Click(object sender, EventArgs e)
  3502. {
  3503. }
  3504. private void getValue(string key, Object value)
  3505. {
  3506. switch (key)
  3507. {
  3508. case "parameter1":
  3509. comboBox2.SelectedIndex = (int)value - 1;
  3510. break;
  3511. case "OpenWhileExportReport":
  3512. checkBox1.Checked = Convert.ToBoolean(value);
  3513. break;
  3514. case "CalculatorDecimalDigits":
  3515. numericUpDown3.Value = Convert.ToDecimal(value);
  3516. break;
  3517. }
  3518. }
  3519. #region [脚本录制]
  3520. private void getScriptRecording()
  3521. {
  3522. string className = InvariantData.path_Action + ".Action" + menuId;
  3523. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3524. List<Args> args = param.Lists;
  3525. foreach (var item in args)
  3526. {
  3527. item.value = setScriptRecording(item.key);
  3528. }
  3529. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3530. }
  3531. private object setScriptRecording(string key)
  3532. {
  3533. object value = null;
  3534. switch (key)
  3535. {
  3536. case "parameter1":
  3537. value = comboBox2.SelectedIndex + 1;
  3538. break;
  3539. case "OpenWhileExportReport":
  3540. value = checkBox1.Checked;
  3541. break;
  3542. case "CalculatorDecimalDigits":
  3543. value = numericUpDown3.Value;
  3544. break;
  3545. }
  3546. return value;
  3547. }
  3548. #endregion
  3549. }
  3550. }